class Newgistics::Requests::UpdateShipmentAddress
Attributes
response_handler[R]
shipment_address_update[R]
Public Class Methods
new(shipment_address_update, response_handler: nil)
click to toggle source
# File lib/newgistics/requests/update_shipment_address.rb, line 6 def initialize(shipment_address_update, response_handler: nil) @shipment_address_update = shipment_address_update @response_handler = response_handler || default_response_handler end
Public Instance Methods
body()
click to toggle source
# File lib/newgistics/requests/update_shipment_address.rb, line 15 def body xml_builder.to_xml end
path()
click to toggle source
# File lib/newgistics/requests/update_shipment_address.rb, line 11 def path '/update_shipment_address.aspx' end
perform()
click to toggle source
# File lib/newgistics/requests/update_shipment_address.rb, line 19 def perform Newgistics.api.post(self, response_handler) end
Private Instance Methods
api_key()
click to toggle source
# File lib/newgistics/requests/update_shipment_address.rb, line 61 def api_key Newgistics.configuration.api_key end
default_response_handler()
click to toggle source
# File lib/newgistics/requests/update_shipment_address.rb, line 25 def default_response_handler ResponseHandlers::UpdateShipmentAddress.new(shipment_address_update) end
shipment_address_update_attributes()
click to toggle source
# File lib/newgistics/requests/update_shipment_address.rb, line 65 def shipment_address_update_attributes { apiKey: api_key, id: shipment_address_update.id, orderID: shipment_address_update.order_id }.reject { |_k, v| v.nil? || v.empty? } end
shipment_address_update_xml(xml)
click to toggle source
# File lib/newgistics/requests/update_shipment_address.rb, line 35 def shipment_address_update_xml(xml) xml.updateShipment(shipment_address_update_attributes) do xml_field(xml, 'FirstName', :first_name) xml_field(xml, 'LastName', :last_name) xml_field(xml, 'Company', :company) xml_field(xml, 'Address1', :address1) xml_field(xml, 'Address2', :address2) xml_field(xml, 'City', :city) xml_field(xml, 'State', :state) xml_field(xml, 'PostalCode', :postal_code) xml_field(xml, 'Country', :country) xml_field(xml, 'Email', :email) xml_field(xml, 'Phone', :phone) xml_field(xml, 'Fax', :fax) xml_field(xml, 'IsResidential', :is_residential) xml_field(xml, 'Status', :status) xml_field(xml, 'StatusNotes', :status_notes) xml_field(xml, 'ShipMethod', :ship_method) end end
xml_builder()
click to toggle source
# File lib/newgistics/requests/update_shipment_address.rb, line 29 def xml_builder Nokogiri::XML::Builder.new do |xml| shipment_address_update_xml(xml) end end
xml_field(xml, xml_node, attribute_name)
click to toggle source
# File lib/newgistics/requests/update_shipment_address.rb, line 56 def xml_field(xml, xml_node, attribute_name) value = shipment_address_update.send(attribute_name) xml.send(xml_node, value) unless value.nil? end