Skip to content

Commit

Permalink
Source Chargebee: added coupon (#10269)
Browse files Browse the repository at this point in the history
* added coupon stream

* changes

* Update airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py

Co-authored-by: Marcos Marx <marcosmarxm@users.noreply.github.com>

Co-authored-by: Marcos Marx <marcosmarxm@users.noreply.github.com>
  • Loading branch information
aadityasinha-dotcom and marcosmarxm committed Feb 15, 2022
1 parent f94f427 commit 1c89320
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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": {}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -38,6 +38,7 @@ def streams(self, config) -> List[Stream]:
Event(**kwargs),
Invoice(**kwargs),
Order(**kwargs),
Coupon(**kwargs),
Subscription(**kwargs),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions docs/integrations/sources/chargebee.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1c89320

Please sign in to comment.