Skip to content

Commit

Permalink
Merge pull request #98 from ins429/handle-202-http-status
Browse files Browse the repository at this point in the history
Parser to handle 202 http status
  • Loading branch information
danielberkompas committed Oct 18, 2018
2 parents 7f1f460 + 1468f9c commit 83fd26d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ex_twilio/parser.ex
Expand Up @@ -99,7 +99,7 @@ defmodule ExTwilio.Parser do
%{body: body, status_code: status} when status in [200, 201] ->
{:ok, fun.(body)}

%{body: _, status_code: 204} ->
%{body: _, status_code: status} when status in [202, 204] ->
:ok

%{body: body, status_code: status} ->
Expand Down
5 changes: 5 additions & 0 deletions test/ex_twilio/parser_test.exs
Expand Up @@ -23,6 +23,11 @@ defmodule ExTwilio.ParserTest do
assert :ok == parse(response, Resource)
end

test ".parse should return :ok when response is 202 'Accepted'" do
response = %{body: "", status_code: 202}
assert :ok == parse(response, Resource)
end

test ".parse_list should decode into a list of named structs" do
json = """
{
Expand Down

0 comments on commit 83fd26d

Please sign in to comment.