Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with empty types in orders #83

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down
1 change: 1 addition & 0 deletions tap_shopify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
77 changes: 77 additions & 0 deletions tap_shopify/schemas/disputes.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
42 changes: 36 additions & 6 deletions tap_shopify/schemas/orders.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions tap_shopify/streams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 11 additions & 9 deletions tap_shopify/streams/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)

Expand Down
16 changes: 16 additions & 0 deletions tap_shopify/streams/disputes.py
Original file line number Diff line number Diff line change
@@ -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