Skip to content

Commit c807d9c

Browse files
authored
Source Amazon Seller Partner: add stream FbaReplacementsReports (#9789)
1 parent fd53352 commit c807d9c

File tree

9 files changed

+145
-5
lines changed

9 files changed

+145
-5
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- name: Amazon Seller Partner
2323
sourceDefinitionId: e55879a8-0ef8-4557-abcf-ab34c53ec460
2424
dockerRepository: airbyte/source-amazon-seller-partner
25-
dockerImageTag: 0.2.14
25+
dockerImageTag: 0.2.15
2626
sourceType: api
2727
documentationUrl: https://docs.airbyte.io/integrations/sources/amazon-seller-partner
2828
icon: amazonsellerpartner.svg

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
supportsNormalization: false
158158
supportsDBT: false
159159
supported_destination_sync_modes: []
160-
- dockerImage: "airbyte/source-amazon-seller-partner:0.2.14"
160+
- dockerImage: "airbyte/source-amazon-seller-partner:0.2.15"
161161
spec:
162162
documentationUrl: "https://docs.airbyte.io/integrations/sources/amazon-seller-partner"
163163
changelogUrl: "https://docs.airbyte.io/integrations/sources/amazon-seller-partner"

airbyte-integrations/connectors/source-amazon-seller-partner/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ RUN pip install .
1212
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1313
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1414

15-
LABEL io.airbyte.version=0.2.14
15+
LABEL io.airbyte.version=0.2.15
1616
LABEL io.airbyte.name=airbyte/source-amazon-seller-partner

airbyte-integrations/connectors/source-amazon-seller-partner/acceptance-test-config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ tests:
3838
# configured_catalog_path: "integration_tests/configured_catalog_brand_analytics_repeat_purchase.json.json"
3939
# - config_path: "secrets/config.json"
4040
# configured_catalog_path: "integration_tests/configured_catalog_brand_analytics_search_terms.json"
41+
# - config_path: "secrets/config.json"
42+
# configured_catalog_path: "integration_tests/configured_catalog_fba_fulfillment_customer_shipment_replacement_data.json"
4143
# TODO: uncomment when Orders (or any other incremental) stream is filled with data
4244
# incremental:
4345
# - config_path: "secrets/config.json"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"streams": [
3+
{
4+
"stream": {
5+
"name": "GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_REPLACEMENT_DATA",
6+
"json_schema": {
7+
"title": "FBA Fulfillment Customer Shipment Replacement Data",
8+
"description": "FBA Fulfillment Customer Shipment Replacement Data Reports",
9+
"type": "object",
10+
"$schema": "http://json-schema.org/draft-07/schema#",
11+
"properties": {
12+
"shipment-date": {
13+
"title": "Date",
14+
"description": "DD-MON-YYYY. Date of free replacement shipment",
15+
"type": ["null", "string"],
16+
"format": "date-time"
17+
},
18+
"sku": {
19+
"title": "Merchant SKU",
20+
"description": "Seller's item identifier",
21+
"type": ["null", "string"]
22+
},
23+
"asin": {
24+
"title": "ASIN",
25+
"description": "Amazon Standard Inventory Number",
26+
"type": ["null", "string"]
27+
},
28+
"fulfillment-center-id": {
29+
"title": "Warehouse ID",
30+
"description": "Fulfillment center shipping this unit.",
31+
"type": ["null", "string"]
32+
},
33+
"original-fulfillment-center-id": {
34+
"title": "Original Warehouse ID",
35+
"description": "Original fulfillment center shipping free replaced item.",
36+
"type": ["null", "string"]
37+
},
38+
"quantity": {
39+
"title": "Quantity",
40+
"description": "Units shipped in replacement shipment",
41+
"type": ["null", "string"]
42+
},
43+
"replacement-reason-code": {
44+
"title": "Replacement Reason Code",
45+
"description": "Reason for replacement",
46+
"type": ["null", "string"]
47+
},
48+
"replacement-customer-order-id": {
49+
"title": "Replacement Customer Order Id",
50+
"description": "Order ID of the replacement order",
51+
"type": ["null", "string"]
52+
},
53+
"original-amazon-order-id": {
54+
"title": "Original Customer Order ID",
55+
"description": "Order ID of original shipment",
56+
"type": ["null", "string"]
57+
}
58+
}
59+
},
60+
"supported_sync_modes": ["full_refresh"]
61+
},
62+
"sync_mode": "full_refresh",
63+
"destination_sync_mode": "overwrite"
64+
}
65+
]
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"title": "FBA Fulfillment Customer Shipment Replacement Data",
3+
"description": "FBA Fulfillment Customer Shipment Replacement Data Reports",
4+
"type": "object",
5+
"$schema": "http://json-schema.org/draft-07/schema#",
6+
"properties": {
7+
"shipment-date": {
8+
"title": "Date",
9+
"description": "DD-MON-YYYY. Date of free replacement shipment",
10+
"type": ["null", "string"],
11+
"format": "date-time"
12+
},
13+
"sku": {
14+
"title": "Merchant SKU",
15+
"description": "Seller's item identifier",
16+
"type": ["null", "string"]
17+
},
18+
"asin": {
19+
"title": "ASIN",
20+
"description": "Amazon Standard Inventory Number",
21+
"type": ["null", "string"]
22+
},
23+
"fulfillment-center-id": {
24+
"title": "Warehouse ID",
25+
"description": "Fulfillment center shipping this unit.",
26+
"type": ["null", "string"]
27+
},
28+
"original-fulfillment-center-id": {
29+
"title": "Original Warehouse ID",
30+
"description": "Original fulfillment center shipping free replaced item.",
31+
"type": ["null", "string"]
32+
},
33+
"quantity": {
34+
"title": "Quantity",
35+
"description": "Units shipped in replacement shipment",
36+
"type": ["null", "string"]
37+
},
38+
"replacement-reason-code": {
39+
"title": "Replacement Reason Code",
40+
"description": "Reason for replacement",
41+
"type": ["null", "string"]
42+
},
43+
"replacement-customer-order-id": {
44+
"title": "Replacement Customer Order Id",
45+
"description": "Order ID of the replacement order",
46+
"type": ["null", "string"]
47+
},
48+
"original-amazon-order-id": {
49+
"title": "Original Customer Order ID",
50+
"description": "Order ID of original shipment",
51+
"type": ["null", "string"]
52+
}
53+
}
54+
}

airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/source.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
BrandAnalyticsSearchTermsReports,
2323
FbaInventoryReports,
2424
FbaOrdersReports,
25+
FbaReplacementsReports,
2526
FbaShipmentsReports,
2627
FlatFileOpenListingsReports,
2728
FlatFileOrdersReports,
@@ -147,6 +148,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
147148
FbaInventoryReports(**stream_kwargs),
148149
FbaOrdersReports(**stream_kwargs),
149150
FbaShipmentsReports(**stream_kwargs),
151+
FbaReplacementsReports(**stream_kwargs),
150152
FlatFileOpenListingsReports(**stream_kwargs),
151153
FlatFileOrdersReports(**stream_kwargs),
152154
FlatFileOrdersReportsByLastUpdate(**stream_kwargs),

airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/streams.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ def read_records(
319319
seconds_waited = (pendulum.now("utc") - start_time).seconds
320320
is_processed = report_payload.get("processingStatus") not in ["IN_QUEUE", "IN_PROGRESS"]
321321
is_done = report_payload.get("processingStatus") == "DONE"
322+
is_cancelled = report_payload.get("processingStatus") == "CANCELLED"
323+
is_fatal = report_payload.get("processingStatus") == "FATAL"
322324
time.sleep(self.sleep_seconds)
323325

324326
if is_done:
@@ -332,8 +334,12 @@ def read_records(
332334
)
333335
response = self._send_request(request)
334336
yield from self.parse_response(response)
337+
elif is_fatal:
338+
raise Exception(f"The report for stream '{self.name}' was aborted due to a fatal error")
339+
elif is_cancelled:
340+
logger.warn(f"The report for stream '{self.name}' was cancelled or there is no data to return")
335341
else:
336-
logger.warn(f"There are no report document related in stream `{self.name}`. Report body {report_payload}")
342+
raise Exception(f"Unknown response for stream `{self.name}`. Response body {report_payload}")
337343

338344

339345
class MerchantListingsReports(ReportsAmazonSPStream):
@@ -384,6 +390,14 @@ class FbaShipmentsReports(ReportsAmazonSPStream):
384390
name = "GET_FBA_FULFILLMENT_REMOVAL_SHIPMENT_DETAIL_DATA"
385391

386392

393+
class FbaReplacementsReports(ReportsAmazonSPStream):
394+
"""
395+
Field definitions: https://sellercentral.amazon.com/help/hub/reference/200453300
396+
"""
397+
398+
name = "GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_REPLACEMENT_DATA"
399+
400+
387401
class VendorInventoryHealthReports(ReportsAmazonSPStream):
388402
name = "GET_VENDOR_INVENTORY_HEALTH_AND_PLANNING_REPORT"
389403

@@ -651,7 +665,7 @@ class VendorDirectFulfillmentShipping(AmazonSPStream):
651665
"""
652666

653667
name = "VendorDirectFulfillmentShipping"
654-
primary_key = [["labelData", "packageIdentifier"]]
668+
primary_key = None
655669
replication_start_date_field = "createdAfter"
656670
next_page_token_field = "nextToken"
657671
page_size_field = "limit"

docs/integrations/sources/amazon-seller-partner.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This source is capable of syncing the following streams:
1616
- [Order Report (by order date and by last update)](https://sellercentral.amazon.com/gp/help/help.html?itemID=201648780)
1717
- [All Listings](https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md#inventory-reports)
1818
- [FBA Inventory Reports](https://sellercentral.amazon.com/gp/help/200740930)
19+
- [FBA Replacements Report](https://sellercentral.amazon.com/help/hub/reference/200453300)
1920
- [Amazon-Fulfilled Shipments Report](https://sellercentral.amazon.com/gp/help/help.html?itemID=200453120)
2021
- [Open Listings Report](https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md#inventory-reports)
2122
- [Removal Order Detail Report (overview)](https://sellercentral.amazon.com/gp/help/help.html?itemID=200989110)
@@ -67,6 +68,7 @@ Information about rate limits you may find [here](https://github.com/amzn/sellin
6768

6869
| Version | Date | Pull Request | Subject |
6970
| :------- | :--------- | :------------------------------------------------------- | :--------------------------------------------------------------------- |
71+
| `0.2.15` | 2022-01-25 | [\#9789](https://github.com/airbytehq/airbyte/pull/9789) | Add stream FbaReplacementsReports |
7072
| `0.2.14` | 2022-01-19 | [\#9621](https://github.com/airbytehq/airbyte/pull/9621) | Add GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL report |
7173
| `0.2.13` | 2022-01-18 | [\#9581](https://github.com/airbytehq/airbyte/pull/9581) | Change createdSince parameter to dataStartTime |
7274
| `0.2.12` | 2022-01-05 | [\#9312](https://github.com/airbytehq/airbyte/pull/9312) | Add all remaining brand analytics report streams |

0 commit comments

Comments
 (0)