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..149191c1b9e1d 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 Coupon(IncrementalChargebeeStream): + """ + API docs: https://apidocs.eu.chargebee.com/docs/api/coupon?prod_cat_ver=2#list_coupon + """ + + cursor_field = "updated_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