diff --git a/setup.py b/setup.py index 3c434353..c1446f72 100755 --- a/setup.py +++ b/setup.py @@ -2,15 +2,15 @@ from setuptools import setup setup( - name="tap-shopify", - version="1.2.9", + name="tap-shopify-scentbird", + version="1.2.15", description="Singer.io tap for extracting Shopify data", author="Stitch", url="http://github.com/singer-io/tap-shopify", classifiers=["Programming Language :: Python :: 3 :: Only"], py_modules=["tap_shopify"], install_requires=[ - "ShopifyAPI==8.0.1", + "ShopifyAPI==8.4.1", "singer-python==5.12.1", ], extras_require={ diff --git a/tap_shopify/__init__.py b/tap_shopify/__init__.py index 34790862..8b7ccbe2 100644 --- a/tap_shopify/__init__.py +++ b/tap_shopify/__init__.py @@ -14,6 +14,7 @@ from tap_shopify.context import Context from tap_shopify.exceptions import ShopifyError import tap_shopify.streams # Load stream objects into Context +from tap_shopify.streams import disputes REQUIRED_CONFIG_KEYS = ["shop", "api_key"] LOGGER = singer.get_logger() diff --git a/tap_shopify/schemas/disputes.json b/tap_shopify/schemas/disputes.json new file mode 100644 index 00000000..ad53c23e --- /dev/null +++ b/tap_shopify/schemas/disputes.json @@ -0,0 +1,77 @@ +{ + + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "order_id": { + "type": "integer" + }, + "type": { + "type": [ + "null", + "string" + ] + }, + "amount": { + "type": [ + "null", + "number" + ] + }, + "currency": { + "type": [ + "null", + "string" + ] + }, + "reason": { + "$id": "#/properties/reason", + "type": [ + "null", + "string" + ] + }, + "network_reason_code": { + "type": [ + "null", + "string" + ] + }, + "status": { + "type": [ + "null", + "string" + ] + }, + "evidence_due_by": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "evidence_sent_on": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "finalized_on": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "initiated_at": { + "type": [ + "null", + "string" + ], + "format": "date-time" + } + } +} \ No newline at end of file diff --git a/tap_shopify/schemas/orders.json b/tap_shopify/schemas/orders.json index dc87ea7e..05b0e4f7 100644 --- a/tap_shopify/schemas/orders.json +++ b/tap_shopify/schemas/orders.json @@ -6,12 +6,42 @@ "string" ] }, - "subtotal_price_set": {}, - "total_discounts_set": {}, - "total_line_items_price_set": {}, - "total_price_set": {}, - "total_shipping_price_set": {}, - "total_tax_set": {}, + "subtotal_price_set": { + "type": [ + "null", + "object" + ] + }, + "total_discounts_set": { + "type": [ + "null", + "object" + ] + }, + "total_line_items_price_set": { + "type": [ + "null", + "object" + ] + }, + "total_price_set": { + "type": [ + "null", + "object" + ] + }, + "total_shipping_price_set": { + "type": [ + "null", + "object" + ] + }, + "total_tax_set": { + "type": [ + "null", + "object" + ] + }, "total_price": { "type": [ "null", diff --git a/tap_shopify/streams/__init__.py b/tap_shopify/streams/__init__.py index dd73ba7a..5d45b4af 100644 --- a/tap_shopify/streams/__init__.py +++ b/tap_shopify/streams/__init__.py @@ -7,3 +7,4 @@ import tap_shopify.streams.products import tap_shopify.streams.collects import tap_shopify.streams.custom_collections +import tap_shopify.streams.disputes diff --git a/tap_shopify/streams/base.py b/tap_shopify/streams/base.py index 4c5ee577..bca551e9 100644 --- a/tap_shopify/streams/base.py +++ b/tap_shopify/streams/base.py @@ -122,6 +122,16 @@ def update_bookmark(self, bookmark_value, bookmark_key=None): def call_api(self, query_params): return self.replication_object.find(**query_params) + def get_query_params(self, since_id, updated_at_min, updated_at_max, results_per_page): + status_key = self.status_key or "status" + return { + "since_id": since_id, + "updated_at_min": updated_at_min, + "updated_at_max": updated_at_max, + "limit": results_per_page, + status_key: "any" + } + def get_objects(self): updated_at_min = self.get_bookmark() @@ -146,15 +156,7 @@ def get_objects(self): if updated_at_max > stop_time: updated_at_max = stop_time while True: - status_key = self.status_key or "status" - query_params = { - "since_id": since_id, - "updated_at_min": updated_at_min, - "updated_at_max": updated_at_max, - "limit": results_per_page, - status_key: "any" - } - + query_params = self.get_query_params(since_id, updated_at_min, updated_at_max, results_per_page) with metrics.http_request_timer(self.name): objects = self.call_api(query_params) diff --git a/tap_shopify/streams/disputes.py b/tap_shopify/streams/disputes.py new file mode 100644 index 00000000..46a8b355 --- /dev/null +++ b/tap_shopify/streams/disputes.py @@ -0,0 +1,16 @@ +import shopify + +from tap_shopify.context import Context +from tap_shopify.streams.base import Stream + +class Disputes(Stream): + name = 'disputes' + replication_object = shopify.Disputes + + def get_query_params(self, since_id, updated_at_min, updated_at_max, results_per_page): + return { + "since_id": since_id, + "initiated_at": updated_at_min + } + +Context.stream_objects['disputes'] = Disputes