Add support for the Global Profile API - #164
Draft
tholovina-sift wants to merge 2 commits into
Draft
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
- Add validate() to GlobalProfileFieldSet throwing MissingFieldException when userId is null/empty (P1) - Type GlobalProfileRequest constructor parameter as GlobalProfileFieldSet instead of raw FieldSet (P2) - Add @Expose/@SerializedName to GlobalProfileFieldSet fields so fromJson() deserializes correctly (P3) - Capture return value and add is_ok()/identity_found assertions to testGlobalProfileLookupByPhone (P4) - Add testLookupIdentityNotFound covering the identity_found=false Lookup response path (P5) - Add assertNull assertions for chargebacks/orders/transactions/locations/lookbackMonths in testIdentityNotFound (P6) - Add Authorization header assertion to testGetGlobalProfileWithoutOptionalParams (P7) - Fix pre-existing test failures: remove null-valued fields from JSONAssert comparison bodies so they match toJson() output (Gson omits nulls by default) Co-Authored-By: Claude <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.
Add support for the Global Profile API
Summary
Sift is launching a new "Global Profile API" that returns cross-tenant identity,
decision, chargeback, order, transaction, and location signals for a user. This PR
adds client support for both of its endpoints, following the existing
FieldSet/SiftRequest/SiftResponseconventions used throughout this SDK(e.g.
GetDecisionsRequest,GetMerchantRequest,ApplyDecisionRequest).What changed
New endpoints
GET /v3/accounts/{accountId}/global_profile/users/{userId}GlobalProfileFieldSet(src/main/java/com/siftscience/model/GlobalProfileFieldSet.java) —carries
userId(path) plus optionalglobalOnly/includeOwnDataquery params.GlobalProfileRequest/GlobalProfileResponse— GET request following theGetDecisionsRequestquery-parameter pattern (only setsglobal_only/include_own_dataon the query string when explicitly provided, letting theserver apply its own defaults otherwise).
POST /v3/accounts/{accountId}/global_profile/lookupGlobalProfileLookupFieldSet(src/main/java/com/siftscience/model/GlobalProfileLookupFieldSet.java) —JSON body with
email/phone. Overridesvalidate()(same pattern asApplyDecisionFieldSet) to throwMissingFieldExceptionclient-side ifboth are missing, so callers get a clear error before any network call.
GlobalProfileLookupRequest/GlobalProfileLookupResponse.SiftClientgains two newbuildRequest(...)overloads for the field setsabove, matching the existing dispatch-by-type convention.
Response model
Both endpoints share
GlobalProfileResponseBody(extendsBaseResponseBody,adds
error_code,lookback_months, and nested objects), plus new supportingmodel classes:
GlobalProfileSummary,GlobalProfileIdentityAge,GlobalProfileUserDecisions,GlobalProfileChargebacks,GlobalProfileOrders,GlobalProfileTransactions,GlobalProfileLocations, andGlobalProfileLocationAccount. All use the repo's@Expose/@SerializedNameGson convention. When
profile_summary.identity_foundisfalse, all otherfields are
null, as documented in the Javadoc onGlobalProfileResponseBody.Tests
GlobalProfileTest— GET happy path with both query params set, GET with nooptional params (verifies they're omitted from the URL), and an
identity_found: falsecase verifying the other fields deserialize tonull.GlobalProfileLookupTest— POST lookup by email, POST lookup by phone(asserts request body), and a client-side validation test asserting
MissingFieldExceptionis thrown when neitheremailnorphoneis set.All tests use the existing
MockWebServer+OkHttpUtils.urlRewritingInterceptorJSONAssertpattern used by the rest of the test suite.Docs
CHANGES.MD: new3.23.0entry (minor bump for the new feature).build.gradle: version bumped to3.23.0.README.md: new "Global Profile API" section with usage examples for bothendpoints, following the style of the existing "Decision Status API" section.
Error handling
No changes were needed to
SiftRequest's error-handlingswitch— thedocumented error codes (
52UNAUTHORIZED,53PERMISSION_DENIED /ENTITLEMENT_REQUIRED,
-4RATE_LIMIT_EXCEEDED,51INVALID_API_KEY,55INVALID_PARAMETER,
-1SERVER_ERROR) are already mapped to the appropriateSiftExceptionsubclasses there.Testing done
GetDecisionsRequest/GetDecisionFieldSet,ApplyDecisionRequest/ApplyDecisionFieldSet,GetMerchantRequest,SiftRequest,SiftResponse,FieldSet, andBaseResponseBodyto keep naming, serialization, andvalidation conventions consistent.
GlobalProfileTest,GlobalProfileLookupTest)covering both endpoints, optional query params, the
identity_found: falseresponse shape, and client-side validation of the lookup endpoint's
required-field rule.
./gradlew build/./gradlew testin this sandbox: theGradle wrapper needs to download the Gradle 8.14 distribution and
dependencies over the network, which is unavailable here. No compiler
errors were spotted during manual review, but a real CI run (e.g. via
/jenkins-teston the PR) is recommended before merge.