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

Add subsciption and subscription_item to line_item PK #28

Merged
merged 1 commit into from
May 24, 2019
Merged
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
13 changes: 12 additions & 1 deletion tap_stripe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
'invoices': {'sdk_object': stripe.Invoice, 'key_properties': ['id']},
'invoice_items': {'sdk_object': stripe.InvoiceItem, 'key_properties': ['id']},
'invoice_line_items': {'sdk_object': stripe.InvoiceLineItem,
'key_properties': ['id', 'invoice']},
'key_properties': ['id',
'invoice',
'subscription',
'subscription_item']},
'transfers': {'sdk_object': stripe.Transfer, 'key_properties': ['id']},
'coupons': {'sdk_object': stripe.Coupon, 'key_properties': ['id']},
'subscriptions': {'sdk_object': stripe.Subscription, 'key_properties': ['id']},
Expand Down Expand Up @@ -583,6 +586,14 @@ def sync_sub_stream(sub_stream_name, parent_obj, updates=False):
if sub_stream_name == "invoice_line_items":
# Synthetic addition of a key to the record we sync
obj_ad_dict["invoice"] = parent_obj.id

# Line item PKs must be a combination of all unique IDs associated
# with the different types a line item can be
# If they are not populated, they must be added here.
if "subscription" not in obj_ad_dict:
obj_ad_dict["subscription"] = None
if "subscription_item" not in obj_ad_dict:
obj_ad_dict["subscription_item"] = None
elif sub_stream_name == "payout_transactions":
# payout_transactions is a join table
obj_ad_dict = {"id": obj_ad_dict['id'], "payout_id": parent_obj['id']}
Expand Down