Skip to content

Commit 1bc850a

Browse files
Add availability_sla_days and fixed_period_in_days to GET_VENDOR_TRAFFIC_REPORT stream (#38210)
1 parent 73a44d0 commit 1bc850a

File tree

7 files changed

+23
-5
lines changed

7 files changed

+23
-5
lines changed

airbyte-integrations/connectors/source-amazon-seller-partner/metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ data:
1515
connectorSubtype: api
1616
connectorType: source
1717
definitionId: e55879a8-0ef8-4557-abcf-ab34c53ec460
18-
dockerImageTag: 4.2.3
18+
dockerImageTag: 4.2.4
1919
dockerRepository: airbyte/source-amazon-seller-partner
2020
documentationUrl: https://docs.airbyte.com/integrations/sources/amazon-seller-partner
2121
githubIssueLabel: source-amazon-seller-partner

airbyte-integrations/connectors/source-amazon-seller-partner/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["poetry-core>=1.0.0"]
33
build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
6-
version = "4.2.3"
6+
version = "4.2.4"
77
name = "source-amazon-seller-partner"
88
description = "Source implementation for Amazon Seller Partner."
99
authors = ["Airbyte <[email protected]>"]

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

+2
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,8 @@ class VendorInventoryReports(IncrementalAnalyticsStream):
854854
class VendorTrafficReport(IncrementalAnalyticsStream):
855855
name = "GET_VENDOR_TRAFFIC_REPORT"
856856
result_key = "trafficByAsin"
857+
availability_sla_days = 3
858+
fixed_period_in_days = 1
857859

858860

859861
class SellerAnalyticsSalesAndTrafficReports(IncrementalAnalyticsStream):

airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/integration/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
CONFIG_START_DATE = "2023-01-01T00:00:00Z"
2020
CONFIG_END_DATE = "2023-01-30T00:00:00Z"
21+
VENDOR_TRAFFIC_REPORT_CONFIG_END_DATE = "2023-01-01T23:59:59Z"
2122
NOW = pendulum.now(tz="utc")
2223
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
2324

airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/integration/request_builder.py

+10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ def create_report_endpoint(cls, report_name: str) -> RequestBuilder:
3232
}
3333
return cls("reports/2021-06-30/reports").with_body(json.dumps(request_body))
3434

35+
@classmethod
36+
def create_vendor_traffic_report_endpoint(cls, report_name: str) -> RequestBuilder:
37+
request_body = {
38+
"reportType": report_name,
39+
"marketplaceIds": [MARKETPLACE_ID],
40+
"dataStartTime": "2023-01-01T00:00:00Z",
41+
"dataEndTime": "2023-01-01T23:59:59Z",
42+
}
43+
return cls("reports/2021-06-30/reports").with_body(json.dumps(request_body))
44+
3545
@classmethod
3646
def check_report_status_endpoint(cls, report_id: str) -> RequestBuilder:
3747
return cls(f"reports/2021-06-30/reports/{report_id}")

airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/integration/test_report_based_streams.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from airbyte_protocol.models import AirbyteStateMessage, FailureType, SyncMode
1818
from source_amazon_seller_partner.streams import ReportProcessingStatus
1919

20-
from .config import CONFIG_END_DATE, CONFIG_START_DATE, MARKETPLACE_ID, NOW, ConfigBuilder
20+
from .config import CONFIG_END_DATE, CONFIG_START_DATE, MARKETPLACE_ID, NOW, VENDOR_TRAFFIC_REPORT_CONFIG_END_DATE, ConfigBuilder
2121
from .request_builder import RequestBuilder
2222
from .response_builder import build_response, response_with_status
2323
from .utils import assert_message_in_log_output, config, find_template, get_stream_by_name, mock_auth, read_output
@@ -68,7 +68,8 @@ def _create_report_request(report_name: str) -> RequestBuilder:
6868
A POST request needed to start generating a report on Amazon SP platform.
6969
Performed in ReportsAmazonSPStream._create_report method.
7070
"""
71-
71+
if report_name == "GET_VENDOR_TRAFFIC_REPORT":
72+
return RequestBuilder.create_vendor_traffic_report_endpoint(report_name)
7273
return RequestBuilder.create_report_endpoint(report_name)
7374

7475

@@ -388,8 +389,11 @@ def test_given_report_status_fatal_when_read_then_exception_raised(
388389

389390
output = self._read(stream_name, config(), expecting_exception=True)
390391
assert output.errors[-1].trace.error.failure_type == FailureType.config_error
392+
config_end_date = CONFIG_END_DATE
393+
if stream_name == "GET_VENDOR_TRAFFIC_REPORT":
394+
config_end_date = VENDOR_TRAFFIC_REPORT_CONFIG_END_DATE
391395
assert (
392-
f"Failed to retrieve the report '{stream_name}' for period {CONFIG_START_DATE}-{CONFIG_END_DATE}. This will be read during the next sync. Error: {{'errorDetails': 'Error in report request: This report type requires the reportPeriod, distributorView, sellingProgram reportOption to be specified. Please review the document for this report type on GitHub, provide a value for this reportOption in your request, and try again.'}}"
396+
f"Failed to retrieve the report '{stream_name}' for period {CONFIG_START_DATE}-{config_end_date}. This will be read during the next sync. Error: {{'errorDetails': 'Error in report request: This report type requires the reportPeriod, distributorView, sellingProgram reportOption to be specified. Please review the document for this report type on GitHub, provide a value for this reportOption in your request, and try again.'}}"
393397
) in output.errors[-1].trace.error.message
394398

395399
@pytest.mark.parametrize(

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

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ Information about rate limits you may find [here](https://developer-docs.amazon.
175175

176176
| Version | Date | Pull Request | Subject |
177177
|:--------|:-----------|:----------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
178+
| 4.2.4 | 2024-05-15 | [#38210](https://github.com/airbytehq/airbyte/pull/38210) | Fix `GET_VENDOR_TRAFFIC_REPORT` stream with report option `reportPeriod=DAY` |
178179
| 4.2.3 | 2024-05-09 | [#38078](https://github.com/airbytehq/airbyte/pull/38078) | Hide OSS-only streams in report options config for cloud users |
179180
| 4.2.2 | 2024-04-24 | [#36630](https://github.com/airbytehq/airbyte/pull/36630) | Schema descriptions and CDK 0.80.0 |
180181
| 4.2.1 | 2024-04-08 | [#36895](https://github.com/airbytehq/airbyte/pull/36895) | Fix `reportPeriod` day query params |

0 commit comments

Comments
 (0)