amazon-sp-cli 0.2.4__tar.gz → 0.2.6__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.
- {amazon_sp_cli-0.2.4/amazon_sp_cli.egg-info → amazon_sp_cli-0.2.6}/PKG-INFO +1 -1
- amazon_sp_cli-0.2.6/amazon_sp_cli/__init__.py +2 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli/models/a_plus.py +94 -16
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6/amazon_sp_cli.egg-info}/PKG-INFO +1 -1
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/tests/test_a_plus.py +43 -8
- amazon_sp_cli-0.2.4/amazon_sp_cli/__init__.py +0 -2
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/LICENSE +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/MANIFEST.in +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/README.md +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli/__main__.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli/auth.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli/cli.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli/client.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli/commands/__init__.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli/commands/a_plus.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli/commands/auth.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli/commands/pricing.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli/main.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli/models/__init__.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli.egg-info/SOURCES.txt +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli.egg-info/dependency_links.txt +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli.egg-info/entry_points.txt +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli.egg-info/requires.txt +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/amazon_sp_cli.egg-info/top_level.txt +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/pyproject.toml +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/setup.cfg +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/setup.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/tests/__init__.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/tests/test_auth.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/tests/test_client.py +0 -0
- {amazon_sp_cli-0.2.4 → amazon_sp_cli-0.2.6}/tests/test_pricing.py +0 -0
|
@@ -76,6 +76,26 @@ class StandardSingleImageModule:
|
|
|
76
76
|
return result
|
|
77
77
|
|
|
78
78
|
|
|
79
|
+
class StandardSingleSideImageModule:
|
|
80
|
+
"""Standard Single Side Image module."""
|
|
81
|
+
|
|
82
|
+
def __init__(self, image=None, description=None, image_position_type="LEFT"):
|
|
83
|
+
self.image = image
|
|
84
|
+
self.description = description
|
|
85
|
+
self.image_position_type = image_position_type
|
|
86
|
+
|
|
87
|
+
def to_dict(self) -> dict:
|
|
88
|
+
result = {"imagePositionType": self.image_position_type}
|
|
89
|
+
block = {}
|
|
90
|
+
if self.image:
|
|
91
|
+
block["image"] = self.image.to_dict()
|
|
92
|
+
if self.description:
|
|
93
|
+
block["description"] = self.description.to_dict()
|
|
94
|
+
if block:
|
|
95
|
+
result["block"] = block
|
|
96
|
+
return result
|
|
97
|
+
|
|
98
|
+
|
|
79
99
|
class StandardMultipleImageTextModule:
|
|
80
100
|
"""Standard Multiple Image & Text module."""
|
|
81
101
|
|
|
@@ -153,19 +173,23 @@ class StandardTextModule:
|
|
|
153
173
|
class StandardImageTextOverlayModule:
|
|
154
174
|
"""Standard Image with Text Overlay module."""
|
|
155
175
|
|
|
156
|
-
def __init__(self, headline=None, image=None, body=None):
|
|
176
|
+
def __init__(self, headline=None, image=None, body=None, overlay_color_type="DARK"):
|
|
157
177
|
self.headline = headline
|
|
158
178
|
self.image = image
|
|
159
179
|
self.body = body
|
|
180
|
+
self.overlay_color_type = overlay_color_type
|
|
160
181
|
|
|
161
182
|
def to_dict(self) -> dict:
|
|
162
|
-
result = {}
|
|
183
|
+
result = {"overlayColorType": self.overlay_color_type}
|
|
184
|
+
block = {}
|
|
163
185
|
if self.headline:
|
|
164
|
-
|
|
186
|
+
block["headline"] = self.headline.to_dict()
|
|
165
187
|
if self.image:
|
|
166
|
-
|
|
188
|
+
block["image"] = self.image.to_dict()
|
|
167
189
|
if self.body:
|
|
168
|
-
|
|
190
|
+
block["body"] = self.body.to_dict()
|
|
191
|
+
if block:
|
|
192
|
+
result["block"] = block
|
|
169
193
|
return result
|
|
170
194
|
|
|
171
195
|
|
|
@@ -186,8 +210,9 @@ class ContentModule:
|
|
|
186
210
|
"""A+ Content module wrapper."""
|
|
187
211
|
|
|
188
212
|
MODULE_TYPES = {
|
|
189
|
-
"STANDARD_IMAGE_TEXT": "
|
|
213
|
+
"STANDARD_IMAGE_TEXT": "standardImageTextOverlay",
|
|
190
214
|
"STANDARD_SINGLE_IMAGE": "standardSingleImage",
|
|
215
|
+
"STANDARD_SINGLE_SIDE_IMAGE": "standardSingleSideImage",
|
|
191
216
|
"STANDARD_MULTIPLE_IMAGE_TEXT": "standardMultipleImageText",
|
|
192
217
|
"STANDARD_FOUR_IMAGE_TEXT": "standardFourImageText",
|
|
193
218
|
"STANDARD_COMPARISON_TABLE": "standardComparisonTable",
|
|
@@ -201,6 +226,7 @@ class ContentModule:
|
|
|
201
226
|
module_type: str,
|
|
202
227
|
standard_image_text: StandardImageTextModule = None,
|
|
203
228
|
standard_single_image: StandardSingleImageModule = None,
|
|
229
|
+
standard_single_side_image: StandardSingleSideImageModule = None,
|
|
204
230
|
standard_multiple_image_text: StandardMultipleImageTextModule = None,
|
|
205
231
|
standard_four_image_text: StandardFourImageTextModule = None,
|
|
206
232
|
standard_comparison_table: StandardComparisonTableModule = None,
|
|
@@ -211,6 +237,7 @@ class ContentModule:
|
|
|
211
237
|
self.module_type = module_type
|
|
212
238
|
self.standard_image_text = standard_image_text
|
|
213
239
|
self.standard_single_image = standard_single_image
|
|
240
|
+
self.standard_single_side_image = standard_single_side_image
|
|
214
241
|
self.standard_multiple_image_text = standard_multiple_image_text
|
|
215
242
|
self.standard_four_image_text = standard_four_image_text
|
|
216
243
|
self.standard_comparison_table = standard_comparison_table
|
|
@@ -222,10 +249,12 @@ class ContentModule:
|
|
|
222
249
|
result = {"contentModuleType": self.module_type}
|
|
223
250
|
field_name = self.MODULE_TYPES.get(self.module_type)
|
|
224
251
|
|
|
225
|
-
if field_name == "
|
|
226
|
-
result["
|
|
252
|
+
if field_name == "standardImageTextOverlay" and self.standard_image_text_overlay:
|
|
253
|
+
result["standardImageTextOverlay"] = self.standard_image_text_overlay.to_dict()
|
|
227
254
|
elif field_name == "standardSingleImage" and self.standard_single_image:
|
|
228
255
|
result["standardSingleImage"] = self.standard_single_image.to_dict()
|
|
256
|
+
elif field_name == "standardSingleSideImage" and self.standard_single_side_image:
|
|
257
|
+
result["standardSingleSideImage"] = self.standard_single_side_image.to_dict()
|
|
229
258
|
elif field_name == "standardMultipleImageText" and self.standard_multiple_image_text:
|
|
230
259
|
result["standardMultipleImageText"] = self.standard_multiple_image_text.to_dict()
|
|
231
260
|
elif field_name == "standardFourImageText" and self.standard_four_image_text:
|
|
@@ -234,8 +263,6 @@ class ContentModule:
|
|
|
234
263
|
result["standardComparisonTable"] = self.standard_comparison_table.to_dict()
|
|
235
264
|
elif field_name == "standardText" and self.standard_text:
|
|
236
265
|
result["standardText"] = self.standard_text.to_dict()
|
|
237
|
-
elif field_name == "standardImageTextOverlay" and self.standard_image_text_overlay:
|
|
238
|
-
result["standardImageTextOverlay"] = self.standard_image_text_overlay.to_dict()
|
|
239
266
|
elif field_name == "standardCompanyLogo" and self.standard_company_logo:
|
|
240
267
|
result["standardCompanyLogo"] = self.standard_company_logo.to_dict()
|
|
241
268
|
|
|
@@ -320,22 +347,61 @@ def build_module_from_json(data: dict) -> ContentModule:
|
|
|
320
347
|
module_type = data.get("contentModuleType") or data.get("moduleType", "STANDARD_TEXT")
|
|
321
348
|
|
|
322
349
|
if module_type == "STANDARD_IMAGE_TEXT":
|
|
350
|
+
body = None
|
|
351
|
+
if data.get("body"):
|
|
352
|
+
body = ParagraphComponent(text_list=[TextComponent(data["body"])])
|
|
323
353
|
return ContentModule(
|
|
324
354
|
module_type=module_type,
|
|
325
|
-
|
|
355
|
+
standard_image_text_overlay=StandardImageTextOverlayModule(
|
|
326
356
|
headline=TextComponent(data["headline"]) if data.get("headline") else None,
|
|
327
|
-
body=
|
|
328
|
-
image=
|
|
357
|
+
body=body,
|
|
358
|
+
image=(
|
|
359
|
+
ImageComponent(
|
|
360
|
+
data["imageId"],
|
|
361
|
+
alt_text=data.get("altText"),
|
|
362
|
+
image_crop_specification=data.get("imageCropSpecification"),
|
|
363
|
+
)
|
|
364
|
+
if data.get("imageId")
|
|
365
|
+
else None
|
|
366
|
+
),
|
|
329
367
|
),
|
|
330
368
|
)
|
|
331
369
|
elif module_type == "STANDARD_SINGLE_IMAGE":
|
|
332
370
|
return ContentModule(
|
|
333
371
|
module_type=module_type,
|
|
334
372
|
standard_single_image=StandardSingleImageModule(
|
|
335
|
-
image=
|
|
373
|
+
image=(
|
|
374
|
+
ImageComponent(
|
|
375
|
+
data["imageId"],
|
|
376
|
+
alt_text=data.get("altText"),
|
|
377
|
+
image_crop_specification=data.get("imageCropSpecification"),
|
|
378
|
+
)
|
|
379
|
+
if data.get("imageId")
|
|
380
|
+
else None
|
|
381
|
+
),
|
|
336
382
|
image_caption=TextComponent(data["caption"]) if data.get("caption") else None,
|
|
337
383
|
),
|
|
338
384
|
)
|
|
385
|
+
elif module_type == "STANDARD_SINGLE_SIDE_IMAGE":
|
|
386
|
+
description = None
|
|
387
|
+
if data.get("description"):
|
|
388
|
+
description = ParagraphComponent(text_list=[TextComponent(data["description"])])
|
|
389
|
+
return ContentModule(
|
|
390
|
+
module_type=module_type,
|
|
391
|
+
standard_single_side_image=StandardSingleSideImageModule(
|
|
392
|
+
image=(
|
|
393
|
+
ImageComponent(
|
|
394
|
+
data["imageId"],
|
|
395
|
+
alt_text=data.get("altText"),
|
|
396
|
+
image_crop_specification=data.get("imageCropSpecification"),
|
|
397
|
+
)
|
|
398
|
+
if data.get("imageId")
|
|
399
|
+
else None
|
|
400
|
+
),
|
|
401
|
+
description=description,
|
|
402
|
+
image_position_type=data.get("imagePositionType", "LEFT"),
|
|
403
|
+
),
|
|
404
|
+
)
|
|
339
405
|
elif module_type == "STANDARD_MULTIPLE_IMAGE_TEXT":
|
|
340
406
|
return ContentModule(
|
|
341
407
|
module_type=module_type,
|
|
@@ -372,12 +438,24 @@ def build_module_from_json(data: dict) -> ContentModule:
|
|
|
372
438
|
),
|
|
373
439
|
)
|
|
374
440
|
elif module_type == "STANDARD_IMAGE_TEXT_OVERLAY":
|
|
441
|
+
body = None
|
|
442
|
+
if data.get("body"):
|
|
443
|
+
body = ParagraphComponent(text_list=[TextComponent(data["body"])])
|
|
375
444
|
return ContentModule(
|
|
376
445
|
module_type=module_type,
|
|
377
446
|
standard_image_text_overlay=StandardImageTextOverlayModule(
|
|
378
447
|
headline=TextComponent(data["headline"]) if data.get("headline") else None,
|
|
379
|
-
body=
|
|
380
|
-
image=
|
|
448
|
+
body=body,
|
|
449
|
+
image=(
|
|
450
|
+
ImageComponent(
|
|
451
|
+
data["imageId"],
|
|
452
|
+
alt_text=data.get("altText"),
|
|
453
|
+
image_crop_specification=data.get("imageCropSpecification"),
|
|
454
|
+
)
|
|
455
|
+
if data.get("imageId")
|
|
456
|
+
else None
|
|
457
|
+
),
|
|
458
|
+
overlay_color_type=data.get("overlayColorType", "DARK"),
|
|
381
459
|
),
|
|
382
460
|
)
|
|
383
461
|
elif module_type == "STANDARD_COMPANY_LOGO":
|
|
@@ -75,7 +75,7 @@ class TestDataModels:
|
|
|
75
75
|
assert "has no content" in doc.validate()[0]
|
|
76
76
|
|
|
77
77
|
def test_module_validate_empty_content(self):
|
|
78
|
-
mod = ContentModule("
|
|
78
|
+
mod = ContentModule("STANDARD_TEXT")
|
|
79
79
|
issues = mod.validate(0)
|
|
80
80
|
assert len(issues) == 1
|
|
81
81
|
assert "has no content" in issues[0]
|
|
@@ -146,8 +146,40 @@ class TestBuildFromJson:
|
|
|
146
146
|
mod = build_module_from_json(data)
|
|
147
147
|
assert mod.module_type == "STANDARD_IMAGE_TEXT"
|
|
148
148
|
result = mod.to_dict()
|
|
149
|
-
assert result["
|
|
150
|
-
assert result["
|
|
149
|
+
assert result["standardImageTextOverlay"]["overlayColorType"] == "DARK"
|
|
150
|
+
assert result["standardImageTextOverlay"]["block"]["headline"]["value"] == "H"
|
|
151
|
+
assert result["standardImageTextOverlay"]["block"]["body"]["textList"][0]["value"] == "B"
|
|
152
|
+
assert result["standardImageTextOverlay"]["block"]["image"]["uploadDestinationId"] == "img-1"
|
|
153
|
+
|
|
154
|
+
def test_build_module_image_text_overlay(self):
|
|
155
|
+
data = {
|
|
156
|
+
"moduleType": "STANDARD_IMAGE_TEXT_OVERLAY",
|
|
157
|
+
"headline": "H",
|
|
158
|
+
"body": "B",
|
|
159
|
+
"imageId": "img-1",
|
|
160
|
+
"overlayColorType": "LIGHT",
|
|
161
|
+
}
|
|
162
|
+
mod = build_module_from_json(data)
|
|
163
|
+
assert mod.module_type == "STANDARD_IMAGE_TEXT_OVERLAY"
|
|
164
|
+
result = mod.to_dict()
|
|
165
|
+
assert result["standardImageTextOverlay"]["overlayColorType"] == "LIGHT"
|
|
166
|
+
assert result["standardImageTextOverlay"]["block"]["headline"]["value"] == "H"
|
|
167
|
+
assert result["standardImageTextOverlay"]["block"]["body"]["textList"][0]["value"] == "B"
|
|
168
|
+
|
|
169
|
+
def test_build_module_single_side_image(self):
|
|
170
|
+
data = {
|
|
171
|
+
"moduleType": "STANDARD_SINGLE_SIDE_IMAGE",
|
|
172
|
+
"imageId": "img-1",
|
|
173
|
+
"altText": "Side",
|
|
174
|
+
"description": "Desc",
|
|
175
|
+
"imagePositionType": "RIGHT",
|
|
176
|
+
}
|
|
177
|
+
mod = build_module_from_json(data)
|
|
178
|
+
assert mod.module_type == "STANDARD_SINGLE_SIDE_IMAGE"
|
|
179
|
+
result = mod.to_dict()
|
|
180
|
+
assert result["standardSingleSideImage"]["imagePositionType"] == "RIGHT"
|
|
181
|
+
assert result["standardSingleSideImage"]["block"]["image"]["uploadDestinationId"] == "img-1"
|
|
182
|
+
assert result["standardSingleSideImage"]["block"]["description"]["textList"][0]["value"] == "Desc"
|
|
151
183
|
|
|
152
184
|
def test_build_module_comparison_table(self):
|
|
153
185
|
data = {
|
|
@@ -225,11 +257,14 @@ class TestBuildFromJson:
|
|
|
225
257
|
assert logo_module["companyLogo"]["imageCropSpecification"]["size"]["width"]["value"] == 600
|
|
226
258
|
|
|
227
259
|
for i in range(1, 5):
|
|
228
|
-
mod = modules[i]["
|
|
229
|
-
assert "
|
|
230
|
-
assert "
|
|
231
|
-
assert "
|
|
232
|
-
assert
|
|
260
|
+
mod = modules[i]["standardImageTextOverlay"]
|
|
261
|
+
assert mod["overlayColorType"] == "DARK"
|
|
262
|
+
assert "block" in mod
|
|
263
|
+
assert "headline" in mod["block"]
|
|
264
|
+
assert "body" in mod["block"]
|
|
265
|
+
assert "textList" in mod["block"]["body"]
|
|
266
|
+
assert "image" in mod["block"]
|
|
267
|
+
assert mod["block"]["image"]["uploadDestinationId"].startswith("aplus-media/sc/")
|
|
233
268
|
|
|
234
269
|
|
|
235
270
|
class TestAPlusCLI:
|
|
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
|
|
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
|