From ea39992a47bdd181fc98ddaa4f920b29b3ef54d6 Mon Sep 17 00:00:00 2001 From: aadityasinha-dotcom Date: Fri, 11 Feb 2022 16:23:13 +0530 Subject: [PATCH 1/3] added coupon stream --- .../source_chargebee/schemas/coupon.json | 164 ++++++++++++++++++ .../source_chargebee/source.py | 3 +- .../source_chargebee/streams.py | 10 ++ docs/integrations/sources/chargebee.md | 1 + 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 airbyte-integrations/connectors/source-chargebee/source_chargebee/schemas/coupon.json diff --git a/airbyte-integrations/connectors/source-chargebee/source_chargebee/schemas/coupon.json b/airbyte-integrations/connectors/source-chargebee/source_chargebee/schemas/coupon.json new file mode 100644 index 0000000000000..547a97d82cc68 --- /dev/null +++ b/airbyte-integrations/connectors/source-chargebee/source_chargebee/schemas/coupon.json @@ -0,0 +1,164 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "name": "Coupon", + "type": "object", + "properties": { + "id": { + "type": ["string", "null"], + "max-length": 40 + }, + "name": { + "type": ["string", "null"], + "max-length": 150 + }, + "invoice_name": { + "type": ["string", "null"], + "max-length": 150 + }, + "discount_type": { + "type": ["string", "null"], + "enum": [ + "fixed_amount", + "percentage" + ] + }, + "discount_percentage": { + "type": ["double", "null"] + }, + "discount_amount": { + "type": ["integer", "null"] + }, + "currency_code": { + "type": ["string", "null"], + "max-length": 3 + }, + "duration_type": { + "type": ["string", "null"], + "enum": [ + "one_time", + "forever", + "limited_period" + ] + }, + "valid_till": { + "type": ["integer", "null"] + }, + "max_redemptions": { + "type": ["integer", "null"] + }, + "status": { + "type": ["string", "null"], + "enum": [ + "active", + "expired", + "archived", + "deleted" + ] + }, + "apply_on": { + "type": ["string", "null"], + "enum": [ + "invoice_amount", + "each_specified_item" + ] + }, + "created_at": { + "type": ["integer", "null"] + }, + "archived_at": { + "type": ["integer", "null"] + }, + "resource_version": { + "type": ["integer", "null"] + }, + "updated_at": { + "type": ["integer", "null"] + }, + "period": { + "type": ["integer", "null"] + }, + "period_unit": { + "type": ["string", "null"], + "enum": [ + "day", + "week", + "month", + "year" + ] + }, + "redemptions": { + "type": ["integer", "null"] + }, + "invoice_notes": { + "type": ["string", "null"], + "max-length": 2000 + }, + "item_constraints": { + "type": ["array", "null"], + "items": { + "type": ["object", "null"], + "properties": { + "item_type": { + "type": ["string", "null"], + "enum": [ + "plan", + "adddon", + "charge" + ] + }, + "constraint": { + "type": ["string", "null"], + "enum": [ + "none", + "all", + "specific", + "criteria" + ] + }, + "item_price_ids": { + "type": ["array", "null"], + "items": { + "type": ["object", "null"], + "properties": {} + } + } + } + } + }, + "item_constraint_criteria": { + "type": ["array", "null"], + "items": ["object", "null"], + "properties": { + "item_type": { + "type": ["string", "null"], + "enum": [ + "plan", + "adddon", + "charge" + ] + }, + "currencies": { + "type": ["array", "null"], + "items": { + "type": ["object", "null"], + "properties": {} + } + }, + "item_family_ids": { + "type": ["array", "null"], + "items": { + "type": ["object", "null"], + "properties": {} + } + }, + "item_price_periods": { + "type": ["array", "null"], + "items": { + "type": ["object", "null"], + "properties": {} + } + } + } + } + } +} \ No newline at end of file diff --git a/airbyte-integrations/connectors/source-chargebee/source_chargebee/source.py b/airbyte-integrations/connectors/source-chargebee/source_chargebee/source.py index 1f3507744655b..f5076a93fd9d3 100644 --- a/airbyte-integrations/connectors/source-chargebee/source_chargebee/source.py +++ b/airbyte-integrations/connectors/source-chargebee/source_chargebee/source.py @@ -9,7 +9,7 @@ from airbyte_cdk.sources import AbstractSource from airbyte_cdk.sources.streams import Stream -from .streams import Addon, AttachedItem, Customer, Event, Invoice, Item, ItemPrice, Order, Plan, Subscription +from .streams import Addon, AttachedItem, Customer, Coupon, Event, Invoice, Item, ItemPrice, Order, Plan, Subscription class SourceChargebee(AbstractSource): @@ -38,6 +38,7 @@ def streams(self, config) -> List[Stream]: Event(**kwargs), Invoice(**kwargs), Order(**kwargs), + Coupon(**kwargs), Subscription(**kwargs), ] diff --git a/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py b/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py index 5594378d8c1da..1385b4fbcaf66 100644 --- a/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py +++ b/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py @@ -15,6 +15,7 @@ from chargebee.models import Customer as CustomerModel from chargebee.models import Event as EventModel from chargebee.models import Invoice as InvoiceModel +from chargebee.models import Coupon as CouponModel from chargebee.models import Item as ItemModel from chargebee.models import ItemPrice as ItemPriceModel from chargebee.models import Order as OrderModel @@ -287,3 +288,12 @@ class Event(IncrementalChargebeeStream): cursor_field = "occurred_at" api = EventModel + +class Event(IncrementalChargebeeStream): + """ + API docs: https://apidocs.eu.chargebee.com/docs/api/coupon?prod_cat_ver=2#list_coupon + """ + + cursor_field = "occurred_at" + + api = CouponModel \ No newline at end of file diff --git a/docs/integrations/sources/chargebee.md b/docs/integrations/sources/chargebee.md index 39ff00ab1b407..d223fae01dd45 100644 --- a/docs/integrations/sources/chargebee.md +++ b/docs/integrations/sources/chargebee.md @@ -29,6 +29,7 @@ Some streams may depend on Product Catalog version and be accessible only on sit * Events * Invoices * Orders + * Coupons * Subscriptions 2. presented only in `Product Catalog 1.0`: * Plans From ea7b1b1c10b969516dbca2274476e6ccff490b78 Mon Sep 17 00:00:00 2001 From: aadityasinha-dotcom Date: Mon, 14 Feb 2022 14:04:45 +0530 Subject: [PATCH 2/3] changes --- .../connectors/source-chargebee/source_chargebee/streams.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py b/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py index 1385b4fbcaf66..a57068eaf3476 100644 --- a/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py +++ b/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py @@ -289,7 +289,7 @@ class Event(IncrementalChargebeeStream): api = EventModel -class Event(IncrementalChargebeeStream): +class Coupon(IncrementalChargebeeStream): """ API docs: https://apidocs.eu.chargebee.com/docs/api/coupon?prod_cat_ver=2#list_coupon """ From ee5b4747529d1ec9ba8f8718e7b3a6a53b911c3f Mon Sep 17 00:00:00 2001 From: Aaditya Sinha <75474786+aadityasinha-dotcom@users.noreply.github.com> Date: Tue, 15 Feb 2022 21:50:56 +0530 Subject: [PATCH 3/3] Update airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py Co-authored-by: Marcos Marx --- .../connectors/source-chargebee/source_chargebee/streams.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py b/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py index a57068eaf3476..149191c1b9e1d 100644 --- a/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py +++ b/airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py @@ -294,6 +294,6 @@ class Coupon(IncrementalChargebeeStream): API docs: https://apidocs.eu.chargebee.com/docs/api/coupon?prod_cat_ver=2#list_coupon """ - cursor_field = "occurred_at" + cursor_field = "updated_at" api = CouponModel \ No newline at end of file