Created
February 13, 2019 22:16
-
-
Save croz1007/2c47c433702b19a516297081bbb116c4 to your computer and use it in GitHub Desktop.
success_calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule SendRequest do | |
@moduledoc """ | |
First, make sure you add HTTPoison to your mix.exs dependencies: | |
def deps do | |
[{:httpoison, "~> 0.10.0"}] | |
end | |
""" | |
@doc """ | |
# Get a Delivery Quote | |
# POST https://api.postmates.com/v1/customers/cus_LtA36OFbUOmSG-/delivery_quotes | |
""" | |
def request() do | |
url = "https://api.postmates.com/v1/customers/cus_LtA36OFbUOmSG-/delivery_quotes" | |
# ====== Headers ====== | |
headers = [ | |
{"Content-Type", "application/x-www-form-urlencoded"}, | |
{"Authorization", "Basic YzE2YTE0YmYtNTc4Ny00NzI5LTkxMmMtMTVjZjc2YTEzMzg3Og=="}, | |
{"Cookie", "__cfduid=d9dc015c2c763804997b4bcead0231d791550091972"}, | |
] | |
# ====== Query Params ====== | |
params = [ ] | |
# ====== Body ====== | |
body = "pickup_address=855+Grandview+Ave%2C+Columbus%2C+OH%2C+43215&dropoff_address=200+W+Nationwide+Blvd%2C+Columbus%2C+OH%2C+43215" | |
HTTPoison.start() | |
case HTTPoison.post(url, body, headers, params: params) do | |
{:ok, response = %HTTPoison.Response{status_code: status_code, body: body}} -> | |
IO.puts("Response Status Code: #{status_code}") | |
IO.puts("Response Body: #{body}") | |
response | |
{:error, error = %HTTPoison.Error{reason: reason}} -> | |
IO.puts("Request failed: #{reason}") | |
error | |
end | |
end | |
end | |
defmodule SendRequest do | |
@moduledoc """ | |
First, make sure you add HTTPoison to your mix.exs dependencies: | |
def deps do | |
[{:httpoison, "~> 0.10.0"}] | |
end | |
""" | |
@doc """ | |
# Create a Delivery | |
# POST https://api.postmates.com/v1/customers/cus_LtA36OFbUOmSG-/deliveries | |
""" | |
def request() do | |
url = "https://api.postmates.com/v1/customers/cus_LtA36OFbUOmSG-/deliveries" | |
# ====== Headers ====== | |
headers = [ | |
{"Authorization", "Basic YzE2YTE0YmYtNTc4Ny00NzI5LTkxMmMtMTVjZjc2YTEzMzg3Og=="}, | |
{"Content-Type", "application/x-www-form-urlencoded; charset=utf-8"}, | |
{"Cookie", "__cfduid=d9dc015c2c763804997b4bcead0231d791550091972"}, | |
] | |
# ====== Query Params ====== | |
params = [ ] | |
# ====== Body ====== | |
body = "manifest=prescriptions&pickup_address=855+GRandview+Ave+%23110%2C+Columbus%2C+OH%2C+43215&pickup_phone_number=614-555-1212&dropoff_address=200+W+Nationwide+Blvd%2C+Columbus%2C+OH%2C+43215&pickup_name=Test+Person&dropoff_phone_number=614-555-1222&dropoff_name=Patient+Name" | |
HTTPoison.start() | |
case HTTPoison.post(url, body, headers, params: params) do | |
{:ok, response = %HTTPoison.Response{status_code: status_code, body: body}} -> | |
IO.puts("Response Status Code: #{status_code}") | |
IO.puts("Response Body: #{body}") | |
response | |
{:error, error = %HTTPoison.Error{reason: reason}} -> | |
IO.puts("Request failed: #{reason}") | |
error | |
end | |
end | |
end | |
defmodule SendRequest do | |
@moduledoc """ | |
First, make sure you add HTTPoison to your mix.exs dependencies: | |
def deps do | |
[{:httpoison, "~> 0.10.0"}] | |
end | |
""" | |
@doc """ | |
# Get Delivery Zones | |
# GET https://api.postmates.com/v1/delivery_zones | |
""" | |
def request() do | |
url = "https://api.postmates.com/v1/delivery_zones" | |
# ====== Headers ====== | |
headers = [ | |
{"Authorization", "Basic YzE2YTE0YmYtNTc4Ny00NzI5LTkxMmMtMTVjZjc2YTEzMzg3Og=="}, | |
{"Cookie", "__cfduid=d9dc015c2c763804997b4bcead0231d791550091972"}, | |
] | |
# ====== Query Params ====== | |
params = [ ] | |
HTTPoison.start() | |
case HTTPoison.get(url, headers, params: params) do | |
{:ok, response = %HTTPoison.Response{status_code: status_code, body: body}} -> | |
IO.puts("Response Status Code: #{status_code}") | |
IO.puts("Response Body: #{body}") | |
response | |
{:error, error = %HTTPoison.Error{reason: reason}} -> | |
IO.puts("Request failed: #{reason}") | |
error | |
end | |
end | |
end | |
defmodule SendRequest do | |
@moduledoc """ | |
First, make sure you add HTTPoison to your mix.exs dependencies: | |
def deps do | |
[{:httpoison, "~> 0.10.0"}] | |
end | |
""" | |
@doc """ | |
# Get a Delivery | |
# GET https://api.postmates.com/v1/customers/cus_LtA36OFbUOmSG-/deliveries/del_M5HLLD-ylW3qAk | |
""" | |
def request() do | |
url = "https://api.postmates.com/v1/customers/cus_LtA36OFbUOmSG-/deliveries/del_M5HLLD-ylW3qAk" | |
# ====== Headers ====== | |
headers = [ | |
{"Authorization", "Basic YzE2YTE0YmYtNTc4Ny00NzI5LTkxMmMtMTVjZjc2YTEzMzg3Og=="}, | |
{"Cookie", "__cfduid=d9dc015c2c763804997b4bcead0231d791550091972"}, | |
] | |
# ====== Query Params ====== | |
params = [ ] | |
HTTPoison.start() | |
case HTTPoison.get(url, headers, params: params) do | |
{:ok, response = %HTTPoison.Response{status_code: status_code, body: body}} -> | |
IO.puts("Response Status Code: #{status_code}") | |
IO.puts("Response Body: #{body}") | |
response | |
{:error, error = %HTTPoison.Error{reason: reason}} -> | |
IO.puts("Request failed: #{reason}") | |
error | |
end | |
end | |
end | |
defmodule SendRequest do | |
@moduledoc """ | |
First, make sure you add HTTPoison to your mix.exs dependencies: | |
def deps do | |
[{:httpoison, "~> 0.10.0"}] | |
end | |
""" | |
@doc """ | |
# Cancel a Delivery | |
# POST https://api.postmates.com/v1/customers/cus_LtA36OFbUOmSG-/deliveries/del_M5HI921Y6-pPM-/cancel | |
""" | |
def request() do | |
url = "https://api.postmates.com/v1/customers/cus_LtA36OFbUOmSG-/deliveries/del_M5HI921Y6-pPM-/cancel" | |
# ====== Headers ====== | |
headers = [ | |
{"Authorization", "Basic YzE2YTE0YmYtNTc4Ny00NzI5LTkxMmMtMTVjZjc2YTEzMzg3Og=="}, | |
{"Cookie", "__cfduid=d9dc015c2c763804997b4bcead0231d791550091972"}, | |
] | |
# ====== Query Params ====== | |
params = [ ] | |
# ====== Body ====== | |
body = "" | |
HTTPoison.start() | |
case HTTPoison.post(url, body, headers, params: params) do | |
{:ok, response = %HTTPoison.Response{status_code: status_code, body: body}} -> | |
IO.puts("Response Status Code: #{status_code}") | |
IO.puts("Response Body: #{body}") | |
response | |
{:error, error = %HTTPoison.Error{reason: reason}} -> | |
IO.puts("Request failed: #{reason}") | |
error | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment