-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Added Sponsored Brands Video Report 2. Added region in config to pull data for multiple regions 3. Fix: amazon ads can't pull data more than 60 days
- Loading branch information
1 parent
f803481
commit 8527a30
Showing
10 changed files
with
177 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/constants.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from enum import Enum | ||
|
||
class AmazonAdsRegion(str, Enum): | ||
NA="NA" | ||
EU="EU" | ||
FE="FE" | ||
SANDBOX="SANDBOX" | ||
|
||
URL_MAPPING = { | ||
"NA": "https://advertising-api.amazon.com/", | ||
"EU": "https://advertising-api-eu.amazon.com/", | ||
"FE": "https://advertising-api-fe.amazon.com/", | ||
"SANDBOX": "https://advertising-api-test.amazon.com/" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
...nectors/source-amazon-ads/source_amazon_ads/streams/report_streams/brands_video_report.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# | ||
# MIT License | ||
# | ||
# Copyright (c) 2020 Airbyte | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
# | ||
|
||
from .report_streams import ReportStream | ||
|
||
METRICS_MAP = { | ||
"keywords": [ | ||
"campaignName", | ||
"campaignId", | ||
"campaignStatus", | ||
"campaignBudget", | ||
"campaignBudgetType", | ||
"campaignRuleBasedBudget", | ||
"applicableBudgetRuleId", | ||
"applicableBudgetRuleName", | ||
"adGroupName", | ||
"adGroupId", | ||
"keywordText", | ||
"keywordBid", | ||
"keywordStatus", | ||
"targetId", | ||
"targetingExpression", | ||
"targetingText", | ||
"targetingType", | ||
"matchType", | ||
"impressions", | ||
"clicks", | ||
"cost", | ||
"attributedSales14d", | ||
"attributedSales14dSameSKU", | ||
"attributedConversions14d", | ||
"attributedConversions14dSameSKU", | ||
], | ||
"adGroups": [ | ||
"campaignName", | ||
"campaignId", | ||
"campaignStatus", | ||
"campaignBudget", | ||
"campaignBudgetType", | ||
"adGroupName", | ||
"adGroupId", | ||
"impressions", | ||
"clicks", | ||
"cost", | ||
"attributedSales14d", | ||
"attributedSales14dSameSKU", | ||
"attributedConversions14d", | ||
"attributedConversions14dSameSKU", | ||
], | ||
"campaigns": [ | ||
"campaignName", | ||
"campaignId", | ||
"campaignStatus", | ||
"campaignBudget", | ||
"campaignBudgetType", | ||
"campaignRuleBasedBudget", | ||
"applicableBudgetRuleId", | ||
"applicableBudgetRuleName", | ||
"impressions", | ||
"clicks", | ||
"cost", | ||
"attributedSales14d", | ||
"attributedSales14dSameSKU", | ||
"attributedConversions14d", | ||
"attributedConversions14dSameSKU", | ||
], | ||
} | ||
|
||
|
||
class SponsoredBrandsVideoReportStream(ReportStream): | ||
""" | ||
https://advertising.amazon.com/API/docs/en-us/reference/sponsored-brands/2/reports | ||
""" | ||
|
||
def report_init_endpoint(self, record_type: str) -> str: | ||
return f"/v2/hsa/{record_type}/report" | ||
|
||
metrics_map = METRICS_MAP | ||
|
||
def _get_init_report_body(self, report_date: str, record_type: str, profile): | ||
metrics_list = self.metrics_map[record_type] | ||
body = { | ||
"reportDate": report_date, | ||
"creativeType": "video", | ||
} | ||
return {**body, "metrics": ",".join(metrics_list)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters