Class: Stellae::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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, options = {})
  raise "Username is required" unless username
  raise "Password is required" unless password

  @username = username
  @password = password
  @options  = default_options.merge!(options)
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



14
15
16
# File 'lib/stellae/client.rb', line 14

def password
  @password
end

#request_uriObject

Returns the value of attribute request_uri.



14
15
16
# File 'lib/stellae/client.rb', line 14

def request_uri
  @request_uri
end

#responseObject

Returns the value of attribute response.



14
15
16
# File 'lib/stellae/client.rb', line 14

def response
  @response
end

#typeObject

Returns the value of attribute type.



14
15
16
# File 'lib/stellae/client.rb', line 14

def type
  @type
end

#usernameObject

Returns the value of attribute username.



14
15
16
# File 'lib/stellae/client.rb', line 14

def username
  @username
end

Instance Method Details

#get_inventoryObject



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