Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PART 3] Networking Refactor - Add VaultPaymentTokensAPI #188

Merged
merged 21 commits into from
Aug 24, 2023

Conversation

scannillo
Copy link
Collaborator

@scannillo scannillo commented Aug 23, 2023

Reason for changes

Restructure vault w/o purchase graphQL call to use new networking layer & add PPaaS API layer.

Summary of changes

  • Add GraphQL response parsing ability to HTTPResponseParser
  • Move Post body encoding from <PPaaSAPI> layers to APIClient to unify process across GraphQL & Rest requests
    • Require Encodable type in RESTRequest & GraphQLRequests instead of Data
  • Add VaultPaymentTokensAPI PPaaS layer
    • Move vault w/o purchase API call here
  • Tests
    • Remove GraphQLClient_Tests now that GraphQLClient is gone
    • Update HTTPResponseParser_Tests

Next

  • Unit tests for work in prior PRs
  • Move JSONEncoding into custom class
  • Reorganize file structure

Note

  • Tests still expected to fail

Checklist

  • Added a changelog entry

Authors

@scannillo

scannillo and others added 18 commits August 10, 2023 09:57
* Remove Eligibility feature

* remove two types for Eligibility feature
* vault without purchase

* clean up cardClient initializer

* Use associatedType for variables for GraphQLQuery protocol

* moving setuptoken call to demo app

* use APIRequest for merchantServer setupToken request

* use enum for PaymentSourceInput for different payment options

* get request for setup token details

* move graphQL request, responses from Core to Card module

* remove APIRequest use in demo app

* Add VaultCardDelegate for VaultCardResult

* Add payment token creation in demo app

* remove duplicate UpdateSetupTokenQuery.swift

* rename UpdateSetupTokenRequest to UpdateSetupTokenQuery

* added newly named file reference to project

* add mocks for unit tests, pr feedback

* disable swiftlint for multiline query, target for card test

* correct target for MockGraphQLClient

* CardClient vault error tests

* docStrings and CHANGELOG

* PR feedback

* PR feedback

* PR feedback nodoc String for GraphQLQuery requestBody()

* spacing in paymentTokenRequest

* PR feedback

* PR feedback from Jax 8/16/23

* PR feedback from Jax cleanup
…r data in GraphQL request types to prevent double encoding
@scannillo scannillo marked this pull request as ready for review August 23, 2023 14:44
@scannillo scannillo requested a review from a team as a code owner August 23, 2023 14:44
@scannillo
Copy link
Collaborator Author

See slightly updated class diagram:

PPCP iOS Networking (1)

@@ -1,5 +1,5 @@
/// Used to decode the HTTP reponse body of GraphQL requests
struct GraphQLHTTPResponse<T: Codable>: Codable {
/// :nodoc: Used to decode the HTTP reponse body of GraphQL requests
Copy link
Collaborator

Choose a reason for hiding this comment

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

This has 0 relation to this PR, but I wonder if we should consider DocC first for PPCP. 👀

Copy link
Collaborator Author

@scannillo scannillo Aug 23, 2023

Choose a reason for hiding this comment

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

We should give it a whirl! We'll run into that same issue of needing to host a landing page for each of our submodules, right? But it would definitely be easier to start with over BT, I agree!

But in terms of nodoc this doesn't actually do anything in PPCP since it isn't set up with Jazzy. We need to write a ticket to update these to @_documentation(visibility: private) so at least things look good in the Xcode generated docs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ticket for this work - DTPPCPSDK-726

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah - it would be a good test for structure/format since we don't have anything currently. We can start fresh with DocC vs switching from Jazzy down the road. 🎉

Comment on lines +23 to +26
return try parseSuccessResult(data, as: T.self)
} else {
return try parseErrorResult(data, as: T.self)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there ever a case where we couldn't parse the data into either an error or success result?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only case I can think of we wouldn't call this function at all, like for analytics. We aren't calling HTTPResponseParser at all from the TrackingEventsAPI, since we only care if it was a successful status or not.

(Example here & here)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I went back and forth on the best way to write this file to be as DRY as possible and landed on this, but totally open to restructuring/ideas to make it more readable!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Gotcha, I think how you have it makes sense! I was moreso curious about cases where we hit the else block but cannot parse the data into an error result. Not sure if that would ever happen though.

Copy link
Collaborator

@jaxdesmarais jaxdesmarais left a comment

Choose a reason for hiding this comment

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

So close to a beautiful networking layer 🥲

Copy link
Collaborator

@sshropshire sshropshire left a comment

Choose a reason for hiding this comment

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

🔥

@scannillo scannillo force-pushed the networking-refactor-main branch from 77cdc78 to af560e2 Compare August 24, 2023 22:05
@scannillo scannillo merged commit 4e18740 into networking-refactor Aug 24, 2023
@scannillo scannillo deleted the networking-refactor-main branch August 24, 2023 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants