Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add availability_sla_days and fixed_period_in_days to GET_VENDOR_TRAFFIC_REPORT stream #38210

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: e55879a8-0ef8-4557-abcf-ab34c53ec460
dockerImageTag: 4.2.3
dockerImageTag: 4.2.4
dockerRepository: airbyte/source-amazon-seller-partner
documentationUrl: https://docs.airbyte.com/integrations/sources/amazon-seller-partner
githubIssueLabel: source-amazon-seller-partner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
version = "4.2.3"
version = "4.2.4"
name = "source-amazon-seller-partner"
description = "Source implementation for Amazon Seller Partner."
authors = ["Airbyte <contact@airbyte.io>"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,8 @@ class VendorInventoryReports(IncrementalAnalyticsStream):
class VendorTrafficReport(IncrementalAnalyticsStream):
name = "GET_VENDOR_TRAFFIC_REPORT"
result_key = "trafficByAsin"
availability_sla_days = 3
fixed_period_in_days = 1


class SellerAnalyticsSalesAndTrafficReports(IncrementalAnalyticsStream):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ def create_report_endpoint(cls, report_name: str) -> RequestBuilder:
}
return cls("reports/2021-06-30/reports").with_body(json.dumps(request_body))

@classmethod
def create_vendor_traffic_report_endpoint(cls, report_name: str) -> RequestBuilder:
request_body = {
"reportType": report_name,
"marketplaceIds": [MARKETPLACE_ID],
"dataStartTime": "2023-01-01T00:00:00Z",
"dataEndTime": "2023-01-01T23:59:59Z",
}
return cls("reports/2021-06-30/reports").with_body(json.dumps(request_body))

@classmethod
def check_report_status_endpoint(cls, report_id: str) -> RequestBuilder:
return cls(f"reports/2021-06-30/reports/{report_id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from airbyte_protocol.models import AirbyteStateMessage, FailureType, SyncMode
from source_amazon_seller_partner.streams import ReportProcessingStatus

from .config import CONFIG_END_DATE, CONFIG_START_DATE, MARKETPLACE_ID, NOW, ConfigBuilder
from .config import CONFIG_END_DATE, CONFIG_START_DATE, MARKETPLACE_ID, NOW, VENDOR_TRAFFIC_REPORT_CONFIG_END_DATE, ConfigBuilder
from .request_builder import RequestBuilder
from .response_builder import build_response, response_with_status
from .utils import assert_message_in_log_output, config, find_template, get_stream_by_name, mock_auth, read_output
Expand Down Expand Up @@ -68,7 +68,8 @@ def _create_report_request(report_name: str) -> RequestBuilder:
A POST request needed to start generating a report on Amazon SP platform.
Performed in ReportsAmazonSPStream._create_report method.
"""

if report_name == "GET_VENDOR_TRAFFIC_REPORT":
return RequestBuilder.create_vendor_traffic_report_endpoint(report_name)
return RequestBuilder.create_report_endpoint(report_name)


Expand Down Expand Up @@ -388,8 +389,11 @@ def test_given_report_status_fatal_when_read_then_exception_raised(

output = self._read(stream_name, config(), expecting_exception=True)
assert output.errors[-1].trace.error.failure_type == FailureType.config_error
config_end_date = CONFIG_END_DATE
if stream_name == "GET_VENDOR_TRAFFIC_REPORT":
config_end_date = VENDOR_TRAFFIC_REPORT_CONFIG_END_DATE
assert (
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.'}}"
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.'}}"
) in output.errors[-1].trace.error.message

@pytest.mark.parametrize(
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/amazon-seller-partner.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Information about rate limits you may find [here](https://developer-docs.amazon.

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:----------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 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` |
| 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 |
| 4.2.2 | 2024-04-24 | [#36630](https://github.com/airbytehq/airbyte/pull/36630) | Schema descriptions and CDK 0.80.0 |
| 4.2.1 | 2024-04-08 | [#36895](https://github.com/airbytehq/airbyte/pull/36895) | Fix `reportPeriod` day query params |
Expand Down
Loading