Class: HermesAPI::DropOffReturnLabel

Inherits:
Base
  • Object
show all
Includes:
ReturnLabelHelper
Defined in:
lib/hermes_api/resources/drop_off_return_label.rb

Constant Summary collapse

DEFAULT_ATTRS =
{
  client_id: "",
  client_name: "",
  child_client_id: "",
  child_client_name: "",
  source_of_request: "",
  collection_routing_request_entries: [{
    customer: {
      address: {
        first_name: "",
        last_name: "",
        house_name: "",
        street_name: "",
        address_line1: "",
        post_code: "",
        city: "",
        region: "",
        country_code: ""
      },
      mobile_phone_no: "",
      email: "",
      customer_reference1: ""
    },
    country_of_origin: ""
  }]
}

Instance Method Summary collapse

Methods included from ReturnLabelHelper

included, #labels, #tracking_numbers

Methods inherited from Base

#initialize, #load, root, #to_xml, with_session

Constructor Details

This class inherits a constructor from HermesAPI::Base

Instance Method Details

#request_print_in_store_qr_code(**attrs) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/hermes_api/resources/drop_off_return_label.rb', line 87

def request_print_in_store_qr_code(**attrs)
  if missing_required_qr_code_attributes?(attrs)
    raise ArgumentError, request_print_in_store_qr_code_error_message
  end

  return nil if attributes["routing_response_entries"].blank?

  entries = routing_response_entries.routing_response_entry
  entry = entries.is_a?(Array) ? entries[0] : entries
  carrier = entry.inbound_carriers.carrier1
  barcode = carrier.barcode1
  customer = collection_routing_request_entries[0].customer
  address = customer.address

  self.print_in_store_qr_code = PrintInStoreQrCode.create(
    customer: {
      customer_reference1: customer.customer_reference1
    },
    label_type: "RETURN",
    barcode: {
      barcode: barcode.barcode_number,
      barcode_display: barcode.barcode_display
    },
    client: {
      client_id: client_id,
      client_name: client_name
    },
    routing: {
      delivery_method: {
        delivery_method_id: carrier.delivery_method_code,
        delivery_method_description: carrier.delivery_method_desc
      },
      sort_levels: {
        sort_level1: carrier.sort_level1.strip,
        sort_level2: carrier.sort_level2
      }
    },
    service_offers: [],
    **attrs
  )
end