diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/acceptance-test-config.yml b/airbyte-integrations/connectors/source-amazon-seller-partner/acceptance-test-config.yml index 0c9ac604800a3..6d9ae3dfbc248 100644 --- a/airbyte-integrations/connectors/source-amazon-seller-partner/acceptance-test-config.yml +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/acceptance-test-config.yml @@ -28,6 +28,16 @@ tests: # "GET_VENDOR_INVENTORY_HEALTH_AND_PLANNING_REPORT", # "VendorDirectFulfillmentShipping", # ] +# - config_path: "secrets/config.json" +# configured_catalog_path: "integration_tests/configured_catalog_brand_analytics_alternate_purchase.json" +# - config_path: "secrets/config.json" +# configured_catalog_path: "integration_tests/configured_catalog_brand_analytics_item_comparison.json" +# - config_path: "secrets/config.json" +# configured_catalog_path: "integration_tests/configured_catalog_brand_analytics_market_basket.json" +# - config_path: "secrets/config.json" +# configured_catalog_path: "integration_tests/configured_catalog_brand_analytics_repeat_purchase.json.json" +# - config_path: "secrets/config.json" +# configured_catalog_path: "integration_tests/configured_catalog_brand_analytics_search_terms.json" # TODO: uncomment when Orders (or any other incremental) stream is filled with data # incremental: # - config_path: "secrets/config.json" diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog.json b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog.json index 0387865e646d1..5c897b44e0b2d 100644 --- a/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog.json +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog.json @@ -104,15 +104,6 @@ "sync_mode": "incremental", "destination_sync_mode": "append", "cursor_field": ["Date"] - }, - { - "stream": { - "name": "GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT", - "json_schema": {}, - "supported_sync_modes": ["full_refresh"] - }, - "sync_mode": "full_refresh", - "destination_sync_mode": "overwrite" } ] } diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_alternate_purchase.json b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_alternate_purchase.json new file mode 100644 index 0000000000000..2ce8fbb81064a --- /dev/null +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_alternate_purchase.json @@ -0,0 +1,40 @@ +{ + "streams": [ + { + "stream": { + "name": "GET_BRAND_ANALYTICS_ALTERNATE_PURCHASE_REPORT", + "json_schema": { + "title": "Brand Analytics Alternate Purchase Reports", + "description": "Brand Analytics Alternate Purchase Reports", + "type": "object", + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "startDate": { + "type": ["null", "string"], + "format": "date" + }, + "endDate": { + "type": ["null", "string"], + "format": "date" + }, + "asin": { + "type": ["null", "string"] + }, + "purchasedAsin": { + "type": ["null", "string"] + }, + "purchasedRank": { + "type": ["null", "integer"] + }, + "purchasedPct": { + "type": ["null", "number"] + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_item_comparison.json b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_item_comparison.json new file mode 100644 index 0000000000000..4d7300e63157f --- /dev/null +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_item_comparison.json @@ -0,0 +1,40 @@ +{ + "streams": [ + { + "stream": { + "name": "GET_BRAND_ANALYTICS_ITEM_COMPARISON_REPORT", + "json_schema": { + "title": "Brand Analytics Item Comparison Reports", + "description": "Brand Analytics Item Comparison Reports", + "type": "object", + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "startDate": { + "type": ["null", "string"], + "format": "date" + }, + "endDate": { + "type": ["null", "string"], + "format": "date" + }, + "asin": { + "type": ["null", "string"] + }, + "comparedAsin": { + "type": ["null", "string"] + }, + "comparedRank": { + "type": ["null", "integer"] + }, + "comparedPct": { + "type": ["null", "number"] + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_market_basket.json b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_market_basket.json new file mode 100644 index 0000000000000..87a75b8aaecee --- /dev/null +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_market_basket.json @@ -0,0 +1,40 @@ +{ + "streams": [ + { + "stream": { + "name": "GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT", + "json_schema": { + "title": "Brand Analytics Market Basket Reports", + "description": "Brand Analytics Market Basket Reports", + "type": "object", + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "startDate": { + "type": ["null", "string"], + "format": "date" + }, + "endDate": { + "type": ["null", "string"], + "format": "date" + }, + "asin": { + "type": ["null", "string"] + }, + "purchasedWithAsin": { + "type": ["null", "string"] + }, + "purchasedWithRank": { + "type": ["null", "integer"] + }, + "combinationPct": { + "type": ["null", "number"] + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_repeat_purchase.json b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_repeat_purchase.json new file mode 100644 index 0000000000000..656b89dfd3100 --- /dev/null +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_repeat_purchase.json @@ -0,0 +1,54 @@ +{ + "streams": [ + { + "stream": { + "name": "GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT", + "json_schema": { + "title": "Brand Analytics Repeat Purchase Reports", + "description": "Brand Analytics Repeat Purchase Reports", + "type": "object", + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "startDate": { + "type": ["null", "string"], + "format": "date" + }, + "endDate": { + "type": ["null", "string"], + "format": "date" + }, + "asin": { + "type": ["null", "string"] + }, + "orders": { + "type": ["null", "integer"] + }, + "uniqueCustomers": { + "type": ["null", "integer"] + }, + "repeatCustomersPctTotal": { + "type": ["null", "number"] + }, + "repeatPurchaseRevenue": { + "type": "object", + "properties": { + "amount": { + "type": ["null", "number"] + }, + "currencyCode": { + "type": ["null", "string"] + } + } + }, + "repeatPurchaseRevenuePctTotal": { + "type": ["null", "number"] + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_search_terms.json b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_search_terms.json new file mode 100644 index 0000000000000..d841e81f9a4ba --- /dev/null +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/integration_tests/configured_catalog_brand_analytics_search_terms.json @@ -0,0 +1,41 @@ +{ + "streams": [ + { + "stream": { + "name": "GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT", + "json_schema": { + "title": "Brand Analytics Search Terms Reports", + "description": "Brand Analytics Search Terms Reports", + "type": "object", + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "departmentName": { + "type": ["null", "string"] + }, + "searchTerm": { + "type": ["null", "string"] + }, + "searchFrequencyRank": { + "type": ["null", "number"] + }, + "clickedAsin": { + "type": ["null", "string"] + }, + "clickShareRank": { + "type": ["null", "number"] + }, + "clickShare": { + "type": ["null", "number"] + }, + "conversionShare": { + "type": ["null", "number"] + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_ALTERNATE_PURCHASE_REPORT.json b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_ALTERNATE_PURCHASE_REPORT.json new file mode 100644 index 0000000000000..84b78bc293858 --- /dev/null +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_ALTERNATE_PURCHASE_REPORT.json @@ -0,0 +1,28 @@ +{ + "title": "Brand Analytics Alternate Purchase Reports", + "description": "Brand Analytics Alternate Purchase Reports", + "type": "object", + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "startDate": { + "type": ["null", "string"], + "format": "date" + }, + "endDate": { + "type": ["null", "string"], + "format": "date" + }, + "asin": { + "type": ["null", "string"] + }, + "purchasedAsin": { + "type": ["null", "string"] + }, + "purchasedRank": { + "type": ["null", "integer"] + }, + "purchasedPct": { + "type": ["null", "number"] + } + } +} diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_ITEM_COMPARISON_REPORT.json b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_ITEM_COMPARISON_REPORT.json new file mode 100644 index 0000000000000..cae42a1150bb3 --- /dev/null +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_ITEM_COMPARISON_REPORT.json @@ -0,0 +1,28 @@ +{ + "title": "Brand Analytics Item Comparison Reports", + "description": "Brand Analytics Item Comparison Reports", + "type": "object", + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "startDate": { + "type": ["null", "string"], + "format": "date" + }, + "endDate": { + "type": ["null", "string"], + "format": "date" + }, + "asin": { + "type": ["null", "string"] + }, + "comparedAsin": { + "type": ["null", "string"] + }, + "comparedRank": { + "type": ["null", "integer"] + }, + "comparedPct": { + "type": ["null", "number"] + } + } +} diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT.json b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT.json new file mode 100644 index 0000000000000..88473f308b034 --- /dev/null +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT.json @@ -0,0 +1,28 @@ +{ + "title": "Brand Analytics Market Basket Reports", + "description": "Brand Analytics Market Basket Reports", + "type": "object", + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "startDate": { + "type": ["null", "string"], + "format": "date" + }, + "endDate": { + "type": ["null", "string"], + "format": "date" + }, + "asin": { + "type": ["null", "string"] + }, + "purchasedWithAsin": { + "type": ["null", "string"] + }, + "purchasedWithRank": { + "type": ["null", "integer"] + }, + "combinationPct": { + "type": ["null", "number"] + } + } +} diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT.json b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT.json new file mode 100644 index 0000000000000..46da2d4f03077 --- /dev/null +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/schemas/GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT.json @@ -0,0 +1,42 @@ +{ + "title": "Brand Analytics Repeat Purchase Reports", + "description": "Brand Analytics Repeat Purchase Reports", + "type": "object", + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "startDate": { + "type": ["null", "string"], + "format": "date" + }, + "endDate": { + "type": ["null", "string"], + "format": "date" + }, + "asin": { + "type": ["null", "string"] + }, + "orders": { + "type": ["null", "integer"] + }, + "uniqueCustomers": { + "type": ["null", "integer"] + }, + "repeatCustomersPctTotal": { + "type": ["null", "number"] + }, + "repeatPurchaseRevenue": { + "type": "object", + "properties": { + "amount": { + "type": ["null", "number"] + }, + "currencyCode": { + "type": ["null", "string"] + } + } + }, + "repeatPurchaseRevenuePctTotal": { + "type": ["null", "number"] + } + } +} diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/source.py b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/source.py index a036001f05f36..e46d83e575f3f 100644 --- a/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/source.py +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/source.py @@ -15,6 +15,10 @@ from source_amazon_seller_partner.auth import AWSAuthenticator, AWSSignature from source_amazon_seller_partner.constants import AWSEnvironment, AWSRegion, get_marketplaces from source_amazon_seller_partner.streams import ( + BrandAnalyticsAlternatePurchaseReports, + BrandAnalyticsItemComparisonReports, + BrandAnalyticsMarketBasketReports, + BrandAnalyticsRepeatPurchaseReports, BrandAnalyticsSearchTermsReports, FbaInventoryReports, FbaOrdersReports, @@ -150,7 +154,11 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]: VendorInventoryHealthReports(**stream_kwargs), Orders(**stream_kwargs), SellerFeedbackReports(**stream_kwargs), + BrandAnalyticsMarketBasketReports(**stream_kwargs), BrandAnalyticsSearchTermsReports(**stream_kwargs), + BrandAnalyticsRepeatPurchaseReports(**stream_kwargs), + BrandAnalyticsAlternatePurchaseReports(**stream_kwargs), + BrandAnalyticsItemComparisonReports(**stream_kwargs), ] def spec(self, *args, **kwargs) -> ConnectorSpecification: diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/streams.py b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/streams.py index 2d8c880cf3e3d..f26dca2d8d192 100644 --- a/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/streams.py +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/streams.py @@ -142,6 +142,7 @@ class ReportsAmazonSPStream(Stream, ABC): path_prefix = f"reports/{REPORTS_API_VERSION}" sleep_seconds = 30 data_field = "payload" + result_key = None def __init__( self, @@ -288,8 +289,7 @@ def parse_response(self, response: requests.Response) -> Iterable[Mapping]: document_records = self.parse_document(document) yield from document_records - @staticmethod - def parse_document(document): + def parse_document(self, document): return csv.DictReader(StringIO(document), delimiter="\t") def report_options(self) -> Mapping[str, Any]: @@ -388,17 +388,10 @@ class VendorInventoryHealthReports(ReportsAmazonSPStream): name = "GET_VENDOR_INVENTORY_HEALTH_AND_PLANNING_REPORT" -class BrandAnalyticsSearchTermsReports(ReportsAmazonSPStream): - """ - Field definitions: https://sellercentral.amazon.co.uk/help/hub/reference/G5NXWNY8HUD3VDCW - """ - - name = "GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT" - - @staticmethod - def parse_document(document): +class BrandAnalyticsStream(ReportsAmazonSPStream): + def parse_document(self, document): parsed = json_lib.loads(document) - return parsed.get("dataByDepartmentAndSearchTerm", {}) + return parsed.get(self.result_key, []) def _report_data( self, @@ -452,6 +445,35 @@ def _augmented_data(report_options) -> Mapping[str, Any]: } +class BrandAnalyticsMarketBasketReports(BrandAnalyticsStream): + name = "GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT" + result_key = "dataByAsin" + + +class BrandAnalyticsSearchTermsReports(BrandAnalyticsStream): + """ + Field definitions: https://sellercentral.amazon.co.uk/help/hub/reference/G5NXWNY8HUD3VDCW + """ + + name = "GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT" + result_key = "dataByDepartmentAndSearchTerm" + + +class BrandAnalyticsRepeatPurchaseReports(BrandAnalyticsStream): + name = "GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT" + result_key = "dataByAsin" + + +class BrandAnalyticsAlternatePurchaseReports(BrandAnalyticsStream): + name = "GET_BRAND_ANALYTICS_ALTERNATE_PURCHASE_REPORT" + result_key = "dataByAsin" + + +class BrandAnalyticsItemComparisonReports(BrandAnalyticsStream): + name = "GET_BRAND_ANALYTICS_ITEM_COMPARISON_REPORT" + result_key = "dataByAsin" + + class IncrementalReportsAmazonSPStream(ReportsAmazonSPStream): @property @abstractmethod diff --git a/docs/integrations/sources/amazon-seller-partner.md b/docs/integrations/sources/amazon-seller-partner.md index e3b9c272fc332..71d336fc1a1f9 100644 --- a/docs/integrations/sources/amazon-seller-partner.md +++ b/docs/integrations/sources/amazon-seller-partner.md @@ -24,6 +24,10 @@ This source is capable of syncing the following streams: - [Orders](https://github.com/amzn/selling-partner-api-docs/blob/main/references/orders-api/ordersV0.md) \(incremental\) - [VendorDirectFulfillmentShipping](https://github.com/amzn/selling-partner-api-docs/blob/main/references/vendor-direct-fulfillment-shipping-api/vendorDirectFulfillmentShippingV1.md) - [Seller Feedback Report](https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md#performance-reports) +- [Brand Analytics Alternate Purchase Report](https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md#brand-analytics-reports) +- [Brand Analytics Item Comparison Report](https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md#brand-analytics-reports) +- [Brand Analytics Market Basket Report](https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md#brand-analytics-reports) +- [Brand Analytics Repeat Purchase Report](https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md#brand-analytics-reports) - [Brand Analytics Search Terms Report](https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md#brand-analytics-reports) ## Getting started @@ -63,6 +67,7 @@ Information about rate limits you may find [here](https://github.com/amzn/sellin | Version | Date | Pull Request | Subject | | :------- | :--------- | :------------------------------------------------------- | :--------------------------------------------------------------------- | +| `0.2.12` | 2022-01-05 | [\#9312](https://github.com/airbytehq/airbyte/pull/9312) | Add all remaining brand analytics report streams | `0.2.11` | 2022-01-05 | [\#9115](https://github.com/airbytehq/airbyte/pull/9115) | Fix reading only 100 orders | | `0.2.10` | 2021-12-31 | [\#9236](https://github.com/airbytehq/airbyte/pull/9236) | Fix NoAuth deprecation warning | | `0.2.9` | 2021-12-30 | [\#9212](https://github.com/airbytehq/airbyte/pull/9212) | Normalize GET_SELLER_FEEDBACK_DATA header field names |