-
Notifications
You must be signed in to change notification settings - Fork 4
/
accounts.clj
343 lines (307 loc) · 11.5 KB
/
accounts.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
(ns happygapi.manufacturers.accounts
"Manufacturer Center API: accounts.
Public API for managing Manufacturer Center related data.
See: https://developers.google.com/manufacturers/api/reference/rest/v1/accounts"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn products-list$
"https://developers.google.com/manufacturers/api/reference/rest/v1/accounts/products/list
Required parameters: parent
Optional parameters: pageSize, pageToken, include
Lists all the products in a Manufacturer Center account."
{:scopes ["https://www.googleapis.com/auth/manufacturercenter"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:parent})]}
(util/get-response
(http/get
(util/get-url
"https://manufacturers.googleapis.com/"
"v1/{+parent}/products"
#{:parent}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn products-get$
"https://developers.google.com/manufacturers/api/reference/rest/v1/accounts/products/get
Required parameters: parent, name
Optional parameters: include
Gets the product from a Manufacturer Center account, including product issues. A recently updated product takes around 15 minutes to process. Changes are only visible after it has been processed. While some issues may be available once the product has been processed, other issues may take days to appear."
{:scopes ["https://www.googleapis.com/auth/manufacturercenter"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:parent :name})]}
(util/get-response
(http/get
(util/get-url
"https://manufacturers.googleapis.com/"
"v1/{+parent}/products/{+name}"
#{:parent :name}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn products-update$
"https://developers.google.com/manufacturers/api/reference/rest/v1/accounts/products/update
Required parameters: parent, name
Optional parameters: none
Body:
{:description string,
:mpn string,
:format string,
:ageGroup string,
:sizeSystem string,
:suggestedRetailPrice {:amount string, :currency string},
:flavor string,
:color string,
:productLine string,
:capacity {:value string, :unit string},
:includedDestination [string],
:additionalImageLink [{:type string,
:status string,
:imageUrl string}],
:productPageUrl string,
:releaseDate string,
:productDetail [{:sectionName string,
:attributeName string,
:attributeValue string}],
:productName string,
:sizeType [string],
:size string,
:brand string,
:title string,
:theme string,
:excludedDestination [string],
:scent string,
:itemGroupId string,
:certification [{:name string, :authority string, :code string}],
:productType [string],
:disclosureDate string,
:featureDescription [{:headline string, :text string, :image Image}],
:count {:value string, :unit string},
:material string,
:virtualModelLink string,
:videoLink [string],
:grocery {:allergens string,
:directions string,
:nutritionClaim [string],
:activeIngredients string,
:storageInstructions string,
:indications string,
:ingredients string,
:derivedNutritionClaim [string],
:alcoholByVolume number},
:gtin [string],
:gender string,
:targetClientId string,
:productHighlight [string],
:nutrition {:folateDailyPercentage number,
:saturatedFatDailyPercentage number,
:calciumDailyPercentage number,
:totalFat FloatUnit,
:nutritionFactMeasure string,
:totalSugarsDailyPercentage number,
:vitaminDDailyPercentage number,
:monounsaturatedFat FloatUnit,
:servingsPerContainer string,
:servingSizeMeasure FloatUnit,
:energyFromFat FloatUnit,
:potassiumDailyPercentage number,
:folateMcgDfe number,
:addedSugarsDailyPercentage number,
:transFatDailyPercentage number,
:voluntaryNutritionFact [VoluntaryNutritionFact],
:energy FloatUnit,
:preparedSizeDescription string,
:calcium FloatUnit,
:dietaryFiberDailyPercentage number,
:iron FloatUnit,
:saturatedFat FloatUnit,
:potassium FloatUnit,
:proteinDailyPercentage number,
:cholesterolDailyPercentage number,
:polyols FloatUnit,
:cholesterol FloatUnit,
:folateFolicAcid FloatUnit,
:ironDailyPercentage number,
:dietaryFiber FloatUnit,
:transFat FloatUnit,
:totalFatDailyPercentage number,
:totalCarbohydrateDailyPercentage number,
:sodium FloatUnit,
:protein FloatUnit,
:totalSugars FloatUnit,
:vitaminD FloatUnit,
:totalCarbohydrate FloatUnit,
:sodiumDailyPercentage number,
:addedSugars FloatUnit,
:starch FloatUnit,
:servingSizeDescription string,
:polyunsaturatedFat FloatUnit},
:imageLink {:type string, :status string, :imageUrl string},
:pattern string,
:richProductContent [string]}
Inserts or updates the attributes of the product in a Manufacturer Center account. Creates a product with the provided attributes. If the product already exists, then all attributes are replaced with the new ones. The checks at upload time are minimal. All required attributes need to be present for a product to be valid. Issues may show up later after the API has accepted a new upload for a product and it is possible to overwrite an existing valid product with an invalid product. To detect this, you should retrieve the product and check it for issues once the new version is available. Uploaded attributes first need to be processed before they can be retrieved. Until then, new products will be unavailable, and retrieval of previously uploaded products will return the original state of the product."
{:scopes ["https://www.googleapis.com/auth/manufacturercenter"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{:parent :name})]}
(util/get-response
(http/put
(util/get-url
"https://manufacturers.googleapis.com/"
"v1/{+parent}/products/{+name}"
#{:parent :name}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn products-delete$
"https://developers.google.com/manufacturers/api/reference/rest/v1/accounts/products/delete
Required parameters: parent, name
Optional parameters: none
Deletes the product from a Manufacturer Center account."
{:scopes ["https://www.googleapis.com/auth/manufacturercenter"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:parent :name})]}
(util/get-response
(http/delete
(util/get-url
"https://manufacturers.googleapis.com/"
"v1/{+parent}/products/{+name}"
#{:parent :name}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn languages-productCertifications-patch$
"https://developers.google.com/manufacturers/api/reference/rest/v1/accounts/languages/productCertifications/patch
Required parameters: name
Optional parameters: updateMask
Body:
{:mpn [string],
:issues [{:type string,
:severity string,
:attribute string,
:title string,
:description string,
:resolution string,
:destination string,
:timestamp string}],
:destinationStatuses [{:destination string, :status string}],
:name string,
:brand string,
:title string,
:certification [{:name string,
:authority string,
:code string,
:value string,
:link string,
:logo string,
:validUntil string}],
:productType [string],
:productCode [string],
:countryCode [string]}
Updates (or creates if allow_missing = true) a product certification which links certifications with products. This method can only be called by certification bodies."
{:scopes ["https://www.googleapis.com/auth/manufacturercenter"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{:name})]}
(util/get-response
(http/patch
(util/get-url
"https://manufacturers.googleapis.com/"
"v1/{+name}"
#{:name}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn languages-productCertifications-list$
"https://developers.google.com/manufacturers/api/reference/rest/v1/accounts/languages/productCertifications/list
Required parameters: parent
Optional parameters: pageSize, pageToken
Lists product certifications from a specified certification body. This method can only be called by certification bodies."
{:scopes ["https://www.googleapis.com/auth/manufacturercenter"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:parent})]}
(util/get-response
(http/get
(util/get-url
"https://manufacturers.googleapis.com/"
"v1/{+parent}/productCertifications"
#{:parent}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn languages-productCertifications-get$
"https://developers.google.com/manufacturers/api/reference/rest/v1/accounts/languages/productCertifications/get
Required parameters: name
Optional parameters: none
Gets a product certification by its name. This method can only be called by certification bodies."
{:scopes ["https://www.googleapis.com/auth/manufacturercenter"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:name})]}
(util/get-response
(http/get
(util/get-url
"https://manufacturers.googleapis.com/"
"v1/{+name}"
#{:name}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn languages-productCertifications-delete$
"https://developers.google.com/manufacturers/api/reference/rest/v1/accounts/languages/productCertifications/delete
Required parameters: name
Optional parameters: none
Deletes a product certification by its name. This method can only be called by certification bodies."
{:scopes ["https://www.googleapis.com/auth/manufacturercenter"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:name})]}
(util/get-response
(http/delete
(util/get-url
"https://manufacturers.googleapis.com/"
"v1/{+name}"
#{:name}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))