Skip to content

Conversation

@armando-rodriguez-cko
Copy link
Contributor

feat: Add Context Support and Improve Readability

Description:

This PR introduces WithContext variants for all publicly exposed methods in the Go SDK clients. These changes provide developers with fine-grained control over timeouts and cancellations using Go’s native context.Context. Additionally, method signatures and calls have been refactored for improved readability and consistency.


Key Changes:

Context Support

  • Added WithContext versions of all public methods across SDK clients.
    • Examples: CreateWithContext, GetWithContext, UpdateWithContext, DeleteWithContext, etc.
  • Existing methods now delegate to their WithContext counterparts using context.Background().

Improved Readability

  • Multi-argument method declarations and calls are now split across multiple lines to improve clarity and reduce merge conflicts.

No Functional Changes

  • All updates are fully backward-compatible.
  • Existing integrations will continue to work without any required code changes.

Impact

  • Better Flexibility: Enables context-aware request management (timeouts, cancellations, etc.).
  • Cleaner Code: Easier to read and maintain.
  • No Breaking Changes: All previous methods remain intact.

Testing

  • Ensured all methods compile and work as expected.
  • Verified WithContext versions internally delegate to the correct context-aware HTTP client functions (PostWithContext, GetWithContext, etc.).
  • Manual validation for backward compatibility.

Notes

  • These changes align the SDK with idiomatic Go practices.
  • Recommended to update usage examples and documentation to promote WithContext versions going forward.

@armando-rodriguez-cko armando-rodriguez-cko requested a review from a team March 21, 2025 13:13
@armando-rodriguez-cko armando-rodriguez-cko linked an issue Mar 21, 2025 that may be closed by this pull request
1 task
@armando-rodriguez-cko armando-rodriguez-cko force-pushed the beta/context-by-jamieaitken branch 3 times, most recently from 3647be0 to f015738 Compare March 28, 2025 10:21
@armando-rodriguez-cko armando-rodriguez-cko force-pushed the beta/context-by-jamieaitken branch from f015738 to e9d71b4 Compare April 3, 2025 08:53
@armando-rodriguez-cko armando-rodriguez-cko force-pushed the beta/context-by-jamieaitken branch from e9d71b4 to 91f3712 Compare April 11, 2025 08:11
@armando-rodriguez-cko
Copy link
Contributor Author

@jamieaitken next week we will release this version, thank you.

@jamieaitken
Copy link

@armando-rodriguez-cko great, thanks for keeping me in the loop!

@armando-rodriguez-cko armando-rodriguez-cko force-pushed the beta/context-by-jamieaitken branch from 91f3712 to b6f1402 Compare April 22, 2025 16:00
@armando-rodriguez-cko
Copy link
Contributor Author

After reviewing and evaluating this PR, it is closed for now due to the need to add more context tests and better cover all areas and endpoints with context. The branch will remain active to add these fixes; we apologise for the inconvenience.

jamieaitken and others added 2 commits November 27, 2025 11:20
* Add Context to HTTP layer

* Add Context to Customers client

* Add Context to Disputes client

* Add Context to Events client

* Add Context to Hosted client

* Add Context to Instruments client

* Add Context to Links client

* Add Context to Payments client

* Add Context to Reconciliation client

* Add Context to Sources client

* Add Context to Tokens client

* Add Context to Webhook client

* Add Context to iDEAL client

* Add Context to Klarna client

* Add Context to SEPA client

* Update tests

* Add Context to NAS Payments

---------

Co-authored-by: Armando Rodríguez <[email protected]>
@sonarqubecloud
Copy link

@armando-rodriguez-cko
Copy link
Contributor Author

@jamieaitken reopened and rebased, we will work on this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Adding context.Context to all API methods

4 participants