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

Source Chargebee: added coupon #10269

Merged
merged 3 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
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
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