Skip to content

HTTP and Networking Protocol Oriented Programming#380

Open
sshropshire wants to merge 11 commits intov3-betafrom
http_protocol_oriented_programming
Open

HTTP and Networking Protocol Oriented Programming#380
sshropshire wants to merge 11 commits intov3-betafrom
http_protocol_oriented_programming

Conversation

@sshropshire
Copy link
Copy Markdown
Collaborator

@sshropshire sshropshire commented Mar 31, 2026

Summary of changes

  • Create HTTPClient protocol and NetworkingClient protocol to adhere to the best practice of Protocol Oriented Programming.
  • Rename HTTP to HTTPNetworkingClient
  • Simplify MockHTTPClient and MockNetworkingClient by making them implement the new protocols rather than subclassing concrete types.

Checklist

  • Added a changelog entry

Authors

List GitHub usernames for everyone who contributed to this pull request.

sshropshire and others added 9 commits March 31, 2026 13:24
Introduce an HTTPClient protocol that defines the interface for performing HTTP requests, mirroring the existing HTTP class API. This is the first step toward adopting protocol-oriented programming in the networking layer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update NetworkingClient to depend on the HTTPClient protocol instead of
the concrete HTTP class, enabling dependency injection with any conforming
type. HTTP class now explicitly conforms to HTTPClient.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rename the class and file across all source references to better reflect
its role as the HTTP-based networking client implementation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract a NetworkingClient protocol from HTTPNetworkingClient and update
all source files to depend on the protocol instead of the concrete type,
enabling dependency injection with any conforming implementation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Align test files with the HTTPClient and NetworkingClient protocol
changes. MockHTTP now conforms to HTTPClient directly instead of
subclassing HTTP. Test setup methods updated to use new initializers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rename the concrete HTTP class to URLSessionHTTPClient to clearly
describe its implementation detail and follow the naming convention
of Protocol / ConcreteClient (HTTPClient / URLSessionHTTPClient).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread Sources/CorePayments/Networking/HTTPNetworkingClient.swift Outdated
Comment thread Sources/CorePayments/Networking/HTTPNetworkingClient.swift Outdated
Copy link
Copy Markdown
Collaborator

@MikeThorntonPayPal MikeThorntonPayPal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there may be some conflicts with feature/app-switch. That branch added ContentType support on RESTRequest for the OAuth token endpoint and an additionalHeaders param on the GraphQL fetch for passing a Bearer token. Neither appears to be currently accounted for in HTTPNetworkingClient or the NetworkingClient protocol here.

@sshropshire
Copy link
Copy Markdown
Collaborator Author

I think there may be some conflicts with feature/app-switch.

Yeah that checks out feature/app-switch still hasn't been merged in. Depending on order of operations either the app switch branch will need to be rebased on top of main or this branch will, depending on whichever gets merged first.

@sshropshire sshropshire changed the base branch from main to v3-beta April 15, 2026 20:38
@sshropshire sshropshire marked this pull request as ready for review April 15, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants