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

Adding comments stream #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions tap_chargebee/schemas/comments.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
2 changes: 2 additions & 0 deletions tap_chargebee/streams/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,6 +18,7 @@
AVAILABLE_STREAMS = [
EventsStream,
AddonsStream,
CommentsStream,
CouponsStream,
CreditNotesStream,
CustomersStream,
Expand Down
3 changes: 3 additions & 0 deletions tap_chargebee/streams/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
17 changes: 17 additions & 0 deletions tap_chargebee/streams/comments.py
Original file line number Diff line number Diff line change
@@ -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'))