|  | @@ -116,7 +116,7 @@ class SPClient(BaseClient):
 | 
											
												
													
														|  |          if "maxResults" not in body:
 |  |          if "maxResults" not in body:
 | 
											
												
													
														|  |              body["maxResults"] = 100
 |  |              body["maxResults"] = 100
 | 
											
												
													
														|  |          while True:
 |  |          while True:
 | 
											
												
													
														|  | -            info: dict = self.get_campaigns(**body)
 |  | 
 | 
											
												
													
														|  | 
 |  | +            info: dict = self.get_ad_groups(**body)
 | 
											
												
													
														|  |              yield from info["adGroups"]
 |  |              yield from info["adGroups"]
 | 
											
												
													
														|  |              if not info.get("nextToken"):
 |  |              if not info.get("nextToken"):
 | 
											
												
													
														|  |                  break
 |  |                  break
 | 
											
										
											
												
													
														|  | @@ -135,7 +135,7 @@ class SPClient(BaseClient):
 | 
											
												
													
														|  |          if "maxResults" not in body:
 |  |          if "maxResults" not in body:
 | 
											
												
													
														|  |              body["maxResults"] = 100
 |  |              body["maxResults"] = 100
 | 
											
												
													
														|  |          while True:
 |  |          while True:
 | 
											
												
													
														|  | -            info: dict = self.get_campaigns(**body)
 |  | 
 | 
											
												
													
														|  | 
 |  | +            info: dict = self.get_ads(**body)
 | 
											
												
													
														|  |              yield from info["productAds"]
 |  |              yield from info["productAds"]
 | 
											
												
													
														|  |              if not info.get("nextToken"):
 |  |              if not info.get("nextToken"):
 | 
											
												
													
														|  |                  break
 |  |                  break
 | 
											
										
											
												
													
														|  | @@ -153,7 +153,7 @@ class SPClient(BaseClient):
 | 
											
												
													
														|  |          if "maxResults" not in body:
 |  |          if "maxResults" not in body:
 | 
											
												
													
														|  |              body["maxResults"] = 100
 |  |              body["maxResults"] = 100
 | 
											
												
													
														|  |          while True:
 |  |          while True:
 | 
											
												
													
														|  | -            info: dict = self.get_campaigns(**body)
 |  | 
 | 
											
												
													
														|  | 
 |  | +            info: dict = self.get_keywords(**body)
 | 
											
												
													
														|  |              yield from info["keywords"]
 |  |              yield from info["keywords"]
 | 
											
												
													
														|  |              if not info.get("nextToken"):
 |  |              if not info.get("nextToken"):
 | 
											
												
													
														|  |                  break
 |  |                  break
 | 
											
										
											
												
													
														|  | @@ -186,7 +186,7 @@ class SPClient(BaseClient):
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          return self._request(url_path, method="POST", body=body)
 |  |          return self._request(url_path, method="POST", body=body)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    def get_bidrecommendation(self,campaignId:str,adGroupId:str,targetingExpressions:list,recommendationType:str="BIDS_FOR_EXISTING_AD_GROUP"):
 |  | 
 | 
											
												
													
														|  | 
 |  | +    def get_adgroup_bidrecommendation(self,campaignId:str,adGroupId:str,targetingExpressions:list,recommendationType:str="BIDS_FOR_EXISTING_AD_GROUP"):
 | 
											
												
													
														|  |          url_path = "/sp/targets/bid/recommendations"
 |  |          url_path = "/sp/targets/bid/recommendations"
 | 
											
												
													
														|  |          headers = {
 |  |          headers = {
 | 
											
												
													
														|  |              "Accept": "application/vnd.spthemebasedbidrecommendation.v3+json",
 |  |              "Accept": "application/vnd.spthemebasedbidrecommendation.v3+json",
 | 
											
										
											
												
													
														|  | @@ -198,6 +198,14 @@ class SPClient(BaseClient):
 | 
											
												
													
														|  |                  "targetingExpressions":targetingExpressions}
 |  |                  "targetingExpressions":targetingExpressions}
 | 
											
												
													
														|  |          return self._request(url_path, method="POST", body=body, headers=headers)
 |  |          return self._request(url_path, method="POST", body=body, headers=headers)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    def get_keyword_bidrecommendation(self,adGroupId:str,keyword:list,matchType:list):
 | 
											
												
													
														|  | 
 |  | +        keywords = list(map(lambda x:{"keyword":x[0],"matchType":x[1]},list(zip(keyword,matchType))))
 | 
											
												
													
														|  | 
 |  | +        print(keywords)
 | 
											
												
													
														|  | 
 |  | +        url_path = "/v2/sp/keywords/bidRecommendations"
 | 
											
												
													
														|  | 
 |  | +        body = {"adGroupId":adGroupId,
 | 
											
												
													
														|  | 
 |  | +                "keywords":keywords}
 | 
											
												
													
														|  | 
 |  | +        return self._request(url_path, method="POST", body=body)
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  class SBClient(BaseClient):
 |  |  class SBClient(BaseClient):
 | 
											
												
													
														|  |      def get_campaigns(self, **body):
 |  |      def get_campaigns(self, **body):
 | 
											
												
													
														|  |          url_path = "/sb/v4/campaigns/list"
 |  |          url_path = "/sb/v4/campaigns/list"
 | 
											
										
											
												
													
														|  | @@ -290,6 +298,11 @@ class SDClient(BaseClient):
 | 
											
												
													
														|  |          url_path = "/sd/campaigns"
 |  |          url_path = "/sd/campaigns"
 | 
											
												
													
														|  |          return self._request(url_path, params=params)
 |  |          return self._request(url_path, params=params)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +class Account(BaseClient):
 | 
											
												
													
														|  | 
 |  | +    def get_portfolio(self):
 | 
											
												
													
														|  | 
 |  | +        url_path = "/v2/portfolios/extended"
 | 
											
												
													
														|  | 
 |  | +        return self._request(url_path)
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  if __name__ == '__main__':
 |  |  if __name__ == '__main__':
 | 
											
												
													
														|  |      AWS_CREDENTIALS = {
 |  |      AWS_CREDENTIALS = {
 | 
											
										
											
												
													
														|  | @@ -299,10 +312,7 @@ if __name__ == '__main__':
 | 
											
												
													
														|  |          'profile_id': "3006125408623189"
 |  |          'profile_id': "3006125408623189"
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      sp = SPClient(**AWS_CREDENTIALS)
 |  |      sp = SPClient(**AWS_CREDENTIALS)
 | 
											
												
													
														|  | -    # sp.get_budget(campaign_ids=["123264383028090"])
 |  | 
 | 
											
												
													
														|  | -    # print(sp.get_campaigns())
 |  | 
 | 
											
												
													
														|  | -    for i in sp.iter_targets():
 |  | 
 | 
											
												
													
														|  | -        print(i)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    print(sp.get_keyword_bidrecommendation(adGroupId="119753215871672",keyword=["8mp security camera system","8mp security camera system"],matchType=["broad","exact"]))
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      # sd = SDClient(**AWS_CREDENTIALS)
 |  |      # sd = SDClient(**AWS_CREDENTIALS)
 |