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

Update CardRoutes.swift #36

Merged
merged 7 commits into from
Mar 6, 2020
Merged

Conversation

Maxim-Inv
Copy link
Contributor

to fix error

@Andrewangeta
Copy link
Member

@Maxim-Inv nice catch! Thanks for this. Can you create a simple issue so it can be linked in a change log I’m planning on adding.

@Maxim-Inv
Copy link
Contributor Author

Yes, of course

@Maxim-Inv
Copy link
Contributor Author

I have optimized the converting of byte buffer to data.

@Andrewangeta
Copy link
Member

@Maxim-Inv you don’t need coding keys because on a response we set the key decoding strategy to snake_case so it automatically decodes.

decoder.keyDecodingStrategy = .convertFromSnakeCase

@Maxim-Inv
Copy link
Contributor Author

Great. I tried to catch webhooks and got decoding issues. I will remove it.

Maxim Anisimov added 2 commits March 5, 2020 19:56
This reverts commit 1675dae.
This reverts commit 24a16b2.
@Andrewangeta
Copy link
Member

What errors where you getting?

@Maxim-Inv
Copy link
Contributor Author

TIL this option. Thanks.

@Maxim-Inv
Copy link
Contributor Author

Maxim-Inv commented Mar 5, 2020

  ▿ keyNotFound : 2 elements
    - .0 : CodingKeys(stringValue: "hasMore", intValue: nil)
    ▿ .1 : Context
      ▿ codingPath : 3 elements
        - 0 : CodingKeys(stringValue: "data", intValue: nil)
        - 1 : CodingKeys(stringValue: "object", intValue: nil)
        - 2 : CodingKeys(stringValue: "refunds", intValue: nil)
      - debugDescription : "No value associated with key CodingKeys(stringValue: \"hasMore\", intValue: nil) (\"hasMore\")."
      - underlyingError : nil

@Andrewangeta
Copy link
Member

And what was your actual json structure being returned by the API?

@Maxim-Inv
Copy link
Contributor Author

Maxim-Inv commented Mar 5, 2020

"{\n "id": "evt_1GJKgsHHE5YBFDMsP3ecEJ6W",\n "object": "event",\n "api_version": "2019-12-03",\n "created": 1583418526,\n "data": {\n "object": {\n "id": "ch_1GJKgrHHE5YBFDMsVepexjfX",\n "object": "charge",\n "amount": 100,\n "amount_refunded": 0,\n "application": null,\n "application_fee": null,\n "application_fee_amount": null,\n "balance_transaction": "txn_1GJKgsHHE5YBFDMsW1FB59Ic",\n "billing_details": {\n "address": {\n "city": null,\n "country": null,\n "line1": null,\n "line2": null,\n "postal_code": null,\n "state": null\n },\n "email": null,\n "name": null,\n "phone": null\n },\n "captured": true,\n "created": 1583418525,\n "currency": "usd",\n "customer": null,\n "description": "(created by Stripe CLI)",\n "destination": null,\n "dispute": null,\n "disputed": false,\n "failure_code": null,\n "failure_message": null,\n "fraud_details": {\n },\n "invoice": null,\n "livemode": false,\n "metadata": {\n },\n "on_behalf_of": null,\n "order": null,\n "outcome": {\n "network_status": "approved_by_network",\n "reason": null,\n "risk_level": "normal",\n "risk_score": 39,\n "seller_message": "Payment complete.",\n "type": "authorized"\n },\n "paid": true,\n "payment_intent": null,\n "payment_method": "card_1GJKgrHHE5YBFDMsyrtTU0Ms",\n "payment_method_details": {\n "card": {\n "brand": "visa",\n "checks": {\n "address_line1_check": null,\n "address_postal_code_check": null,\n "cvc_check": null\n },\n "country": "US",\n "exp_month": 3,\n "exp_year": 2021,\n "fingerprint": "DSVlgCD7yApjOAEy",\n "funding": "credit",\n "installments": null,\n "last4": "4242",\n "network": "visa",\n "three_d_secure": null,\n "wallet": null\n },\n "type": "card"\n },\n "receipt_email": null,\n "receipt_number": null,\n "receipt_url": "",\n "refunded": false,\n "refunds": {\n "object": "list",\n "data": [\n\n ],\n "has_more": false,\n "total_count": 0,\n "url": "/v1/charges/ch_1GJKgrHHE5YBFDMsVepexjfX/refunds"\n },\n "review": null,\n "shipping": null,\n "source": {\n "id": "card_1GJKgrHHE5YBFDMsyrtTU0Ms",\n "object": "card",\n "address_city": null,\n "address_country": null,\n "address_line1": null,\n "address_line1_check": null,\n "address_line2": null,\n "address_state": null,\n "address_zip": null,\n "address_zip_check": null,\n "brand": "Visa",\n "country": "US",\n "customer": null,\n "cvc_check": null,\n "dynamic_last4": null,\n "exp_month": 3,\n "exp_year": 2021,\n "fingerprint": "DSVlgCD7yApjOAEy",\n "funding": "credit",\n "last4": "4242",\n "metadata": {\n },\n "name": null,\n "tokenization_method": null\n },\n "source_transfer": null,\n "statement_descriptor": null,\n "statement_descriptor_suffix": null,\n "status": "succeeded",\n "transfer_data": null,\n "transfer_group": null\n }\n },\n "livemode": false,\n "pending_webhooks": 2,\n "request": {\n "id": "req_u3etzWjCjvCgbi",\n "idempotency_key": null\n },\n "type": "charge.succeeded"\n}"

@Andrewangeta
Copy link
Member

Can you format that not as a single line lol

@Andrewangeta Andrewangeta added this to the 5.2.0 milestone Mar 6, 2020
@Andrewangeta
Copy link
Member

@Maxim-Inv Your webhooks data Seemed fine to me. Also I'm not sure why you got a decoding error for that field when all the other fields decode just fine? But this PR looks good so far.

@Andrewangeta Andrewangeta merged commit 1b86232 into vapor-community:master Mar 6, 2020
@Maxim-Inv
Copy link
Contributor Author

I hadn't used decoder.keyDecodingStrategy = .convertFromSnakeCase before. It works fine after I added it.

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.

None yet

2 participants