logos-sdk 0.0.25.dev25__tar.gz → 0.0.25.dev27__tar.gz
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.
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/PKG-INFO +1 -1
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/MerchantCenter.py +8 -8
- logos_sdk-0.0.25.dev27/logos_sdk/services/MicrosoftAdvertisingMerchantCenter.py +203 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk.egg-info/PKG-INFO +1 -1
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk.egg-info/SOURCES.txt +1 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/LICENSE +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/README.md +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/__init__.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/big_query/BigQuery.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/big_query/__init__.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/logging/LogosLogger.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/logging/__init__.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/CampaignManager.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/Collabim.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/DV360.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/Facebook.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/GoogleAds.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/GoogleSheets.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/MarketMiner.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/MicrosoftAdvertising.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/Sklik.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/__init__.py +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk.egg-info/dependency_links.txt +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk.egg-info/requires.txt +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk.egg-info/top_level.txt +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/setup.cfg +0 -0
- {logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/setup.py +0 -0
|
@@ -21,7 +21,7 @@ class MerchantCenterService:
|
|
|
21
21
|
self._LIST_PRODUCT_STATUSES = self._URL + "/product-service/product-statuses"
|
|
22
22
|
self._REPORTS_SEARCH = self._URL + "/reports-search"
|
|
23
23
|
self._GET_SUPPLEMENTAL_FEEDS = self._URL + "/feed-service/supplemental-feeds"
|
|
24
|
-
self.
|
|
24
|
+
self._PRIMARY_FEEDS = self._URL + "/feed-service/feeds"
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def list_accounts(self, merchant_account_id: str, secret_id: str):
|
|
@@ -228,11 +228,11 @@ class MerchantCenterService:
|
|
|
228
228
|
else:
|
|
229
229
|
raise MerchantServiceException(response.content)
|
|
230
230
|
|
|
231
|
-
def
|
|
231
|
+
def get_primary_feeds(self, secret_id: str, merchant_account_id: str):
|
|
232
232
|
body = {"secret_id": secret_id, "merchant_account_id": merchant_account_id}
|
|
233
|
-
header = get_headers(self.
|
|
233
|
+
header = get_headers(self._PRIMARY_FEEDS)
|
|
234
234
|
response = self.session.request(
|
|
235
|
-
"post", url=self.
|
|
235
|
+
"post", url=self._PRIMARY_FEEDS, json=body, headers=header
|
|
236
236
|
)
|
|
237
237
|
|
|
238
238
|
if response.status_code == HTTPStatus.OK:
|
|
@@ -255,9 +255,9 @@ class MerchantCenterService:
|
|
|
255
255
|
"supplemental_feed_id": supplemental_feed_id,
|
|
256
256
|
"action": "attach"
|
|
257
257
|
}
|
|
258
|
-
header = get_headers(self.
|
|
258
|
+
header = get_headers(self._PRIMARY_FEEDS)
|
|
259
259
|
response = self.session.request(
|
|
260
|
-
"patch", url=self.
|
|
260
|
+
"patch", url=self._PRIMARY_FEEDS, json=body, headers=header
|
|
261
261
|
)
|
|
262
262
|
|
|
263
263
|
if response.status_code == HTTPStatus.OK:
|
|
@@ -280,9 +280,9 @@ class MerchantCenterService:
|
|
|
280
280
|
"supplemental_feed_id": supplemental_feed_id,
|
|
281
281
|
"action": "detach"
|
|
282
282
|
}
|
|
283
|
-
header = get_headers(self.
|
|
283
|
+
header = get_headers(self._PRIMARY_FEEDS)
|
|
284
284
|
response = self.session.request(
|
|
285
|
-
"patch", url=self.
|
|
285
|
+
"patch", url=self._PRIMARY_FEEDS, json=body, headers=header
|
|
286
286
|
)
|
|
287
287
|
|
|
288
288
|
if response.status_code == HTTPStatus.OK:
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from logos_sdk.services import get_headers, get_retry_session
|
|
3
|
+
from typing import Any, Generator, List
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MicrosoftAdvertisingMerchantCenterException(Exception):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class MicrosoftAdvertisingMerchantCenter:
|
|
13
|
+
def __init__(self, url=None):
|
|
14
|
+
load_dotenv()
|
|
15
|
+
self.session = get_retry_session()
|
|
16
|
+
self._URL = url or os.environ.get("MICROSOFT_ADVERTISING_MERCHANT_CENTER_PATH")
|
|
17
|
+
self._GET_ACCESSIBLE_ACCOUNTS = self._URL + "/accessible-accounts"
|
|
18
|
+
self._GET_ACCOUNT_ACCESSIBILITY = self._URL + "/get-account-accessibility"
|
|
19
|
+
self._GET_PRODUCTS_STATUSES_SUMMARY = (
|
|
20
|
+
self._URL + "/get-products-statuses-summary"
|
|
21
|
+
)
|
|
22
|
+
self._GET_PRODUCTS = self._URL + "/get-products"
|
|
23
|
+
self._GET_STORES = self._URL + "/get-stores"
|
|
24
|
+
self._GET_STORE = self._URL + "/get-store"
|
|
25
|
+
|
|
26
|
+
def get_accessible_accounts(self, secret_id: str) -> List[dict]:
|
|
27
|
+
"""
|
|
28
|
+
Gets accessible accounts
|
|
29
|
+
:param secret_id: The ID of the secret in secret manager
|
|
30
|
+
:return: List of dicts with account_id and name keys
|
|
31
|
+
"""
|
|
32
|
+
body = {"secret_id": secret_id}
|
|
33
|
+
header = get_headers(self._GET_ACCESSIBLE_ACCOUNTS)
|
|
34
|
+
response = self.session.request(
|
|
35
|
+
"post", url=self._GET_ACCESSIBLE_ACCOUNTS, json=body, headers=header
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
if response.status_code == HTTPStatus.OK:
|
|
39
|
+
service_response = response.json()
|
|
40
|
+
return service_response["data"]
|
|
41
|
+
else:
|
|
42
|
+
raise MicrosoftAdvertisingMerchantCenterException(response.content)
|
|
43
|
+
|
|
44
|
+
def get_account_accessibility(
|
|
45
|
+
self, secret_id: str, customer_id, customer_account_id, merchant_id: str
|
|
46
|
+
) -> bool:
|
|
47
|
+
"""
|
|
48
|
+
Gets account accessibility
|
|
49
|
+
:param secret_id: The ID of the secret in secret manager
|
|
50
|
+
:param customer_id: The ID of the customer (parent ID) in Microsoft Advertising
|
|
51
|
+
:param customer_account_id: The ID of the customer account in Microsoft Advertising
|
|
52
|
+
:param merchant_id: The ID of the store in Microsoft Advertising
|
|
53
|
+
:return: True if account has access
|
|
54
|
+
"""
|
|
55
|
+
body = {
|
|
56
|
+
"secret_id": secret_id,
|
|
57
|
+
"customer_id": customer_id,
|
|
58
|
+
"customer_account_id": customer_account_id,
|
|
59
|
+
"merchant_id": merchant_id,
|
|
60
|
+
}
|
|
61
|
+
header = get_headers(self._GET_ACCOUNT_ACCESSIBILITY)
|
|
62
|
+
response = self.session.request(
|
|
63
|
+
"post", url=self._GET_ACCOUNT_ACCESSIBILITY, json=body, headers=header
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
if response.status_code == HTTPStatus.OK:
|
|
67
|
+
service_response = response.json()
|
|
68
|
+
return service_response["data"]
|
|
69
|
+
else:
|
|
70
|
+
raise MicrosoftAdvertisingMerchantCenterException(response.content)
|
|
71
|
+
|
|
72
|
+
def get_products_statuses_summary(
|
|
73
|
+
self, secret_id: str, customer_id, customer_account_id, merchant_id: str
|
|
74
|
+
) -> dict:
|
|
75
|
+
"""
|
|
76
|
+
Gets products statuses summary
|
|
77
|
+
:param secret_id: The ID of the secret in secret manager
|
|
78
|
+
:param customer_id: The ID of the customer (parent ID) in Microsoft Advertising
|
|
79
|
+
:param customer_account_id: The ID of the customer account in Microsoft Advertising
|
|
80
|
+
:param merchant_id: The ID of the store in Microsoft Advertising
|
|
81
|
+
:return: products statuses summary
|
|
82
|
+
"""
|
|
83
|
+
body = {
|
|
84
|
+
"secret_id": secret_id,
|
|
85
|
+
"customer_id": customer_id,
|
|
86
|
+
"customer_account_id": customer_account_id,
|
|
87
|
+
"merchant_id": merchant_id,
|
|
88
|
+
}
|
|
89
|
+
header = get_headers(self._GET_PRODUCTS_STATUSES_SUMMARY)
|
|
90
|
+
response = self.session.request(
|
|
91
|
+
"post", url=self._GET_PRODUCTS_STATUSES_SUMMARY, json=body, headers=header
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
if response.status_code == HTTPStatus.OK:
|
|
95
|
+
service_response = response.json()
|
|
96
|
+
return service_response["data"]
|
|
97
|
+
else:
|
|
98
|
+
raise MicrosoftAdvertisingMerchantCenterException(response.content)
|
|
99
|
+
|
|
100
|
+
def get_products(
|
|
101
|
+
self,
|
|
102
|
+
secret_id: str,
|
|
103
|
+
customer_id,
|
|
104
|
+
customer_account_id,
|
|
105
|
+
merchant_id: str,
|
|
106
|
+
page_size: int = 250,
|
|
107
|
+
) -> Generator[Any, Any, Any]:
|
|
108
|
+
"""
|
|
109
|
+
Gets products
|
|
110
|
+
:param secret_id: The ID of the secret in secret manager
|
|
111
|
+
:param customer_id: The ID of the customer (parent ID) in Microsoft Advertising
|
|
112
|
+
:param customer_account_id: The ID of the customer account in Microsoft Advertising
|
|
113
|
+
:param merchant_id: The ID of the store in Microsoft Advertising
|
|
114
|
+
:param page_size: page size
|
|
115
|
+
:return: products
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
body = {
|
|
119
|
+
"secret_id": secret_id,
|
|
120
|
+
"customer_id": customer_id,
|
|
121
|
+
"customer_account_id": customer_account_id,
|
|
122
|
+
"merchant_id": merchant_id,
|
|
123
|
+
"page_token": None,
|
|
124
|
+
"page_size": page_size,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
header = get_headers(self._GET_PRODUCTS)
|
|
128
|
+
response = self.session.request(
|
|
129
|
+
"post", url=self._GET_PRODUCTS, json=body, headers=header
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
if response.status_code != HTTPStatus.OK:
|
|
133
|
+
raise MicrosoftAdvertisingMerchantCenterException(response.content)
|
|
134
|
+
|
|
135
|
+
service_response = response.json()
|
|
136
|
+
yield service_response["data"]["results"]
|
|
137
|
+
|
|
138
|
+
while service_response["data"]["next_page_token"]:
|
|
139
|
+
body["page_token"] = service_response["data"]["next_page_token"]
|
|
140
|
+
response = self.session.request(
|
|
141
|
+
"post",
|
|
142
|
+
url=self._GET_PRODUCTS,
|
|
143
|
+
json=body,
|
|
144
|
+
headers=header,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
if response.status_code != HTTPStatus.OK:
|
|
148
|
+
raise MicrosoftAdvertisingMerchantCenterException(response.content)
|
|
149
|
+
|
|
150
|
+
service_response = response.json()
|
|
151
|
+
yield service_response["data"]["results"]
|
|
152
|
+
|
|
153
|
+
def get_stores(self, secret_id: str, customer_id, customer_account_id) -> List[dict]:
|
|
154
|
+
"""
|
|
155
|
+
Gets stores
|
|
156
|
+
:param secret_id: The ID of the secret in secret manager
|
|
157
|
+
:param customer_id: The ID of the customer (parent ID) in Microsoft Advertising
|
|
158
|
+
:param customer_account_id: The ID of the customer account in Microsoft Advertising
|
|
159
|
+
:return: stores
|
|
160
|
+
"""
|
|
161
|
+
body = {
|
|
162
|
+
"secret_id": secret_id,
|
|
163
|
+
"customer_id": customer_id,
|
|
164
|
+
"customer_account_id": customer_account_id,
|
|
165
|
+
}
|
|
166
|
+
header = get_headers(self._GET_STORES)
|
|
167
|
+
response = self.session.request(
|
|
168
|
+
"post", url=self._GET_STORES, json=body, headers=header
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
if response.status_code == HTTPStatus.OK:
|
|
172
|
+
service_response = response.json()
|
|
173
|
+
return service_response["data"]
|
|
174
|
+
else:
|
|
175
|
+
raise MicrosoftAdvertisingMerchantCenterException(response.content)
|
|
176
|
+
|
|
177
|
+
def get_store(
|
|
178
|
+
self, secret_id: str, customer_id, customer_account_id, merchant_id: str
|
|
179
|
+
) -> dict:
|
|
180
|
+
"""
|
|
181
|
+
Gets store
|
|
182
|
+
:param secret_id: The ID of the secret in secret manager
|
|
183
|
+
:param customer_id: The ID of the customer (parent ID) in Microsoft Advertising
|
|
184
|
+
:param customer_account_id: The ID of the customer account in Microsoft Advertising
|
|
185
|
+
:param merchant_id: The ID of the store in Microsoft Advertising
|
|
186
|
+
:return: store
|
|
187
|
+
"""
|
|
188
|
+
body = {
|
|
189
|
+
"secret_id": secret_id,
|
|
190
|
+
"customer_id": customer_id,
|
|
191
|
+
"customer_account_id": customer_account_id,
|
|
192
|
+
"merchant_id": merchant_id,
|
|
193
|
+
}
|
|
194
|
+
header = get_headers(self._GET_STORE)
|
|
195
|
+
response = self.session.request(
|
|
196
|
+
"post", url=self._GET_STORE, json=body, headers=header
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
if response.status_code == HTTPStatus.OK:
|
|
200
|
+
service_response = response.json()
|
|
201
|
+
return service_response["data"]
|
|
202
|
+
else:
|
|
203
|
+
raise MicrosoftAdvertisingMerchantCenterException(response.content)
|
|
@@ -21,5 +21,6 @@ logos_sdk/services/GoogleSheets.py
|
|
|
21
21
|
logos_sdk/services/MarketMiner.py
|
|
22
22
|
logos_sdk/services/MerchantCenter.py
|
|
23
23
|
logos_sdk/services/MicrosoftAdvertising.py
|
|
24
|
+
logos_sdk/services/MicrosoftAdvertisingMerchantCenter.py
|
|
24
25
|
logos_sdk/services/Sklik.py
|
|
25
26
|
logos_sdk/services/__init__.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{logos_sdk-0.0.25.dev25 → logos_sdk-0.0.25.dev27}/logos_sdk/services/MicrosoftAdvertising.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|