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

Error when deleting a charge #24

Closed
DavidVII opened this issue Apr 3, 2018 · 1 comment
Closed

Error when deleting a charge #24

DavidVII opened this issue Apr 3, 2018 · 1 comment
Labels

Comments

@DavidVII
Copy link
Contributor

DavidVII commented Apr 3, 2018

Hello, I got an error when deleting a charge. It appears that the request to cancel works, but the parse_json/2 function in the Response module throws an error.

Shopify.RecurringApplicationCharge.delete(session, 1234)
> no case clause matching: {:error, :invalid, 0}
    (shopify) lib/shopify/response.ex:24: Shopify.Response.parse_json/2
    (shopify) lib/shopify/response.ex:12: Shopify.Response.new/3

It appears that parse_json is being called with the following arguments: parse_json(nil, "")

nil being the resource, and "" is the body.

This results in the following being called here:

Poison.decode("", as: nil)
> {:error, :invalid, 0}

You'll notice the result there is the same as my error above. I'm happy to take a stab at a PR for this, but I'm curious how we might want to handle the response here?

There's no response body from Shopify according to their docs. This seems inconsistent with other DELETE calls where the response body is an empty JSON object.

@Ninigi
Copy link
Collaborator

Ninigi commented Apr 3, 2018

The API is full of inconsistencies, so I am not really surprised ;)
I guess we could just pattern match here and replace empty strings with an empty json object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants