python-amazon-ad-api 2.2.2__py3-none-any.whl → 2.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ad_api/api/__init__.py CHANGED
@@ -31,6 +31,7 @@ from .recommendations import Recommendations
31
31
  from .stream import Stream
32
32
  from .exports import Exports
33
33
  from .stores import Stores
34
+ from .brand_home import BrandHome
34
35
 
35
36
  __all__ = [
36
37
  "v1",
@@ -68,5 +69,6 @@ __all__ = [
68
69
  "Stream",
69
70
  "Exports",
70
71
  "Stores",
72
+ "BrandHome",
71
73
  "Account"
72
74
  ]
@@ -0,0 +1,135 @@
1
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
2
+
3
+
4
+ class BrandHome(Client):
5
+ r"""
6
+ BrandHome(account='default', marketplace: Marketplaces = Marketplaces.EU, credentials=None, debug=False)
7
+
8
+ Amazon Ads API v0 - Brand Home
9
+
10
+ Two routes, both POST: the stores of an advertiser, and the pages inside
11
+ one store.
12
+
13
+ POST /brand/stores/v1/stores/list
14
+ POST /brand/stores/v1/storePages/list
15
+
16
+ Not the same family as :class:`~ad_api.api.v1.BrandStores`
17
+ (``/adsApi/v1/query/brandStores``): that one is the v1 query and demands a
18
+ ``storeNameFilter``; this one lists stores by advertiser and pages by
19
+ store.
20
+
21
+ Contract: ``specs/BrandHome_prod_3p.json`` (Brand Home 3.0, 9 050 B,
22
+ sha256 8cbb22a5...789eaf).
23
+
24
+ Media types, copied from the contract
25
+ -------------------------------------
26
+ Each route declares its own ``Content-Type``, and bare
27
+ ``application/json`` is NOT among them:
28
+
29
+ stores/list application/vnd.bhstoreslist.v1+json
30
+ storePages/list application/vnd.bhstorepageslist.v1+json
31
+
32
+ Measured against the service (2026-11-30, leadtech_fr)
33
+ ---------------------------------------------------------
34
+ Both routes answer 200. What the service accepts:
35
+
36
+ * **Identity**: ``Amazon-Advertising-API-Scope`` only. Sending
37
+ ``Amazon-Advertising-AccountId`` or ``Amazon-Advertising-GlobalAccountId``
38
+ instead answers 400 "profile ID required".
39
+ * **Media type**: the one the contract declares, or its BNF twin
40
+ (``application/brandStores.ListStores.v1+json``). Bare
41
+ ``application/json`` answers 400 "Cannot consume content type".
42
+ * **``identifierType``**: ``ENTITY_ID`` on stores, ``STORE`` on pages.
43
+ ``BRAND_AID_ID`` answers 400 "not supported".
44
+ * **``identifier``**: required on both, and it must match the entity id the
45
+ service derives from the identity headers. Stores take the advertiser
46
+ entity (``ENTITY3412Q8SIECJWW``); pages take the ``storeId`` returned by
47
+ stores (``106FD13E-...``).
48
+
49
+ Getting the advertiser entity id: the service truncates it in the error
50
+ ("entityId derived from headers = ENTITY3412Q8SIE" for a 21-char id), so
51
+ send a wrong value once and read the next message, which carries the full
52
+ one.
53
+
54
+ ``identifierType``, in the contract and in practice
55
+ ---------------------------------------------------
56
+ The contract lists ``ASIN``, ``BRAND_AID_ID``, ``ENTITY_ID``, ``GCOR``,
57
+ ``NODE`` and ``STORE``; the service accepts ``ENTITY_ID`` on stores and
58
+ ``STORE`` on pages, and refuses ``BRAND_AID_ID`` on both.
59
+ """
60
+
61
+ @sp_endpoint('/brand/stores/v1/stores/list', method='POST', headers=['Amazon-Advertising-API-Scope'])
62
+ def list_stores(self, **kwargs) -> ApiResponse:
63
+ r"""
64
+ list_stores(body: dict) -> ApiResponse
65
+
66
+ Amazon Ads API v0 - Brand Home ListStores (operationId: ListStores)
67
+
68
+ Request Body [identifier and identifierType are REQUIRED by the service]
69
+ | **identifier** (string) : [required] advertiser entityId, ENTITY3412Q8SIECJWW in leadtech_fr
70
+ | **identifierType** (string) : [required] ENTITY_ID (the only value the service accepts here)
71
+ | **maxResults** (int) [optional] : 1..30, default 30
72
+ | **nextToken** (string) [optional]
73
+
74
+ The contract marks no member as required and the probe answers 400
75
+ "Both identifier and identifierType need to be present." without
76
+ them, so they are required here.
77
+
78
+ Media type
79
+ application/vnd.bhstoreslist.v1+json
80
+
81
+ Returns
82
+ ApiResponse
83
+ | **stores** (list<StoreInfo>) : may be empty; each one 200-tested
84
+ | **storeId** (string)
85
+ | **storeName** (string)
86
+ | **brandEntityId** (string)
87
+ | **storeStatus** (State) : APPROVED | CANCELED | DRAFT | LIVE | PENDING | REJECTED | SCHEDULED
88
+ | **nextToken** (string)
89
+ """
90
+ headers = {
91
+ "Accept": 'application/json',
92
+ "Content-Type": 'application/vnd.bhstoreslist.v1+json',
93
+ }
94
+ return self._request(
95
+ kwargs.pop('path'),
96
+ data=Utils.convert_body(kwargs.pop('body'), False),
97
+ params=kwargs,
98
+ headers=headers,
99
+ )
100
+
101
+ @sp_endpoint('/brand/stores/v1/storePages/list', method='POST', headers=['Amazon-Advertising-API-Scope'])
102
+ def list_store_pages(self, **kwargs) -> ApiResponse:
103
+ r"""
104
+ list_store_pages(body: dict) -> ApiResponse
105
+
106
+ Amazon Ads API v0 - Brand Home ListPages (operationId: ListPages)
107
+
108
+ Request Body [Required]
109
+ | **identifier** (string) : [required] storeId from list_stores
110
+ | **identifierType** (string) : [required] STORE (BRAND_AID_ID answers not supported)
111
+ | **maxResults** (int) [optional] : 1..30, default 30
112
+ | **nextToken** (string) [optional]
113
+
114
+ Media type
115
+ application/vnd.bhstorepageslist.v1+json
116
+
117
+ Returns
118
+ ApiResponse
119
+ | **storePages** (list<StorePageInfo>)
120
+ | **storePageId** (string)
121
+ | **storePageUrl** (string)
122
+ | **storePageName** (string)
123
+ | **storePageStatus** (State)
124
+ | **nextToken** (string)
125
+ """
126
+ headers = {
127
+ "Accept": 'application/json',
128
+ "Content-Type": 'application/vnd.bhstorepageslist.v1+json',
129
+ }
130
+ return self._request(
131
+ kwargs.pop('path'),
132
+ data=Utils.convert_body(kwargs.pop('body'), False),
133
+ params=kwargs,
134
+ headers=headers,
135
+ )
@@ -0,0 +1,21 @@
1
+ from .ad_groups import AdGroups
2
+ from .ads import Ads
3
+ from .campaigns import Campaigns
4
+ from .creatives import Creatives
5
+ from .creatives_moderations import CreativesModerations
6
+ from .creatives_preview import CreativesPreview
7
+ from .forecasts import Forecasts
8
+ from .locations import Locations
9
+ from .targets import Targets
10
+
11
+ __all__ = [
12
+ "AdGroups",
13
+ "Ads",
14
+ "Campaigns",
15
+ "Creatives",
16
+ "CreativesModerations",
17
+ "CreativesPreview",
18
+ "Forecasts",
19
+ "Locations",
20
+ "Targets",
21
+ ]
@@ -0,0 +1,129 @@
1
+ """Sponsored TV ad groups.
2
+
3
+ Contract: Sponsored TV 3.0, ``/st/adGroups``. Every route needs the profile
4
+ scope, so each one declares ``Amazon-Advertising-API-Scope``; the body media
5
+ type is ``application/vnd.stAdGroup.v<version>+json``.
6
+
7
+ ``Prefer`` is not an identity header. The contract allows
8
+ ``include=extendedData`` on list and ``return=representation`` on create,
9
+ update and delete, optionally combined. The parameter takes the value as text
10
+ and the caller decides.
11
+ """
12
+
13
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
14
+
15
+
16
+ class AdGroups(Client):
17
+ r"""Sponsored TV - AdGroups"""
18
+
19
+ @sp_endpoint('/st/adGroups', method='POST', headers=['Amazon-Advertising-API-Scope'])
20
+ def create_ad_groups(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
21
+ r"""
22
+ Creates Sponsored TV ad groups.
23
+
24
+ Request Body [Required]
25
+ | **adGroups** (list): 1 to 100 ad groups. Each one carries:
26
+ | **campaignId** (string) [required]: the Campaign the ad group belongs to.
27
+ | **name** (string) [required]: 1 to 255 characters.
28
+ | **state** (string) [required]: ENABLED or PAUSED.
29
+ | **defaultBid** (object) [optional]: ``{"bid": number}``, used when no bid is given.
30
+
31
+ Keyword Args
32
+
33
+ - ``version`` (int): media type version. Defaults to 1.
34
+ - ``prefer`` (str): ``return=representation`` to get the full objects back,
35
+ optionally ``return=representation,include=extendedData``. [optional]
36
+
37
+ Returns
38
+ ApiResponse with ``adGroups``: ``success`` and ``error`` lists, so one
39
+ call can accept some entries and refuse others. Check both.
40
+ """
41
+ schema = 'application/vnd.stAdGroup.v' + str(version) + '+json'
42
+ headers = {'Accept': schema, 'Content-Type': schema}
43
+ if prefer:
44
+ headers.update({'Prefer': prefer})
45
+ body = Utils.convert_body(kwargs.pop('body'), False)
46
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
47
+
48
+ @sp_endpoint('/st/adGroups', method='PUT', headers=['Amazon-Advertising-API-Scope'])
49
+ def update_ad_groups(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
50
+ r"""
51
+ Updates Sponsored TV ad groups.
52
+
53
+ Request Body [Required]
54
+ | **adGroups** (list): 1 to 100 ad groups. Each one carries:
55
+ | **adGroupId** (string) [required]
56
+ | **name** (string) [optional]: 1 to 255 characters.
57
+ | **state** (string) [optional]: ENABLED or PAUSED.
58
+ | **defaultBid** (object) [optional]: ``{"bid": number}``.
59
+
60
+ Keyword Args
61
+
62
+ - ``version`` (int): media type version. Defaults to 1.
63
+ - ``prefer`` (str): ``return=representation``, optionally with
64
+ ``include=extendedData``. [optional]
65
+
66
+ Returns
67
+ ApiResponse with ``adGroups``: ``success`` and ``error`` lists.
68
+ """
69
+ schema = 'application/vnd.stAdGroup.v' + str(version) + '+json'
70
+ headers = {'Accept': schema, 'Content-Type': schema}
71
+ if prefer:
72
+ headers.update({'Prefer': prefer})
73
+ body = Utils.convert_body(kwargs.pop('body'), False)
74
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
75
+
76
+ @sp_endpoint('/st/adGroups/delete', method='POST', headers=['Amazon-Advertising-API-Scope'])
77
+ def delete_ad_groups(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
78
+ r"""
79
+ Deletes Sponsored TV ad groups. The ids travel in the **body**.
80
+
81
+ Request Body [Required]
82
+ | **adGroupIdFilter** (object) [required]: ``{"include": [adGroupId, ...]}``,
83
+ 1 to 100 ids.
84
+
85
+ Keyword Args
86
+
87
+ - ``version`` (int): media type version. Defaults to 1.
88
+ - ``prefer`` (str): ``return=representation``, optionally with
89
+ ``include=extendedData``. [optional]
90
+
91
+ Returns
92
+ ApiResponse with ``adGroups``: ``success`` and ``error`` lists.
93
+ """
94
+ schema = 'application/vnd.stAdGroup.v' + str(version) + '+json'
95
+ headers = {'Accept': schema, 'Content-Type': schema}
96
+ if prefer:
97
+ headers.update({'Prefer': prefer})
98
+ body = Utils.convert_body(kwargs.pop('body'), False)
99
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
100
+
101
+ @sp_endpoint('/st/adGroups/list', method='POST', headers=['Amazon-Advertising-API-Scope'])
102
+ def list_ad_groups(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
103
+ r"""
104
+ Lists Sponsored TV ad groups.
105
+
106
+ Request Body [Optional]
107
+ | **adGroupIdFilter** (object): ``{"include": [...]}``, 1 to 100 ids.
108
+ | **campaignIdFilter** (object): ``{"include": [...]}``, 1 to 100 ids.
109
+ | **fullFunnelCampaignIdFilter** (object): ``{"include": [...]}``, 1 to 100 ids.
110
+ | **nameFilter** (object): ``{"include": [...], "queryTermMatchType": BROAD_MATCH|EXACT_MATCH}``.
111
+ | **stateFilter** (object): ``{"include": [ARCHIVED|ENABLED|PAUSED, ...]}``, 1 to 10 values.
112
+ | **maxResults** (int): 1 to 100, defaults to the maximum page size.
113
+ | **nextToken** (string): pagination token from a previous answer.
114
+
115
+ Keyword Args
116
+
117
+ - ``version`` (int): media type version. Defaults to 1.
118
+ - ``prefer`` (str): ``include=extendedData``, optionally with
119
+ ``return=representation``. [optional]
120
+
121
+ Returns
122
+ ApiResponse with the ad groups, ``nextToken`` and ``totalResults``.
123
+ """
124
+ schema = 'application/vnd.stAdGroup.v' + str(version) + '+json'
125
+ headers = {'Accept': schema, 'Content-Type': schema}
126
+ if prefer:
127
+ headers.update({'Prefer': prefer})
128
+ body = kwargs.pop('body', None)
129
+ return self._request(kwargs.pop('path'), params=kwargs, headers=headers, **({'data': Utils.convert_body(body, False)} if body is not None else {}))
ad_api/api/st/ads.py ADDED
@@ -0,0 +1,111 @@
1
+ """Sponsored TV /st/ads.
2
+
3
+ Contract: Sponsored TV 3.0, ``/st/ads``. Every route needs the profile
4
+ scope, so each one declares ``Amazon-Advertising-API-Scope``; the body media
5
+ type is ``stAd.v<version>+json``.
6
+
7
+ ``Prefer`` is not an identity header. The contract allows
8
+ ``include=extendedData`` on list and ``return=representation`` on create,
9
+ update and delete, optionally combined.
10
+ """
11
+
12
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
13
+
14
+
15
+ class Ads(Client):
16
+ r"""Sponsored TV - /st/ads"""
17
+
18
+ @sp_endpoint('/st/ads', method='POST', headers=['Amazon-Advertising-API-Scope'])
19
+ def create_ads(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
20
+ r"""
21
+ Creates Sponsored TV ads.
22
+
23
+ Request Body [Required]
24
+ | **ads** (list): 1 to 100 ads.
25
+
26
+ Keyword Args
27
+
28
+ - ``version`` (int): media type version. Defaults to 1.
29
+ - ``prefer`` (str): ``return=representation``, optionally with ``include=extendedData``. [optional]
30
+
31
+ Returns
32
+ ApiResponse with ``ads``: ``success`` and ``error`` lists.
33
+ """
34
+ schema = 'application/vnd.stAd.v' + str(version) + '+json'
35
+ headers = {'Accept': schema, 'Content-Type': schema}
36
+ if prefer:
37
+ headers.update({'Prefer': prefer})
38
+ body = Utils.convert_body(kwargs.pop('body'), False)
39
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
40
+
41
+ @sp_endpoint('/st/ads', method='PUT', headers=['Amazon-Advertising-API-Scope'])
42
+ def update_ads(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
43
+ r"""
44
+ Updates Sponsored TV ads.
45
+
46
+ Request Body [Required]
47
+ | **ads** (list): 1 to 100 ads, each with **adId**.
48
+
49
+ Keyword Args
50
+
51
+ - ``version`` (int): media type version. Defaults to 1.
52
+ - ``prefer`` (str): ``return=representation``, optionally with ``include=extendedData``. [optional]
53
+
54
+ Returns
55
+ ApiResponse with ``ads``: ``success`` and ``error`` lists.
56
+ """
57
+ schema = 'application/vnd.stAd.v' + str(version) + '+json'
58
+ headers = {'Accept': schema, 'Content-Type': schema}
59
+ if prefer:
60
+ headers.update({'Prefer': prefer})
61
+ body = Utils.convert_body(kwargs.pop('body'), False)
62
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
63
+
64
+ @sp_endpoint('/st/ads/delete', method='POST', headers=['Amazon-Advertising-API-Scope'])
65
+ def delete_ads(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
66
+ r"""
67
+ Deletes Sponsored TV ads. The ids travel in the **body**.
68
+
69
+ Request Body [Required]
70
+ | **adIdFilter** (object) [required]: ``{"include": [adId, ...]}``.
71
+
72
+ Keyword Args
73
+
74
+ - ``version`` (int): media type version. Defaults to 1.
75
+ - ``prefer`` (str): ``return=representation``, optionally with ``include=extendedData``. [optional]
76
+
77
+ Returns
78
+ ApiResponse with ``ads``: ``success`` and ``error`` lists.
79
+ """
80
+ schema = 'application/vnd.stAd.v' + str(version) + '+json'
81
+ headers = {'Accept': schema, 'Content-Type': schema}
82
+ if prefer:
83
+ headers.update({'Prefer': prefer})
84
+ body = Utils.convert_body(kwargs.pop('body'), False)
85
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
86
+
87
+ @sp_endpoint('/st/ads/list', method='POST', headers=['Amazon-Advertising-API-Scope'])
88
+ def list_ads(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
89
+ r"""
90
+ Lists Sponsored TV ads.
91
+
92
+ Request Body [Optional]
93
+ | **adIdFilter**, **adGroupIdFilter**, **campaignIdFilter**, **fullFunnelCampaignIdFilter** (objects): each ``{"include": [...]}``.
94
+ | **stateFilter** (object): ``{"include": [ARCHIVED|ENABLED|PAUSED, ...]}``.
95
+ | **maxResults** (int): 1 to 100.
96
+ | **nextToken** (string): pagination token.
97
+
98
+ Keyword Args
99
+
100
+ - ``version`` (int): media type version. Defaults to 1.
101
+ - ``prefer`` (str): ``include=extendedData``, optionally with ``return=representation``. [optional]
102
+
103
+ Returns
104
+ ApiResponse with the ads, ``nextToken`` and ``totalResults``.
105
+ """
106
+ schema = 'application/vnd.stAd.v' + str(version) + '+json'
107
+ headers = {'Accept': schema, 'Content-Type': schema}
108
+ if prefer:
109
+ headers.update({'Prefer': prefer})
110
+ body = kwargs.pop('body', None)
111
+ return self._request(kwargs.pop('path'), params=kwargs, headers=headers, **({'data': Utils.convert_body(body, False)} if body is not None else {}))
@@ -0,0 +1,112 @@
1
+ """Sponsored TV /st/campaigns.
2
+
3
+ Contract: Sponsored TV 3.0, ``/st/campaigns``. Every route needs the profile
4
+ scope, so each one declares ``Amazon-Advertising-API-Scope``; the body media
5
+ type is ``stCampaign.v<version>+json``.
6
+
7
+ ``Prefer`` is not an identity header. The contract allows
8
+ ``include=extendedData`` on list and ``return=representation`` on create,
9
+ update and delete, optionally combined.
10
+ """
11
+
12
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
13
+
14
+
15
+ class Campaigns(Client):
16
+ r"""Sponsored TV - /st/campaigns"""
17
+
18
+ @sp_endpoint('/st/campaigns', method='POST', headers=['Amazon-Advertising-API-Scope'])
19
+ def create_campaigns(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
20
+ r"""
21
+ Creates Sponsored TV campaigns.
22
+
23
+ Request Body [Required]
24
+ | **campaigns** (list): 1 to 100 campaigns.
25
+
26
+ Keyword Args
27
+
28
+ - ``version`` (int): media type version. Defaults to 1.
29
+ - ``prefer`` (str): ``return=representation``, optionally with ``include=extendedData``. [optional]
30
+
31
+ Returns
32
+ ApiResponse with ``campaigns``: ``success`` and ``error`` lists.
33
+ """
34
+ schema = 'application/vnd.stCampaign.v' + str(version) + '+json'
35
+ headers = {'Accept': schema, 'Content-Type': schema}
36
+ if prefer:
37
+ headers.update({'Prefer': prefer})
38
+ body = Utils.convert_body(kwargs.pop('body'), False)
39
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
40
+
41
+ @sp_endpoint('/st/campaigns', method='PUT', headers=['Amazon-Advertising-API-Scope'])
42
+ def update_campaigns(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
43
+ r"""
44
+ Updates Sponsored TV campaigns.
45
+
46
+ Request Body [Required]
47
+ | **campaigns** (list): 1 to 100 campaigns, each with **campaignId**.
48
+
49
+ Keyword Args
50
+
51
+ - ``version`` (int): media type version. Defaults to 1.
52
+ - ``prefer`` (str): ``return=representation``, optionally with ``include=extendedData``. [optional]
53
+
54
+ Returns
55
+ ApiResponse with ``campaigns``: ``success`` and ``error`` lists.
56
+ """
57
+ schema = 'application/vnd.stCampaign.v' + str(version) + '+json'
58
+ headers = {'Accept': schema, 'Content-Type': schema}
59
+ if prefer:
60
+ headers.update({'Prefer': prefer})
61
+ body = Utils.convert_body(kwargs.pop('body'), False)
62
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
63
+
64
+ @sp_endpoint('/st/campaigns/delete', method='POST', headers=['Amazon-Advertising-API-Scope'])
65
+ def delete_campaigns(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
66
+ r"""
67
+ Deletes Sponsored TV campaigns. The ids travel in the **body**.
68
+
69
+ Request Body [Required]
70
+ | **campaignIdFilter** (object) [required]: ``{"include": [campaignId, ...]}``.
71
+
72
+ Keyword Args
73
+
74
+ - ``version`` (int): media type version. Defaults to 1.
75
+ - ``prefer`` (str): ``return=representation``, optionally with ``include=extendedData``. [optional]
76
+
77
+ Returns
78
+ ApiResponse with ``campaigns``: ``success`` and ``error`` lists.
79
+ """
80
+ schema = 'application/vnd.stCampaign.v' + str(version) + '+json'
81
+ headers = {'Accept': schema, 'Content-Type': schema}
82
+ if prefer:
83
+ headers.update({'Prefer': prefer})
84
+ body = Utils.convert_body(kwargs.pop('body'), False)
85
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
86
+
87
+ @sp_endpoint('/st/campaigns/list', method='POST', headers=['Amazon-Advertising-API-Scope'])
88
+ def list_campaigns(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
89
+ r"""
90
+ Lists Sponsored TV campaigns.
91
+
92
+ Request Body [Optional]
93
+ | **campaignIdFilter**, **fullFunnelCampaignIdFilter** (objects): each ``{"include": [...]}``.
94
+ | **nameFilter** (object): ``{"include": [...], "queryTermMatchType": BROAD_MATCH|EXACT_MATCH}``.
95
+ | **stateFilter**, **targetingTypeFilter**: each ``{"include": [...]}``.
96
+ | **maxResults** (int): 1 to 100.
97
+ | **nextToken** (string): pagination token.
98
+
99
+ Keyword Args
100
+
101
+ - ``version`` (int): media type version. Defaults to 1.
102
+ - ``prefer`` (str): ``include=extendedData``, optionally with ``return=representation``. [optional]
103
+
104
+ Returns
105
+ ApiResponse with the campaigns, ``nextToken`` and ``totalResults``.
106
+ """
107
+ schema = 'application/vnd.stCampaign.v' + str(version) + '+json'
108
+ headers = {'Accept': schema, 'Content-Type': schema}
109
+ if prefer:
110
+ headers.update({'Prefer': prefer})
111
+ body = kwargs.pop('body', None)
112
+ return self._request(kwargs.pop('path'), params=kwargs, headers=headers, **({'data': Utils.convert_body(body, False)} if body is not None else {}))
@@ -0,0 +1,76 @@
1
+ """Sponsored TV /st/creatives.
2
+
3
+ Contract: Sponsored TV 3.0, ``/st/creatives``. Every route needs the profile
4
+ scope, so each one declares ``Amazon-Advertising-API-Scope``; the body media
5
+ type is ``stCreative.v<version>+json``.
6
+
7
+ ``Prefer`` is not an identity header.
8
+ """
9
+
10
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
11
+
12
+
13
+ class Creatives(Client):
14
+ r"""Sponsored TV - /st/creatives"""
15
+
16
+ @sp_endpoint('/st/creatives', method='POST', headers=['Amazon-Advertising-API-Scope'])
17
+ def create_creatives(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
18
+ r"""
19
+ Creates Sponsored TV creatives.
20
+
21
+ Request Body [Required]
22
+ | **creatives** (list): each one with **adGroupId**, **assetId** and **assetVersion**.
23
+
24
+ Keyword Args
25
+
26
+ - ``version`` (int): media type version. Defaults to 1.
27
+
28
+ Returns
29
+ ApiResponse with ``creatives``: ``success`` and ``error`` lists.
30
+ """
31
+ schema = 'application/vnd.stCreative.v' + str(version) + '+json'
32
+ headers = {'Accept': schema, 'Content-Type': schema}
33
+ body = Utils.convert_body(kwargs.pop('body'), False)
34
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
35
+
36
+ @sp_endpoint('/st/creatives', method='PUT', headers=['Amazon-Advertising-API-Scope'])
37
+ def update_creatives(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
38
+ r"""
39
+ Updates Sponsored TV creatives.
40
+
41
+ Request Body [Required]
42
+ | **creatives** (list): each one with **creativeId**, **assetId** and **assetVersion**.
43
+
44
+ Keyword Args
45
+
46
+ - ``version`` (int): media type version. Defaults to 1.
47
+
48
+ Returns
49
+ ApiResponse with ``creatives``: ``success`` and ``error`` lists.
50
+ """
51
+ schema = 'application/vnd.stCreative.v' + str(version) + '+json'
52
+ headers = {'Accept': schema, 'Content-Type': schema}
53
+ body = Utils.convert_body(kwargs.pop('body'), False)
54
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
55
+
56
+ @sp_endpoint('/st/creatives/list', method='POST', headers=['Amazon-Advertising-API-Scope'])
57
+ def list_creatives(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
58
+ r"""
59
+ Lists Sponsored TV creatives.
60
+
61
+ Request Body [Optional]
62
+ | **adGroupIdFilter**, **creativeIdFilter**, **fullFunnelCampaignIdFilter** (objects): each ``{"include": [...]}``.
63
+ | **maxResults** (int): 1 to 100.
64
+ | **nextToken** (string): pagination token.
65
+
66
+ Keyword Args
67
+
68
+ - ``version`` (int): media type version. Defaults to 1.
69
+
70
+ Returns
71
+ ApiResponse with the creatives, ``nextToken`` and ``totalResults``.
72
+ """
73
+ schema = 'application/vnd.stCreative.v' + str(version) + '+json'
74
+ headers = {'Accept': schema, 'Content-Type': schema}
75
+ body = kwargs.pop('body', None)
76
+ return self._request(kwargs.pop('path'), params=kwargs, headers=headers, **({'data': Utils.convert_body(body, False)} if body is not None else {}))
@@ -0,0 +1,58 @@
1
+ """Sponsored TV /st/creatives/moderations.
2
+
3
+ Contract: Sponsored TV 3.0, ``/st/creatives/moderations``. Every route needs the profile
4
+ scope, so each one declares ``Amazon-Advertising-API-Scope``; the body media
5
+ type is ``stCreativesModerations.v<version>+json``.
6
+
7
+ ``Prefer`` is not an identity header.
8
+ """
9
+
10
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
11
+
12
+
13
+ class CreativesModerations(Client):
14
+ r"""Sponsored TV - /st/creatives/moderations"""
15
+
16
+ @sp_endpoint('/st/creatives/moderations/list', method='POST', headers=['Amazon-Advertising-API-Scope'])
17
+ def list_creatives_moderations(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
18
+ r"""
19
+ Lists the moderation results of Sponsored TV creatives.
20
+
21
+ Request Body [Optional]
22
+ | **adGroupIdFilter**, **creativeIdFilter** (objects): each ``{"include": [...]}``.
23
+ | **locale** (string): locale of the moderation text.
24
+ | **maxResults** (int): 1 to 100.
25
+ | **nextToken** (string): pagination token.
26
+
27
+ Keyword Args
28
+
29
+ - ``version`` (int): media type version. Defaults to 1.
30
+
31
+ Returns
32
+ ApiResponse with the moderation results.
33
+ """
34
+ schema = 'application/vnd.stCreativesModerations.v' + str(version) + '+json'
35
+ headers = {'Accept': schema, 'Content-Type': schema}
36
+ body = kwargs.pop('body', None)
37
+ return self._request(kwargs.pop('path'), params=kwargs, headers=headers, **({'data': Utils.convert_body(body, False)} if body is not None else {}))
38
+
39
+ @sp_endpoint('/st/creatives/moderations/policyViolations/list', method='POST', headers=['Amazon-Advertising-API-Scope'])
40
+ def list_creatives_moderations_policy_violations(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
41
+ r"""
42
+ Lists the policy violations found in the moderation of Sponsored TV creatives.
43
+
44
+ Request Body [Required]
45
+ | **adGroupIdFilter**, **creativeIdFilter** (objects): each ``{"include": [...]}``.
46
+ | **locale** (string): locale of the moderation text.
47
+
48
+ Keyword Args
49
+
50
+ - ``version`` (int): media type version. Defaults to 1.
51
+
52
+ Returns
53
+ ApiResponse with the policy violations.
54
+ """
55
+ schema = 'application/vnd.stCreativesModerations.v' + str(version) + '+json'
56
+ headers = {'Accept': schema, 'Content-Type': schema}
57
+ body = Utils.convert_body(kwargs.pop('body'), False)
58
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)