Skip to content

Commit

Permalink
added modules product_targeting, negative_product_targeting
Browse files Browse the repository at this point in the history
  • Loading branch information
denisneuf committed Sep 17, 2021
1 parent 6c80867 commit 88fb547
Show file tree
Hide file tree
Showing 11 changed files with 486 additions and 50 deletions.
18 changes: 17 additions & 1 deletion ad_api/api/sp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@
from .campaigns import Campaigns
from .ad_groups import AdGroups
from .product_ads import ProductAds
from .bid_recommendations import BidRecommendations
from .keywords import Keywords
from .negative_keywords import NegativeKeywords
from .campaign_negative_keywords import CampaignNegativeKeywords
from .suggested_keywords import SuggestedKeywords
from .product_targeting import Targets
from .negative_product_targeting import NegativeTargets
from .reports import Reports
__all__ = [
"Campaigns",
"AdGroups",
"ProductAds"
"ProductAds",
"BidRecommendations",
"Keywords",
"NegativeKeywords",
"CampaignNegativeKeywords",
"SuggestedKeywords",
"Targets",
"NegativeTargets",
"Reports"
]
16 changes: 9 additions & 7 deletions ad_api/api/sp/ad_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class AdGroups(Client):
@sp_endpoint('/v2/sp/adGroups', method='POST')
def create_ad_groups(self, **kwargs) -> ApiResponse:
r"""
create_ad_groups(self, **kwargs) -> ApiResponse
create_ad_groups(self, \*\*kwargs) -> ApiResponse
Creates one or more ad groups.
Expand All @@ -16,6 +16,7 @@ def create_ad_groups(self, **kwargs) -> ApiResponse:
| '**defaultBid**': *number($float)*, {'description': 'A bid value for use when no bid is specified for keywords in the ad group', 'minimum': '0.02'}
| '**state**': *string*, {'description': 'A name for the ad group', 'Enum': '[ enabled, paused, archived ]'}
Returns:
ApiResponse
Expand All @@ -26,7 +27,7 @@ def create_ad_groups(self, **kwargs) -> ApiResponse:
@sp_endpoint('/v2/sp/adGroups', method='PUT')
def edit_ad_groups(self, **kwargs) -> ApiResponse:
r"""
edit_ad_group(self, **kwargs) -> ApiResponse
edit_ad_group(self, \*\*kwargs) -> ApiResponse
Updates one or more ad groups.
Expand All @@ -47,7 +48,7 @@ def edit_ad_groups(self, **kwargs) -> ApiResponse:
@sp_endpoint('/v2/sp/adGroups', method='GET')
def list_ad_groups(self, **kwargs) -> ApiResponse:
r"""
list_ad_groups(self, **kwargs) -> ApiResponse
list_ad_groups(self, \*\*kwargs) -> ApiResponse
Gets an array of AdGroup objects for a requested set of Sponsored Display ad groups. Note that the AdGroup object is designed for performance, and includes a small set of commonly used fields to reduce size. If the extended set of fields is required, use the ad group operations that return the AdGroupResponseEx object.
Expand All @@ -64,6 +65,7 @@ def list_ad_groups(self, **kwargs) -> ApiResponse:
query **name**:*string* | Optional. The returned array includes only ad groups with the specified name.
Returns:
ApiResponse
Expand All @@ -75,7 +77,7 @@ def list_ad_groups(self, **kwargs) -> ApiResponse:
def get_ad_group(self, adGroupId, **kwargs) -> ApiResponse:
r"""
get_ad_group(self, adGroupId, **kwargs) -> ApiResponse
get_ad_group(self, adGroupId, \*\*kwargs) -> ApiResponse
Gets an ad group specified by identifier.
Expand All @@ -92,7 +94,7 @@ def get_ad_group(self, adGroupId, **kwargs) -> ApiResponse:
def delete_ad_group(self, adGroupId, **kwargs) -> ApiResponse:
r"""
delete_ad_group(self, adGroupId, **kwargs) -> ApiResponse
delete_ad_group(self, adGroupId, \*\*kwargs) -> ApiResponse
Sets the ad group status to archived. Archived entities cannot be made active again. See developer notes for more information.
Expand All @@ -108,7 +110,7 @@ def delete_ad_group(self, adGroupId, **kwargs) -> ApiResponse:
@sp_endpoint('/v2/sp/adGroups/extended', method='GET')
def list_ad_groups_extended(self, **kwargs) -> ApiResponse:
r"""
list_ad_groups_extended(self, **kwargs) -> ApiResponse
list_ad_groups_extended(self, \*\*kwargs) -> ApiResponse
Gets an array of AdGroup objects for a requested set of Sponsored Display ad groups. Note that the AdGroup object is designed for performance, and includes a small set of commonly used fields to reduce size. If the extended set of fields is required, use the ad group operations that return the AdGroupResponseEx object.
Expand All @@ -135,7 +137,7 @@ def list_ad_groups_extended(self, **kwargs) -> ApiResponse:
def get_ad_group_extended(self, adGroupId, **kwargs) -> ApiResponse:
r"""
get_ad_group_extended(self, adGroupId, **kwargs) -> ApiResponse
get_ad_group_extended(self, adGroupId, \*\*kwargs) -> ApiResponse
Gets an ad group that has extended data fields.
Expand Down
10 changes: 6 additions & 4 deletions ad_api/api/sp/bid_recommendations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class BidRecommendations(Client):
@sp_endpoint('/v2/sp/adGroups/{}/bidRecommendations', method='GET')
def get_ad_group_bid_recommendations(self, adGroupId, **kwargs) -> ApiResponse:
r"""
get_ad_group_bid_recommendations(self, adGroupId, **kwargs) -> ApiResponse
get_ad_group_bid_recommendations(self, adGroupId, \*\*kwargs) -> ApiResponse
Gets a bid recommendation for an ad group.
Expand All @@ -22,7 +22,7 @@ def get_ad_group_bid_recommendations(self, adGroupId, **kwargs) -> ApiResponse:
@sp_endpoint('/v2/sp/keywords/{}/bidRecommendations', method='GET')
def get_keyword_bid_recommendations(self, keywordId, **kwargs) -> ApiResponse:
r"""
get_ad_group_bid_recommendations(self, adGroupId, **kwargs) -> ApiResponse
get_ad_group_bid_recommendations(self, adGroupId, \*\*kwargs) -> ApiResponse
Gets a bid recommendation for a keyword.
Expand All @@ -38,7 +38,7 @@ def get_keyword_bid_recommendations(self, keywordId, **kwargs) -> ApiResponse:
@sp_endpoint('/v2/sp/keywords/bidRecommendations', method='POST')
def get_keywords_bid_recommendations(self, **kwargs) -> ApiResponse:
r"""
get_keywords_bid_recommendations(self, **kwargs) -> ApiResponse:
get_keywords_bid_recommendations(self, \*\*kwargs) -> ApiResponse:
Gets bid recommendations for keywords.
Expand All @@ -50,6 +50,7 @@ def get_keywords_bid_recommendations(self, **kwargs) -> ApiResponse:
| '**matchType**': *string*, {'description': 'The type of match', 'Enum': '[ exact, phrase, broad ]'}
| }
Returns:
ApiResponse
Expand All @@ -60,7 +61,7 @@ def get_keywords_bid_recommendations(self, **kwargs) -> ApiResponse:
@sp_endpoint('/v2/sp/targets/bidRecommendations', method='POST')
def get_targets_bid_recommendations(self, **kwargs) -> ApiResponse:
r"""
get_targets_bid_recommendations(self, **kwargs) -> ApiResponse:
get_targets_bid_recommendations(self, \*\*kwargs) -> ApiResponse:
Gets a list of bid recommendations for keyword, product, or auto targeting expressions.
Expand All @@ -72,6 +73,7 @@ def get_targets_bid_recommendations(self, **kwargs) -> ApiResponse:
| '**type**': *string*, {'description': 'The type of targeting expression', 'Enum': '[ queryBroadMatches, queryPhraseMatches, queryExactMatches, asinCategorySameAs, asinBrandSameAs, asinPriceLessThan, asinPriceBetween, asinPriceGreaterThan, asinReviewRatingLessThan, asinReviewRatingBetween, asinReviewRatingGreaterThan, asinSameAs, queryBroadRelMatches, queryHighRelMatches, asinSubstituteRelated, asinAccessoryRelated, asinAgeRangeSameAs, asinGenreSameAs, asinIsPrimeShippingEligible ]'}
| }
Returns:
ApiResponse
Expand Down
31 changes: 31 additions & 0 deletions ad_api/api/sp/campaign_negative_keywords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse

class CampaignNegativeKeywords(Client):

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

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

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

@sp_endpoint('/v2/sp/campaignNegativeKeywords/extended/{}', method='GET')
def get_campaign_negative_keywords_extended_request(self, keywordId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), keywordId), params=kwargs)

@sp_endpoint('/v2/sp/campaignNegativeKeywords/{}', method='DELETE')
def delete_campaign_negative_keywords_request(self, keywordId, **kwargs) -> ApiResponse:
return self._request(fill_query_params(kwargs.pop('path'), keywordId), params=kwargs)

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

@sp_endpoint('/v2/sp/campaignNegativeKeywords', method='PUT')
def edit_campaign_negative_keywords_request(self, **kwargs) -> ApiResponse:
return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs)
5 changes: 2 additions & 3 deletions ad_api/api/sp/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,12 @@ def create_keywords(self, **kwargs) -> ApiResponse:
| '**nativeLanguageLocale**': *string*, {'description': 'The locale preference of the advertiser.'}
| '**matchType**': *string*, {'description': 'The type of match.' , 'Enum': '[ exact, phrase, broad ]'}
| '**bid**': *number($float)* {'description': 'Bid associated with this keyword. Applicable to biddable match types only.'}
Returns:
ApiResponse
Returns:
ApiResponse
"""
return self._request(kwargs.pop('path'), data=kwargs.pop('body'), params=kwargs)

Expand All @@ -158,6 +156,7 @@ def edit_keywords(self, **kwargs) -> ApiResponse:
| '**keywordId**': *number*, {'description': 'The identifer of the campaign to which the keyword is associated.'}
| '**state**': *string*, {'description': 'The current resource state.' , 'Enum': '[ enabled, paused, archived ]'}
| '**bid**': *number($float)* {'description': 'Bid associated with this keyword. Applicable to biddable match types only.'}
Returns:
ApiResponse
Expand Down
24 changes: 14 additions & 10 deletions ad_api/api/sp/negative_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ class NegativeKeywords(Client):
def get_negative_keyword(self, keywordId, **kwargs) -> ApiResponse:
r"""
get_negative_keyword(self, keywordId, **kwargs) -> ApiResponse
get_negative_keyword(self, keywordId, \*\*kwargs) -> ApiResponse
Gets a campaign negative keyword specified by identifier.
path **keywordId**:*number* | Required. The identifier of an existing keyword.
Returns:
ApiResponse
Expand All @@ -23,12 +24,13 @@ def get_negative_keyword(self, keywordId, **kwargs) -> ApiResponse:
def delete_negative_keyword(self, keywordId, **kwargs) -> ApiResponse:
r"""
delete_negative_keyword(self, keywordId, **kwargs) -> ApiResponse
delete_negative_keyword(self, keywordId, \*\*kwargs) -> ApiResponse
Archives a campaign negative keyword.
path **keywordId**:*number* | Required. The identifier of an existing keyword.
Returns:
ApiResponse
Expand All @@ -40,7 +42,7 @@ def delete_negative_keyword(self, keywordId, **kwargs) -> ApiResponse:
def get_negative_keyword_extended(self, keywordId, **kwargs) -> ApiResponse:
r"""
get_negative_keyword_extended(self, keywordId, **kwargs) -> ApiResponse
get_negative_keyword_extended(self, keywordId, \*\*kwargs) -> ApiResponse
Gets a campaign negative keyword that has extended data fields.
Expand All @@ -56,7 +58,7 @@ def get_negative_keyword_extended(self, keywordId, **kwargs) -> ApiResponse:
@sp_endpoint('/v2/sp/negativeKeywords/extended', method='GET')
def list_negative_keywords_extended(self, **kwargs) -> ApiResponse:
r"""
list_negative_keywords_extended(self, **kwargs) -> ApiResponse
list_negative_keywords_extended(self, \*\*kwargs) -> ApiResponse
Gets a list of negative keywords that have extended data fields.
Expand All @@ -74,19 +76,19 @@ def list_negative_keywords_extended(self, **kwargs) -> ApiResponse:
query **adGroupIdFilter**:*string* | Optional. Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list.
query **keywordIdFilter**:*string* | Optional. Restricts results to keywords associated with campaigns specified by identifier in the comma-delimited list..
query **keywordIdFilter**:*string* | Optional. Restricts results to keywords associated with campaigns specified by identifier in the comma-delimited list.
Returns:
Returns:
ApiResponse
"""
"""
return self._request(kwargs.pop('path'), params=kwargs)

