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

TDL-19328: Change Shop API #27

Merged
merged 7 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This tap:
- [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)
- [Store](https://developer.rechargepayments.com/2021-11/store/store_retrieve)
- [Subscriptions](https://developer.rechargepayments.com/#list-subscriptions)
- Outputs the schema for each resource
- Incrementally pulls data based on the input state
Expand Down Expand Up @@ -120,8 +120,8 @@ This tap:
- 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
Expand Down Expand Up @@ -189,7 +189,6 @@ This tap:
"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"
}
}
Expand Down Expand Up @@ -254,7 +253,7 @@ This tap:
| discounts | 1 | 1 |
| metafields_subscription | 0 | 1 |
| addresses | 4 | 1 |
| shop | 1 | 1 |
| store | 1 | 1 |
| charges | 4 | 1 |
| products | 4 | 1 |
| onetimes | 0 | 1 |
Expand Down
1 change: 0 additions & 1 deletion state.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"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"
}
}
2 changes: 1 addition & 1 deletion tap_recharge/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def request(self, method, path=None, url=None, **kwargs): # pylint: disable=too-
# If we did not specify any API Version during API Call, the Recharge will use the default API Version of our store
# the 'collections' was added as part of API Version: '2021-11', for older API Version,
# we will get empty records so adding 'X-Recharge-Version' for 'collections' API call
if path == 'collections':
if path in ['collections', 'store']:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update comment above regarding the reason for store as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added PR comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgraded API version only for Store as part of this PR. As for some fields, there is schema change in the new version that will result in a Transform error.

kwargs['headers']['X-Recharge-Version'] = '2021-11'

if self.__user_agent:
Expand Down
38 changes: 36 additions & 2 deletions tap_recharge/schemas/shop.json → tap_recharge/schemas/store.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"type": ["null", "string"]
},
"created_at": {
"type": ["null", "string"]
"type": ["null", "string"],
"format": "date-time"
},
"currency": {
"type": ["null", "string"]
Expand Down Expand Up @@ -36,9 +37,42 @@
"type": ["null", "string"]
},
"timezone": {
"type": ["null", "string"]
"type": ["null", "object"],
"properties": {
"iana_name": {
"type": ["null", "string"]
},
"iana_timezone": {
"type": ["null", "string"]
},
"name": {
"type": ["null", "string"]
}
}
},
"updated_at": {
"type": ["null", "string"],
"format": "date-time"
},
"phone": {
"type": ["null", "string"]
},
"checkout_platform": {
"type": ["null", "string"]
},
"customer_portal_base_url": {
"type": ["null", "string"]
},
"external_platform": {
"type": ["null", "string"]
},
"identifier": {
"type": ["null", "string"]
},
"merchant_portal_base_url": {
"type": ["null", "string"]
},
"weight_unit": {
"type": ["null", "string"]
}
}
Expand Down
12 changes: 6 additions & 6 deletions tap_recharge/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,16 +433,16 @@ class Products(CursorPagingStream):
data_key = 'products'


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
"""
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,
Expand Down Expand Up @@ -480,6 +480,6 @@ class Subscriptions(CursorPagingStream):
'onetimes': Onetimes,
'orders': Orders,
'products': Products,
'shop': Shop,
'store': Store,
'subscriptions': Subscriptions
}
2 changes: 1 addition & 1 deletion tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def expected_metadata(self):
self.REPLICATION_METHOD: self.INCREMENTAL,
self.REPLICATION_KEYS: {"updated_at"}
},
"shop": {
"store": {
self.PRIMARY_KEYS: {"id"},
self.REPLICATION_METHOD: self.FULL_TABLE
},
Expand Down