-
Notifications
You must be signed in to change notification settings - Fork 296
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
Create encodable for credit cards post #1488
base: v7
Are you sure you want to change the base?
Conversation
…dingKeys for the rest body
…create-encodable-for-credit-cards-post # Conflicts: # Sources/BraintreePayPal/Models/PayPalCheckoutPOSTBody.swift
|
||
import Foundation | ||
|
||
struct CreditCardGraphQLBody: Encodable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this swiftlint disable here instead:
struct CreditCardGraphQLBody: Encodable { | |
// swiftlint:disable nesting | |
struct CreditCardGraphQLBody: Encodable { |
@@ -0,0 +1,139 @@ | |||
// swiftlint:disable nesting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this since we have it below as well
|
||
import Foundation | ||
|
||
struct CreditCardGraphQLBody: Encodable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a docstring for this? Can use /// The POST body for <endpoint_here>
like we have in other files.
#endif | ||
|
||
// swiftlint:disable nesting | ||
struct CreditCardPOSTBody: Encodable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a docstring for this? Can use /// The POST body for <endpoint_here>
like we have in other files.
} | ||
} | ||
|
||
/// POST Body Model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take it or leave it but not sure this comment is helpful. Can likely remove once we add the one to the top of this struct.
] as [String: Any] as NSObject) | ||
let params = card.graphQLParameters() | ||
|
||
XCTAssertEqual(params.variables.input.options.validate, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XCTAssertEqual(params.variables.input.options.validate, false) | |
XCTAssertEqual(params.variables.input.options.validate, false) |
XCTAssertEqual(params.variables.input.creditCard.number, "6111111111111111") | ||
XCTAssertEqual(params.operationName, "TokenizeCreditCard") | ||
XCTAssertNotNil(params.query) | ||
XCTAssertEqual(params.variables.input.options.validate, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XCTAssertEqual(params.variables.input.options.validate, false) | |
XCTAssertEqual(params.variables.input.options.validate, false) |
] | ||
] as [String: Any] as NSObject) | ||
let params = card.graphQLParameters() | ||
printEncodableObject(params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this? It doesn't look like we are using the output.
XCTAssertEqual(params.variables.input.creditCard.number, "8111111111111111") | ||
XCTAssertEqual(params.operationName, "TokenizeCreditCard") | ||
XCTAssertNotNil(params.query) | ||
XCTAssertEqual(params.variables.input.options.validate, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XCTAssertEqual(params.variables.input.options.validate, false) | |
XCTAssertEqual(params.variables.input.options.validate, false) |
@@ -55,6 +56,7 @@ public class MockAPIClient: BTAPIClient { | |||
public override func post(_ path: String, parameters: Encodable, headers: [String: String]? = nil, httpType: BTAPIClientHTTPService = .gateway, completion completionBlock: ((BTJSON?, HTTPURLResponse?, Error?) -> Void)? = nil) { | |||
lastPOSTPath = path | |||
lastPOSTParameters = try? parameters.toDictionary() | |||
lastPOSTEncodableParameters = parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General question. Do we need this? I think the other encodable PRs were using lastPOSTParameters
which converts the Encodable
class to a dictionary so we wouldn't need to change tests. Just trying to make sure I understand why we needed to make large changes to the tests here but not in the other PRs.
|
||
struct CreditCardGraphQLBody: Encodable { | ||
|
||
// MARK: - Internal Properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo we can remove this
var number: String? | ||
var expirationMonth: String? | ||
var cvv: String? | ||
var options: Options? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is causing your integration test failures. CreditCard.options
does not exist in the API. This should be removed and it's correlating struct below. Right now you have options
in 2 places and it actually only exists in Input
at the API layer.
Summary of changes
Move
/credit_cards
POST to Encodable.Checklist
Authors
@warmkesselj
@jwarmkessel