Class: Stellae::Client
- Inherits:
-
Object
- Object
- Stellae::Client
- Defined in:
- lib/stellae/client.rb
Constant Summary collapse
- PORT =
443- TEST_HOST =
"webservice.stellae.us"- TEST_PATH =
"/SIIServices/Siiservice.svc?wsdl"- LIVE_HOST =
"www.stellae.us"- LIVE_PATH =
"/webservices/SIIService.svc?wsdl"- KEYS_MAP =
{ "on_hand" => "qty" }
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#request_uri ⇒ Object
Returns the value of attribute request_uri.
-
#response ⇒ Object
Returns the value of attribute response.
-
#type ⇒ Object
Returns the value of attribute type.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #get_inventory ⇒ Object
-
#initialize(username, password, options = {}) ⇒ Client
constructor
A new instance of Client.
- #mapped_inventory(upcs, inventory) ⇒ Object
- #order_request(order) ⇒ Object
- #send_order_request(order) ⇒ Object
- #upcs(inventory) ⇒ Object
Constructor Details
#initialize(username, password, options = {}) ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 22 23 |
# File 'lib/stellae/client.rb', line 16 def initialize(username, password, = {}) raise "Username is required" unless username raise "Password is required" unless password @username = username @password = password = .merge!() end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
14 15 16 |
# File 'lib/stellae/client.rb', line 14 def password @password end |
#request_uri ⇒ Object
Returns the value of attribute request_uri.
14 15 16 |
# File 'lib/stellae/client.rb', line 14 def request_uri @request_uri end |
#response ⇒ Object
Returns the value of attribute response.
14 15 16 |
# File 'lib/stellae/client.rb', line 14 def response @response end |
#type ⇒ Object
Returns the value of attribute type.
14 15 16 |
# File 'lib/stellae/client.rb', line 14 def type @type end |
#username ⇒ Object
Returns the value of attribute username.
14 15 16 |
# File 'lib/stellae/client.rb', line 14 def username @username end |
Instance Method Details
#get_inventory ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/stellae/client.rb', line 34 def get_inventory request = Inventory.new(self).build_inventory_request response = post(request) result = response.result['Inventory_values'][0]['UPC_Inventory_Response'] return nil if result.blank? map_results(result) end |
#mapped_inventory(upcs, inventory) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/stellae/client.rb', line 46 def mapped_inventory(upcs, inventory) inventory.collect do |stock| if upcs.include?(stock["upc"]) { quantity: stock["qty"].to_i } end end.compact end |
#order_request(order) ⇒ Object
30 31 32 |
# File 'lib/stellae/client.rb', line 30 def order_request(order) Order.new(self).build_order_request(order) end |
#send_order_request(order) ⇒ Object
25 26 27 28 |
# File 'lib/stellae/client.rb', line 25 def send_order_request(order) request = Order.new(self).build_order_request(order) response = post(request) end |
#upcs(inventory) ⇒ Object
42 43 44 |
# File 'lib/stellae/client.rb', line 42 def upcs(inventory) inventory.collect { |s| s["upc"] } end |