python-amazon-ad-api 2.3.1__py3-none-any.whl → 2.4.1__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.
Files changed (41) hide show
  1. ad_api/api/__init__.py +68 -0
  2. ad_api/api/dsp_ad_creative_association.py +147 -0
  3. ad_api/api/dsp_ad_group_and_campaign.py +139 -0
  4. ad_api/api/dsp_audience_create.py +53 -0
  5. ad_api/api/dsp_bid_adjustments.py +193 -0
  6. ad_api/api/dsp_campaign_flights.py +119 -0
  7. ad_api/api/dsp_campaign_insights.py +59 -0
  8. ad_api/api/dsp_combined_audiences.py +83 -0
  9. ad_api/api/dsp_conversion_tracking_products.py +92 -0
  10. ad_api/api/dsp_conversions.py +442 -0
  11. ad_api/api/dsp_creatives.py +114 -0
  12. ad_api/api/dsp_deal_permissions.py +170 -0
  13. ad_api/api/dsp_deal_proposals.py +440 -0
  14. ad_api/api/dsp_deals.py +204 -0
  15. ad_api/api/dsp_deals_management.py +66 -0
  16. ad_api/api/dsp_discovery_advertised_product_categories.py +35 -0
  17. ad_api/api/dsp_discovery_apps.py +36 -0
  18. ad_api/api/dsp_discovery_domain_lists.py +36 -0
  19. ad_api/api/dsp_discovery_geo_locations.py +42 -0
  20. ad_api/api/dsp_discovery_iab_content.py +37 -0
  21. ad_api/api/dsp_discovery_inventory_source_exchanges.py +36 -0
  22. ad_api/api/dsp_discovery_products.py +102 -0
  23. ad_api/api/dsp_discovery_third_party_target_segments.py +36 -0
  24. ad_api/api/dsp_frequency_associations.py +138 -0
  25. ad_api/api/dsp_frequency_groups.py +112 -0
  26. ad_api/api/dsp_frequency_insights.py +85 -0
  27. ad_api/api/dsp_guidance.py +111 -0
  28. ad_api/api/dsp_inherited_settings.py +133 -0
  29. ad_api/api/dsp_inventory_groups.py +209 -0
  30. ad_api/api/dsp_measurement.py +693 -0
  31. ad_api/api/dsp_quick_actions.py +177 -0
  32. ad_api/api/dsp_seats.py +43 -0
  33. ad_api/api/dsp_seats_management.py +84 -0
  34. ad_api/api/dsp_target_kpi_recommendations.py +44 -0
  35. ad_api/api/dsp_targeting.py +98 -0
  36. ad_api/version.py +1 -1
  37. {python_amazon_ad_api-2.3.1.dist-info → python_amazon_ad_api-2.4.1.dist-info}/METADATA +1 -1
  38. {python_amazon_ad_api-2.3.1.dist-info → python_amazon_ad_api-2.4.1.dist-info}/RECORD +41 -7
  39. {python_amazon_ad_api-2.3.1.dist-info → python_amazon_ad_api-2.4.1.dist-info}/WHEEL +0 -0
  40. {python_amazon_ad_api-2.3.1.dist-info → python_amazon_ad_api-2.4.1.dist-info}/licenses/LICENSE +0 -0
  41. {python_amazon_ad_api-2.3.1.dist-info → python_amazon_ad_api-2.4.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,204 @@
1
+ """Deals /dsp/inventory/deals and /dsp/inventorySourceDeals.
2
+
3
+ Contract: Deals 3.0, part of *Deal management*. Eight read routes, plain
4
+ ``vnd.deals.v1`` except the last one, which speaks ``vnd.dspinventorysourcedeals``.
5
+
6
+ **All 200: nothing here writes.** Note that ``/dsp/inventorySourceDeals/list``
7
+ has no ``inventory/`` in the middle, unlike its siblings.
8
+
9
+ ``ClientId`` is the only required header; ``Scope`` and ``AccountId`` are
10
+ optional. The last route requires all three.
11
+ """
12
+
13
+ from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
14
+
15
+
16
+ class DspDeals(Client):
17
+ r"""Deals - /dsp/inventory/deals
18
+
19
+ Documentation: https://advertising.amazon.com/API/docs/en-us/deals-performance-and-exchanges
20
+ """
21
+
22
+ @sp_endpoint('/dsp/inventory/deals/list', method='POST',
23
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
24
+ def list_deals(self, version: str = "1", **kwargs) -> ApiResponse:
25
+ r"""
26
+ Lists deals. Read only.
27
+
28
+ Keyword Args
29
+
30
+ - ``version`` (str): the version in the media type, ``1``. [optional]
31
+
32
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
33
+
34
+ Returns
35
+ ApiResponse, ``200``, with the deals.
36
+ """
37
+ media_type = 'application/vnd.deals.v' + version + '+json'
38
+ headers = {'Accept': media_type}
39
+ headers['Content-Type'] = media_type
40
+ body = Utils.convert_body(kwargs.pop('body'), False)
41
+ return self._request(kwargs.pop('path'),
42
+ data=body, params=kwargs, headers=headers)
43
+
44
+ @sp_endpoint('/dsp/inventory/deals/performance/list', method='POST',
45
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
46
+ def list_deal_performance(self, version: str = "1", **kwargs) -> ApiResponse:
47
+ r"""
48
+ Lists deal performance. Read only.
49
+
50
+ Keyword Args
51
+
52
+ - ``version`` (str): the version in the media type, ``1``. [optional]
53
+
54
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
55
+
56
+ Returns
57
+ ApiResponse, ``200``, with the performance.
58
+ """
59
+ media_type = 'application/vnd.deals.v' + version + '+json'
60
+ headers = {'Accept': media_type}
61
+ headers['Content-Type'] = media_type
62
+ body = Utils.convert_body(kwargs.pop('body'), False)
63
+ return self._request(kwargs.pop('path'),
64
+ data=body, params=kwargs, headers=headers)
65
+
66
+ @sp_endpoint('/dsp/inventory/deals/exchanges/list', method='POST',
67
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
68
+ def list_deal_exchanges(self, version: str = "1", **kwargs) -> ApiResponse:
69
+ r"""
70
+ Lists the exchanges a deal can run on. Read only.
71
+
72
+ Keyword Args
73
+
74
+ - ``version`` (str): the version in the media type, ``1``. [optional]
75
+
76
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
77
+
78
+ Returns
79
+ ApiResponse, ``200``, with the exchanges.
80
+ """
81
+ media_type = 'application/vnd.deals.v' + version + '+json'
82
+ headers = {'Accept': media_type}
83
+ headers['Content-Type'] = media_type
84
+ body = Utils.convert_body(kwargs.pop('body'), False)
85
+ return self._request(kwargs.pop('path'),
86
+ data=body, params=kwargs, headers=headers)
87
+
88
+ @sp_endpoint('/dsp/inventory/deals/inferredAttributes/list', method='POST',
89
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
90
+ def list_inferred_attributes(self, version: str = "1", **kwargs) -> ApiResponse:
91
+ r"""
92
+ Lists the inferred attributes across deals. Read only.
93
+
94
+ Keyword Args
95
+
96
+ - ``version`` (str): the version in the media type, ``1``. [optional]
97
+
98
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
99
+
100
+ Returns
101
+ ApiResponse, ``200``, with the attributes.
102
+ """
103
+ media_type = 'application/vnd.deals.v' + version + '+json'
104
+ headers = {'Accept': media_type}
105
+ headers['Content-Type'] = media_type
106
+ body = Utils.convert_body(kwargs.pop('body'), False)
107
+ return self._request(kwargs.pop('path'),
108
+ data=body, params=kwargs, headers=headers)
109
+
110
+ @sp_endpoint('/dsp/inventory/deals/{}/inferredAttributes', method='GET',
111
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
112
+ def get_deal_inferred_attributes(self, dealId, version: str = "1", **kwargs) -> ApiResponse:
113
+ r"""
114
+ Reads the inferred attributes of one deal. Read only.
115
+
116
+ Path Parameters
117
+
118
+ - ``dealId`` (str): the deal. [required]
119
+
120
+ Query Params
121
+
122
+ - ``includeMediaTypes``, ``includeDevices``, ``includeLocations``,
123
+ ``includeEnvironments``. [optional]
124
+
125
+ Keyword Args
126
+
127
+ - ``version`` (str): the version in the media type, ``1``. [optional]
128
+
129
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
130
+
131
+ Returns
132
+ ApiResponse, ``200``, with the attributes.
133
+ """
134
+ media_type = 'application/vnd.deals.v' + version + '+json'
135
+ headers = {'Accept': media_type}
136
+ return self._request(fill_query_params(kwargs.pop('path'), dealId),
137
+ params=kwargs, headers=headers)
138
+
139
+ @sp_endpoint('/dsp/inventory/deals/{}/inferredAttributes/supplySellers/list', method='POST',
140
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
141
+ def list_deal_supply_sellers(self, dealId, version: str = "1", **kwargs) -> ApiResponse:
142
+ r"""
143
+ Lists the supply sellers of a deal. Read only.
144
+
145
+ Keyword Args
146
+
147
+ - ``version`` (str): the version in the media type, ``1``. [optional]
148
+
149
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
150
+
151
+ Returns
152
+ ApiResponse, ``200``, with the sellers.
153
+ """
154
+ media_type = 'application/vnd.deals.v' + version + '+json'
155
+ headers = {'Accept': media_type}
156
+ headers['Content-Type'] = media_type
157
+ body = Utils.convert_body(kwargs.pop('body'), False)
158
+ return self._request(fill_query_params(kwargs.pop('path'), dealId),
159
+ data=body, params=kwargs, headers=headers)
160
+
161
+ @sp_endpoint('/dsp/inventory/deals/{}/lineItems', method='GET',
162
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
163
+ def list_deal_line_items(self, dealId, version: str = "1", **kwargs) -> ApiResponse:
164
+ r"""
165
+ Lists the line items of a deal. Read only.
166
+
167
+ Keyword Args
168
+
169
+ - ``version`` (str): the version in the media type, ``1``. [optional]
170
+
171
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
172
+
173
+ Returns
174
+ ApiResponse, ``200``, with the line items.
175
+ """
176
+ media_type = 'application/vnd.deals.v' + version + '+json'
177
+ headers = {'Accept': media_type}
178
+ return self._request(fill_query_params(kwargs.pop('path'), dealId),
179
+ params=kwargs, headers=headers)
180
+
181
+ @sp_endpoint('/dsp/inventorySourceDeals/list', method='POST',
182
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
183
+ def list_inventory_source_deals(self, version: str = "1", **kwargs) -> ApiResponse:
184
+ r"""
185
+ Lists the deals of the inventory sources. Read only.
186
+
187
+ This one does not sit under ``/dsp/inventory``, and its media type is
188
+ ``dspinventorysourcedeals``, not ``deals``.
189
+
190
+ Keyword Args
191
+
192
+ - ``version`` (str): the version in the media type, ``1``. [optional]
193
+
194
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
195
+
196
+ Returns
197
+ ApiResponse, ``200``, with the deals.
198
+ """
199
+ media_type = 'application/vnd.dspinventorysourcedeals.v' + version + '+json'
200
+ headers = {'Accept': media_type}
201
+ headers['Content-Type'] = media_type
202
+ body = Utils.convert_body(kwargs.pop('body'), False)
203
+ return self._request(kwargs.pop('path'),
204
+ data=body, params=kwargs, headers=headers)
@@ -0,0 +1,66 @@
1
+ """Deals management /dsp/inventory/deals.
2
+
3
+ Contract: D16GDspApiDeals 3.0, the *Deals management* child of *Deal management*:
4
+ the two routes that write a deal. **Not the same contract as *Deals performance
5
+ and exchanges***, which is a different family with eight read routes.
6
+
7
+ ``vnd.dspDealResource`` both ways, version in whole.
8
+
9
+ ``Amazon-Advertising-API-ClientId`` is required; ``Scope`` and ``AccountId`` are
10
+ optional.
11
+
12
+ **The create answers 201; the update answers 200 with no body.**
13
+ """
14
+
15
+ from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
16
+
17
+
18
+ class DspDealsManagement(Client):
19
+ r"""Deals management - /dsp/inventory/deals
20
+
21
+ Documentation: https://advertising.amazon.com/API/docs/en-us/deals-management
22
+ """
23
+
24
+ @sp_endpoint('/dsp/inventory/deals', method='POST',
25
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
26
+ def create_deal(self, version: str = "1", **kwargs) -> ApiResponse:
27
+ r"""
28
+ Creates a deal.
29
+
30
+ Keyword Args
31
+
32
+ - ``version`` (str): the version in the media type, ``1``. [optional]
33
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
34
+
35
+ Returns
36
+ ApiResponse, **201 created**.
37
+ """
38
+ media_type = 'application/vnd.dspDealResource.v' + version + '+json'
39
+ headers = {'Accept': media_type, 'Content-Type': media_type}
40
+ body = Utils.convert_body(kwargs.pop('body'), False)
41
+ return self._request(kwargs.pop('path'),
42
+ data=body, params=kwargs, headers=headers)
43
+
44
+ @sp_endpoint('/dsp/inventory/deals/{}', method='PUT',
45
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
46
+ def update_deal(self, dealId, version: str = "1", **kwargs) -> ApiResponse:
47
+ r"""
48
+ Updates a deal.
49
+
50
+ Path Parameters
51
+
52
+ - ``dealId`` (str): the deal. [required]
53
+
54
+ Keyword Args
55
+
56
+ - ``version`` (str): the version in the media type, ``1``. [optional]
57
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
58
+
59
+ Returns
60
+ ApiResponse, ``200``, with **no body**.
61
+ """
62
+ media_type = 'application/vnd.dspDealResource.v' + version + '+json'
63
+ headers = {'Accept': media_type, 'Content-Type': media_type}
64
+ body = Utils.convert_body(kwargs.pop('body'), False)
65
+ return self._request(fill_query_params(kwargs.pop('path'), dealId),
66
+ data=body, params=kwargs, headers=headers)
@@ -0,0 +1,35 @@
1
+ """Discovery - Advertised Product Categories /dsp/v1/advertisedProductCategories/list.
2
+
3
+ Contract: Discovery - Advertised Product Categories - V1 3.0. One read route,
4
+ plain ``application/json``.
5
+
6
+ This is the one child of Discovery that declares **no account id header**: only
7
+ ``ClientId`` and ``Scope``.
8
+
9
+ """
10
+
11
+ from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
12
+
13
+
14
+ class DspDiscoveryAdvertisedProductCategories(Client):
15
+ r"""Discovery - Advertised Product Categories - /dsp/v1/advertisedProductCategories
16
+
17
+ Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-discovery-advertised-product-categories
18
+ """
19
+
20
+ @sp_endpoint('/dsp/v1/advertisedProductCategories/list', method='POST',
21
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
22
+ def list_advertised_product_categories(self, **kwargs) -> ApiResponse:
23
+ r"""
24
+ Lists the advertised product categories. Read only.
25
+
26
+ Keyword Args
27
+
28
+ Returns
29
+ ApiResponse, ``200``, with the categories.
30
+ """
31
+ headers = {'Accept': 'application/json'}
32
+ headers['Content-Type'] = 'application/json'
33
+ body = Utils.convert_body(kwargs.pop('body'), False)
34
+ return self._request(kwargs.pop('path'),
35
+ data=body, params=kwargs, headers=headers)
@@ -0,0 +1,36 @@
1
+ """Discovery - Apps /dsp/v1/apps/list.
2
+
3
+ Contract: Discovery - Apps - V1 3.0. One read route, plain ``application/json``.
4
+
5
+ ``ClientId`` is the only required header here; ``Scope`` and
6
+ ``Amazon-Ads-AccountId`` are both optional in the contract.
7
+
8
+ """
9
+
10
+ from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
11
+
12
+
13
+ class DspDiscoveryApps(Client):
14
+ r"""Discovery - Apps - /dsp/v1/apps
15
+
16
+ Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-discovery-apps
17
+ """
18
+
19
+ @sp_endpoint('/dsp/v1/apps/list', method='POST',
20
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
21
+ def list_apps(self, **kwargs) -> ApiResponse:
22
+ r"""
23
+ Lists the apps a campaign can target. Read only.
24
+
25
+ Keyword Args
26
+
27
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
28
+
29
+ Returns
30
+ ApiResponse, ``200``, with the apps.
31
+ """
32
+ headers = {'Accept': 'application/json'}
33
+ headers['Content-Type'] = 'application/json'
34
+ body = Utils.convert_body(kwargs.pop('body'), False)
35
+ return self._request(kwargs.pop('path'),
36
+ data=body, params=kwargs, headers=headers)
@@ -0,0 +1,36 @@
1
+ """Discovery - Domain Lists /dsp/v1/domainLists/list.
2
+
3
+ Contract: Discovery - Domain Lists - V1 3.0. One read route, plain
4
+ ``application/json``.
5
+
6
+ ``ClientId`` and ``Scope`` are required; ``Amazon-Ads-AccountId`` is optional.
7
+
8
+ """
9
+
10
+ from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
11
+
12
+
13
+ class DspDiscoveryDomainLists(Client):
14
+ r"""Discovery - Domain Lists - /dsp/v1/domainLists
15
+
16
+ Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-discovery-domain-lists
17
+ """
18
+
19
+ @sp_endpoint('/dsp/v1/domainLists/list', method='POST',
20
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
21
+ def list_domain_lists(self, **kwargs) -> ApiResponse:
22
+ r"""
23
+ Lists the domain lists a campaign can target. Read only.
24
+
25
+ Keyword Args
26
+
27
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
28
+
29
+ Returns
30
+ ApiResponse, ``200``, with the lists.
31
+ """
32
+ headers = {'Accept': 'application/json'}
33
+ headers['Content-Type'] = 'application/json'
34
+ body = Utils.convert_body(kwargs.pop('body'), False)
35
+ return self._request(kwargs.pop('path'),
36
+ data=body, params=kwargs, headers=headers)
@@ -0,0 +1,42 @@
1
+ """Discovery - Geo locations /dsp/geoLocations.
2
+
3
+ Contract: DSP Discovery 3.0. One **GET** route, the only read of Discovery that
4
+ needs no body: the filters are query parameters.
5
+
6
+ Path is ``/dsp/geoLocations``, with no ``v1``: unlike its siblings, this one is
7
+ not versioned in the path nor in the media type.
8
+
9
+ ``ClientId`` and ``Scope`` are required; ``Amazon-Ads-AccountId`` is optional.
10
+
11
+ """
12
+
13
+ from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
14
+
15
+
16
+ class DspDiscoveryGeoLocations(Client):
17
+ r"""Discovery - Geo locations - /dsp/geoLocations
18
+
19
+ Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-discovery-geo
20
+ """
21
+
22
+ @sp_endpoint('/dsp/geoLocations', method='GET',
23
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
24
+ def list_geo_locations(self, **kwargs) -> ApiResponse:
25
+ r"""
26
+ Lists the geographic locations a campaign can target. Read only.
27
+
28
+ Query Params
29
+
30
+ - ``geoLocationIdFilter``, ``textQuery``, ``maxResults``, ``nextToken``.
31
+ [optional]
32
+
33
+ Keyword Args
34
+
35
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
36
+
37
+ Returns
38
+ ApiResponse, ``200``, with the locations.
39
+ """
40
+ headers = {'Accept': 'application/json'}
41
+ return self._request(kwargs.pop('path'),
42
+ params=kwargs, headers=headers)
@@ -0,0 +1,37 @@
1
+ """Discovery - IAB Content Categories /dsp/v1/iabContentCategories/list.
2
+
3
+ Contract: Discovery - IAB Content Categories - V1 3.0. One read route, and one
4
+ of the few that speaks a ``vnd`` type: ``vnd.dspiabcontentcategories.v<n>``.
5
+
6
+ ``ClientId`` and ``Scope`` are required; no account id header.
7
+
8
+ """
9
+
10
+ from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
11
+
12
+
13
+ class DspDiscoveryIabContentCategories(Client):
14
+ r"""Discovery - IAB Content Categories - /dsp/v1/iabContentCategories
15
+
16
+ Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-discovery-iab-content
17
+ """
18
+
19
+ @sp_endpoint('/dsp/v1/iabContentCategories/list', method='POST',
20
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
21
+ def list_iab_content_categories(self, version: str = "1", **kwargs) -> ApiResponse:
22
+ r"""
23
+ Lists the IAB content categories a campaign can target. Read only.
24
+
25
+ Keyword Args
26
+
27
+ - ``version`` (str): the version in the media type, ``1``. [optional]
28
+
29
+ Returns
30
+ ApiResponse, ``200``, with the categories.
31
+ """
32
+ media_type = 'application/vnd.dspiabcontentcategories.v' + version + '+json'
33
+ headers = {'Accept': media_type}
34
+ headers['Content-Type'] = media_type
35
+ body = Utils.convert_body(kwargs.pop('body'), False)
36
+ return self._request(kwargs.pop('path'),
37
+ data=body, params=kwargs, headers=headers)
@@ -0,0 +1,36 @@
1
+ """Discovery - Inventory Source Exchanges /dsp/v1/inventorySourceExchanges/list.
2
+
3
+ Contract: Discovery - Inventory Source Exchanges - V1 3.0. One read route, plain
4
+ ``application/json``.
5
+
6
+ ``ClientId`` is required; ``Scope`` and ``Amazon-Ads-AccountId`` are optional.
7
+
8
+ """
9
+
10
+ from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
11
+
12
+
13
+ class DspDiscoveryInventorySourceExchanges(Client):
14
+ r"""Discovery - Inventory Source Exchanges - /dsp/v1/inventorySourceExchanges
15
+
16
+ Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-discovery-inventory-source-exchanges
17
+ """
18
+
19
+ @sp_endpoint('/dsp/v1/inventorySourceExchanges/list', method='POST',
20
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
21
+ def list_inventory_source_exchanges(self, **kwargs) -> ApiResponse:
22
+ r"""
23
+ Lists the inventory source exchanges. Read only.
24
+
25
+ Keyword Args
26
+
27
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
28
+
29
+ Returns
30
+ ApiResponse, ``200``, with the exchanges.
31
+ """
32
+ headers = {'Accept': 'application/json'}
33
+ headers['Content-Type'] = 'application/json'
34
+ body = Utils.convert_body(kwargs.pop('body'), False)
35
+ return self._request(kwargs.pop('path'),
36
+ data=body, params=kwargs, headers=headers)
@@ -0,0 +1,102 @@
1
+ """Discovery - Product and Product Category /dsp/v1 and /dsp/v2.
2
+
3
+ Contract: Discovery - Product and Product Category 3.0, the first child of
4
+ *Discovery*. Four read routes, two generations side by side.
5
+
6
+ **The two generations are not the same shape:** ``v1`` speaks
7
+ ``vnd.dspproductcategories`` and ``vnd.dspproducts``, while ``v2`` speaks plain
8
+ ``application/json``. The path carries the version, not the media type, which is
9
+ why there is no ``version`` argument here: ``v1`` and ``v2`` are separate
10
+ methods with their own paths.
11
+
12
+ ``ClientId`` and ``Amazon-Ads-AccountId`` are required, ``Scope`` is optional.
13
+
14
+ """
15
+
16
+ from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
17
+
18
+
19
+ class DspDiscoveryProducts(Client):
20
+ r"""Discovery - Product and Product Category - /dsp/v1 and /dsp/v2
21
+
22
+ Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-category-discovery
23
+ """
24
+
25
+ @sp_endpoint('/dsp/v1/productCategories/list', method='POST',
26
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
27
+ def list_product_categories(self, version: str = "1", **kwargs) -> ApiResponse:
28
+ r"""
29
+ Lists the product categories a campaign can target. Version 1 of the route.
30
+
31
+ Keyword Args
32
+
33
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
34
+
35
+ Returns
36
+ ApiResponse, ``200``, with the categories.
37
+ """
38
+ media_type = 'application/vnd.dspproductcategories.v' + version + '+json'
39
+ headers = {'Accept': media_type}
40
+ headers['Content-Type'] = media_type
41
+ body = Utils.convert_body(kwargs.pop('body'), False)
42
+ return self._request(kwargs.pop('path'),
43
+ data=body, params=kwargs, headers=headers)
44
+
45
+ @sp_endpoint('/dsp/v1/products/list', method='POST',
46
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
47
+ def list_products(self, version: str = "1", **kwargs) -> ApiResponse:
48
+ r"""
49
+ Lists the products a campaign can target. Version 1 of the route.
50
+
51
+ Keyword Args
52
+
53
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
54
+
55
+ Returns
56
+ ApiResponse, ``200``, with the products.
57
+ """
58
+ media_type = 'application/vnd.dspproducts.v' + version + '+json'
59
+ headers = {'Accept': media_type}
60
+ headers['Content-Type'] = media_type
61
+ body = Utils.convert_body(kwargs.pop('body'), False)
62
+ return self._request(kwargs.pop('path'),
63
+ data=body, params=kwargs, headers=headers)
64
+
65
+ @sp_endpoint('/dsp/v2/productCategories/list', method='POST',
66
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
67
+ def list_product_categories_v2(self, **kwargs) -> ApiResponse:
68
+ r"""
69
+ Lists the product categories. Version 2 speaks plain ``application/json``:
70
+ no ``vnd`` and no version, unlike the v1 route above.
71
+
72
+ Keyword Args
73
+
74
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
75
+
76
+ Returns
77
+ ApiResponse, ``200``, with the categories.
78
+ """
79
+ headers = {'Accept': 'application/json'}
80
+ headers['Content-Type'] = 'application/json'
81
+ body = Utils.convert_body(kwargs.pop('body'), False)
82
+ return self._request(kwargs.pop('path'),
83
+ data=body, params=kwargs, headers=headers)
84
+
85
+ @sp_endpoint('/dsp/v2/products/list', method='POST',
86
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
87
+ def list_products_v2(self, **kwargs) -> ApiResponse:
88
+ r"""
89
+ Lists the products. Version 2 speaks plain ``application/json``.
90
+
91
+ Keyword Args
92
+
93
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
94
+
95
+ Returns
96
+ ApiResponse, ``200``, with the products.
97
+ """
98
+ headers = {'Accept': 'application/json'}
99
+ headers['Content-Type'] = 'application/json'
100
+ body = Utils.convert_body(kwargs.pop('body'), False)
101
+ return self._request(kwargs.pop('path'),
102
+ data=body, params=kwargs, headers=headers)
@@ -0,0 +1,36 @@
1
+ """Discovery - Third-party Target Segments /dsp/v1/thirdPartyTargetSegments/list.
2
+
3
+ Contract: Discovery - Third-party Target Segments - V1 3.0. One read route,
4
+ plain ``application/json``.
5
+
6
+ All three headers are required here, ``Scope`` included.
7
+
8
+ """
9
+
10
+ from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
11
+
12
+
13
+ class DspDiscoveryThirdPartyTargetSegments(Client):
14
+ r"""Discovery - Third-party Target Segments - /dsp/v1/thirdPartyTargetSegments
15
+
16
+ Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-thirdparty-target-segments
17
+ """
18
+
19
+ @sp_endpoint('/dsp/v1/thirdPartyTargetSegments/list', method='POST',
20
+ headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
21
+ def list_third_party_target_segments(self, **kwargs) -> ApiResponse:
22
+ r"""
23
+ Lists the third-party target segments a campaign can target. Read only.
24
+
25
+ Keyword Args
26
+
27
+ - ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
28
+
29
+ Returns
30
+ ApiResponse, ``200``, with the segments.
31
+ """
32
+ headers = {'Accept': 'application/json'}
33
+ headers['Content-Type'] = 'application/json'
34
+ body = Utils.convert_body(kwargs.pop('body'), False)
35
+ return self._request(kwargs.pop('path'),
36
+ data=body, params=kwargs, headers=headers)