Class: Rex11::Client
- Inherits:
-
Object
- Object
- Rex11::Client
- Defined in:
- lib/rex11/client.rb
Constant Summary collapse
- TEST_HOST =
"sync.rex11.com"
- TEST_PATH =
"/ws/v2staging/publicapiws.asmx"
- LIVE_HOST =
"sync.rex11.com"
- LIVE_PATH =
"/ws/v2prod/publicapiws.asmx"
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
Instance Method Summary collapse
- #add_style(item) ⇒ Object
- #authenticate ⇒ Object
- #cancel_pick_ticket(pick_ticket_id) ⇒ Object
- #create_pick_ticket(items, ship_to_address, pick_ticket_options) ⇒ Object
- #create_receiving_ticket(items, receiving_ticket_options) ⇒ Object
-
#initialize(username, password, web_address, testing = false, options = {}) ⇒ Client
constructor
A new instance of Client.
- #parse_cancel_pick_ticket(xml_response) ⇒ Object
- #pick_ticket_by_number(pick_ticket_id) ⇒ Object
- #receiving_ticket_by_receiving_ticket_id(receiving_ticket_id) ⇒ Object
Constructor Details
#initialize(username, password, web_address, testing = false, options = {}) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rex11/client.rb', line 15 def initialize(username, password, web_address, testing = false, = {}) raise "Username is required" unless username raise "Password is required" unless password = { :logging => true, } @options = .update() @username = username @password = password @web_address = web_address @logging = [:logging] @host = testing ? TEST_HOST : LIVE_HOST @path = testing ? TEST_PATH : LIVE_PATH end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
13 14 15 |
# File 'lib/rex11/client.rb', line 13 def auth_token @auth_token end |
Instance Method Details
#add_style(item) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rex11/client.rb', line 49 def add_style(item) require_auth_token xml_request = Builder::XmlMarkup.new xml_request.instruct! xml_request.soap :Envelope, :"xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/", :"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", :"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" do xml_request.soap :Body do xml_request.StyleMasterProductAdd(:xmlns => "http://rex11.com/webmethods/") do |xml_request| xml_request.AuthenticationString(@auth_token) xml_request.products do |xml_request| xml_request.StyleMasterProduct do |xml_request| xml_request.Style(item[:style], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd") xml_request.UPC(item[:upc], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd") xml_request.Size(item[:size], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd") xml_request.Color(item[:color], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd") xml_request.Description(item[:description], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd") xml_request.Price(item[:price], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd") end end end end end parse_add_style_response(commit(xml_request.target!)) end |
#authenticate ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rex11/client.rb', line 34 def authenticate xml = Builder::XmlMarkup.new xml.instruct! xml.soap :Envelope, :"xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/", :"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", :"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" do xml.soap :Body do xml.AuthenticationTokenGet(:xmlns => "http://rex11.com/webmethods/") do |xml| xml.WebAddress(@web_address) xml.UserName(@username) xml.Password(@password) end end end parse_authenticate_response(commit(xml.target!)) end |
#cancel_pick_ticket(pick_ticket_id) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/rex11/client.rb', line 130 def cancel_pick_ticket(pick_ticket_id) require_auth_token xml_request = Builder::XmlMarkup.new xml_request.instruct! xml_request.soap :Envelope, :"xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/", :"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", :"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" do xml_request.soap :Body do xml_request.CancelPickTicket(:xmlns => "http://rex11.com/webmethods/") do |xml_request| xml_request.AuthenticationString(@auth_token) xml_request.PickTicketId(pick_ticket_id) end end end parse_cancel_pick_ticket(commit(xml_request.target!)) end |
#create_pick_ticket(items, ship_to_address, pick_ticket_options) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 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 128 |
# File 'lib/rex11/client.rb', line 73 def create_pick_ticket(items, ship_to_address, ) require_auth_token xml_request = Builder::XmlMarkup.new xml_request.instruct! xml_request.soap :Envelope, :"xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/", :"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", :"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" do xml_request.soap :Body do xml_request.PickTicketAdd(:xmlns => "http://rex11.com/webmethods/") do |xml_request| xml_request.AuthenticationString(@auth_token) xml_request.PickTicket(:xmlns => "http://rex11.com/swpublicapi/PickTicket.xsd") do |xml_request| xml_request.PickTicketNumber([:pick_ticket_id]) xml_request.WareHouse([:warehouse]) xml_request.PaymentTerms([:payment_terms]) xml_request.UseAccountUPS([:use_ups_account]) xml_request.ShipViaAccountNumber([:ship_via_account_number]) xml_request.ShipVia([:ship_via]) xml_request.ShipService([:ship_service]) xml_request.BillingOption([:billing_option]) xml_request.BillToAddress do |xml_request| xml_request.FirstName([:bill_to_address][:first_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.LastName([:bill_to_address][:last_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.CompanyName([:bill_to_address][:company_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Address1([:bill_to_address][:address1], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Address2([:bill_to_address][:address2], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.City([:bill_to_address][:city], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.State([:bill_to_address][:state], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Zip([:bill_to_address][:zip], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Country([:bill_to_address][:country], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Phone([:bill_to_address][:phone], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Email([:bill_to_address][:email], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") end xml_request.ShipToAddress do |xml_request| xml_request.FirstName(ship_to_address[:first_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.LastName(ship_to_address[:last_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.CompanyName(ship_to_address[:company_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Address1(ship_to_address[:address1], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Address2(ship_to_address[:address2], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.City(ship_to_address[:city], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.State(ship_to_address[:state], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Zip(ship_to_address[:zip], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Country(ship_to_address[:country], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Phone(ship_to_address[:phone], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Email(ship_to_address[:email], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") end items.each do |item| xml_request.LineItem do |xml_request| xml_request.UPC(item[:upc], :xmlns => "http://rex11.com/swpublicapi/PickTicketDetails.xsd") xml_request.Quantity(item[:quantity], :xmlns => "http://rex11.com/swpublicapi/PickTicketDetails.xsd") end end end end end end parse_pick_ticket_add_response(commit(xml_request.target!)) end |
#create_receiving_ticket(items, receiving_ticket_options) ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/rex11/client.rb', line 173 def create_receiving_ticket(items, ) require_auth_token xml_request = Builder::XmlMarkup.new xml_request.instruct! xml_request.soap :Envelope, :"xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/", :"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", :"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" do xml_request.soap :Body do xml_request.ReceivingTicketAdd(:xmlns => "http://rex11.com/webmethods/") do |xml_request| xml_request.AuthenticationString(@auth_token) xml_request.receivingTicket(:xmlns => "http://rex11.com/swpublicapi/ReceivingTicket.xsd") do |xml_request| items.each do |item| xml_request.Shipmentitemslist do |xml_request| xml_request.Style(item[:style], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd") xml_request.UPC(item[:upc], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd") xml_request.Size(item[:size], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd") xml_request.Color(item[:color], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd") xml_request.ProductDescription(item[:description], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd") xml_request.ExpectedQuantity(item[:quantity], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd") xml_request.Comments(item[:comments], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd") xml_request.ShipmentType(item[:shipment_type], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd") end xml_request.ShipmentTypelist(item[:shipment_type]) end xml_request.Warehouse([:warehouse]) xml_request.Memo([:memo]) xml_request.Carrier([:carrier]) xml_request.SupplierDetails do |xml_request| xml_request.CompanyName([:supplier][:company_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Address1([:supplier][:address1], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Address2([:supplier][:address2], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.City([:supplier][:city], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.State([:supplier][:state], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Zip([:supplier][:zip], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Country([:supplier][:country], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Phone([:supplier][:phone], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") xml_request.Email([:supplier][:email], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd") end end end end end parse_receiving_ticket_add_response(commit(xml_request.target!)) end |
#parse_cancel_pick_ticket(xml_response) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/rex11/client.rb', line 145 def parse_cancel_pick_ticket(xml_response) response = XmlSimple.xml_in(xml_response, :ForceArray => ["Notification"]) response_content = response["Body"]["CancelPickTicketResponse"]["CancelPickTicketResult"] error_string = parse_error(response_content) if error_string.empty? true else raise error_string end end |
#pick_ticket_by_number(pick_ticket_id) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/rex11/client.rb', line 158 def pick_ticket_by_number(pick_ticket_id) require_auth_token xml_request = Builder::XmlMarkup.new xml_request.instruct! xml_request.soap :Envelope, :"xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/", :"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", :"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" do xml_request.soap :Body do xml_request.GetPickTicketObjectByBarCode(:xmlns => "http://rex11.com/webmethods/") do |xml_request| xml_request.AuthenticationString(@auth_token) xml_request.(pick_ticket_id) end end end (commit(xml_request.target!)) end |
#receiving_ticket_by_receiving_ticket_id(receiving_ticket_id) ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/rex11/client.rb', line 217 def receiving_ticket_by_receiving_ticket_id(receiving_ticket_id) require_auth_token xml_request = Builder::XmlMarkup.new xml_request.instruct! xml_request.soap :Envelope, :"xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/", :"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", :"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" do xml_request.soap :Body do xml_request.GetReceivingTicketObjectByTicketNo(:xmlns => "http://rex11.com/webmethods/") do |xml_request| xml_request.AuthenticationString(@auth_token) xml_request.AsnTicketNumber(receiving_ticket_id) end end end parse_get_receiving_ticket_object_by_ticket_number(commit(xml_request.target!)) end |