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

Python client notes and call logs API support #86

Merged

Conversation

SoeunSona
Copy link
Contributor

@SoeunSona SoeunSona commented Dec 13, 2023

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

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={})

Customer Notes

chartmogul.CustomerNote.create(config, data={})
chartmogul.CustomerNote.all(config, cursor='aabbcc', per_page=20, customer_uuid='cus_5915ee5a-babd-406b-b8ce-d207133fb4cb')
chartmogul.CustomerNote.retrieve(config, uuid='note_5915ee5a-babd-406b-b8ce-d207133fb4cb')
chartmogul.CustomerNote.patch(config, uuid='note_5915ee5a-babd-406b-b8ce-d207133fb4cb')
chartmogul.CustomerNote.destroy(config, uuid='note_5915ee5a-babd-406b-b8ce-d207133fb4cb')

Copy link

This pull request has been linked to Shortcut Story #55270: Python client notes and call logs API support.

@SoeunSona SoeunSona marked this pull request as ready for review December 13, 2023 12:59
@SoeunSona SoeunSona requested a review from briwa December 13, 2023 12:59
Copy link
Contributor

@briwa briwa left a 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

"DELETE",
"https://api.chartmogul.com/v1/customer_notes/note_00000000-0000-0000-0000-000000000000",
status_code=200,
json=note,
Copy link
Contributor

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

Suggested change
json=note,
json={},

Comment on lines 123 to 127
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, {})
Copy link
Contributor

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

Comment on lines 73 to 76
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)
Copy link
Contributor

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

Comment on lines 17 to 18
customer_uuid = fields.String(allow_none=True)
type = fields.String(allow_none=True)
Copy link
Contributor

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

Comment on lines 20 to 23
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)
Copy link
Contributor

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

)

config = Config("token")
notes = Customer.notes(config, uuid="cus_00000000-0000-0000-0000-000000000000").get()
Copy link
Contributor

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={})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
chartmogul.Customer.createrNote(config, uuid='cus_5915ee5a-babd-406b-b8ce-d207133fb4cb', data={})
chartmogul.Customer.createNote(config, uuid='cus_5915ee5a-babd-406b-b8ce-d207133fb4cb', data={})

Copy link

@kmossco kmossco left a 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 :shipit:

Copy link

codeclimate bot commented Dec 20, 2023

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.

@SoeunSona SoeunSona merged commit e68f1ca into main Dec 20, 2023
9 checks passed
@SoeunSona SoeunSona deleted the soeunlee/sc-55270/python-client-notes-and-call-logs-api-support branch December 20, 2023 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants