diff --git a/README.md b/README.md index 15d57ca9..e9b260c7 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ This tap: - [Locations](https://help.shopify.com/en/api/reference/inventory/location) - [Inventory Levels](https://help.shopify.com/en/api/reference/inventory/inventorylevel) - [Inventory Item](https://help.shopify.com/en/api/reference/inventory/inventoryitem) + - [Draft Orders](https://help.shopify.com/en/api/reference/draftorder) - Outputs the schema for each resource - Incrementally pulls data based on the input state - When Metafields are selected, this tap will sync the Shopify store's top-level Metafields and any additional Metafields for selected tables that also have them (ie: Orders, Products, Customers) diff --git a/tap_shopify/schemas/definitions.json b/tap_shopify/schemas/definitions.json index 9c2bdf15..9420a8a8 100644 --- a/tap_shopify/schemas/definitions.json +++ b/tap_shopify/schemas/definitions.json @@ -610,6 +610,263 @@ "object" ] }, + "draft_line_item": { + "properties": { + "applied_discount": { + "$ref": "definitions.json#/applied_discount" + }, + "total_discount_set": { + "$ref": "definitions.json#/price_set" + }, + "price_set": { + "$ref": "definitions.json#/price_set" + }, + "grams": { + "type": [ + "null", + "integer" + ] + }, + "compare_at_price": { + "type": [ + "null", + "string" + ] + }, + "destination_location_id": { + "type": [ + "null", + "integer" + ] + }, + "key": { + "type": [ + "null", + "string" + ] + }, + "line_price": { + "type": [ + "null", + "string" + ] + }, + "origin_location_id": { + "type": [ + "null", + "integer" + ] + }, + "fulfillable_quantity": { + "type": [ + "null", + "integer" + ] + }, + "variant_title": { + "type": [ + "null", + "string" + ] + }, + "properties": { + "items": { + "properties": { + "name": { + "type": [ + "null", + "string" + ] + }, + "value": { + "type": [ + "null", + "string" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + }, + "tax_code": { + "type": [ + "null", + "string" + ] + }, + "discount_allocations": { + "items": { + "properties": { + "discount_application_index": { + "type": [ + "null", + "integer" + ] + }, + "amount_set": { + "$ref": "definitions.json#/price_set" + }, + "amount": { + "type": [ + "null", + "number" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "type": [ + "null", + "array" + ] + }, + "admin_graphql_api_id": { + "type": [ + "null", + "string" + ] + }, + "pre_tax_price": { + "type": [ + "null", + "number" + ] + }, + "sku": { + "type": [ + "null", + "string" + ] + }, + "product_exists": { + "type": [ + "null", + "boolean" + ] + }, + "total_discount": { + "type": [ + "null", + "string" + ], + "format": "singer.decimal" + }, + "name": { + "type": [ + "null", + "string" + ] + }, + "fulfillment_status": { + "type": [ + "null", + "string" + ] + }, + "gift_card": { + "type": [ + "null", + "boolean" + ] + }, + "id": { + "type": ["null", "integer", "string"] + }, + "taxable": { + "type": [ + "null", + "boolean" + ] + }, + "vendor": { + "type": [ + "null", + "string" + ] + }, + "tax_lines": { + "$ref": "definitions.json#/tax_lines" + }, + "origin_location": { + "$ref": "definitions.json#/location" + }, + "price": { + "type": [ + "null", + "string" + ], + "format": "singer.decimal" + }, + "requires_shipping": { + "type": [ + "null", + "boolean" + ] + }, + "fulfillment_service": { + "type": [ + "null", + "string" + ] + }, + "variant_inventory_management": { + "type": [ + "null", + "string" + ] + }, + "title": { + "type": [ + "null", + "string" + ] + }, + "destination_location": { + "$ref": "definitions.json#/location" + }, + "quantity": { + "type": [ + "null", + "integer" + ] + }, + "product_id": { + "type": [ + "null", + "integer" + ] + }, + "variant_id": { + "type": [ + "null", + "integer" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "draft_line_items": { + "items": { + "$ref": "definitions.json#/draft_line_item" + }, + "type": [ + "null", + "array" + ] + }, "line_item": { "properties": { "applied_discounts": { @@ -963,10 +1220,97 @@ "object" ] }, + "price_set" : { + "properties": { + "shop_money": { + "properties": { + "currency_code": { + "type": [ + "null", + "string" + ] + }, + "amount": { + "type": [ + "null", + "string" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "presentment_money": { + "properties": { + "currency_code": { + "type": [ + "null", + "string" + ] + }, + "amount": { + "type": [ + "null", + "string" + ] + } + }, + "type": [ + "null", + "object" + ] + } + }, + "type": [ + "null", + "object" + ] + }, + "applied_discount": { + "properties": { + "title": { + "type": [ + "null", + "string" + ] + }, + "description": { + "type": [ + "null", + "string" + ] + }, + "value": { + "type": [ + "null", + "string" + ] + }, + "value_type": { + "type": [ + "null", + "string" + ] + }, + "amount": { + "type": [ + "null", + "string" + ] + } + }, + "type": [ + "null", + "object" + ] + }, "tax_lines": { "items": { "properties": { "price_set": { + "$ref": "definitions.json#/price_set" }, "price": { "type": [ diff --git a/tap_shopify/schemas/draft_orders.json b/tap_shopify/schemas/draft_orders.json new file mode 100644 index 00000000..829114e9 --- /dev/null +++ b/tap_shopify/schemas/draft_orders.json @@ -0,0 +1,212 @@ +{ + "properties": { + "id": { + "type": ["null", "integer"] + }, + "order_id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "customer": { + "$ref": "definitions.json#/customer" + }, + "shipping_address": { + "properties": { + "phone": { + "type": ["null", "string"] + }, + "country": { + "type": ["null", "string"] + }, + "name": { + "type": ["null", "string"] + }, + "address1": { + "type": ["null", "string"] + }, + "longitude": { + "type": ["null", "number"] + }, + "address2": { + "type": ["null", "string"] + }, + "last_name": { + "type": ["null", "string"] + }, + "first_name": { + "type": ["null", "string"] + }, + "province": { + "type": ["null", "string"] + }, + "city": { + "type": ["null", "string"] + }, + "company": { + "type": ["null", "string"] + }, + "latitude": { + "type": ["null", "number"] + }, + "country_code": { + "type": ["null", "string"] + }, + "province_code": { + "type": ["null", "string"] + }, + "zip": { + "type": ["null", "string"] + } + }, + "type": ["null", "object"] + }, + "billing_address": { + "properties": { + "phone": { + "type": ["null", "string"] + }, + "country": { + "type": ["null", "string"] + }, + "name": { + "type": ["null", "string"] + }, + "address1": { + "type": ["null", "string"] + }, + "longitude": { + "type": ["null", "number"] + }, + "address2": { + "type": ["null", "string"] + }, + "last_name": { + "type": ["null", "string"] + }, + "first_name": { + "type": ["null", "string"] + }, + "province": { + "type": ["null", "string"] + }, + "city": { + "type": ["null", "string"] + }, + "company": { + "type": ["null", "string"] + }, + "latitude": { + "type": ["null", "number"] + }, + "country_code": { + "type": ["null", "string"] + }, + "province_code": { + "type": ["null", "string"] + }, + "zip": { + "type": ["null", "string"] + } + }, + "type": ["null", "object"] + }, + "note": { + "type": ["null", "string"] + }, + "note_attributes": { + "items": { + "properties": { + "name": { + "type": ["null", "string"] + }, + "value": { + "type": ["null", "string"] + } + }, + "type": ["null", "object"] + }, + "type": ["null", "array"] + }, + "email": { + "type": ["null", "string"] + }, + "currency": { + "type": ["null", "string"] + }, + "invoice_sent_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "invoice_url": { + "type": ["null", "string"] + }, + "line_items": { + "$ref": "definitions.json#/draft_line_items" + }, + "shipping_line": { + "properties": { + "title": { + "type": ["null", "string"] + }, + "custom": { + "type": ["null", "boolean"] + }, + "handle": { + "type": ["null", "string"] + }, + "price": { + "type": ["null", "number"] + } + }, + "type": ["null", "object"] + }, + "source_name": { + "type": ["null", "string"] + }, + "tags": { + "type": ["null", "string"] + }, + "tax_exempt": { + "type": ["null", "boolean"] + }, + "tax_lines": { + "$ref": "definitions.json#/tax_lines" + }, + "applied_discount": { + "$ref": "definitions.json#/applied_discount" + }, + "taxes_included": { + "type": ["null", "boolean"] + }, + "total_price": { + "type": ["null", "string"], + "format": "singer.decimal" + }, + "subtotal_price": { + "type": ["null", "string"], + "format": "singer.decimal" + }, + "total_tax": { + "type": ["null", "string"], + "format": "singer.decimal" + }, + "completed_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "status": { + "type": ["null", "string"] + } + }, + "type": "object" +} diff --git a/tap_shopify/streams/__init__.py b/tap_shopify/streams/__init__.py index 27a03e90..90789c4c 100644 --- a/tap_shopify/streams/__init__.py +++ b/tap_shopify/streams/__init__.py @@ -11,3 +11,4 @@ import tap_shopify.streams.inventory_levels import tap_shopify.streams.inventory_items import tap_shopify.streams.events +import tap_shopify.streams.draft_orders diff --git a/tap_shopify/streams/draft_orders.py b/tap_shopify/streams/draft_orders.py new file mode 100644 index 00000000..6b16e853 --- /dev/null +++ b/tap_shopify/streams/draft_orders.py @@ -0,0 +1,14 @@ +import shopify +from tap_shopify.context import Context +from tap_shopify.streams.base import Stream + + +class DraftOrders(Stream): + name = "draft_orders" + replication_object = shopify.DraftOrder + # needed because filter="any" does not work as expected + # https://community.shopify.com/c/Shopify-APIs-SDKs/Draft-Order-API-status-any-stopped-working/td-p/557365 + status_key = "_" + + +Context.stream_objects["draft_orders"] = DraftOrders