Class: IntersoftAPI::ShipmentResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/intersoft_api/resources/shipment.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#get_request, #initialize, #post_request, #put_request

Constructor Details

This class inherits a constructor from IntersoftAPI::Resource

Instance Method Details

#all(shipping_location_id, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/intersoft_api/resources/shipment.rb', line 11

def all(shipping_location_id, options = {})
  url = "shipments/#{shipping_location_id}"
  options = options.slice(:shipping_account_id, :carrier_code, :status, :destination_country_code, :date_from, :date_to, :page_size, :page_number)
  options = options.transform_keys { |key| key.to_s.camelize(:lower) }
  url += "?#{options.to_query}" if options.any?

  Shipment.new(get_request(url).body)
end

#create(attributes) ⇒ Object



3
4
5
# File 'lib/intersoft_api/resources/shipment.rb', line 3

def create(attributes)
  Shipment.new(post_request("shipments/rm", body: attributes).body)
end

#generate_label_qr_code(shipment_id) ⇒ Object



7
8
9
# File 'lib/intersoft_api/resources/shipment.rb', line 7

def generate_label_qr_code(shipment_id)
  Shipment.new(get_request("shipments/printMyLabelQRCode/rm/#{shipment_id}").body)
end