@sp_endpoint('/v2/sp/negativeKeywords', method='GET')
def list_negative_keywords(self, **kwargs) -> ApiResponse:
r"""
list_negative_keywords(self, **kwargs) -> ApiResponse
list_negative_keywords(self, \*\*kwargs) -> ApiResponse
Gets a list of negative keyword objects.
Expand Down Expand Up @@ -116,7 +118,7 @@ def list_negative_keywords(self, **kwargs) -> ApiResponse:
@sp_endpoint('/v2/sp/negativeKeywords', method='POST')
def create_negative_keywords(self, **kwargs) -> ApiResponse:
r"""
create_negative_keywords(self, **kwargs) -> ApiResponse:
create_negative_keywords(self, \*\*kwargs) -> ApiResponse:
Creates one or more campaign negative keywords.
Expand All @@ -127,6 +129,7 @@ def create_negative_keywords(self, **kwargs) -> ApiResponse:
| '**state**': *string*, {'description': 'The current resource state.' , 'Enum': '[ enabled ]'}
| '**keywordText**': *string*, {'description': 'The text of the expression to match against a search query.'}
| '**matchType**': *string*, {'description': 'The type of match.' , 'Enum': '[ negativeExact, negativePhrase ]'}
Returns:
ApiResponse
Expand All @@ -137,14 +140,15 @@ def create_negative_keywords(self, **kwargs) -> ApiResponse:
@sp_endpoint('/v2/sp/negativeKeywords', method='PUT')
def edit_negative_keywords(self, **kwargs) -> ApiResponse:
r"""
edit_negative_keywords(self, **kwargs) -> ApiResponse:
edit_negative_keywords(self, \*\*kwargs) -> ApiResponse:
Updates one or more campaign negative keywords.
body: | REQUIRED {'description': 'An array of campaign negative keywords with updated values.'}
| '**keywordId**': *number*, {'description': 'The identifer of the campaign to which the keyword is associated.'}
| '**state**': *string*, {'description': 'The current resource state.' , 'Enum': '[ enabled, paused, archived ]'}
Returns:
ApiResponse
Expand Down
Loading

0 comments on commit 88fb547

Please sign in to comment.