-
Notifications
You must be signed in to change notification settings - Fork 8
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
Python client notes and call logs API support #86
Python client notes and call logs API support #86
Conversation
This pull request has been linked to Shortcut Story #55270: Python client notes and call logs API support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it looks good though I have some feedback on the schema and the test.
Also @SoeunSona could you request for another person to review? I'm not too comfortable with being the lone reviewer for Python since I'm not too fluent in it. You may ask for someone else from Analytics, for example, since they work on Python code too
test/api/test_customer_note.py
Outdated
"DELETE", | ||
"https://api.chartmogul.com/v1/customer_notes/note_00000000-0000-0000-0000-000000000000", | ||
status_code=200, | ||
json=note, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look right; when the note is deleted, it returns {}
instead
json=note, | |
json={}, |
test/api/test_customer_note.py
Outdated
CustomerNote.destroy( | ||
config, uuid="note_00000000-0000-0000-0000-000000000000" | ||
).get() | ||
self.assertEqual(mock_requests.call_count, 1, "expected call") | ||
self.assertEqual(mock_requests.last_request.qs, {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to assert the return value of the .destroy
too for consistency
test/api/test_customer_note.py
Outdated
CustomerNote.create(config, data=createNote).get() | ||
self.assertEqual(mock_requests.call_count, 1, "expected call") | ||
self.assertEqual(mock_requests.last_request.qs, {}) | ||
self.assertEqual(mock_requests.last_request.json(), createNote) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also IMO it's better to assert the return value of .create
instead of asserting the data payload to confirm that the return value matches the mocked data
chartmogul/api/customer_note.py
Outdated
customer_uuid = fields.String(allow_none=True) | ||
type = fields.String(allow_none=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should set allow_none=True
for these fields. Customer note should always belong to a customer and the type
should always be there
chartmogul/api/customer_note.py
Outdated
author_email = fields.String(allow_none=True) | ||
call_duration = fields.Int(allow_none=True) | ||
created_at = fields.DateTime(allow_none=True) | ||
updated_at = fields.DateTime(allow_none=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for author_email
, created_at
and updated_at
test/api/test_customer.py
Outdated
) | ||
|
||
config = Config("token") | ||
notes = Customer.notes(config, uuid="cus_00000000-0000-0000-0000-000000000000").get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also test with other params? e.g. per_page
, cursor
. Reason why I asked is because you defined the URL here:
Customer.notes = CustomerNote._method("all", "get", "/customer_notes?customer_uuid={uuid}", useCallerClass=True) |
and the customer_uuid
is part of the URL. I'm not sure if the parameters would merge correctly with the rest (i.e. would it look like ?customer_uuid=nn&cursor=nn
or ?customer_uuid=nn?cursor=nn
), so maybe it's better to test that
README.md
Outdated
@@ -146,6 +146,8 @@ chartmogul.Customer.connectSubscriptions(config, uuid='cus_5915ee5a-babd-406b-b8 | |||
}) | |||
chartmogul.Customer.contacts(config, uuid='cus_5915ee5a-babd-406b-b8ce-d207133fb4cb', cursor='aabbcc', per_page=20) | |||
chartmogul.Customer.createContact(config, uuid='cus_5915ee5a-babd-406b-b8ce-d207133fb4cb', data={}) | |||
chartmogul.Customer.notes(config, uuid='cus_5915ee5a-babd-406b-b8ce-d207133fb4cb', cursor='aabbcc', per_page=20) | |||
chartmogul.Customer.createrNote(config, uuid='cus_5915ee5a-babd-406b-b8ce-d207133fb4cb', data={}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chartmogul.Customer.createrNote(config, uuid='cus_5915ee5a-babd-406b-b8ce-d207133fb4cb', data={}) | |
chartmogul.Customer.createNote(config, uuid='cus_5915ee5a-babd-406b-b8ce-d207133fb4cb', data={}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small change, and LGTM
Code Climate has analyzed commit c74dfd7 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 98.4% (0.0% change). View more on Code Climate. |
API Specs: https://www.notion.so/chartmogul/API-endpoints-for-adding-notes-call-logs-798b788a08764549a334db5d48d65469?pvs=4
https://app.shortcut.com/chartmogul/story/55270/python-client-notes-and-call-logs-api-support
Customers
Customer Notes