From 4251aec1dc9579d16e10ac2261b036edb831098d Mon Sep 17 00:00:00 2001 From: Ivan Zerin Date: Thu, 18 Feb 2021 18:48:22 +0300 Subject: [PATCH 1/4] Fix issue with empty types in orders --- tap_shopify/schemas/orders.json | 42 ++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/tap_shopify/schemas/orders.json b/tap_shopify/schemas/orders.json index ac0a8b2a..d096d1a8 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", From ec84b8313502af60142fd0cb0bc464dafa4fd64c Mon Sep 17 00:00:00 2001 From: andreyshalitkin Date: Wed, 31 Mar 2021 19:39:27 +0300 Subject: [PATCH 2/4] Shopify disputes --- setup.py | 6 +-- tap_shopify/__init__.py | 1 + tap_shopify/schemas/disputes.json | 77 +++++++++++++++++++++++++++++++ tap_shopify/streams/__init__.py | 1 + tap_shopify/streams/disputes.py | 10 ++++ 5 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 tap_shopify/schemas/disputes.json create mode 100644 tap_shopify/streams/disputes.py diff --git a/setup.py b/setup.py index 3c434353..00c70b73 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.10", 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..cfc18a60 --- /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", + "integer" + ] + }, + "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/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/disputes.py b/tap_shopify/streams/disputes.py new file mode 100644 index 00000000..22680142 --- /dev/null +++ b/tap_shopify/streams/disputes.py @@ -0,0 +1,10 @@ +import shopify + +from tap_shopify.context import Context +from tap_shopify.streams.base import Stream + +class Disputes(Stream): + name = 'disputes' + replication_object = shopify.Disputes + +Context.stream_objects['disputes'] = Disputes From af79beb1fed56e1a11e6f78decdc0bb915e44fbb Mon Sep 17 00:00:00 2001 From: andreyshalitkin Date: Thu, 1 Apr 2021 19:35:31 +0300 Subject: [PATCH 3/4] Shopify disputes. Some fixes --- setup.py | 2 +- tap_shopify/streams/base.py | 20 +++++++++++--------- tap_shopify/streams/disputes.py | 6 ++++++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 00c70b73..f8a26650 100755 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name="tap-shopify-scentbird", - version="1.2.10", + version="1.2.11", description="Singer.io tap for extracting Shopify data", author="Stitch", url="http://github.com/singer-io/tap-shopify", 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 index 22680142..46a8b355 100644 --- a/tap_shopify/streams/disputes.py +++ b/tap_shopify/streams/disputes.py @@ -7,4 +7,10 @@ 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 From dfb88d76a5d8990a34dd8b8f9c257960a6459703 Mon Sep 17 00:00:00 2001 From: andreyshalitkin Date: Thu, 1 Apr 2021 21:35:44 +0300 Subject: [PATCH 4/4] Shopify disputes. Schema fix --- setup.py | 2 +- tap_shopify/schemas/disputes.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f8a26650..c1446f72 100755 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name="tap-shopify-scentbird", - version="1.2.11", + version="1.2.15", description="Singer.io tap for extracting Shopify data", author="Stitch", url="http://github.com/singer-io/tap-shopify", diff --git a/tap_shopify/schemas/disputes.json b/tap_shopify/schemas/disputes.json index cfc18a60..ad53c23e 100644 --- a/tap_shopify/schemas/disputes.json +++ b/tap_shopify/schemas/disputes.json @@ -36,7 +36,7 @@ "network_reason_code": { "type": [ "null", - "integer" + "string" ] }, "status": {