Skip to content
Open
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
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
packages=find_packages(),
package_data={
'tap_chargebee': [
'schemas/*.json'
'schemas/common/*.json',
'schemas/item_model/*.json',
'schemas/plan_model/*.json'
]
})
30 changes: 28 additions & 2 deletions tap_chargebee/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import singer
import tap_framework

import tap_chargebee.client
import tap_chargebee.streams

Expand All @@ -18,8 +19,8 @@ def main():
client = tap_chargebee.client.ChargebeeClient(args.config)

runner = ChargebeeRunner(
args, client, tap_chargebee.streams.AVAILABLE_STREAMS
)
args, client, get_available_streams(args, client)
)

if args.discover:
runner.do_discover()
Expand All @@ -29,3 +30,28 @@ def main():

if __name__ == '__main__':
main()


def get_available_streams(self, cb_client):
site_name = self.config.get('site')
LOGGER.info("Site Name {}".format(site_name))
configuration_url = 'https://{}.chargebee.com/api/v2/configurations'.format(site_name)
response = cb_client.make_request(
url=configuration_url,
method='GET')
site_configurations = response['configurations']
product_catalog_version = next(iter(config['product_catalog_version'] for config in site_configurations if
config['domain'] == site_name),
None)
if product_catalog_version == 'v2':
available_streams = tap_chargebee.streams.ITEM_MODEL_AVAILABLE_STREAMS
self.config['item_model'] = True
LOGGER.info('Item Model')
elif product_catalog_version == 'v1':
available_streams = tap_chargebee.streams.PLAN_MODEL_AVAILABLE_STREAMS
self.config['item_model'] = False
LOGGER.info('Plan Model')
else:
LOGGER.error("Incorrect Product Catalog version {}".format(product_catalog_version))
raise RuntimeError("Incorrect Product Catalog version")
return available_streams
Original file line number Diff line number Diff line change
Expand Up @@ -140,46 +140,6 @@
"custom_fields": {
"type": ["null", "string"]
},
"vat_number_validated_time": {
"type": ["null", "string"],
"format": "date-time"
},
"vat_number_status": {
"type": ["null", "string"]
},
"is_location_valid": {
"type": ["null", "boolean"]
},
"created_from_ip": {
"type": ["null", "string"]
},
"entity_code": {
"type": ["null", "string"]
},
"exempt_number": {
"type": ["null", "string"]
},
"resource_version": {
"type": ["null", "integer"]
},
"fraud_flag": {
"type": ["null", "string"]
},
"backup_payment_source_id": {
"type": ["null", "string"]
},
"registered_for_gst": {
"type": ["null", "boolean"]
},
"customer_type": {
"type": ["null", "string"]
},
"meta_data": {
"type": ["null", "string"]
},
"exemption_details": {
"type": ["null", "string"]
},
"billing_address": {
"type": ["null","object"],
"properties": {
Expand Down Expand Up @@ -344,6 +304,23 @@
}
}
}
},
"relationship": {
"type": ["null","object"],
"properties": {
"parent_id": {
"type": ["null", "string"]
},
"payment_owner_id": {
"type": ["null", "string"]
},
"invoice_owner_id": {
"type": ["null", "string"]
},
"root_id": {
"type": ["null", "string"]
}
}
}
}
}
232 changes: 232 additions & 0 deletions tap_chargebee/schemas/item_model/coupons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
{
"type":[
"null",
"object"
],
"additionalProperties":false,
"properties":{
"id":{
"type":[
"null",
"string"
]
},
"name":{
"type":[
"null",
"string"
]
},
"invoice_name":{
"type":[
"null",
"string"
]
},
"discount_type":{
"type":[
"null",
"string"
]
},
"discount_percentage":{
"type":[
"null",
"number"
]
},
"discount_amount":{
"type":[
"null",
"number"
]
},
"currency_code":{
"type":[
"null",
"string"
]
},
"duration_type":{
"type":[
"null",
"string"
]
},
"duration_month":{
"type":[
"null",
"integer"
]
},
"max_redemptions":{
"type":[
"null",
"integer"
]
},
"status":{
"type":[
"null",
"string"
]
},
"apply_discount_on":{
"type":[
"null",
"string"
]
},
"apply_on":{
"type":[
"null",
"string"
]
},
"created_at":{
"type":[
"null",
"string"
],
"format":"date-time"
},
"archived_at":{
"type":[
"null",
"string"
],
"format":"date-time"
},
"resource_version":{
"type":[
"null",
"integer"
]
},
"updated_at":{
"type":[
"null",
"string"
],
"format":"date-time"
},
"object":{
"type":[
"null",
"string"
]
},
"redemptions":{
"type":[
"null",
"integer"
]
},
"invoice_notes":{
"type":[
"null",
"string"
]
},
"meta_data":{
"type":[
"null",
"string"
]
},
"item_constraints":{
"type":[
"null",
"array"
],
"items":{
"type":[
"null",
"object"
],
"properties":{
"item_type":{
"type":[
"null",
"string"
]
},
"constraint":{
"type":[
"null",
"string"
]
},
"item_price_ids":{
"type":[
"null",
"array"
],
"items":{
"type":[
"null",
"string"
]
}
}
}
}
},
"item_constraint_criteria":{
"type":[
"null",
"array"
],
"items":{
"type":[
"null",
"object"
],
"properties":{
"item_type":{
"type":[
"null",
"string"
]
},
"currencies":{
"type":[
"null",
"array"
],
"items":{
"type":[
"null",
"string"
]
}
},
"item_family_ids":{
"type":[
"null",
"array"
],
"items":{
"type":[
"null",
"string"
]
}
},
"item_price_periods":{
"type":[
"null",
"array"
],
"items":{
"type":[
"null",
"string"
]
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
"round_off_amount": {
"type": ["null", "integer"]
},
"payment_owner": {
"type": ["null", "string"]
},
"deleted": {
"type": ["null", "boolean"]
},
Expand Down Expand Up @@ -558,9 +561,6 @@
},
"subscription_id": {
"type": ["null", "string"]
},
"total": {
"type": ["null", "integer"]
}
}
}
Loading