refactor: enhance type safety and add OrderAccountingResponse interface#13
refactor: enhance type safety and add OrderAccountingResponse interface#13TarikSogukpinar wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors and tightens TypeScript typings around order creation/accounting, introducing an explicit OrderAccountingResponse type and expanding several existing request/DTO interfaces to better reflect the API payloads.
Changes:
- Add
OrderAccountingResponseinterface and export it from the public entrypoint. - Update
TapsilatSDK.orderAccounting()to return a typedOrderAccountingResponse(and adjust the unit test mock accordingly). - Expand multiple order-related types (e.g.,
OrderCreateRequest,BasketItem,BillingAddress,Buyer, and related DTOs) with additional optional fields.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/types/index.ts |
Expands order-related request/DTO shapes and adds OrderAccountingResponse. |
src/TapsilatSDK.ts |
Updates orderAccounting() typing to return OrderAccountingResponse. |
src/index.ts |
Re-exports OrderAccountingResponse from the package entrypoint. |
src/__tests__/TapsilatSDK.test.ts |
Updates the mocked accounting response payload to match the new response type. |
.gitignore |
Adds example.swagger.json to ignored files (but currently with a trailing-space issue). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| currency: Currency; | ||
| shipping_address?: Address; | ||
| checkout_design?: CheckoutDesignDTO; | ||
| shipping_address?: ShippingAddressDTO; | ||
| basket_items?: BasketItem[]; | ||
| billing_address?: BillingAddress; |
There was a problem hiding this comment.
OrderCreateRequest.shipping_address changed from Address to ShippingAddressDTO. This is a breaking typing change for SDK consumers and also narrows/remodels the allowed fields (e.g., district/contact_phone no longer allowed, while tracking_code/shipping_date become allowed). If backward compatibility matters, consider using a union (Address | ShippingAddressDTO) or introducing a dedicated request type that matches what the API accepts and deprecating the old shape.
| * @param {OrderAccountingRequest} request - Accounting request details | ||
| * @returns {Promise<APIResponse<unknown>>} Promise resolving to the accounting response | ||
| * @returns {Promise<OrderAccountingResponse>} Promise resolving to the accounting response | ||
| * @throws {TapsilatValidationError} When input validation fails | ||
| * @throws {TapsilatError} When API returns an error response | ||
| */ | ||
| async orderAccounting( | ||
| request: OrderAccountingRequest | ||
| ): Promise<APIResponse<unknown>> { | ||
| ): Promise<OrderAccountingResponse> { | ||
|
|
There was a problem hiding this comment.
orderAccounting() return type changed from Promise<APIResponse<unknown>> to Promise<OrderAccountingResponse>, which is a breaking change for callers that previously relied on the wrapper shape. If this SDK follows semver, this should be called out in changelog/release notes (or consider returning APIResponse<OrderAccountingResponse> if the intent is to preserve the wrapper).
…ing method return types
…aces and updating related methods
…OrderResponse interfaces, and update cancelOrder method accordingly
…ing method return types in TapsilatSDK
…pdating existing method return types in TapsilatSDK
…rfaces, and updating method signatures in TapsilatSDK
No description provided.