Skip to content

Commit 1c89320

Browse files
Source Chargebee: added coupon (#10269)
* added coupon stream * changes * Update airbyte-integrations/connectors/source-chargebee/source_chargebee/streams.py Co-authored-by: Marcos Marx <[email protected]> Co-authored-by: Marcos Marx <[email protected]>
1 parent f94f427 commit 1c89320

File tree

4 files changed

+177
-1
lines changed

4 files changed

+177
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"name": "Coupon",
4+
"type": "object",
5+
"properties": {
6+
"id": {
7+
"type": ["string", "null"],
8+
"max-length": 40
9+
},
10+
"name": {
11+
"type": ["string", "null"],
12+
"max-length": 150
13+
},
14+
"invoice_name": {
15+
"type": ["string", "null"],
16+
"max-length": 150
17+
},
18+
"discount_type": {
19+
"type": ["string", "null"],
20+
"enum": [
21+
"fixed_amount",
22+
"percentage"
23+
]
24+
},
25+
"discount_percentage": {
26+
"type": ["double", "null"]
27+
},
28+
"discount_amount": {
29+
"type": ["integer", "null"]
30+
},
31+
"currency_code": {
32+
"type": ["string", "null"],
33+
"max-length": 3
34+
},
35+
"duration_type": {
36+
"type": ["string", "null"],
37+
"enum": [
38+
"one_time",
39+
"forever",
40+
"limited_period"
41+
]
42+
},
43+
"valid_till": {
44+
"type": ["integer", "null"]
45+
},
46+
"max_redemptions": {
47+
"type": ["integer", "null"]
48+
},
49+
"status": {
50+
"type": ["string", "null"],
51+
"enum": [
52+
"active",
53+
"expired",
54+
"archived",
55+
"deleted"
56+
]
57+
},
58+
"apply_on": {
59+
"type": ["string", "null"],
60+
"enum": [
61+
"invoice_amount",
62+
"each_specified_item"
63+
]
64+
},
65+
"created_at": {
66+
"type": ["integer", "null"]
67+
},
68+
"archived_at": {
69+
"type": ["integer", "null"]
70+
},
71+
"resource_version": {
72+
"type": ["integer", "null"]
73+
},
74+
"updated_at": {
75+
"type": ["integer", "null"]
76+
},
77+
"period": {
78+
"type": ["integer", "null"]
79+
},
80+
"period_unit": {
81+
"type": ["string", "null"],
82+
"enum": [
83+
"day",
84+
"week",
85+
"month",
86+
"year"
87+
]
88+
},
89+
"redemptions": {
90+
"type": ["integer", "null"]
91+
},
92+
"invoice_notes": {
93+
"type": ["string", "null"],
94+
"max-length": 2000
95+
},
96+
"item_constraints": {
97+
"type": ["array", "null"],
98+
"items": {
99+
"type": ["object", "null"],
100+
"properties": {
101+
"item_type": {
102+
"type": ["string", "null"],
103+
"enum": [
104+
"plan",
105+
"adddon",
106+
"charge"
107+
]
108+
},
109+
"constraint": {
110+
"type": ["string", "null"],
111+
"enum": [
112+
"none",
113+
"all",
114+
"specific",
115+
"criteria"
116+
]
117+
},
118+
"item_price_ids": {
119+
"type": ["array", "null"],
120+
"items": {
121+
"type": ["object", "null"],
122+
"properties": {}
123+
}
124+
}
125+
}
126+
}
127+
},
128+
"item_constraint_criteria": {
129+
"type": ["array", "null"],
130+
"items": ["object", "null"],
131+
"properties": {
132+
"item_type": {
133+
"type": ["string", "null"],
134+
"enum": [
135+
"plan",
136+
"adddon",
137+
"charge"
138+
]
139+
},
140+
"currencies": {
141+
"type": ["array", "null"],
142+
"items": {
143+
"type": ["object", "null"],
144+
"properties": {}
145+
}
146+
},
147+
"item_family_ids": {
148+
"type": ["array", "null"],
149+
"items": {
150+
"type": ["object", "null"],
151+
"properties": {}
152+
}
153+
},
154+
"item_price_periods": {
155+
"type": ["array", "null"],
156+
"items": {
157+
"type": ["object", "null"],
158+
"properties": {}
159+
}
160+
}
161+
}
162+
}
163+
}
164+
}

airbyte-integrations/connectors/source-chargebee/source_chargebee/source.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from airbyte_cdk.sources import AbstractSource
1010
from airbyte_cdk.sources.streams import Stream
1111

12-
from .streams import Addon, AttachedItem, Customer, Event, Invoice, Item, ItemPrice, Order, Plan, Subscription
12+
from .streams import Addon, AttachedItem, Customer, Coupon, Event, Invoice, Item, ItemPrice, Order, Plan, Subscription
1313

1414

1515
class SourceChargebee(AbstractSource):
@@ -38,6 +38,7 @@ def streams(self, config) -> List[Stream]:
3838
Event(**kwargs),
3939
Invoice(**kwargs),
4040
Order(**kwargs),
41+
Coupon(**kwargs),
4142
Subscription(**kwargs),
4243
]
4344

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

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from chargebee.models import Customer as CustomerModel
1616
from chargebee.models import Event as EventModel
1717
from chargebee.models import Invoice as InvoiceModel
18+
from chargebee.models import Coupon as CouponModel
1819
from chargebee.models import Item as ItemModel
1920
from chargebee.models import ItemPrice as ItemPriceModel
2021
from chargebee.models import Order as OrderModel
@@ -287,3 +288,12 @@ class Event(IncrementalChargebeeStream):
287288
cursor_field = "occurred_at"
288289

289290
api = EventModel
291+
292+
class Coupon(IncrementalChargebeeStream):
293+
"""
294+
API docs: https://apidocs.eu.chargebee.com/docs/api/coupon?prod_cat_ver=2#list_coupon
295+
"""
296+
297+
cursor_field = "updated_at"
298+
299+
api = CouponModel

docs/integrations/sources/chargebee.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Some streams may depend on Product Catalog version and be accessible only on sit
2929
* Events
3030
* Invoices
3131
* Orders
32+
* Coupons
3233
* Subscriptions
3334
2. presented only in `Product Catalog 1.0`:
3435
* Plans

0 commit comments

Comments
 (0)