|
1 | 1 | Create Label From Rate
|
2 | 2 | ======================================
|
3 |
| -When retrieving rates for shipments using the `getRates` method, the returned information contains a `rate_id` property that can be used to purchase a label without having to refill in the shipment information repeatedly. |
| 3 | +[ShipEngine](www.shipengine.com) allows you programmatically create shipping labels. You can use the `create_label_from_rate` to create a shipping label from pre defined shipment information that is persisted in the `rate_id` that is passed to the function. Please see [our docs](https://www.shipengine.com/docs/labels/create-from-rate/) to learn more about creating shipping labels from a rate. |
4 | 4 |
|
5 |
| -> Coming Soon |
| 5 | +Input Parameters |
| 6 | +------------------------------------- |
| 7 | + |
| 8 | +The `create_label_from_rate` method requires a `rate_id` as well as some label details that are detailed in the documentation above. |
| 9 | + |
| 10 | +Output |
| 11 | +-------------------------------- |
| 12 | +The `create_label_from_rate` method returns the label that was created in a response class of ShipEngine::Domain::Labels::CreateFromRate::Response. |
| 13 | + |
| 14 | +Example |
| 15 | +```ruby |
| 16 | +def create_label_from_rate_demo_function() |
| 17 | + client = ShipEngine::Client.new("API-Key") |
| 18 | + |
| 19 | + params = { |
| 20 | + validate_address: "no_validation", |
| 21 | + label_layout: "4x6", |
| 22 | + label_format: "pdf", |
| 23 | + label_download_type: "url", |
| 24 | + display_scheme: "label" |
| 25 | + } |
| 26 | + |
| 27 | + begin |
| 28 | + result = client.create_label_from_rate('se-795684260', params) |
| 29 | + puts result |
| 30 | + rescue ShipEngine::Exceptions::ShipEngineError => err |
| 31 | + puts err |
| 32 | + end |
| 33 | +end |
| 34 | + |
| 35 | +create_label_from_rate_demo_function |
| 36 | +``` |
| 37 | + |
| 38 | +Example Output |
| 39 | +----------------------------------------------------- |
| 40 | + |
| 41 | +### Successful Create Label From Rate Result |
| 42 | +```ruby |
| 43 | +#<ShipEngine::Domain::Labels::CreateFromRate::Response |
| 44 | + @batch_id="", |
| 45 | + @carrier_code="stamps_com", |
| 46 | + @carrier_id="se-423887", |
| 47 | + @charge_event="carrier_default", |
| 48 | + @created_at="2021-08-03T19:52:40.6378591Z", |
| 49 | + @display_scheme="label", |
| 50 | + @form_download=nil, |
| 51 | + @insurance_claim=nil, |
| 52 | + @insurance_cost= |
| 53 | + #<ShipEngine::Domain::Labels::CreateFromRate::Response::MonetaryValue |
| 54 | + @amount=0.0, |
| 55 | + @currency="usd">, |
| 56 | + @is_international=false, |
| 57 | + @is_return_label=false, |
| 58 | + @label_download= |
| 59 | + #<ShipEngine::Domain::Labels::CreateFromRate::Response::LabelDownload |
| 60 | + @href= |
| 61 | + "https://api.shipengine.com/v1/downloads/10/nqQR0gqdkUmd_UWNiRy6Ew/label-75301494.pdf", |
| 62 | + @pdf= |
| 63 | + "https://api.shipengine.com/v1/downloads/10/nqQR0gqdkUmd_UWNiRy6Ew/label-75301494.pdf", |
| 64 | + @png= |
| 65 | + "https://api.shipengine.com/v1/downloads/10/nqQR0gqdkUmd_UWNiRy6Ew/label-75301494.png", |
| 66 | + @zpl= |
| 67 | + "https://api.shipengine.com/v1/downloads/10/nqQR0gqdkUmd_UWNiRy6Ew/label-75301494.zpl">, |
| 68 | + @label_format="pdf", |
| 69 | + @label_id="se-75301494", |
| 70 | + @label_image_id=nil, |
| 71 | + @label_layout="4x6", |
| 72 | + @package_code="package", |
| 73 | + @packages= |
| 74 | + [#<ShipEngine::Domain::Labels::CreateFromRate::Response::Package |
| 75 | + @dimensions= |
| 76 | + #<ShipEngine::Domain::Labels::CreateFromRate::Response::Dimensions |
| 77 | + @height=0.0, |
| 78 | + @length=0.0, |
| 79 | + @unit="inch", |
| 80 | + @width=0.0>, |
| 81 | + @external_package_id=nil, |
| 82 | + @insured_value= |
| 83 | + #<ShipEngine::Domain::Labels::CreateFromRate::Response::MonetaryValue |
| 84 | + @amount=0.0, |
| 85 | + @currency="usd">, |
| 86 | + @label_messages= |
| 87 | + #<ShipEngine::Domain::Labels::CreateFromRate::Response::Package::LabelMessages |
| 88 | + @reference1=nil, |
| 89 | + @reference2=nil, |
| 90 | + @reference3=nil>, |
| 91 | + @package_code="package", |
| 92 | + @tracking_number="9400111899560334170636", |
| 93 | + @weight= |
| 94 | + #<ShipEngine::Domain::Labels::CreateFromRate::Response::Weight |
| 95 | + @unit="ounce", |
| 96 | + @value=1.0>>], |
| 97 | + @rma_number=nil, |
| 98 | + @service_code="usps_first_class_mail", |
| 99 | + @ship_date="2021-08-03T00:00:00Z", |
| 100 | + @shipment_cost= |
| 101 | + #<ShipEngine::Domain::Labels::CreateFromRate::Response::MonetaryValue |
| 102 | + @amount=3.35, |
| 103 | + @currency="usd">, |
| 104 | + @shipment_id="se-144039990", |
| 105 | + @status="completed", |
| 106 | + @trackable=true, |
| 107 | + @tracking_number="9400111899560334170636", |
| 108 | + @tracking_status="in_transit", |
| 109 | + @voided=false, |
| 110 | + @voided_at=nil> |
| 111 | +``` |
0 commit comments