Skip to content

Commit

Permalink
v0.2.1 Amazon Attribution unify in one Class
Browse files Browse the repository at this point in the history
  • Loading branch information
denisneuf committed Feb 9, 2022
1 parent 35a606d commit 86bbcae
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 79 deletions.
4 changes: 2 additions & 2 deletions ad_api/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from . import sp as sponsored_products
from . import sb as sponsored_brands
from . import sd as sponsored_display
from . import attribution
from .attribution import Attribution

__all__ = [
"sp",
Expand All @@ -19,7 +19,7 @@
"sponsored_products",
"sponsored_brands",
"sponsored_display",
"attribution",
"Attribution",
"Profiles",
"Invoices",
"Eligibility",
Expand Down
59 changes: 56 additions & 3 deletions ad_api/api/attribution/tags.py → ad_api/api/attribution.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,62 @@
from typing import List

from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse

class Attribution(Client):
"""
Audience Discovery API
"""
@sp_endpoint("/attribution/advertisers", method="GET")
def get_advertisers(self, **kwargs) -> ApiResponse:
"""
Use the response to determine whether to use either the macroTags or nonMacroTemplateTags resource to get tags for a certain publisher.
Args:
**kwargs:
Returns:
ApiResponse
"""
return self._request(fill_query_params(kwargs.pop("path")), params=kwargs)

@sp_endpoint("/attribution/publishers", method="GET")
def get_publishers(self, **kwargs) -> ApiResponse:
"""
Args:
**kwargs:
Returns:
ApiResponse
"""
return self._request(fill_query_params(kwargs.pop("path")), params=kwargs)

@sp_endpoint("/attribution/report", method="POST")
def post_report(self, **kwargs) -> ApiResponse:
"""Gets an attribution report for a specified list of advertisers.
class Tags(Client):
Args:
**kwargs:
Request body:
| **reportType** (string): The type of report. Either `PERFORMANCE` or `PRODUCTS`. It is an optional parameter. If not used in request body, default reportType is `PERFORMANCE`. Each report type is aggregated at different levels. See below table for list of dimensions available within each report type.
| **advertiserIds** (string): One or more advertiser Ids to filter reporting by. If requesting reporting for multiple advertiser Ids, input via a comma-delimited list.
| **endDate** (string): The end date for the report, form as "YYYYMMDD"
| **count** (integer): maximum: 10000, minimum:1, The number of entries to include in the report.
| **metrics** (string):
| **startDate** (string): The start date for the report, in "YYYYMMDD" format. For reportType PRODUCTS, startDate can only be within last 90 days from current date.
| **cursorId** (string): The value of cursorId must be set to null without "", or set to "" for the first request. For each following request, the value of cursorId from the previous response must be included in the current request. Note that for the cursorId values the " character must be escaped with \.
Returns:
ApiResponse
"""
data = json.dumps(kwargs.pop("body"))
resp = self._request(
fill_query_params(kwargs.pop("path")),
data=data,
params=kwargs,
)
resp.set_next_token(resp.payload.pop("cursorId"))
return resp

@sp_endpoint("/attribution/tags/macroTag", method="GET")
def get_macro_tag(self, **kwargs) -> ApiResponse:
Expand Down
6 changes: 0 additions & 6 deletions ad_api/api/attribution/__init__.py

This file was deleted.

17 changes: 0 additions & 17 deletions ad_api/api/attribution/advertisers.py

This file was deleted.

15 changes: 0 additions & 15 deletions ad_api/api/attribution/publishers.py

This file was deleted.

33 changes: 0 additions & 33 deletions ad_api/api/attribution/reports.py

This file was deleted.

2 changes: 1 addition & 1 deletion ad_api/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.0"
__version__ = "0.2.1"
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = python-amazon-ad-api
version = 0.2.0
version = 0.2.1
author = Daniel Alvaro
author_email = [email protected]
description = Python wrapper for the Amazon Advertising API
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='python-amazon-ad-api',
version='0.2.0',
version='0.2.1',
install_requires=[
"requests~=2.27.1",
"six~=1.16.0",
Expand Down

0 comments on commit 86bbcae

Please sign in to comment.