Expand PurchaseBuilder with all missing API fields#16
Merged
Conversation
Add fluent methods for every field defined in the CHIP Collect OpenAPI spec that was previously only accessible via direct model assignment: - Top-level Purchase: clientId, sendReceipt, skipCapture, forceRecurring, reference, issued, due, creatorAgent, platform, tags - PurchaseDetails: notes, debt, subtotalOverride, totalTaxOverride, totalDiscountOverride, totalOverride, requestClientDetails, timezone, dueStrict, emailMessage, shippingOptions, paymentMethodDetails, hasUpsellProducts, singleAttempt, metadata - ClientDetails: clientPersonalCode, clientStreetAddress, clientCountry, clientCity, clientZipCode, clientState, clientShippingStreetAddress, clientShippingCountry, clientShippingCity, clientShippingZipCode, clientShippingState, clientCc, clientBcc, clientLegalName, clientBrandName, clientRegistrationNumber, clientTaxNumber, clientBankAccount, clientBankCode - Product: extend addProduct() with optional discount, taxPercent, category, totalPriceOverride Also add comprehensive test coverage for all new methods. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
azuddin
approved these changes
May 18, 2026
- Remove nullable types from builder methods where model properties are typed as non-nullable (clientId, due, subtotalOverride, totalTaxOverride, totalDiscountOverride, totalOverride) - Add array value type annotations to array-typed parameters (tags, clientCc, clientBcc, requestClientDetails, shippingOptions, paymentMethodWhitelist) - Remove assertNull tests for properties that cannot be null per model types - Add CHANGELOG.md entry documenting all new builder methods Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <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.
What does this change?
This PR brings the
PurchaseBuilderinto full parity with the CHIP Collect OpenAPI specification. Previously, the SDK's fluent interface was incomplete, forcing developers to manually assign values to model properties, which bypassed type safety and led to inconsistent code styles.Key technical changes:
clientId,sendReceipt,skipCapture,forceRecurring,reference,issued,due,creatorAgent,platform,tags, andpaymentMethodWhitelist.notes,debt,subtotalOverride,totalTaxOverride,totalDiscountOverride,totalOverride,requestClientDetails,timezone,dueStrict,emailMessage,shippingOptions,paymentMethodDetails,hasUpsellProducts,singleAttempt, andmetadata.cc,bcc), and corporate identity fields (legal name, registration, tax numbers, bank details).addProduct()method signature has been extended to support optional fields (discount,tax_percent,category,total_price_override).quantityfield to be handled as a string. This aligns with the API's expectation for high-precision decimals and prevents floating-point rounding issues during serialization.ensureClient()within the builder to manage nestedClientDetailsobjects, ensuring the fluent API remains clean without requiring the developer to instantiate nested models manually.Asana / Jira / Trello task link
How to test
testTopLevelPurchaseFields: Verifies mapping of root-level properties.testPurchaseDetailsFields: Verifies overrides and metadata nesting.testClientDetailsFields&testNullableClientDetailsFields: Validates theClientDetailsobject construction and handling ofnullvalues for optional states/bank codes.testProductWithAllFields: Confirms the new optional parameters inaddProductmap to theProductmodel correctly.testClientIsCreatedOnlyOnce: Ensures theensureClient()logic preserves state across multiple calls.Potential Risks & Senior Review Items
addProduct()now has four additional optional parameters. While this is backward compatible for positional arguments, it may affect consumers using reflection or specific interceptors.PurchaseBuilder.php(e.g.,total_tax_override,shipping_street_address) against the official CHIP Collect API docs to ensure no typos were introduced in the mapping logic.quantityis now strictly cast tostring. Verify that existing integrations expectingfloatin the resulting model object (though unlikely for a builder) are not negatively impacted.ensureClient()pattern to confirm that calling multipleclient*methods sequentially correctly modifies the sameClientDetailsinstance.Is this PR warrant an automatic approval?
No. While many of the additions are boilerplate setters, the sheer volume of new fields and the modification of the
addProductsignature require a manual sanity check to ensure architectural consistency and API alignment.Images