Class: Ruberto::DeliveryResource

Inherits:
Object
  • Object
show all
Defined in:
lib/ruberto/resources/delivery_resource.rb

Class Method Summary collapse

Class Method Details

.all(**params) ⇒ Object



6
7
8
9
10
# File 'lib/ruberto/resources/delivery_resource.rb', line 6

def all(**params)
  response = Request.new("customers/#{Ruberto.customer_id}/deliveries").get(params: params)

  Collection.from_response(response.body, type: Delivery)
end

.cancel(id) ⇒ Object



24
25
26
27
28
# File 'lib/ruberto/resources/delivery_resource.rb', line 24

def cancel(id)
  response = Request.new("customers/#{Ruberto.customer_id}/deliveries/#{id}/cancel").post

  Delivery.new response.body
end

.create(params) ⇒ Object



18
19
20
21
22
# File 'lib/ruberto/resources/delivery_resource.rb', line 18

def create(params)
  response = Request.new("customers/#{Ruberto.customer_id}/deliveries").post(body: params)

  Delivery.new response.body
end

.find(id) ⇒ Object



12
13
14
15
16
# File 'lib/ruberto/resources/delivery_resource.rb', line 12

def find(id)
  response = Request.new("customers/#{Ruberto.customer_id}/deliveries/#{id}").get

  Delivery.new response.body
end

.proof_of_delivery(id, params) ⇒ Object



36
37
38
39
40
# File 'lib/ruberto/resources/delivery_resource.rb', line 36

def proof_of_delivery(id, params)
  response = Request.new("customers/#{Ruberto.customer_id}/deliveries/#{id}/proof_of_delivery").post(body: params)

  Delivery::ProofOfDelivery.new response.body
end

.update(id, params) ⇒ Object



30
31
32
33
34
# File 'lib/ruberto/resources/delivery_resource.rb', line 30

def update(id, params)
  response = Request.new("customers/#{Ruberto.customer_id}/deliveries/#{id}").post(body: params)

  Delivery.new response.body
end