Class: Postmates::Client

Inherits:
Object
  • Object
show all
Includes:
Configuration, Connection, Request
Defined in:
lib/postmates/client.rb

Constant Summary

Constants included from Configuration

Postmates::Configuration::DEFAULT_API_URL, Postmates::Configuration::DEFAULT_HEADERS, Postmates::Configuration::VALID_CONFIGURATION_KEYS

Instance Method Summary collapse

Methods included from Configuration

#configure, #reset

Methods included from Request

#get, #post

Constructor Details

#initializeClient

Returns a new instance of Client.



11
12
13
# File 'lib/postmates/client.rb', line 11

def initialize
  reset
end

Instance Method Details

#cancel(delivery_id) ⇒ Object

POST /v1/customers/:customer_id/deliveries/:delivery_id/cancel

Returns a Delivery object or the raw Faraday response if raw_response = true



69
70
71
# File 'lib/postmates/client.rb', line 69

def cancel(delivery_id)
  post("customers/#{customer_id}/deliveries/#{delivery_id}/cancel")
end

#create(options = {}) ⇒ Object

POST /v1/customers/:customer_id/deliveries

manifest=“a box of kittens” pickup_name=“The Warehouse” pickup_address=“20 McAllister St, San Francisco, CA” pickup_phone_number=“555-555-5555” pickup_business_name=“Optional Pickup Business Name, Inc.” pickup_notes=“Optional note that this is Invoice #123” dropoff_name=“Alice” dropoff_address=“101 Market St, San Francisco, CA” dropoff_phone_number=“415-555-1234” dropoff_business_name=“Optional Dropoff Business Name, Inc.” dropoff_notes=“Optional note to ring the bell” quote_id=qUdje83jhdk

Returns a Delivery object or the raw Faraday response if raw_response = true



43
44
45
# File 'lib/postmates/client.rb', line 43

def create(options = {})
  post("customers/#{customer_id}/deliveries", options)
end

#list(options = {}) ⇒ Object

GET /v1/customers/:customer_id/deliveries

?filter=ongoing

Returns a list of Delivery objects or the raw Faraday response if raw_response = true



53
54
55
# File 'lib/postmates/client.rb', line 53

def list(options = {})
  get("customers/#{customer_id}/deliveries", options)
end

#quote(options = {}) ⇒ Object

POST /v1/customers/:customer_id/delivery_quotes

pickup_address=“20 McAllister St, San Francisco, CA” dropoff_address=“101 Market St, San Francisco, CA”

Returns a Quote object or the raw Faraday response if raw_response = true



22
23
24
# File 'lib/postmates/client.rb', line 22

def quote(options = {})
  post("customers/#{customer_id}/delivery_quotes", options)
end

#retrieve(delivery_id) ⇒ Object

GET /v1/customers/:customer_id/deliveries/:delivery_id

Returns a Delivery object or the raw Faraday response if raw_response = true



61
62
63
# File 'lib/postmates/client.rb', line 61

def retrieve(delivery_id)
  get("customers/#{customer_id}/deliveries/#{delivery_id}")
end

#return(delivery_id) ⇒ Object

POST /v1/customers/:customer_id/deliveries/:delivery_id/return

Returns a Delivery object or the raw Faraday response if raw_response = true



77
78
79
# File 'lib/postmates/client.rb', line 77

def return(delivery_id)
  post("customers/#{customer_id}/deliveries/#{delivery_id}/return")
end