Class: DPD::Shipment

Inherits:
Resource
  • Object
show all
Defined in:
lib/dpd.rb

Overview

Shipments endpoint resource

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

credentials, error_response?, extract_error, parse_response, request

Class Method Details

.find(id) ⇒ DPD::Response

Handles the shipment fetching request

Returns:

  • (DPD::Response)


86
87
88
89
90
# File 'lib/dpd.rb', line 86

def self.find(id)
  params = { shipmentIds: [id] }
  params.merge!(credentials)
  new(request(:post, uri('info'), json: params).values.flatten.first)
end

Instance Method Details

#cancel(comment) ⇒ DPD::Response

Handles the shipment cancellation request

Returns:

  • (DPD::Response)


95
96
97
98
99
100
101
102
# File 'lib/dpd.rb', line 95

def cancel(comment)
  params = { shipmentId: id, comment: comment }
  self.class.request(
    :post,
    self.class.uri('cancel'),
    json: params.merge(self.class.credentials)
  )
end