Add App API customer, object, activity, and segment read methods - #81
Open
oke11o wants to merge 2 commits into
Open
Add App API customer, object, activity, and segment read methods#81oke11o wants to merge 2 commits into
oke11o wants to merge 2 commits into
Conversation
Ports the read-side App API endpoints that customerio-node's APIClient already covers but this Go client didn't: customer search/lookup/messages/ activities/relationships/segments/subscription-preferences, bulk customer attributes, the subscription center token endpoint, object attributes/ relationships/search, object type listing, cross-workspace activity listing, segment management (list/create/get/delete/customer_count/ membership/used_by), and subscription topic/channel listing. Request shapes are cross-checked against customerio-node's lib/api.ts and lib/types.ts; response shapes against the published App API OpenAPI spec. Fields the API documents inconsistently as string vs. integer across endpoints (e.g. object_type_id, topic id) are decoded via json.Number rather than a fixed Go type.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 2ad89c4. Configure here.
This was referenced Jul 24, 2026
The list subscription topics endpoint may return topic IDs as either a JSON string or an integer, matching how SubscriptionTopicPreference.ID is already decoded elsewhere in this package. Typing SubscriptionTopic.ID as a plain int made ListSubscriptionTopics fail JSON unmarshaling on string-encoded IDs. Use json.Number for consistent, lenient decoding. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
APIClientcurrently only exposes the write/send side of the App API (SendEmail,SendPush,SendSMS,SendInApp,SendInboxMessage,TriggerBroadcast). This adds the read-side methods that the Node SDK'sAPIClientalready covers:SearchCustomers,GetCustomersByEmail,GetAttributes,GetCustomerActivities,GetCustomerMessages,GetCustomerRelationships,GetCustomerSegments,GetCustomerSubscriptionPreferences,GetCustomersAttributes(bulk),GetSubscriptionCenterTokenGetObjectAttributes,GetObjectRelationships,FindObjects,ListObjectTypesListActivitiesListSegments,CreateSegment,GetSegment,DeleteSegment,GetSegmentCustomerCount,GetSegmentMembership,GetSegmentUsedByListSubscriptionTopics,ListSubscriptionChannelsSearchCustomersandFindObjectstake a composable filter (AudienceFilter/ObjectFilter, built viaFilterBySegment/FilterByAttribute/FilterAnd/FilterOr/FilterNotand theirObjectFilter*counterparts) mirroring the Node SDK'sAudienceFilter/ObjectFilterunion types, flattened to a single struct since Go has no union types.Notes on shapes
customerio-node'slib/api.ts/lib/types.ts.object_type_id, a subscription topic'sid. Those are decoded viajson.Numberrather than a fixed type so either representation round-trips.GetCustomerMessages/GetCustomerActivitiesaccept anIDTypeoption (id/email/cio_id), matching the Node SDK — this lets a caller look a customer up by email directly instead of a separate search call first.Test plan
go build ./...go vet ./...go test ./...golangci-lint run ./...(v2.11.3, matching this repo's CI)Note
Low Risk
Additive SDK surface and shared HTTP helpers; segment delete is the only mutating new call, with validation and tests. No changes to existing send/auth paths.
Overview
Expands
APIClientbeyond send/trigger APIs with read-side Customer.io App API coverage aligned to the Node SDK: customer search and profiles, objects, workspace activities, segments (including create/delete), and subscription topic/channel listing.Shared plumbing adds
doJSONonAPIClient(marshal/unmarshal plus configurable success statuses), aqueryBuilderinurl.gothat omits zero-value query params,PaginationOptions, and composableAudienceFilter/ObjectFilterhelpers forSearchCustomersandFindObjects. Several response fields usejson.Numberwhere the API inconsistently returns string vs integer IDs.HTTP tests use a new
apiServerhelper that records request method, path, and body for assertions.Reviewed by Cursor Bugbot for commit 2784f7d. Bugbot is set up for automated code reviews on this repo. Configure here.