Skip to content

Commit

Permalink
Amazon SP: ref
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Inzhyyants <[email protected]>
  • Loading branch information
artem1205 committed Jan 8, 2025
1 parent 1e646a2 commit fecf6fa
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@

from .decoder import GzipCsvDecoder

from .type_transformers import LedgerDetailedViewReportsTypeTransformer, MerchantListingsFypReportTypeTransformer, FlatFileSettlementV2ReportsTypeTransformer, \
MerchantReportsTypeTransformer, SellerFeedbackReportsTypeTransformer

__all__ = [
"AmazonSPOauthAuthenticator",
"AmazonSPWaitTimeFromHeaderBackoffStrategy",
"GzipCsvDecoder"
]
"GzipCsvDecoder",
"LedgerDetailedViewReportsTypeTransformer",
"MerchantListingsFypReportTypeTransformer",
"FlatFileSettlementV2ReportsTypeTransformer",
"MerchantReportsTypeTransformer",
"SellerFeedbackReportsTypeTransformer"
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

import backoff
import requests

from airbyte_cdk import InterpolatedString
from airbyte_cdk.models import FailureType
from airbyte_cdk.sources.declarative.auth import DeclarativeOauth2Authenticator
from airbyte_cdk.sources.streams.http.exceptions import DefaultBackoffException
from airbyte_cdk.utils import AirbyteTracedException
from airbyte_cdk.utils.airbyte_secrets_utils import add_to_secrets


logger = logging.getLogger("airbyte")
import pendulum

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Optional, Union

import requests

from airbyte_cdk.sources.declarative.requesters.error_handlers.backoff_strategies.wait_time_from_header_backoff_strategy import (
WaitTimeFromHeaderBackoffStrategy,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from airbyte_cdk.sources.declarative.decoders.decoder import Decoder


logger = logging.getLogger("airbyte")


Expand Down Expand Up @@ -94,7 +95,6 @@ class GetXmlBrowseTreeDataDecoder(Decoder):
parameters: InitVar[Mapping[str, Any]]
NORMALIZED_FIELD_NAMES = ["date", "rating", "comments", "response", "order_id", "rater_email"]


def is_stream_response(self) -> bool:
return False

Expand All @@ -119,4 +119,4 @@ def decode(self, response: requests.Response) -> Generator[MutableMapping[str, A
logger.warning(f"Unable to parse the report for the stream, error: {str(e)}")
parsed = {}

yield from parsed.get("Result", {}).get("Node", [])
yield from parsed.get("Result", {}).get("Node", [])
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import Dict, Any
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.

from typing import Any, Dict

import dateparser
import pendulum

from airbyte_cdk.sources.utils.transform import TypeTransformer, TransformConfig

from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer


class LedgerDetailedViewReportsTypeTransformer(TypeTransformer):

def __init__(self, *args, **kwargs):
config = TransformConfig.DefaultSchemaNormalization | TransformConfig.CustomSchemaNormalization
super().__init__(config)
Expand All @@ -28,8 +28,8 @@ def transform_function(original_value: str, field_schema: Dict[str, Any]) -> str

return transform_function

class MerchantListingsFypReportTypeTransformer(TypeTransformer):

class MerchantListingsFypReportTypeTransformer(TypeTransformer):
def __init__(self, *args, **kwargs):
config = TransformConfig.DefaultSchemaNormalization | TransformConfig.CustomSchemaNormalization
super().__init__(config)
Expand All @@ -48,8 +48,8 @@ def transform_function(original_value: Any, field_schema: Dict[str, Any]) -> Any

return transform_function

class MerchantReportsTypeTransformer(TypeTransformer):

class MerchantReportsTypeTransformer(TypeTransformer):
def __init__(self, *args, **kwargs):
config = TransformConfig.DefaultSchemaNormalization | TransformConfig.CustomSchemaNormalization
super().__init__(config)
Expand All @@ -67,7 +67,6 @@ def transform_function(original_value: Any, field_schema: Dict[str, Any]) -> Any
return transform_function



class SellerFeedbackReportsTypeTransformer(TypeTransformer):
MARKETPLACE_DATE_FORMAT_MAP = dict(
# eu
Expand Down Expand Up @@ -120,7 +119,6 @@ def transform_function(original_value: Any, field_schema: Dict[str, Any]) -> Any


class FlatFileSettlementV2ReportsTypeTransformer(TypeTransformer):

def __init__(self, *args, **kwargs):
config = TransformConfig.DefaultSchemaNormalization | TransformConfig.CustomSchemaNormalization
super().__init__(config)
Expand All @@ -134,4 +132,3 @@ def transform_function(original_value: Any, field_schema: Dict[str, Any]) -> Any
return original_value

return transform_function

Loading

0 comments on commit fecf6fa

Please sign in to comment.