Skip to content

Commit

Permalink
v0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
denisneuf committed Nov 17, 2021
1 parent 578b08a commit ff8d282
Show file tree
Hide file tree
Showing 24 changed files with 668 additions and 56 deletions.
14 changes: 13 additions & 1 deletion ad_api/api/sp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
from .negative_product_targeting import NegativeTargets
from .reports import Reports
from .snapshots import Snapshots
from .budget_rules import BudgetRules
from .campaings_optimization import CampaignOptimization
from .ranked_keywords_recommendations import RankedKeywordsRecommendations
from .budget_recommendations import BudgetRecommendations
from .budget_rules_recommendations import BudgetRulesRecommendations
from .product_recommendations import ProductRecommendations

__all__ = [
"Campaigns",
Expand All @@ -23,5 +29,11 @@
"Targets",
"NegativeTargets",
"Reports",
"Snapshots"
"Snapshots",
"BudgetRules",
"CampaignOptimization",
"RankedKeywordsRecommendations",
"BudgetRecommendations",
"BudgetRulesRecommendations",
"ProductRecommendations"
]
11 changes: 11 additions & 0 deletions ad_api/api/sp/budget_recommendations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse

class BudgetRecommendations(Client):

@sp_endpoint('/sp/campaigns/budgetRecommendations', method='POST')
def list_campaigns_budget_recommendations(self, **kwargs) -> ApiResponse:
contentType = 'application/vnd.budgetrecommendation.v3+json'
headers = {'Content-Type': contentType}
return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs, headers=headers)
# return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs)

39 changes: 39 additions & 0 deletions ad_api/api/sp/budget_rules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse

class BudgetRules(Client):

@sp_endpoint('/sp/campaigns/{}/budgetRules/budgetHistory', method='GET')
def get_budget_history(self, campaignId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), campaignId), params=kwargs)

@sp_endpoint('/sp/budgetRules', method='POST')
def create_budget_rules(self, **kwargs) -> ApiResponse:
return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs)

@sp_endpoint('/sp/budgetRules', method='GET')
def list_budget_rules(self, **kwargs) -> ApiResponse:
return self._request(kwargs.pop('path'), params=kwargs)

@sp_endpoint('/sp/budgetRules', method='PUT')
def edit_budget_rules(self, **kwargs) -> ApiResponse:
return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs)

@sp_endpoint('/sp/budgetRules/{}', method='GET')
def get_budget_rule(self, budgetRuleId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), budgetRuleId), params=kwargs)

@sp_endpoint('/sp/budgetRules/{}/campaigns', method='GET')
def get_campaigns_budget_rule(self, budgetRuleId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), budgetRuleId), params=kwargs)

@sp_endpoint('/sp/campaigns/{}/budgetRules', method='POST')
def create_campaign_budget_rules(self, campaignId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), campaignId), data=kwargs.pop('body'), params=kwargs)

@sp_endpoint('/sp/campaigns/{}/budgetRules', method='GET')
def get_budget_rules_campaign(self, campaignId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), campaignId), params=kwargs)

@sp_endpoint('/sp/campaigns/{}/budgetRules/{}', method='DELETE')
def delete_budget_rule_campaign(self, campaignId, budgetRuleId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), campaignId, budgetRuleId), params=kwargs)
11 changes: 11 additions & 0 deletions ad_api/api/sp/budget_rules_recommendations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse

class BudgetRulesRecommendations(Client):

@sp_endpoint('/sp/campaigns/budgetRules/recommendations', method='POST')
def list_campaigns_budget_rules_recommendations(self, **kwargs) -> ApiResponse:
contentType = 'application/vnd.spbudgetrulesrecommendation.v3+json'
headers = {'Content-Type': contentType}
return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs, headers=headers)
# return self._request(fill_query_params(kwargs.pop('path')), data=kwargs.pop('body'), params=kwargs)

43 changes: 43 additions & 0 deletions ad_api/api/sp/campaings_optimization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse

class CampaignOptimization(Client):
"""
Sponsored Products Targeting API.
Documentation: https://advertising.amazon.com/API/docs/en-us/sponsored-products/3-0/openapi/prod#/
Specification: https://dtrnk0o2zy01c.cloudfront.net/openapi/en-us/dest/SponsoredProducts_prod_3p.json
"""

@sp_endpoint('/sp/rules/campaignOptimization/eligibility', method='POST')
def list_campaigns_optimization_eligibility(self, **kwargs) -> ApiResponse:
contentType = 'application/vnd.optimizationrules.v1+json'
headers = {'Content-Type': contentType}
return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs, headers=headers)

@sp_endpoint('/sp/rules/campaignOptimization/{}', method='GET')
def get_budget_campaign_optimization(self, campaignOptimizationId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), campaignOptimizationId), params=kwargs)

@sp_endpoint('/sp/rules/campaignOptimization/{}', method='DELETE')
def delete_budget_campaign_optimization(self, campaignOptimizationId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), campaignOptimizationId), params=kwargs)

@sp_endpoint('/sp/rules/campaignOptimization', method='POST')
def create_budget_campaign_optimization(self, **kwargs) -> ApiResponse:
contentType = 'application/vnd.optimizationrules.v1+json'
headers = {'Content-Type': contentType}
return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs, headers=headers)

@sp_endpoint('/sp/rules/campaignOptimization', method='PUT')
def edit_budget_campaign_optimization(self, **kwargs) -> ApiResponse:
contentType = 'application/vnd.optimizationrules.v1+json'
headers = {'Content-Type': contentType}
return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs, headers=headers)

@sp_endpoint('/sp/rules/campaignOptimization/state', method='POST')
def get_state_budget_campaign_optimization(self, **kwargs) -> ApiResponse:
contentType = 'application/vnd.optimizationrules.v1+json'
headers = {'Content-Type': contentType}
return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs, headers=headers)
10 changes: 10 additions & 0 deletions ad_api/api/sp/product_recommendations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse

class ProductRecommendations(Client):

@sp_endpoint('/sp/targets/products/recommendations', method='POST')
def list_products_recommendations(self, **kwargs) -> ApiResponse:
contentType = 'application/vnd.spproductrecommendation.v3+json'
headers = {'Content-Type': contentType}
return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs, headers=headers)

Loading

0 comments on commit ff8d282

Please sign in to comment.