diff --git a/CHANGELOG.md b/CHANGELOG.md index 97c7cfa..f9e1bdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 2.0.0 + * Major revision to use new version of the Recharge-API [2021-11](https://docs.rechargepayments.com/changelog/2021-11-api-release-notes). This deprecates `collections`, adds `payment_methods`, changes `shop` endpoint to `store`, and adds/removes fields in all other objects. Also, added retry to `client.py` and decrease batch size to address [intermittent unterminated string issue](https://github.com/singer-io/tap-recharge/issues/4). + ## 1 1.2 * Request timeout functionality added [#19](https://github.com/singer-io/tap-recharge/pull/19) ## 1.1.1 diff --git a/README.md b/README.md index b98fe3f..99f4103 100644 --- a/README.md +++ b/README.md @@ -8,22 +8,23 @@ This tap: - Pulls raw data from the [ReCharge Payments API](https://developer.rechargepayments.com/) - Extracts the following resources: - - [Addresses](https://developer.rechargepayments.com/#list-addresses) - - [Charges](https://developer.rechargepayments.com/#list-charges) - - [Collections](https://developer.rechargepayments.com/#list-collections-alpha) - - [Customers](https://developer.rechargepayments.com/#list-customers) - - [Discounts](https://developer.rechargepayments.com/#list-discounts) - - [Metafields for Store, Customers, Subscriptions](https://developer.rechargepayments.com/#list-metafields) - - [One-time Products](https://developer.rechargepayments.com/#list-onetimes) - - [Orders](https://developer.rechargepayments.com/#list-orders) - - [Products](https://developer.rechargepayments.com/#list-products) - - [Shop](https://developer.rechargepayments.com/#retrieve-a-shop) - - [Subscriptions](https://developer.rechargepayments.com/#list-subscriptions) + - [Addresses](https://developer.rechargepayments.com/2021-11/addresses/list_addresses) + - [Charges](https://developer.rechargepayments.com/2021-11/charges/charge_list) + - [Collections, DEPRECATED](https://developer.rechargepayments.com/#list-collections-alpha) + - [Customers](https://developer.rechargepayments.com/2021-11/customers/customers_list) + - [Discounts](https://developer.rechargepayments.com/2021-11/discounts/discounts_list) + - [Metafields for Store, Customers, Subscriptions](https://developer.rechargepayments.com/2021-11/metafields/metafields_list) + - [One-time Products](https://developer.rechargepayments.com/2021-11/onetimes/onetimes_list) + - [Orders](https://developer.rechargepayments.com/2021-11/orders/orders_list) + - [Payment Methods](https://developer.rechargepayments.com/2021-11/payment_methods/payment_methods_list) + - [Products](https://developer.rechargepayments.com/2021-11/products/products_list) + - [Store](https://developer.rechargepayments.com/2021-11/store/store_retrieve) + - [Subscriptions](https://developer.rechargepayments.com/2021-11/subscriptions/subscriptions_list) - Outputs the schema for each resource - Incrementally pulls data based on the input state ## Streams -[**addresses**](https://developer.rechargepayments.com/#list-addresses) +[**addresses**](https://developer.rechargepayments.com/2021-11/addresses/list_addresses) - Endpoint: https://api.rechargeapps.com/addresses - Primary keys: id - Foreign keys: customer_id (customers), discount_id (discounts) @@ -32,10 +33,10 @@ This tap: - Bookmark: updated_at (date-time) - Transformations: None -[**charges**](https://developer.rechargepayments.com/#list-charges) +[**charges**](https://developer.rechargepayments.com/2021-11/charges/charge_list) - Endpoint: https://api.rechargeapps.com/charges - Primary keys: id -- Foreign keys: address_id (addresses), customer_id (customers), subscription_id (subscriptions), shopify_product_id, shopify_variant_id, transaction_id +- Foreign keys: address_id (addresses), customer_id (customers), subscription_id (subscriptions), external_product_id, external_variant_id, transaction_id - Replication strategy: Incremental (query filtered) - Bookmark query parameter: updated_at_min - Bookmark: updated_at (date-time) @@ -43,22 +44,23 @@ This tap: [**collections**](https://developer.rechargepayments.com/#list-collections-alpha) - Endpoint: https://api.rechargeapps.com/collections +- This endpoint is DEPRECATED (not included) in 2021-11 version of the API - Primary keys: id - Foreign keys: None - Replication strategy: Incremental (query all, filter results) - Bookmark: updated_at (date-time) - Transformations: None -[**customers**](https://developer.rechargepayments.com/#list-customers) +[**customers**](https://developer.rechargepayments.com/2021-11/customers/customers_list) - Endpoint: https://api.rechargeapps.com/customers - Primary keys: id -- Foreign keys: shopify_customer_id +- Foreign keys: external_customer_id - Replication strategy: Incremental (query filtered) - Bookmark query parameter: updated_at_min - Bookmark: updated_at (date-time) - Transformations: None -[**discounts**](https://developer.rechargepayments.com/#list-discounts) +[**discounts**](https://developer.rechargepayments.com/2021-11/discounts/discounts_list) - Endpoint: https://api.rechargeapps.com/discounts - Primary keys: id - Foreign keys: applies_to_id @@ -67,7 +69,7 @@ This tap: - Bookmark: updated_at (date-time) - Transformations: None -[**metafields_customer**](https://developer.rechargepayments.com/#list-metafields) +[**metafields_customer**](hhttps://developer.rechargepayments.com/2021-11/metafields/metafields_list) - Endpoint: https://api.rechargeapps.com/metafields - Primary keys: id - Foreign keys: owner_id @@ -76,7 +78,7 @@ This tap: - Bookmark: updated_at (date-time) - Transformations: None -[**metafields_store**](https://developer.rechargepayments.com/#list-metafields) +[**metafields_store**](https://developer.rechargepayments.com/2021-11/metafields/metafields_list) - Endpoint: https://api.rechargeapps.com/metafields - Primary keys: id - Foreign keys: owner_id @@ -85,7 +87,7 @@ This tap: - Bookmark: updated_at (date-time) - Transformations: None -[**metafields_subscription**](https://developer.rechargepayments.com/#list-metafields) +[**metafields_subscription**](https://developer.rechargepayments.com/2021-11/metafields/metafields_list) - Endpoint: https://api.rechargeapps.com/metafields - Primary keys: id - Foreign keys: owner_id @@ -94,43 +96,53 @@ This tap: - Bookmark: updated_at (date-time) - Transformations: None -[**onetimes**](https://developer.rechargepayments.com/#list-onetimes) +[**onetimes**](https://developer.rechargepayments.com/2021-11/onetimes/onetimes_list) - Endpoint: https://api.rechargeapps.com/onetimes - Primary keys: id -- Foreign keys: address_id (addresses), customer_id (customers), recharge_product_id (products), shopify_product_id, shopify_variant_id +- Foreign keys: address_id (addresses), customer_id (customers), recharge_product_id (products), external_product_id, external_variant_id - Replication strategy: Incremental (query filtered) - Bookmark query parameter: updated_at_min - Bookmark: updated_at (date-time) - Transformations: None -[**orders**](https://developer.rechargepayments.com/#list-orders) +[**orders**](https://developer.rechargepayments.com/2021-11/orders/orders_list) - Endpoint: https://api.rechargeapps.com/orders - Primary keys: id -- Foreign keys: address_id (addresses), charge_id (charges), customer_id (customers), subscription_id (subscriptions), shopify_product_id, shopify_variant_id, shopify_order_id, shopify_id, shopify_customer_id, transaction_id +- Foreign keys: address_id (addresses), charge_id (charges), customer_id (customers), subscription_id (subscriptions), external_product_id, external_variant_id, external_order_id, external_id, external_customer_id, transaction_id - Replication strategy: Incremental (query filtered) - Bookmark query parameter: updated_at_min - Bookmark: updated_at (date-time) - Transformations: None -[**products**](https://developer.rechargepayments.com/#list-products) +[**payment_methods**](https://developer.rechargepayments.com/2021-11/payment_methods/payment_methods_list) +- Endpoint: https://api.rechargeapps.com/payment_methods +- Endpoint not available for ALL orgs, needs to be enabled by Recharge Support +- Primary keys: id +- Foreign keys: customer_id +- Replication strategy: Incremental (query all, filter results) + - Bookmark: updated_at (date-time) +- Transformations: None + +[**products**](https://developer.rechargepayments.com/2021-11/products/products_list) - Endpoint: https://api.rechargeapps.com/products +- Endpoint not available for ALL orgs - Primary keys: id -- Foreign keys: collection_id (collections), shopify_product_id +- Foreign keys: collection_id (collections), external_product_id - Replication strategy: Incremental (query all, filter results) - Bookmark: updated_at (date-time) - Transformations: None -[**shop**](https://developer.rechargepayments.com/#retrieve-a-shop) -- Endpoint: https://api.rechargeapps.com/shop +[**store**](https://developer.rechargepayments.com/2021-11/store/store_retrieve) +- Endpoint: https://api.rechargeapps.com/store - Primary keys: id - Foreign keys: None - Replication strategy: Full table - Transformations: None -[**subscriptions**](https://developer.rechargepayments.com/#list-subscriptions) +[**subscriptions**](https://developer.rechargepayments.com/2021-11/subscriptions/subscriptions_list) - Endpoint: https://api.rechargeapps.com/subscriptions - Primary keys: id -- Foreign keys: address_id (addresses), customer_id (customers), recharge_product_id (products), shopify_product_id, shopify_variant_id +- Foreign keys: address_id (addresses), customer_id (customers), recharge_product_id (products), external_product_id, external_variant_id - Replication strategy: Incremental (query filtered) - Bookmark query parameter: updated_at_min - Bookmark: updated_at (date-time) @@ -176,21 +188,22 @@ This tap: ```json { - "currently_syncing": "users", + "currently_syncing": "addresses", "bookmarks": { - "addresses": "2019-06-11T13:37:55Z", - "charges": "2019-06-19T19:48:42Z", - "collections": "2019-06-18T18:23:58Z", - "customers": "2019-06-20T00:52:46Z", - "discounts": "2019-06-19T19:48:44Z", - "metafields_store": "2019-06-11T13:37:55Z", - "metafields_customers": "2019-06-19T19:48:42Z", - "metafields_subscriptions": "2019-06-18T18:23:58Z", - "onetimes": "2019-06-20T00:52:46", - "orders": "2019-06-19T19:48:44Z", - "products": "2019-06-11T13:37:55Z", - "shop": "2019-06-19T19:48:42Z", - "subscriptions": "2019-06-18T18:23:58Z" + "addresses": "2021-10-11T13:37:55Z", + "charges": "2021-10-19T19:48:42Z", + "collections": "2019-01-20T00:52:46", + "customers": "2021-10-20T00:52:46Z", + "discounts": "2021-10-19T19:48:44Z", + "metafields_store": "2019-10-11T13:37:55Z", + "metafields_customers": "2019-10-19T19:48:42Z", + "metafields_subscriptions": "2019-10-18T18:23:58Z", + "onetimes": "2019-01-20T00:52:46", + "orders": "2021-10-19T19:48:44Z", + "payment_methods": "2019-10-11T13:37:55Z", + "products": "2019-10-11T13:37:55Z", + "store": "2019-10-19T19:48:42Z", + "subscriptions": "2021-10-18T18:23:58Z" } } ``` @@ -230,7 +243,7 @@ This tap: ``` Pylint test resulted in the following score: ```bash - Your code has been rated at 9.78/10 + Your code has been rated at 9.54/10 ``` To [check the tap](https://github.com/singer-io/singer-tools#singer-check-tap) and verify working: @@ -241,29 +254,28 @@ This tap: Check tap resulted in the following: ```bash The output is valid. - It contained 75 messages for 13 streams. + It contained 145815 messages for 12 streams. - 13 schema messages - 24 record messages - 38 state messages + 12 schema messages + 145766 record messages + 37 state messages Details by stream: +-------------------------+---------+---------+ | stream | records | schemas | +-------------------------+---------+---------+ - | discounts | 1 | 1 | - | metafields_subscription | 0 | 1 | - | addresses | 4 | 1 | - | shop | 1 | 1 | - | charges | 4 | 1 | - | products | 4 | 1 | - | onetimes | 0 | 1 | - | orders | 4 | 1 | - | collections | 1 | 1 | + | customers | 7375 | 1 | | metafields_store | 0 | 1 | + | metafields_subscription | 0 | 1 | + | charges | 17356 | 1 | + | store | 1 | 1 | + | plans | 198 | 1 | + | discounts | 25370 | 1 | + | orders | 11666 | 1 | | metafields_customer | 0 | 1 | - | subscriptions | 4 | 1 | - | customers | 1 | 1 | + | onetimes | 0 | 1 | + | subscriptions | 75426 | 1 | + | addresses | 8374 | 1 | +-------------------------+---------+---------+ ``` diff --git a/setup.py b/setup.py index 32bd450..908287d 100644 --- a/setup.py +++ b/setup.py @@ -3,15 +3,15 @@ from setuptools import setup, find_packages setup(name='tap-recharge', - version='1.1.2', - description='Singer.io tap for extracting data from the ReCharge Payments API 2.0', + version='2.0.0', + description='Singer.io tap for extracting data from the ReCharge Payments API v.2021-11', author='jeff.huth@bytecode.io', classifiers=['Programming Language :: Python :: 3 :: Only'], py_modules=['tap_recharge'], install_requires=[ 'backoff==1.8.0', 'requests==2.23.0', - 'singer-python==5.10.0' + 'singer-python==5.12.2' ], entry_points=''' [console_scripts] diff --git a/state.json.example b/state.json.example old mode 100644 new mode 100755 index 079d1cf..b80e470 --- a/state.json.example +++ b/state.json.example @@ -1,18 +1,18 @@ { - "currently_syncing": "users", - "bookmarks": { - "addresses": "2019-06-11T13:37:55Z", - "charges": "2019-06-19T19:48:42Z", - "collections": "2019-06-18T18:23:58Z", - "customers": "2019-06-20T00:52:46Z", - "discounts": "2019-06-19T19:48:44Z", - "metafields_store": "2019-06-11T13:37:55Z", - "metafields_customers": "2019-06-19T19:48:42Z", - "metafields_subscriptions": "2019-06-18T18:23:58Z", - "onetimes": "2019-06-20T00:52:46", - "orders": "2019-06-19T19:48:44Z", - "products": "2019-06-11T13:37:55Z", - "shop": "2019-06-19T19:48:42Z", - "subscriptions": "2019-06-18T18:23:58Z" - } + "bookmarks": { + "addresses": "2021-10-11T13:37:55Z", + "charges": "2021-10-19T19:48:42Z", + "collections": "2019-01-20T00:52:46", + "customers": "2021-10-20T00:52:46Z", + "discounts": "2021-10-19T19:48:44Z", + "metafields_store": "2019-10-11T13:37:55Z", + "metafields_customers": "2019-10-19T19:48:42Z", + "metafields_subscriptions": "2019-10-18T18:23:58Z", + "onetimes": "2019-01-20T00:52:46", + "orders": "2021-10-19T19:48:44Z", + "payment_methods": "2019-10-11T13:37:55Z", + "products": "2019-10-11T13:37:55Z", + "store": "2019-10-19T19:48:42Z", + "subscriptions": "2021-10-18T18:23:58Z" + } } \ No newline at end of file diff --git a/tap_recharge/__init__.py b/tap_recharge/__init__.py index e0e252f..0c3503e 100644 --- a/tap_recharge/__init__.py +++ b/tap_recharge/__init__.py @@ -14,10 +14,10 @@ 'user_agent' ] -def do_discover(): +def do_discover(client): LOGGER.info('Starting discover') - catalog = discover() + catalog = discover(client) catalog.dump() LOGGER.info('Finished discover') @@ -39,7 +39,7 @@ def main(): state = parsed_args.state if parsed_args.discover: - do_discover() + do_discover(client) elif parsed_args.catalog: sync( client=client, diff --git a/tap_recharge/client.py b/tap_recharge/client.py index d6c45e1..e00fffc 100644 --- a/tap_recharge/client.py +++ b/tap_recharge/client.py @@ -6,7 +6,8 @@ from requests.exceptions import Timeout LOGGER = singer.get_logger() -REQUEST_TIMEOUT = 300 +REQUEST_TIMEOUT = 600 +API_VERSION = '2021-11' class Server5xxError(Exception): pass @@ -180,6 +181,10 @@ def request(self, method, path=None, url=None, **kwargs): if 'headers' not in kwargs: kwargs['headers'] = {} + + # Pagination w/ cursor requires version header + # Reference: https://developer.rechargepayments.com/2021-11/cursor_pagination + kwargs['headers']['X-Recharge-Version'] = API_VERSION kwargs['headers']['X-Recharge-Access-Token'] = self.__access_token kwargs['headers']['Accept'] = 'application/json' @@ -189,6 +194,8 @@ def request(self, method, path=None, url=None, **kwargs): if method == 'POST': kwargs['headers']['Content-Type'] = 'application/json' + # Intermittent JSONDecodeErrors when parsing JSON; Adding 2 attempts + # FIRST ATTEMPT with metrics.http_request_timer(endpoint) as timer: response = self.__session.request(method, url, stream=True, timeout=self.request_timeout, **kwargs) timer.tags[metrics.Tag.http_status_code] = response.status_code @@ -202,13 +209,39 @@ def request(self, method, path=None, url=None, **kwargs): if response.status_code != 200: raise_for_error(response) + # Catch invalid JSON (e.g. unterminated string errors) + try: + response_json = response.json() + return response_json + except ValueError as err: # includes simplejson.decoder.JSONDecodeError + LOGGER.warn(err) + + # SECOND ATTEMPT, if there is a ValueError (unterminated string error) + with metrics.http_request_timer(endpoint) as timer: + response = self.__session.request( + method, + url, + stream=True, + timeout=self.request_timeout, + **kwargs) + timer.tags[metrics.Tag.http_status_code] = response.status_code + + if response.status_code >= 500: + raise Server5xxError() + + if response.status_code == 429: + raise Server429Error() + + if response.status_code != 200: + raise_for_error(response) + # Log invalid JSON (e.g. unterminated string errors) try: response_json = response.json() - except Exception as err: + return response_json + except ValueError as err: # includes simplejson.decoder.JSONDecodeError LOGGER.error(err) raise Exception(err) - return response_json, response.links def get(self, path, **kwargs): return self.request('GET', path=path, **kwargs) diff --git a/tap_recharge/discover.py b/tap_recharge/discover.py index fcd2a61..fb6bacf 100644 --- a/tap_recharge/discover.py +++ b/tap_recharge/discover.py @@ -2,11 +2,11 @@ from tap_recharge.schema import get_schemas -def discover(): +def discover(client): """ Constructs a singer Catalog object based on the schemas and metadata. """ - schemas, field_metadata = get_schemas() + schemas, field_metadata = get_schemas(client) streams = [] for schema_name, schema in schemas.items(): diff --git a/tap_recharge/schema.py b/tap_recharge/schema.py index df843a5..4dd66cb 100644 --- a/tap_recharge/schema.py +++ b/tap_recharge/schema.py @@ -1,14 +1,16 @@ import os import json +import singer from singer import metadata from tap_recharge.streams import STREAMS +LOGGER = singer.get_logger() def get_abs_path(path): return os.path.join(os.path.dirname(os.path.realpath(__file__)), path) -def get_schemas(): +def get_schemas(client): """ Loads the schemas defined for the tap. @@ -20,34 +22,54 @@ def get_schemas(): field_metadata = {} for stream_name, stream_object in STREAMS.items(): - schema_path = get_abs_path(f'schemas/{stream_name}.json') - with open(schema_path, encoding='utf-8') as file: - schema = json.load(file) - schemas[stream_name] = schema - - if stream_object.replication_method == 'INCREMENTAL': - replication_keys = stream_object.valid_replication_keys - else: - replication_keys = None - - # pylint: disable=line-too-long - # Documentation: https://github.com/singer-io/getting-started/blob/master/docs/DISCOVERY_MODE.md#singer-python-helper-functions - # Reference: https://github.com/singer-io/singer-python/blob/master/singer/metadata.py#L25-L44 - mdata = metadata.get_standard_metadata( - schema=schema, - key_properties=stream_object.key_properties, - replication_method=stream_object.replication_method, - valid_replication_keys=replication_keys, - ) - - mdata = metadata.to_map(mdata) - - if replication_keys: - for replication_key in replication_keys: - mdata = metadata.write(mdata, ('properties', replication_key), 'inclusion', 'automatic') - - mdata = metadata.to_list(mdata) - - field_metadata[stream_name] = mdata + + # Check if endpoint is valid + # products and payment_methods are sometimes invalid + valid_enpoint = True + params = stream_object.params + params.update({'limit': 1}) + path = stream_object.path + data_key = stream_object.data_key + # Try to get a record + try: + result = client.get(path, params=params) + record = result.get(data_key) + except Exception as err: + LOGGER.warn('Endpoint: {}, access error: {}'.format(stream_name, err)) + schema_path = get_abs_path(f'schemas/{stream_name}.json') + valid_enpoint = False + + # Only include valid endpoints in Discovery + # products and payment_methods need to be enabled by Recharge Support + if valid_enpoint: + schema_path = get_abs_path(f'schemas/{stream_name}.json') + with open(schema_path, encoding='utf-8') as file: + schema = json.load(file) + schemas[stream_name] = schema + + if stream_object.replication_method == 'INCREMENTAL': + replication_keys = stream_object.valid_replication_keys + else: + replication_keys = None + + # pylint: disable=line-too-long + # Documentation: https://github.com/singer-io/getting-started/blob/master/docs/DISCOVERY_MODE.md#singer-python-helper-functions + # Reference: https://github.com/singer-io/singer-python/blob/master/singer/metadata.py#L25-L44 + mdata = metadata.get_standard_metadata( + schema=schema, + key_properties=stream_object.key_properties, + replication_method=stream_object.replication_method, + valid_replication_keys=replication_keys, + ) + + mdata = metadata.to_map(mdata) + + if replication_keys: + for replication_key in replication_keys: + mdata = metadata.write(mdata, ('properties', replication_key), 'inclusion', 'automatic') + + mdata = metadata.to_list(mdata) + + field_metadata[stream_name] = mdata return schemas, field_metadata diff --git a/tap_recharge/schemas/addresses.json b/tap_recharge/schemas/addresses.json index 3880aac..406aed2 100644 --- a/tap_recharge/schemas/addresses.json +++ b/tap_recharge/schemas/addresses.json @@ -2,44 +2,22 @@ "type": "object", "additionalProperties": false, "properties": { + "id": { + "type": ["null", "integer"] + }, "address1": { "type": ["null", "string"] }, "address2": { "type": ["null", "string"] }, - "cart_attributes": { - "anyOf": [ - { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": ["null", "string"] - }, - "value": { - "type": ["null", "string"] - } - } - } - }, - { - "type": "null" - } - ] - }, - "cart_note": { - "type": ["null", "string"] - }, "city": { "type": ["null", "string"] }, "company": { "type": ["null", "string"] }, - "country": { + "country_code": { "type": ["null", "string"] }, "created_at": { @@ -49,19 +27,7 @@ "customer_id": { "type": ["null", "integer"] }, - "discount_id": { - "type": ["null", "integer"] - }, - "first_name": { - "type": ["null", "string"] - }, - "id": { - "type": ["null", "integer"] - }, - "last_name": { - "type": ["null", "string"] - }, - "note_attributes": { + "discounts": { "anyOf": [ { "type": "array", @@ -69,11 +35,8 @@ "type": "object", "additionalProperties": false, "properties": { - "name": { - "type": ["null", "string"] - }, - "value": { - "type": ["null", "string"] + "id": { + "type": ["null", "integer"] } } } @@ -83,7 +46,13 @@ } ] }, - "original_shipping_lines": { + "first_name": { + "type": ["null", "string"] + }, + "last_name": { + "type": ["null", "string"] + }, + "order_attributes": { "anyOf": [ { "type": "array", @@ -91,13 +60,10 @@ "type": "object", "additionalProperties": false, "properties": { - "code": { - "type": ["null", "string"] - }, - "price": { + "name": { "type": ["null", "string"] }, - "title": { + "value": { "type": ["null", "string"] } } @@ -108,9 +74,15 @@ } ] }, + "order_note": { + "type": ["null", "string"] + }, "phone": { "type": ["null", "string"] }, + "presentation_currency": { + "type": ["null", "string"] + }, "province": { "type": ["null", "string"] }, diff --git a/tap_recharge/schemas/charges.json b/tap_recharge/schemas/charges.json index 3804fb5..f6d4c1a 100644 --- a/tap_recharge/schemas/charges.json +++ b/tap_recharge/schemas/charges.json @@ -2,9 +2,50 @@ "type": "object", "additionalProperties": false, "properties": { + "id": { + "type": ["null", "integer"] + }, "address_id": { "type": ["null", "integer"] }, + "utm_params": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "utm_campaign": { + "type": ["null", "string"] + }, + "utm_content": { + "type": ["null", "string"] + }, + "utm_data_source": { + "type": ["null", "string"] + }, + "utm_medium": { + "type": ["null", "string"] + }, + "utm_source": { + "type": ["null", "string"] + }, + "utm_term": { + "type": ["null", "string"] + }, + "utm_timestamp": { + "type": ["null", "string"], + "format": "date-time" + } + } + } + }, + { + "type": "null" + } + ] + }, "billing_address": { "type": ["null", "object"], "additionalProperties": false, @@ -21,7 +62,7 @@ "company": { "type": ["null", "string"] }, - "country": { + "country_code": { "type": ["null", "string"] }, "first_name": { @@ -41,9 +82,6 @@ } } }, - "browser_ip": { - "type": ["null", "string"] - }, "client_details": { "type": ["null", "object"], "additionalProperties": false, @@ -60,13 +98,34 @@ "type": ["null", "string"], "format": "date-time" }, - "customer_hash": { + "currency": { "type": ["null", "string"] }, - "customer_id": { - "type": ["null", "integer"] + "customer": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "id": { + "type": ["null", "integer"] + }, + "email": { + "type": ["null", "string"] + }, + "external_customer_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } + }, + "hash": { + "type": ["null", "string"] + } + } }, - "discount_codes": { + "discounts": { "anyOf": [ { "type": "array", @@ -74,13 +133,16 @@ "type": "object", "additionalProperties": false, "properties": { - "amount": { - "type": ["null", "string"] + "id": { + "type": ["null", "integer"] }, "code": { "type": ["null", "string"] }, - "type": { + "value": { + "type": ["null", "string"] + }, + "value_type": { "type": ["null", "string"] } } @@ -91,17 +153,32 @@ } ] }, - "email": { + "error": { "type": ["null", "string"] }, - "first_name": { + "error_type": { "type": ["null", "string"] }, - "has_uncommited_changes": { - "type": ["null", "boolean"] + "external_order_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } }, - "id": { - "type": ["null", "integer"] + "external_transaction_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "payment_processor": { + "type": ["null", "string"] + } + } + }, + "has_uncommiteed_changes": { + "type": ["null", "boolean"] }, "last_name": { "type": ["null", "string"] @@ -114,9 +191,33 @@ "type": "object", "additionalProperties": false, "properties": { + "purchase_item_id": { + "type": ["null", "integer"] + }, + "external_product_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "payment_processor": { + "type": ["null", "string"] + } + } + }, + "external_variant_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "payment_processor": { + "type": ["null", "string"] + } + } + }, "grams": { "type": ["null", "integer"] }, + "handle": { + "type": ["null", "string"] + }, "images": { "type": ["null", "object"], "additionalProperties": false, @@ -135,9 +236,6 @@ } } }, - "price": { - "type": ["null", "string"] - }, "properties": { "anyOf": [ { @@ -160,24 +258,61 @@ } ] }, + "purchase_item_type": { + "type": ["null", "string"] + }, "quantity": { "type": ["null", "integer"] }, - "shopify_product_id": { + "sku": { "type": ["null", "string"] }, - "shopify_variant_id": { + "tax_due": { "type": ["null", "string"] }, - "sku": { - "type": ["null", "string"] + "tax_lines": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "price": { + "type": ["null", "string"] + }, + "rate": { + "type": ["null", "string"] + }, + "title": { + "type": ["null", "string"] + } + } + } + }, + { + "type": "null" + } + ] }, - "subscription_id": { - "type": ["null", "integer"] + "taxable": { + "type": ["null", "boolean"] + }, + "taxable_amount": { + "type": ["null", "string"] }, "title": { "type": ["null", "string"] }, + "total_price": { + "type": ["null", "string"] + }, + "unit_price": { + "type": ["null", "string"] + }, + "unit_price_includes_tax": { + "type": ["null", "boolean"] + }, "variant_title": { "type": ["null", "string"] } @@ -192,7 +327,7 @@ "note": { "type": ["null", "string"] }, - "note_attributes": { + "order_attributes": { "anyOf": [ { "type": "array", @@ -214,20 +349,24 @@ } ] }, + "orders_count": { + "type": ["null", "integer"] + }, + "payment_processor": { + "type": ["null", "string"] + }, "processed_at": { "type": ["null", "string"], "format": "date-time" }, - "processor_name": { - "type": ["null", "string"] + "retry_date": { + "type": ["null", "string"], + "format": "date-time" }, "scheduled_at": { "type": ["null", "string"], "format": "date-time" }, - "shipments_count": { - "type": ["null", "integer"] - }, "shipping_address": { "type": ["null", "object"], "additionalProperties": false, @@ -244,7 +383,7 @@ "company": { "type": ["null", "string"] }, - "country": { + "country_code": { "type": ["null", "string"] }, "first_name": { @@ -278,6 +417,37 @@ "price": { "type": ["null", "string"] }, + "source": { + "type": ["null", "string"] + }, + "tax_lines": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "price": { + "type": ["null", "string"] + }, + "rate": { + "type": ["null", "string"] + }, + "title": { + "type": ["null", "string"] + } + } + } + }, + { + "type": "null" + } + ] + }, + "taxable": { + "type": ["null", "boolean"] + }, "title": { "type": ["null", "string"] } @@ -289,15 +459,9 @@ } ] }, - "shopify_order_id": { - "type": ["null", "string"] - }, "status": { "type": ["null", "string"] }, - "sub_total": { - "type": ["null", "string"] - }, "subtotal_price": { "type": ["null", "string"] }, @@ -305,8 +469,29 @@ "type": ["null", "string"] }, "tax_lines": { - "type": ["null", "number"], - "multipleOf": 1e-08 + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "price": { + "type": ["null", "string"] + }, + "rate": { + "type": ["null", "string"] + }, + "title": { + "type": ["null", "string"] + } + } + } + }, + { + "type": "null" + } + ] }, "total_discounts": { "type": ["null", "string"] @@ -318,14 +503,12 @@ "type": ["null", "string"] }, "total_refunds": { - "type": ["null", "number"], - "multipleOf": 1e-08 + "type": ["null", "string"] }, "total_tax": { - "type": ["null", "number"], - "multipleOf": 1e-08 + "type": ["null", "string"] }, - "total_weight": { + "total_weight_grams": { "type": ["null", "integer"] }, "transaction_id": { diff --git a/tap_recharge/schemas/collections.json b/tap_recharge/schemas/collections.json index 2131a88..cefd9eb 100644 --- a/tap_recharge/schemas/collections.json +++ b/tap_recharge/schemas/collections.json @@ -1,20 +1,20 @@ { - "type": "object", - "additionalProperties": false, - "properties": { - "created_at": { - "type": ["null", "string"], - "format": "date-time" - }, - "id": { - "type": ["null", "integer"] - }, - "name": { - "type": ["null", "string"] - }, - "updated_at": { - "type": ["null", "string"], - "format": "date-time" + "type": "object", + "additionalProperties": false, + "properties": { + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } } } -} diff --git a/tap_recharge/schemas/customers.json b/tap_recharge/schemas/customers.json index 4eb441e..ea65c71 100644 --- a/tap_recharge/schemas/customers.json +++ b/tap_recharge/schemas/customers.json @@ -5,81 +5,92 @@ "id": { "type": ["null", "integer"] }, - "hash": { - "type": ["null", "string"] + "analytics_data": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "utm_params": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "utm_campaign": { + "type": ["null", "string"] + }, + "utm_content": { + "type": ["null", "string"] + }, + "utm_data_source": { + "type": ["null", "string"] + }, + "utm_medium": { + "type": ["null", "string"] + }, + "utm_source": { + "type": ["null", "string"] + }, + "utm_term": { + "type": ["null", "string"] + }, + "utm_timestamp": { + "type": ["null", "string"], + "format": "date-time" + } + } + } + }, + { + "type": "null" + } + ] + } + } }, - "shopify_customer_id": { - "type": ["null", "string"] + "created_at": { + "type": ["null", "string"], + "format": "date-time" }, "email": { "type": ["null", "string"] }, - "created_at": { - "type": ["null", "string"], - "format": "date-time" + "external_customer_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } }, - "updated_at": { + "first_charge_processed_at": { "type": ["null", "string"], "format": "date-time" }, "first_name": { "type": ["null", "string"] }, - "last_name": { - "type": ["null", "string"] - }, - "billing_address1": { - "type": ["null", "string"] - }, - "billing_address2": { - "type": ["null", "string"] - }, - "billing_zip": { - "type": ["null", "string"] - }, - "billing_city": { - "type": ["null", "string"] - }, - "billing_company": { - "type": ["null", "string"] - }, - "billing_province": { - "type": ["null", "string"] - }, - "billing_country": { - "type": ["null", "string"] - }, - "billing_phone": { - "type": ["null", "string"] - }, - "processor_type": { - "type": ["null", "string"] - }, - "status": { - "type": ["null", "string"] - }, - "paypal_customer_token": { - "type": ["null", "string"] - }, - "braintree_customer_token": { - "type": ["null", "string"] + "has_payment_method_in_dunning": { + "type": ["null", "boolean"] }, "has_valid_payment_method": { "type": ["null", "boolean"] }, - "reason_payment_method_not_valid": { + "hash": { "type": ["null", "string"] }, - "has_card_error_in_dunning": { - "type": ["null", "boolean"] + "last_name": { + "type": ["null", "string"] }, - "number_active_subscriptions": { + "subscriptions_active_count": { "type": ["null", "integer"] }, - "number_subscriptions": { + "subscriptions_total_count": { "type": ["null", "integer"] }, - "first_charge_processed_at": { + "updated_at": { "type": ["null", "string"], "format": "date-time" } diff --git a/tap_recharge/schemas/discounts.json b/tap_recharge/schemas/discounts.json index 1990148..dad1392 100644 --- a/tap_recharge/schemas/discounts.json +++ b/tap_recharge/schemas/discounts.json @@ -5,54 +5,130 @@ "id": { "type": ["null", "integer"] }, + "applies_to": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ids": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "integer" + } + }, + { + "type": "null" + } + ] + }, + "purchase_item_type": { + "type": ["null", "string"] + }, + "resource": { + "type": ["null", "string"] + } + } + }, + "channel_settings": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "api": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "can_apply": { + "type": ["null", "boolean"] + } + } + }, + "customer_portal": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "can_apply": { + "type": ["null", "boolean"] + } + } + }, + "merchant_portal": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "can_apply": { + "type": ["null", "boolean"] + } + } + }, + "checkout_page": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "can_apply": { + "type": ["null", "boolean"] + } + } + } + } + }, "code": { "type": ["null", "string"] }, - "value": { - "type": ["null", "integer"] - }, - "ends_at": { + "created_at": { "type": ["null", "string"], "format": "date-time" }, - "starts_at": { + "ends_at": { "type": ["null", "string"], "format": "date-time" }, - "status": { - "type": ["null", "string"] - }, - "usage_limit": { - "type": ["null", "integer"] - }, - "applies_to_id": { - "type": ["null", "integer"] + "external_discount_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } }, - "applies_to_resource": { + "external_discount_source": { "type": ["null", "string"] }, - "times_used": { - "type": ["null", "integer"] - }, - "duration": { - "type": ["null", "string"] - }, - "duration_usage_limit": { - "type": ["null", "integer"] - }, - "applies_to_product_type": { + "prerequisite_subtotal_min": { "type": ["null", "string"] }, - "created_at": { + "starts_at": { "type": ["null", "string"], "format": "date-time" }, + "status": { + "type": ["null", "string"] + }, "updated_at": { "type": ["null", "string"], "format": "date-time" }, - "once_per_customer": { - "type": ["null", "boolean"] + "usage_limits": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "automatic_redemptions_per_customer": { + "type": ["null", "integer"] + }, + "first_time_customer_restriction": { + "type": ["null", "boolean"] + }, + "one_application_per_customer": { + "type": ["null", "boolean"] + } + } + }, + "value": { + "type": ["null", "string"] + }, + "value_type": { + "type": ["null", "string"] } } } diff --git a/tap_recharge/schemas/metafields_customer.json b/tap_recharge/schemas/metafields_customer.json index 6f8eefe..ec57b4c 100644 --- a/tap_recharge/schemas/metafields_customer.json +++ b/tap_recharge/schemas/metafields_customer.json @@ -2,6 +2,9 @@ "type": "object", "additionalProperties": false, "properties": { + "id": { + "type": ["null", "integer"] + }, "created_at": { "type": ["null", "string"], "format": "date-time" @@ -9,9 +12,6 @@ "description": { "type": ["null", "string"] }, - "id": { - "type": ["null", "integer"] - }, "key": { "type": ["null", "string"] }, diff --git a/tap_recharge/schemas/metafields_store.json b/tap_recharge/schemas/metafields_store.json index 6f8eefe..ec57b4c 100644 --- a/tap_recharge/schemas/metafields_store.json +++ b/tap_recharge/schemas/metafields_store.json @@ -2,6 +2,9 @@ "type": "object", "additionalProperties": false, "properties": { + "id": { + "type": ["null", "integer"] + }, "created_at": { "type": ["null", "string"], "format": "date-time" @@ -9,9 +12,6 @@ "description": { "type": ["null", "string"] }, - "id": { - "type": ["null", "integer"] - }, "key": { "type": ["null", "string"] }, diff --git a/tap_recharge/schemas/metafields_subscription.json b/tap_recharge/schemas/metafields_subscription.json index 6f8eefe..ec57b4c 100644 --- a/tap_recharge/schemas/metafields_subscription.json +++ b/tap_recharge/schemas/metafields_subscription.json @@ -2,6 +2,9 @@ "type": "object", "additionalProperties": false, "properties": { + "id": { + "type": ["null", "integer"] + }, "created_at": { "type": ["null", "string"], "format": "date-time" @@ -9,9 +12,6 @@ "description": { "type": ["null", "string"] }, - "id": { - "type": ["null", "integer"] - }, "key": { "type": ["null", "string"] }, diff --git a/tap_recharge/schemas/onetimes.json b/tap_recharge/schemas/onetimes.json index b0a3acd..e1cfde3 100644 --- a/tap_recharge/schemas/onetimes.json +++ b/tap_recharge/schemas/onetimes.json @@ -2,6 +2,9 @@ "type": "object", "additionalProperties": false, "properties": { + "id": { + "type": ["null", "integer"] + }, "address_id": { "type": ["null", "integer"] }, @@ -12,8 +15,23 @@ "customer_id": { "type": ["null", "integer"] }, - "id": { - "type": ["null", "integer"] + "external_product_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } + }, + "external_variant_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } }, "next_charge_scheduled_at": { "type": ["null", "string"], @@ -51,20 +69,11 @@ "quantity": { "type": ["null", "integer"] }, - "recharge_product_id": { - "type": ["null", "integer"] - }, - "shopify_product_id": { - "type": ["null", "integer"] - }, - "shopify_variant_id": { - "type": ["null", "integer"] - }, "sku": { "type": ["null", "string"] }, - "status": { - "type": ["null", "string"] + "sku_override": { + "type": ["null", "boolean"] }, "updated_at": { "type": ["null", "string"], diff --git a/tap_recharge/schemas/orders.json b/tap_recharge/schemas/orders.json index d7c60a9..3355f21 100644 --- a/tap_recharge/schemas/orders.json +++ b/tap_recharge/schemas/orders.json @@ -2,6 +2,9 @@ "type": "object", "additionalProperties": false, "properties": { + "id": { + "type": ["null", "integer"] + }, "address_id": { "type": ["null", "integer"] }, @@ -24,7 +27,7 @@ "company": { "type": ["null", "string"] }, - "country": { + "country_code": { "type": ["null", "string"] }, "first_name": { @@ -44,20 +47,68 @@ } } }, - "charge_id": { - "type": ["null", "integer"] + "charge": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "id": { + "type": ["null", "integer"] + }, + "external_transaction_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "payment_processor": { + "type": ["null", "string"] + } + } + } + } }, - "charge_status": { - "type": ["null", "string"] + "client_details": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "browser_ip": { + "type": ["null", "string"] + }, + "user_agent": { + "type": ["null", "string"] + } + } }, "created_at": { "type": ["null", "string"], "format": "date-time" }, - "customer_id": { - "type": ["null", "integer"] + "currency": { + "type": ["null", "string"] + }, + "customer": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "id": { + "type": ["null", "integer"] + }, + "email": { + "type": ["null", "string"] + }, + "external_customer_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } + }, + "hash": { + "type": ["null", "string"] + } + } }, - "discount_codes": { + "discounts": { "anyOf": [ { "type": "array", @@ -65,13 +116,16 @@ "type": "object", "additionalProperties": false, "properties": { - "amount": { - "type": ["null", "string"] + "id": { + "type": ["null", "integer"] }, "code": { "type": ["null", "string"] }, - "type": { + "value": { + "type": ["null", "string"] + }, + "value_type": { "type": ["null", "string"] } } @@ -82,23 +136,20 @@ } ] }, - "email": { + "external_cart_token": { "type": ["null", "string"] }, - "first_name": { - "type": ["null", "string"] - }, - "hash": { - "type": ["null", "string"] - }, - "id": { - "type": ["null", "integer"] + "external_order_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } }, "is_prepaid": { - "type": ["null", "integer"] - }, - "last_name": { - "type": ["null", "string"] + "type": ["null", "boolean"] }, "line_items": { "anyOf": [ @@ -108,9 +159,33 @@ "type": "object", "additionalProperties": false, "properties": { + "purchase_item_id": { + "type": ["null", "integer"] + }, + "external_product_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } + }, + "external_variant_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } + }, "grams": { "type": ["null", "integer"] }, + "handle": { + "type": ["null", "string"] + }, "images": { "type": ["null", "object"], "additionalProperties": false, @@ -126,13 +201,12 @@ }, "small": { "type": ["null", "string"] + }, + "sort_order": { + "type": ["null", "integer"] } } }, - "price": { - "type": ["null", "number"], - "multipleOf": 1e-08 - }, "properties": { "anyOf": [ { @@ -155,24 +229,61 @@ } ] }, + "purchase_item_type": { + "type": ["null", "string"] + }, "quantity": { "type": ["null", "integer"] }, - "shopify_product_id": { + "sku": { "type": ["null", "string"] }, - "shopify_variant_id": { + "tax_due": { "type": ["null", "string"] }, - "sku": { - "type": ["null", "string"] + "tax_lines": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "price": { + "type": ["null", "string"] + }, + "rate": { + "type": ["null", "string"] + }, + "title": { + "type": ["null", "string"] + } + } + } + }, + { + "type": "null" + } + ] }, - "subscription_id": { - "type": ["null", "integer"] + "taxable": { + "type": ["null", "boolean"] + }, + "taxable_amount": { + "type": ["null", "string"] }, "title": { "type": ["null", "string"] }, + "total_price": { + "type": ["null", "string"] + }, + "unit_price": { + "type": ["null", "string"] + }, + "unit_price_includes_tax": { + "type": ["null", "boolean"] + }, "variant_title": { "type": ["null", "string"] } @@ -187,7 +298,7 @@ "note": { "type": ["null", "string"] }, - "note_attributes": { + "order_attributes": { "anyOf": [ { "type": "array", @@ -209,9 +320,6 @@ } ] }, - "payment_processor": { - "type": ["null", "string"] - }, "processed_at": { "type": ["null", "string"], "format": "date-time" @@ -220,10 +328,6 @@ "type": ["null", "string"], "format": "date-time" }, - "shipped_date": { - "type": ["null", "string"], - "format": "date-time" - }, "shipping_address": { "type": ["null", "object"], "additionalProperties": false, @@ -240,7 +344,7 @@ "company": { "type": ["null", "string"] }, - "country": { + "country_code": { "type": ["null", "string"] }, "first_name": { @@ -260,10 +364,6 @@ } } }, - "shipping_date": { - "type": ["null", "string"], - "format": "date-time" - }, "shipping_lines": { "anyOf": [ { @@ -278,6 +378,37 @@ "price": { "type": ["null", "string"] }, + "source": { + "type": ["null", "string"] + }, + "tax_lines": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "price": { + "type": ["null", "string"] + }, + "rate": { + "type": ["null", "string"] + }, + "title": { + "type": ["null", "string"] + } + } + } + }, + { + "type": "null" + } + ] + }, + "taxable": { + "type": ["null", "boolean"] + }, "title": { "type": ["null", "string"] } @@ -289,21 +420,6 @@ } ] }, - "shopify_cart_token": { - "type": ["null", "string"] - }, - "shopify_customer_id": { - "type": ["null", "string"] - }, - "shopify_id": { - "type": ["null", "string"] - }, - "shopify_order_id": { - "type": ["null", "string"] - }, - "shopify_order_number": { - "type": ["null", "integer"] - }, "status": { "type": ["null", "string"] }, @@ -321,10 +437,10 @@ "type": "object", "additionalProperties": false, "properties": { - "code": { + "price": { "type": ["null", "string"] }, - "price": { + "rate": { "type": ["null", "string"] }, "title": { @@ -338,31 +454,27 @@ } ] }, + "taxable": { + "type": ["null", "boolean"] + }, "total_discounts": { - "type": ["null", "number"], - "multipleOf": 1e-08 + "type": ["null", "string"] }, "total_line_items_price": { - "type": ["null", "number"], - "multipleOf": 1e-08 + "type": ["null", "string"] }, "total_price": { "type": ["null", "string"] }, "total_refunds": { - "type": ["null", "number"], - "multipleOf": 1e-08 + "type": ["null", "string"] }, "total_tax": { - "type": ["null", "number"], - "multipleOf": 1e-08 + "type": ["null", "string"] }, - "total_weight": { + "total_weight_grams": { "type": ["null", "integer"] }, - "transaction_id": { - "type": ["null", "string"] - }, "type": { "type": ["null", "string"] }, diff --git a/tap_recharge/schemas/payment_methods.json b/tap_recharge/schemas/payment_methods.json new file mode 100644 index 0000000..1932dd8 --- /dev/null +++ b/tap_recharge/schemas/payment_methods.json @@ -0,0 +1,100 @@ +{ + "type": "object", + "additionalProperties": false, + "properties": { + "id": { + "type": ["null", "integer"] + }, + "billing_address": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "address1": { + "type": ["null", "string"] + }, + "address2": { + "type": ["null", "string"] + }, + "city": { + "type": ["null", "string"] + }, + "company": { + "type": ["null", "string"] + }, + "country_code": { + "type": ["null", "string"] + }, + "first_name": { + "type": ["null", "string"] + }, + "last_name": { + "type": ["null", "string"] + }, + "phone": { + "type": ["null", "string"] + }, + "province": { + "type": ["null", "string"] + }, + "zip": { + "type": ["null", "string"] + } + } + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "customer_id": { + "type": ["null", "integer"] + }, + "default": { + "type": ["null", "boolean"] + }, + "payment_details": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "brand": { + "type": ["null", "string"] + }, + "exp_month": { + "type": ["null", "integer"] + }, + "exp_year": { + "type": ["null", "integer"] + }, + "last4": { + "type": ["null", "integer"] + } + } + } + }, + { + "type": "null" + } + ] + }, + "payment_type": { + "type": ["null", "string"] + }, + "processor_customer_token": { + "type": ["null", "string"] + }, + "processor_name": { + "type": ["null", "boolean"] + }, + "processor_payment_method_token": { + "type": ["null", "string"] + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } + } + \ No newline at end of file diff --git a/tap_recharge/schemas/plans.json b/tap_recharge/schemas/plans.json new file mode 100644 index 0000000..5616c59 --- /dev/null +++ b/tap_recharge/schemas/plans.json @@ -0,0 +1,127 @@ +{ + "type": "object", + "additionalProperties": false, + "properties": { + "id": { + "type": ["null", "integer"] + }, + "channel_settings": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "api": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "can_apply": { + "type": ["null", "boolean"] + } + } + }, + "customer_portal": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "can_apply": { + "type": ["null", "boolean"] + } + } + }, + "merchant_portal": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "can_apply": { + "type": ["null", "boolean"] + } + } + }, + "checkout_page": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "can_apply": { + "type": ["null", "boolean"] + } + } + } + } + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "deleted_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "discount_amount": { + "type": ["null", "string"] + }, + "discount_type": { + "type": ["null", "string"] + }, + "external_plan_group_id": { + "type": ["null", "string"] + }, + "external_plan_id": { + "type": ["null", "string"] + }, + "external_plan_name": { + "type": ["null", "string"] + }, + "external_product_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } + }, + "sort_order": { + "type": ["null", "integer"] + }, + "subscription_preferences": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "charge_interval_frequency": { + "type": ["null", "integer"] + }, + "cutoff_day_of_month": { + "type": ["null", "integer"] + }, + "cutoff_day_of_week": { + "type": ["null", "integer"] + }, + "expire_after_specific_number_of_charges": { + "type": ["null", "integer"] + }, + "order_day_of_month": { + "type": ["null", "integer"] + }, + "order_day_of_week": { + "type": ["null", "integer"] + }, + "order_interval_frequency": { + "type": ["null", "integer"] + }, + "interval_unit": { + "type": ["null", "boolean"] + } + } + }, + "title": { + "type": ["null", "string"] + }, + "type": { + "type": ["null", "string"] + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } + } + \ No newline at end of file diff --git a/tap_recharge/schemas/products.json b/tap_recharge/schemas/products.json index 76ca4d2..caa9868 100644 --- a/tap_recharge/schemas/products.json +++ b/tap_recharge/schemas/products.json @@ -2,22 +2,15 @@ "type": "object", "additionalProperties": false, "properties": { - "collection_id": { - "type": ["null", "integer"] - }, - "created_at": { - "type": ["null", "string"], - "format": "date-time" - }, - "discount_amount": { - "type": ["null", "number"], - "multipleOf": 1e-08 + "external_product_id": { + "type": ["null", "string"] }, - "discount_type": { + "brand": { "type": ["null", "string"] }, - "id": { - "type": ["null", "integer"] + "external_created_at": { + "type": ["null", "string"], + "format": "date-time" }, "images": { "type": ["null", "object"], @@ -34,73 +27,164 @@ }, "small": { "type": ["null", "string"] + }, + "sort_order": { + "type": ["null", "integer"] } } }, - "product_id": { - "type": ["null", "integer"] + "options": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": ["null", "string"] + }, + "position": { + "type": ["null", "integer"] + }, + "values": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "label": { + "type": ["null", "string"] + }, + "position": { + "type": ["null", "integer"] + } + } + } + }, + { + "type": "null" + } + ] + } + } + } + }, + { + "type": "null" + } + ] }, - "shopify_product_id": { - "type": ["null", "integer"] + "published_at": { + "type": ["null", "string"], + "format": "date-time" }, - "subscription_defaults": { - "type": ["null", "object"], - "additionalProperties": false, - "properties": { - "charge_interval_frequency": { - "type": ["null", "integer"] - }, - "cutoff_day_of_month": { - "type": ["null", "string"] - }, - "cutoff_day_of_week": { - "type": ["null", "string"] - }, - "expire_after_specific_number_of_charges": { - "type": ["null", "integer"] - }, - "handle": { - "type": ["null", "string"] - }, - "number_charges_until_expiration": { - "type": ["null", "integer"] - }, - "order_day_of_month": { - "type": ["null", "string"] - }, - "order_day_of_week": { - "type": ["null", "string"] - }, - "order_interval_frequency": { - "type": ["null", "integer"] - }, - "order_interval_frequency_options": { - "anyOf": [ - { - "type": "array", - "items": { - "type": "string" + "requires_shipping": { + "type": ["null", "boolean"] + }, + "title": { + "type": ["null", "string"] + }, + "variants": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "dimensions": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "weight": { + "type": ["null", "integer"] + }, + "weight_unit": { + "type": ["null", "string"] + } + } + }, + "image": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "large": { + "type": ["null", "string"] + }, + "medium": { + "type": ["null", "string"] + }, + "original": { + "type": ["null", "string"] + }, + "small": { + "type": ["null", "string"] + }, + "sort_order": { + "type": ["null", "integer"] + } + } + }, + "option_values": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "label": { + "type": ["null", "string"] + }, + "position": { + "type": ["null", "integer"] + } + } + } + }, + { + "type": "null" + } + ] + }, + "prices": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "compare_at_price": { + "type": ["null", "string"] + }, + "unit_price": { + "type": ["null", "string"] + } } }, - { - "type": "null" + "requires_shipping": { + "type": ["null", "boolean"] + }, + "sku": { + "type": ["null", "string"] + }, + "tax_code": { + "type": ["null", "string"] + }, + "taxable": { + "type": ["null", "boolean"] + }, + "title": { + "type": ["null", "string"] } - ] - }, - "order_interval_unit": { - "type": ["null", "string"] + } }, - "storefront_purchase_options": { - "type": ["null", "string"] + { + "type": "null" } - } + ] }, - "title": { + "vendor": { "type": ["null", "string"] - }, - "updated_at": { - "type": ["null", "string"], - "format": "date-time" } } } diff --git a/tap_recharge/schemas/shop.json b/tap_recharge/schemas/store.json similarity index 58% rename from tap_recharge/schemas/shop.json rename to tap_recharge/schemas/store.json index 5b6552b..67ee064 100644 --- a/tap_recharge/schemas/shop.json +++ b/tap_recharge/schemas/store.json @@ -2,44 +2,62 @@ "type": "object", "additionalProperties": false, "properties": { + "id": { + "type": ["null", "integer"] + }, "checkout_logo_url": { "type": ["null", "string"] }, + "checkout_platform": { + "type": ["null", "string"] + }, "created_at": { "type": ["null", "string"] }, "currency": { "type": ["null", "string"] }, - "domain": { + "customer_portal_base_url": { "type": ["null", "string"] }, - "email": { + "default_api_version": { "type": ["null", "string"] }, - "iana_timezone": { + "email": { "type": ["null", "string"] }, - "id": { - "type": ["null", "integer"] + "external_platform": { + "type": ["null", "string"] }, - "my_shopify_domain": { + "identifier": { "type": ["null", "string"] }, - "name": { + "merchant_portal_base_url": { "type": ["null", "string"] }, - "shop_email": { + "name": { "type": ["null", "string"] }, - "shop_phone": { + "phone": { "type": ["null", "string"] }, "timezone": { - "type": ["null", "string"] + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "iana_name": { + "type": ["null", "string"] + }, + "name": { + "type": ["null", "string"] + } + } }, "updated_at": { "type": ["null", "string"] + }, + "weight_unit": { + "type": ["null", "string"] } } } diff --git a/tap_recharge/schemas/subscriptions.json b/tap_recharge/schemas/subscriptions.json index 610429a..23c8ca6 100644 --- a/tap_recharge/schemas/subscriptions.json +++ b/tap_recharge/schemas/subscriptions.json @@ -2,9 +2,59 @@ "type": "object", "additionalProperties": false, "properties": { + "id": { + "type": ["null", "integer"] + }, "address_id": { "type": ["null", "integer"] }, + "customer_id": { + "type": ["null", "integer"] + }, + "analytics_data": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "utm_params": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "utm_campaign": { + "type": ["null", "string"] + }, + "utm_content": { + "type": ["null", "string"] + }, + "utm_data_source": { + "type": ["null", "string"] + }, + "utm_medium": { + "type": ["null", "string"] + }, + "utm_source": { + "type": ["null", "string"] + }, + "utm_term": { + "type": ["null", "string"] + }, + "utm_timestamp": { + "type": ["null", "string"], + "format": "date-time" + } + } + } + }, + { + "type": "null" + } + ] + } + } + }, "cancellation_reason": { "type": ["null", "string"] }, @@ -22,17 +72,32 @@ "type": ["null", "string"], "format": "date-time" }, - "customer_id": { - "type": ["null", "integer"] - }, "expire_after_specific_number_of_charges": { "type": ["null", "integer"] }, + "external_product_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } + }, + "external_variant_id": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "ecommerce": { + "type": ["null", "string"] + } + } + }, "has_queued_charges": { "type": ["null", "integer"] }, - "id": { - "type": ["null", "integer"] + "is_prepaid": { + "type": ["null", "boolean"] }, "is_skippable": { "type": ["null", "boolean"] @@ -60,8 +125,7 @@ "type": ["null", "string"] }, "price": { - "type": ["null", "number"], - "multipleOf": 1e-08 + "type": ["null", "string"] }, "product_title": { "type": ["null", "string"] @@ -91,20 +155,11 @@ "quantity": { "type": ["null", "integer"] }, - "recharge_product_id": { - "type": ["null", "integer"] - }, - "shopify_product_id": { - "type": ["null", "integer"] - }, - "shopify_variant_id": { - "type": ["null", "integer"] - }, "sku": { "type": ["null", "string"] }, "sku_override": { - "type": ["null", "string"] + "type": ["null", "boolean"] }, "status": { "type": ["null", "string"] diff --git a/tap_recharge/streams.py b/tap_recharge/streams.py index 25fb739..bd19249 100644 --- a/tap_recharge/streams.py +++ b/tap_recharge/streams.py @@ -3,18 +3,15 @@ """ import datetime - from typing import Iterator - import singer from singer import Transformer, utils, metrics, bookmarks - from tap_recharge.client import RechargeClient LOGGER = singer.get_logger() -MAX_PAGE_LIMIT = 250 +MAX_PAGE_LIMIT = 50 # Reduced from 250 prevent truncated JSON string termination errors def get_recharge_bookmark( @@ -132,7 +129,7 @@ def sync( max_datetime = bookmark_datetime with metrics.record_counter(self.tap_stream_id) as counter: - for record in self.get_records(config, bookmark_datetime): + for record in self.get_records(bookmark_datetime): transformed_record = transformer.transform(record, stream_schema, stream_metadata) record_datetime = utils.strptime_to_utc(transformed_record[self.replication_key]) @@ -194,69 +191,52 @@ def sync( return state - -class PageBasedPagingStream(IncrementalStream): +class CursorPagingStream(IncrementalStream): """ - A generic page based pagination implementation for the Recharge API. + A generic cursor pagination implemantation for the Recharge API. - Docs: https://developer.rechargepayments.com/?python#page-based-pagination + Docs: https://developer.rechargepayments.com/2021-11/cursor_pagination """ def get_records( self, bookmark_datetime: datetime = None, is_parent: bool = False) -> Iterator[list]: - page = 1 + self.params.update({ 'limit': MAX_PAGE_LIMIT, - 'page': page - }) - result_size = MAX_PAGE_LIMIT - - while result_size == MAX_PAGE_LIMIT: - records, _ = self.client.get(self.path, params=self.params) + 'cursor': None, + 'updated_at_min': None + }) - result_size = len(records.get(self.data_key)) - page += 1 - self.params.update({'page': page}) - - yield from records.get(self.data_key) + if self.updated_at_min: + self.params.update({ + 'updated_at_min': utils.strftime(bookmark_datetime) + }) + more_data = True -class CursorPagingStream(IncrementalStream): - """ - A generic cursor pagination implemantation for the Recharge API. + while more_data: + records = self.client.get(self.path, params=self.params) - Docs: https://developer.rechargepayments.com/?python#cursor-pagination - """ + if records.get('next_cursor') is not None: + next_cursor = records['next_cursor'] + self.params.update({'cursor': next_cursor}) - def get_records( - self, - bookmark_datetime: datetime = None, - is_parent: bool = False) -> Iterator[list]: - self.params.update({'limit': MAX_PAGE_LIMIT}) - paging = True - path = self.path - url = None - - while paging: - records, links = self.client.get(path, url=url, params=self.params) - - if links.get('next'): - path = None - self.params = None - url = links.get('next', {}).get('url') + # Remove other params (besides limit) + self.params.pop('updated_at_min', None) + self.params.pop('sort_by', None) + more_data = True else: - paging = False + more_data = False yield from records.get(self.data_key) - class Addresses(CursorPagingStream): """ Retrieves addresses from the Recharge API. - Docs: https://developer.rechargepayments.com/#list-addresses + Docs: https://developer.rechargepayments.com/2021-11/addresses/list_addresses """ tap_stream_id = 'addresses' key_properties = ['id'] @@ -265,43 +245,45 @@ class Addresses(CursorPagingStream): valid_replication_keys = ['updated_at'] params = {'sort_by': f'{replication_key}-asc'} data_key = 'addresses' + updated_at_min = True -class Charges(CursorPagingStream): +# Endpoinnt may not be available for all orgs +class Collections(CursorPagingStream): """ - Retrieves charges from the Recharge API. - - Docs: https://developer.rechargepayments.com/#list-charges + Retrieves collections from the Recharge API. + Docs: https://developer.rechargepayments.com/#list-collections """ - tap_stream_id = 'charges' + tap_stream_id = 'collections' key_properties = ['id'] - path = 'charges' + path = 'collections' replication_key = 'updated_at' valid_replication_keys = ['updated_at'] params = {'sort_by': f'{replication_key}-asc'} - data_key = 'charges' - + data_key = 'collections' + updated_at_min = False -class Collections(CursorPagingStream): +class Charges(CursorPagingStream): """ - Retrieves collections from the Recharge API. + Retrieves charges from the Recharge API. - Docs: https://developer.rechargepayments.com/#list-collections + Docs: https://developer.rechargepayments.com/2021-11/charges/charge_list """ - tap_stream_id = 'collections' + tap_stream_id = 'charges' key_properties = ['id'] - path = 'collections' + path = 'charges' replication_key = 'updated_at' valid_replication_keys = ['updated_at'] params = {'sort_by': f'{replication_key}-asc'} - data_key = 'collections' + data_key = 'charges' + updated_at_min = True -class Customers(PageBasedPagingStream): +class Customers(CursorPagingStream): """ Retrieves customers from the Recharge API. - Docs: https://developer.rechargepayments.com/#list-customers + Docs: https://developer.rechargepayments.com/2021-11/customers/customers_list """ tap_stream_id = 'customers' key_properties = ['id'] @@ -310,13 +292,14 @@ class Customers(PageBasedPagingStream): valid_replication_keys = ['updated_at'] params = {'sort_by': f'{replication_key}-asc'} data_key = 'customers' + updated_at_min = True class Discounts(CursorPagingStream): """ Retrieves discounts from the Recharge API. - Docs: https://developer.rechargepayments.com/#list-discounts + Docs: https://developer.rechargepayments.com/2021-11/discounts/discounts_list """ tap_stream_id = 'discounts' key_properties = ['id'] @@ -325,13 +308,14 @@ class Discounts(CursorPagingStream): valid_replication_keys = ['updated_at'] params = {'sort_by': f'{replication_key}-asc'} data_key = 'discounts' + updated_at_min = True -class MetafieldsStore(PageBasedPagingStream): +class MetafieldsStore(CursorPagingStream): """ Retrieves store metafields from the Recharge API. - Docs: https://developer.rechargepayments.com/#list-metafields + Docs: https://developer.rechargepayments.com/2021-11/metafields/metafields_list """ tap_stream_id = 'metafields_store' key_properties = ['id'] @@ -341,15 +325,16 @@ class MetafieldsStore(PageBasedPagingStream): params = { 'sort_by': f'{replication_key}-asc', 'owner_resource': 'store' - } + } data_key = 'metafields' + updated_at_min = False -class MetafieldsCustomer(PageBasedPagingStream): +class MetafieldsCustomer(CursorPagingStream): """ Retrieves customer metafields from the Recharge API. - Docs: https://developer.rechargepayments.com/#list-metafields + Docs: https://developer.rechargepayments.com/2021-11/metafields/metafields_list """ tap_stream_id = 'metafields_customer' key_properties = ['id'] @@ -359,33 +344,36 @@ class MetafieldsCustomer(PageBasedPagingStream): params = { 'sort_by': f'{replication_key}-asc', 'owner_resource': 'customer' - } + } data_key = 'metafields' + updated_at_min = False -class MetafieldsSubscription(PageBasedPagingStream): +class MetafieldsSubscription(CursorPagingStream): """ Retrieves subscription metafields from the Recharge API. - Docs: https://developer.rechargepayments.com/#list-metafields + Docs: https://developer.rechargepayments.com/2021-11/metafields/metafields_list """ tap_stream_id = 'metafields_subscription' key_properties = ['id'] path = 'metafields' - replication_key = 'updated_at' # pseudo-incremental; doesn't support `updated_at_min` param + # pseudo-incremental; doesn't support `updated_at_min` param + replication_key = 'updated_at' valid_replication_keys = ['updated_at'] params = { 'sort_by': f'{replication_key}-asc', 'owner_resource': 'subscription' - } + } data_key = 'metafields' + updated_at_min = False -class Onetimes(PageBasedPagingStream): +class Onetimes(CursorPagingStream): """ Retrieves non-recurring line items on queued orders from the Recharge API. - Docs: https://developer.rechargepayments.com/#list-onetimes + Docs: https://developer.rechargepayments.com/2021-11/onetimes/onetimes_list """ tap_stream_id = 'onetimes' key_properties = ['id'] @@ -394,13 +382,14 @@ class Onetimes(PageBasedPagingStream): valid_replication_keys = ['updated_at'] params = {'sort_by': f'{replication_key}-asc'} data_key = 'onetimes' + updated_at_min = True class Orders(CursorPagingStream): """ Retrieves orders from the Recharge API. - Docs: https://developer.rechargepayments.com/#list-orders + Docs: https://developer.rechargepayments.com/2021-11/orders/orders_list """ tap_stream_id = 'orders' key_properties = ['id'] @@ -409,39 +398,76 @@ class Orders(CursorPagingStream): valid_replication_keys = ['updated_at'] params = {'sort_by': f'{replication_key}-asc'} data_key = 'orders' + updated_at_min = True +class Plans(CursorPagingStream): + """ + Retrieves plans from the Recharge API. + Docs: https://developer.rechargepayments.com/2021-11/plans/plans_list + """ + tap_stream_id = 'plans' + key_properties = ['id'] + path = 'plans' + replication_key = 'updated_at' + valid_replication_keys = ['updated_at'] + params = {'sort_by': f'{replication_key}-asc'} + data_key = 'plans' + updated_at_min = True + + +# Endpoinnt may not be available for all orgs +class PaymentMethods(CursorPagingStream): + """ + Retrieves payment methods from the Recharge API. + + Docs: https://developer.rechargepayments.com/2021-11/payment_methods/payment_methods_list + """ + tap_stream_id = 'payment_methods' + key_properties = ['id'] + path = 'payment_methods' + # pseudo-incremental; doesn't support `updated_at_min` param + replication_key = 'updated_at' + valid_replication_keys = ['updated_at'] + params = {'sort_by': f'{replication_key}-asc'} + data_key = 'payment_methods' + updated_at_min = False + + +# Endpoinnt may not be available for all orgs class Products(CursorPagingStream): """ Retrieves products from the Recharge API. - Docs: https://developer.rechargepayments.com/#list-products + Docs: https://developer.rechargepayments.com/2021-11/products/products_list """ tap_stream_id = 'products' - key_properties = ['id'] + key_properties = ['external_product_id'] path = 'products' - replication_key = 'updated_at' # pseudo-incremental; doesn't support `updated_at_min` param - valid_replication_keys = ['updated_at'] + # pseudo-incremental; doesn't support `updated_at_min` param + replication_key = 'external_updated_at' + valid_replication_keys = ['external_updated_at'] params = {'sort_by': f'{replication_key}-asc'} data_key = 'products' + updated_at_min = False -class Shop(FullTableStream): +class Store(FullTableStream): """ Retrieves basic info about your store setup from the Recharge API. - Docs: https://developer.rechargepayments.com/#shop + Docs: https://developer.rechargepayments.com/2021-11/store/store_retrieve """ - tap_stream_id = 'shop' + tap_stream_id = 'store' key_properties = ['id'] - path = 'shop' - data_key = 'shop' + path = 'store' + data_key = 'store' def get_records( self, bookmark_datetime: datetime = None, is_parent: bool = False) -> Iterator[list]: - records, _ = self.client.get(self.path) + records = self.client.get(self.path) return [records.get(self.data_key)] @@ -450,7 +476,7 @@ class Subscriptions(CursorPagingStream): """ Retrieves subscriptions from the Recharge API. - Docs: https://developer.rechargepayments.com/#list-subscriptions + Docs: https://developer.rechargepayments.com/2021-11/subscriptions/subscriptions_list """ tap_stream_id = 'subscriptions' key_properties = ['id'] @@ -459,6 +485,7 @@ class Subscriptions(CursorPagingStream): valid_replication_keys = ['updated_at'] params = {'sort_by': f'{replication_key}-asc'} data_key = 'subscriptions' + updated_at_min = True STREAMS = { @@ -472,7 +499,9 @@ class Subscriptions(CursorPagingStream): 'metafields_subscription': MetafieldsSubscription, 'onetimes': Onetimes, 'orders': Orders, + 'payment_methods': PaymentMethods, + 'plans': Plans, 'products': Products, - 'shop': Shop, + 'store': Store, 'subscriptions': Subscriptions } diff --git a/tests/base.py b/tests/base.py index f35d676..4b90229 100644 --- a/tests/base.py +++ b/tests/base.py @@ -113,12 +113,17 @@ def expected_metadata(self): self.REPLICATION_METHOD: self.INCREMENTAL, self.REPLICATION_KEYS: {"updated_at"} }, - "products": { + "payment_methods": { self.PRIMARY_KEYS: {"id", }, self.REPLICATION_METHOD: self.INCREMENTAL, self.REPLICATION_KEYS: {"updated_at"} }, - "shop": { + "products": { + self.PRIMARY_KEYS: {"id", }, + self.REPLICATION_METHOD: self.INCREMENTAL, + self.REPLICATION_KEYS: {"external_updated_at"} + }, + "store": { self.PRIMARY_KEYS: {"id"}, self.REPLICATION_METHOD: self.FULL_TABLE },