Skip to content

Commit

Permalink
Provide full url to process_page when there is more than 50 entries.
Browse files Browse the repository at this point in the history
The previous variable next_page_uri was returning the end point

`/2010-04-01/Accounts/xxxxxxx/Messages.json`

and causing HTTPotion to raise a HTTPotion.HTTPError because it wasn't a
full url.
  • Loading branch information
rlb3 committed Jun 3, 2016
1 parent 9720bfe commit 66fbe1d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/ex_twilio/result_stream.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ defmodule ExTwilio.ResultStream do
alias ExTwilio.Api
alias ExTwilio.Parser
alias ExTwilio.UrlGenerator
alias ExTwilio.Config

@type url :: String.t

Expand All @@ -27,7 +28,7 @@ defmodule ExTwilio.ResultStream do
## Example
ExTwilio.ResultStream.new(ExTwilio.Call)
ExTwilio.ResultStream.new(ExTwilio.Call)
"""
def new(module, options \\ []) do
url = UrlGenerator.build_url(module, nil, options)
Expand All @@ -52,13 +53,15 @@ defmodule ExTwilio.ResultStream do
{:halt, nil}
end

defp process_page({nil, next_page_url, module}) do
next_page_url
defp process_page({nil, next_page_uri, module}) do
next_page_url(next_page_uri)
|> fetch_page(module)
|> process_page
end

defp process_page({items, next_page_url, module}) do
{items, {nil, next_page_url, module}}
end

defp next_page_url(uri), do: "https://#{Config.api_domain}" <> uri
end

0 comments on commit 66fbe1d

Please sign in to comment.