Skip to content

sdk-sync: Add CustomerIO.entity(**kwargs) to customerio/track.py. It posts one v2 entity operation (type, action, identi - #138

Closed
sydneycollins-cio wants to merge 1 commit into
mainfrom
sdk-sync/track-v2-customerio-python
Closed

sydneycollins-cio wants to merge 1 commit into
mainfrom
sdk-sync/track-v2-customerio-python

Conversation

@sydneycollins-cio

Copy link
Copy Markdown

Add CustomerIO.entity() for POST /api/v2/entity

Edge (customerio/edge@af983b4) serves the public POST /api/v2/entity route ("Make a single request"). customerio-node wraps it as TrackClient.entity(), but customerio-python had no equivalent.

Changes

  • customerio/track.py: new entity(**kwargs) method. It posts one v2 operation (type, action, identifiers, attributes, ...) to /api/v2/entity. It builds the URL the same way batch() does, including host and port. It raises CustomerIOException when called with no arguments.

Probe result
entity_identify at edge af983b44: HTTP 200 (proven)

Test output (tail)

_used (tests.test_customerio.TestCustomerIO.test_device_call_last_used) ... ok
test_device_call_valid_platform (tests.test_customerio.TestCustomerIO.test_device_call_valid_platform) ... ok
test_device_delete_call (tests.test_customerio.TestCustomerIO.test_device_delete_call) ... ok
test_entity_call (tests.test_customerio.TestCustomerIO.test_entity_call) ... ok
test_entity_empty_raises (tests.test_customerio.TestCustomerIO.test_entity_empty_raises) ... ok
test_identify_call (tests.test_customerio.TestCustomerIO.test_identify_call) ... ok
test_identify_with_empty_string_raises (tests.test_customerio.TestCustomerIO.test_identify_with_empty_string_raises) ... ok
test_identify_with_none_raises (tests.test_customerio.TestCustomerIO.test_identify_with_none_raises) ... ok
test_identify_with_zero_id (tests.test_customerio.TestCustomerIO.test_identify_with_zero_id) ... ok
test_ids_are_encoded_in_url (tests.test_customerio.TestCustomerIO.test_ids_are_encoded_in_url) ... ok
test_keepalive_socket_options_are_configured_on_adapter (tests.test_customerio.TestCustomerIO.test_keepalive_socket_options_are_configured_on_adapter) ... ok
test_merge_customers_call (tests.test_customerio.TestCustomerIO.test_merge_customers_call) ... ok
test_pageview_call (tests.test_customerio.TestCustomerIO.test_pageview_call) ... ok
test_sanitize (tests.test_customerio.TestCustomerIO.test_sanitize) ... ok
test_sanitize_aware_non_utc_datetime (tests.test_customerio.TestCustomerIO.test_sanitize_aware_non_utc_datetime)
Tz-aware non-UTC datetimes are converted, not silently replaced. ... ok
test_sanitize_deeply_nested (tests.test_customerio.TestCustomerIO.test_sanitize_deeply_nested) ... ok
test_sanitize_list_datetime (tests.test_customerio.TestCustomerIO.test_sanitize_list_datetime) ... ok
test_sanitize_naive_datetime (tests.test_customerio.TestCustomerIO.test_sanitize_naive_datetime)
Naive datetimes are assumed UTC (backward compatible). ... ok
test_sanitize_nested_dict_datetime (tests.test_customerio.TestCustomerIO.test_sanitize_nested_dict_datetime) ... ok
test_sanitize_nested_dict_nan (tests.test_customerio.TestCustomerIO.test_sanitize_nested_dict_nan) ... ok
test_suppress_call (tests.test_customerio.TestCustomerIO.test_suppress_call) ... ok
test_track_anonymous_call (tests.test_customerio.TestCustomerIO.test_track_anonymous_call) ... ok
test_track_anonymous_invite_with_data_dict (tests.test_customerio.TestCustomerIO.test_track_anonymous_invite_with_data_dict) ... ok
test_track_anonymous_with_id (tests.test_customerio.TestCustomerIO.test_track_anonymous_with_id) ... ok
test_track_anonymous_with_timestamp (tests.test_customerio.TestCustomerIO.test_track_anonymous_with_timestamp) ... ok
test_track_call (tests.test_customerio.TestCustomerIO.test_track_call) ... ok
test_track_with_id (tests.test_customerio.TestCustomerIO.test_track_with_id) ... ok
test_track_with_id_and_timestamp (tests.test_customerio.TestCustomerIO.test_track_with_id_and_timestamp) ... ok
test_track_with_invalid_timestamp (tests.test_customerio.TestCustomerIO.test_track_with_invalid_timestamp) ... ok
test_track_with_no_data (tests.test_customerio.TestCustomerIO.test_track_with_no_data) ... ok
test_track_with_timestamp (tests.test_customerio.TestCustomerIO.test_track_with_timestamp) ... ok
test_track_with_zero_customer_id (tests.test_customerio.TestCustomerIO.test_track_with_zero_customer_id) ... ok
test_track_without_id (tests.test_customerio.TestCustomerIO.test_track_without_id) ... ok
test_unsuppress_call (tests.test_customerio.TestCustomerIO.test_unsuppress_call) ... ok
test_track_anonymous_rejects_event_data_keyword_arguments (tests.test_customerio.TestCustomerIOTrackSignatures.test_track_anonymous_rejects_event_data_keyword_arguments) ... ok
test_track_rejects_event_data_keyword_arguments (tests.test_customerio.TestCustomerIOTrackSignatures.test_track_rejects_event_data_keyword_arguments) ... ok

----------------------------------------------------------------------
Ran 62 tests in 3.695s

OK

Reference SDK customerio-node at 7897f4c1d7194752d20721a43eef89f3349f65c2

Label: sdk-sync

…nds the keyword arguments as one operation to `/api/v2/entity` using a POST request, and it builds the URL the same way `batch()` does, including the host and port handling. If you call it with no arguments, it raises `CustomerIOException`, just as the node `entity()` rejects an empty operation. I added two tests, `test_entity_call` and `test_entity_empty_raises`, written like the existing batch test. All 62 tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant