Class: Iupick::Shipment
- Inherits:
-
Object
- Object
- Iupick::Shipment
- Defined in:
- lib/iupick/shipment.rb
Overview
This is the class object for the shipments.
Class Method Summary collapse
-
.add_information(shipment_token, waypoint_id, shipper_address, shipper_contact, recipient_contact, third_party_reference, recipient_address = Iupick.empty_address()) ⇒ Object
This method allows you to fill the information required for the package, and receive a confirmation_token in exchange.
-
.create(length, width, height, weight) ⇒ Object
Allows you to generate a token for the new shipment.
-
.generate_waybill(confirmation_token) ⇒ Object
Generates a waybill, once the information has been properly filled for the shipment.
-
.track(carrier, tracking_number) ⇒ Object
Allows you to track the status of a shipment, with the tracking number and carrier.
Class Method Details
.add_information(shipment_token, waypoint_id, shipper_address, shipper_contact, recipient_contact, third_party_reference, recipient_address = Iupick.empty_address()) ⇒ Object
This method allows you to fill the information required for the package, and receive a confirmation_token in exchange.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/iupick/shipment.rb', line 27 def self.add_information( shipment_token, waypoint_id, shipper_address, shipper_contact, recipient_contact, third_party_reference, recipient_address = Iupick.empty_address() ) waypoint_id = waypoint_id ? waypoint_id : nil; recipient_address = recipient_address ? recipient_address : Iupick.emptyAddress(); if waypoint_id or recipient_address != Iupick.empty_address() url = Iupick.get_base_url() + 'fill-shipment-information/' + shipment_token + '/' headers = Iupick.generate_headers(auth = 'public') payload = { 'waypoint': waypoint_id, 'shipper_address': shipper_address, 'shipper_contact': shipper_contact, 'recipient_address': recipient_address, 'recipient_contact': recipient_contact, 'third_party_reference': third_party_reference } response = Unirest.post url, headers: headers, parameters: payload.to_json decoded_response = response.body['confirmation_token'] return decoded_response end return false end |
.create(length, width, height, weight) ⇒ Object
Allows you to generate a token for the new shipment. Needs weight Needs Dimensions Receive a shipment id.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/iupick/shipment.rb', line 9 def self.create(length, width, height, weight) url = Iupick.get_base_url() + 'create-shipment-token/' headers = Iupick.generate_headers(auth = 'secret') payload = { 'length': length.to_i, 'width': width.to_i, 'height': height.to_i, 'weight': weight.to_i } response = Unirest.post url, headers: headers, parameters: payload.to_json decoded_response = response.body['shipment_token'] end |
.generate_waybill(confirmation_token) ⇒ Object
Generates a waybill, once the information has been properly filled for the shipment.
67 68 69 70 71 72 73 74 75 |
# File 'lib/iupick/shipment.rb', line 67 def self.generate_waybill(confirmation_token) url = Iupick.get_base_url() + 'generate-waybill/' + confirmation_token + '/' headers = Iupick.generate_headers(auth = 'secret') response = Unirest.post url, headers: headers decoded_response = response.body.to_json return decoded_response end |
.track(carrier, tracking_number) ⇒ Object
Allows you to track the status of a shipment, with the tracking number and carrier.
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/iupick/shipment.rb', line 79 def self.track(carrier, tracking_number) url = Iupick.get_base_url() + 'track-shipment/' payload = { 'carrier': carrier, 'tracking_number': tracking_number } headers = Iupick.generate_headers(auth = 'public') response = Unirest.get url, headers: headers, parameters: payload decoded_response = response.body['Message'] end |