diff --git a/README.md b/README.md index fd64e9d..a94ecac 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ This tap: - [Addons](https://apidocs.chargebee.com/docs/api/addons) - [Coupons](https://apidocs.chargebee.com/docs/api/coupons) - [Credit Notes](https://apidocs.chargebee.com/docs/api/credit_notes) + - [Comments](https://apidocs.chargebee.com/docs/api/comments) - [Customers](https://apidocs.chargebee.com/docs/api/customers) - [Events](https://apidocs.chargebee.com/docs/api/events) - [Gifts](https://apidocs.chargebee.com/docs/api/gifts) diff --git a/tap_chargebee/schemas/comments.json b/tap_chargebee/schemas/comments.json new file mode 100644 index 0000000..a03ee6b --- /dev/null +++ b/tap_chargebee/schemas/comments.json @@ -0,0 +1,31 @@ +{ + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "id": { + "type": ["null", "string"] + }, + "notes": { + "type": ["null", "string"] + }, + "entity_type": { + "type": ["null", "string"] + }, + "object": { + "type": ["null", "string"] + }, + "type": { + "type": ["null", "string"] + }, + "entity_id": { + "type": ["null", "string"] + }, + "added_by": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + } + } +} diff --git a/tap_chargebee/streams/__init__.py b/tap_chargebee/streams/__init__.py index b93e33b..7e8d524 100644 --- a/tap_chargebee/streams/__init__.py +++ b/tap_chargebee/streams/__init__.py @@ -1,5 +1,6 @@ from .addons import AddonsStream from .coupons import CouponsStream +from .comments import CommentsStream from .credit_notes import CreditNotesStream from .customers import CustomersStream from .events import EventsStream @@ -17,6 +18,7 @@ AVAILABLE_STREAMS = [ EventsStream, AddonsStream, + CommentsStream, CouponsStream, CreditNotesStream, CustomersStream, diff --git a/tap_chargebee/streams/base.py b/tap_chargebee/streams/base.py index b3544f3..671e498 100644 --- a/tap_chargebee/streams/base.py +++ b/tap_chargebee/streams/base.py @@ -141,6 +141,9 @@ def sync_data(self): elif self.ENTITY == 'promotional_credit': params = {"created_at[after]": bookmark_date_posix} bookmark_key = 'created_at' + elif self.ENTITY == 'comment': + params = {"created_at[after]": bookmark_date_posix} + bookmark_key = 'created_at' else: params = {"updated_at[after]": bookmark_date_posix} bookmark_key = 'updated_at' diff --git a/tap_chargebee/streams/comments.py b/tap_chargebee/streams/comments.py new file mode 100644 index 0000000..95b081a --- /dev/null +++ b/tap_chargebee/streams/comments.py @@ -0,0 +1,17 @@ +from tap_chargebee.streams.base import BaseChargebeeStream + + +class CommentsStream(BaseChargebeeStream): + TABLE = 'comments' + ENTITY = 'comment' + REPLICATION_METHOD = 'INCREMENTAL' + REPLICATION_KEY = 'created_at' + KEY_PROPERTIES = ['id'] + BOOKMARK_PROPERTIES = ['created_at'] + SELECTED_BY_DEFAULT = True + VALID_REPLICATION_KEYS = ['created_at'] + INCLUSION = 'available' + API_METHOD = 'GET' + + def get_url(self): + return 'https://{}.chargebee.com/api/v2/comments'.format(self.config.get('site'))