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

v1.5.1: Request all types of subscriptions #113

Merged
merged 4 commits into from
Dec 31, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 14 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
# Changelog

** 1.5.0
## 1.5.1
* Subscriptions stream will now request subscriptions of all statuses [#113](https://github.com/singer-io/tap-stripe/pull/113)

## 1.5.0
* Add schema for card_present charges [#101](https://github.com/singer-io/tap-stripe/pull/101)

** 1.4.9
## 1.4.9
* Allow partial days in the `date_window_size` config value [#100](https://github.com/singer-io/tap-stripe/pull/100)

** 1.4.8
## 1.4.8
* Reverts 1.4.7 [#82](https://github.com/singer-io/tap-stripe/pull/82)

** 1.4.7
## 1.4.7
* Updates singer-python from 5.5.1 to 5.12.1 [#81](https://github.com/singer-io/tap-stripe/pull/81)

** 1.4.6
## 1.4.6
* Removed fields that caused transform errors

** 1.4.5
## 1.4.5
* Added various schema [#77](https://github.com/singer-io/tap-stripe/pull/77)

** 1.4.4
## 1.4.4
* Use the default timeout in the stripe client [#61](https://github.com/singer-io/tap-stripe/pull/61)

** 1.4.3
## 1.4.3
* Revert 1.4.2 changes from #59 [#60](https://github.com/singer-io/tap-stripe/pull/60)
* Remove invalid and unused schema pieces [#60](https://github.com/singer-io/tap-stripe/pull/60)

** 1.4.2
## 1.4.2
* Revert 1.4.1 [#59](https://github.com/singer-io/tap-stripe/pull/59)

** 1.4.1
## 1.4.1
* Add functionality that recursively converts `StripeObject`s to dictionaries. [#53](https://github.com/singer-io/tap-stripe/pull/53)

** 1.4.0
## 1.4.0
* Added the `payment_method_details` field to the charges stream. [#49](https://github.com/singer-io/tap-stripe/pull/49)

## 1.3.7
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="tap-stripe",
version="1.5.0",
version="1.5.1",
description="Singer.io tap for extracting data",
author="Stitch",
url="http://singer.io",
Expand Down
20 changes: 15 additions & 5 deletions tap_stripe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
'key_properties': ['id', 'invoice']},
'transfers': {'sdk_object': stripe.Transfer, 'key_properties': ['id']},
'coupons': {'sdk_object': stripe.Coupon, 'key_properties': ['id']},
'subscriptions': {'sdk_object': stripe.Subscription, 'key_properties': ['id']},
'subscriptions': {
'sdk_object': stripe.Subscription,
'key_properties': ['id'],
'request_args': {'status': 'all'}
},
'subscription_items': {'sdk_object': stripe.SubscriptionItem, 'key_properties': ['id']},
'balance_transactions': {'sdk_object': stripe.BalanceTransaction,
'key_properties': ['id']},
Expand Down Expand Up @@ -371,14 +375,15 @@ def reduce_foreign_keys(rec, stream_name):
return rec


def paginate(sdk_obj, filter_key, start_date, end_date, limit=100):
def paginate(sdk_obj, filter_key, start_date, end_date, request_args=None, limit=100):
yield from sdk_obj.list(
limit=limit,
stripe_account=Context.config.get('account_id'),
# None passed to starting_after appears to retrieve
# all of them so this should always be safe.
**{filter_key + "[gte]": start_date,
filter_key + "[lt]": end_date}
filter_key + "[lt]": end_date},
**request_args or {}
).auto_paging_iter()


Expand Down Expand Up @@ -453,8 +458,13 @@ def sync_stream(stream_name):
if stop_window > end_time:
stop_window = end_time

for stream_obj in paginate(STREAM_SDK_OBJECTS[stream_name]['sdk_object'],
filter_key, start_window, stop_window):
for stream_obj in paginate(
STREAM_SDK_OBJECTS[stream_name]['sdk_object'],
filter_key,
start_window,
stop_window,
STREAM_SDK_OBJECTS[stream_name].get('request_args')
):

# get the replication key value from the object
rec = unwrap_data_objects(stream_obj.to_dict_recursive())
Expand Down