From 84befd0fa8066351e6be9e6170f91439ef5bdcb4 Mon Sep 17 00:00:00 2001 From: Rodrigo Parra Date: Mon, 14 Jun 2021 19:17:28 -0400 Subject: [PATCH] Add support for draft orders, closes #105 --- tap_shopify/schemas/draft_orders.json | 242 ++++++++++++++++++++++++++ tap_shopify/streams/__init__.py | 1 + tap_shopify/streams/draft_orders.py | 14 ++ 3 files changed, 257 insertions(+) create mode 100644 tap_shopify/schemas/draft_orders.json create mode 100644 tap_shopify/streams/draft_orders.py diff --git a/tap_shopify/schemas/draft_orders.json b/tap_shopify/schemas/draft_orders.json new file mode 100644 index 00000000..05259712 --- /dev/null +++ b/tap_shopify/schemas/draft_orders.json @@ -0,0 +1,242 @@ +{ + "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#/line_items" + }, + "shipping_line": { + "properties": { + "tax_lines": { + "$ref": "definitions.json#/tax_lines" + }, + "phone": { + "type": ["null", "string"] + }, + "discounted_price_set": {}, + "price_set": {}, + "price": { + "type": ["null", "string"], + "format": "singer.decimal" + }, + "title": { + "type": ["null", "string"] + }, + "discount_allocations": { + "items": { + "properties": { + "discount_application_index": { + "type": ["null", "integer"] + }, + "amount": { + "type": ["null", "number"] + } + }, + "type": ["null", "object"] + }, + "type": ["null", "array"] + }, + "delivery_category": { + "type": ["null", "string"] + }, + "discounted_price": { + "type": ["null", "number"] + }, + "code": { + "type": ["null", "string"] + }, + "requested_fulfillment_service_id": { + "type": ["null", "string"] + }, + "carrier_identifier": { + "type": ["null", "string"] + }, + "id": { + "type": ["null", "integer"] + }, + "source": { + "type": ["null", "string"] + } + }, + "type": ["null", "object"] + }, + "tags": { + "type": ["null", "string"] + }, + "tax_exempt": { + "type": ["null", "boolean"] + }, + "tax_lines": { + "$ref": "definitions.json#/tax_lines" + }, + "applied_discounts": { + "items": { + "type": ["null", "object"] + }, + "type": ["null", "array"] + }, + "taxes_included": { + "type": ["null", "boolean"] + }, + "total_price": { + "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 dd73ba7a..a17fcfeb 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.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