Skip to content

Commit

Permalink
Merge pull request #1 from hotgluexyz/feature/inTransit
Browse files Browse the repository at this point in the history
added incoming
  • Loading branch information
hsyyid authored Dec 21, 2021
2 parents 3f238d0 + 48235d7 commit a51edc2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.secrets
todo.org
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="tap-shopify",
version="1.4.1",
version="1.4.2",
description="Singer.io tap for extracting Shopify data",
author="Stitch",
url="http://github.com/singer-io/tap-shopify",
Expand Down
3 changes: 3 additions & 0 deletions tap_shopify/schemas/inventory_levels.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"location_id": {
"type": ["null", "integer"]
},
"incoming": {
"type": ["null", "integer"]
},
"admin_graphql_api_id": {
"type": ["null", "string"]
}
Expand Down
7 changes: 7 additions & 0 deletions tap_shopify/streams/inventory_levels.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import shopify
from singer.utils import strftime, strptime_to_utc
from tap_shopify.streams.base import (Stream,
Expand All @@ -10,6 +11,7 @@ class InventoryLevels(Stream):
replication_key = 'updated_at'
key_properties = ['location_id', 'inventory_item_id']
replication_object = shopify.InventoryLevel
gql_query = "query inventoryLevel($id: ID!){inventoryLevel(id: $id){incoming}}"

@shopify_error_handling
def api_call_for_inventory_levels(self, parent_object_id, bookmark):
Expand Down Expand Up @@ -41,10 +43,15 @@ def get_objects(self):
yield from self.get_inventory_levels(parent_object.id, bookmark)

def sync(self):
gql_client = shopify.GraphQL()
bookmark = self.get_bookmark()
max_bookmark = bookmark
for inventory_level in self.get_objects():
inventory_level_dict = inventory_level.to_dict()
variables = dict(id = inventory_level_dict.get("admin_graphql_api_id"))
response = gql_client.execute(self.gql_query, variables)
response_dict = json.loads(response)
inventory_level_dict["incoming"] = response_dict["data"]["inventoryLevel"].get("incoming")
replication_value = strptime_to_utc(inventory_level_dict[self.replication_key])
if replication_value >= bookmark:
yield inventory_level_dict
Expand Down

0 comments on commit a51edc2

Please sign in to comment.