Class: Blastramp::Session
- Inherits:
-
Object
- Object
- Blastramp::Session
- Defined in:
- lib/blastramp/session.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#vendor_access_key ⇒ Object
Returns the value of attribute vendor_access_key.
-
#vendor_code ⇒ Object
Returns the value of attribute vendor_code.
Instance Method Summary collapse
-
#client ⇒ Object
Returns the Savon::Client used to connect to Blastramp.
-
#initialize(vendor_code, vendor_access_key) ⇒ Session
constructor
A new instance of Session.
-
#inventory_counts ⇒ Object
Provides access to the inventory counts.
- #request(ep, action, &block) ⇒ Object
Constructor Details
#initialize(vendor_code, vendor_access_key) ⇒ Session
Returns a new instance of Session.
6 7 8 9 10 |
# File 'lib/blastramp/session.rb', line 6 def initialize(vendor_code, vendor_access_key) self.vendor_code = vendor_code self.vendor_access_key = vendor_access_key self.endpoint = nil end |
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint.
4 5 6 |
# File 'lib/blastramp/session.rb', line 4 def endpoint @endpoint end |
#vendor_access_key ⇒ Object
Returns the value of attribute vendor_access_key.
3 4 5 |
# File 'lib/blastramp/session.rb', line 3 def vendor_access_key @vendor_access_key end |
#vendor_code ⇒ Object
Returns the value of attribute vendor_code.
3 4 5 |
# File 'lib/blastramp/session.rb', line 3 def vendor_code @vendor_code end |
Instance Method Details
#client ⇒ Object
Returns the Savon::Client used to connect to Blastramp
13 14 15 16 17 |
# File 'lib/blastramp/session.rb', line 13 def client @client ||= Savon::Client.new do wsdl.document = self.endpoint end end |
#inventory_counts ⇒ Object
Provides access to the inventory counts
20 21 22 |
# File 'lib/blastramp/session.rb', line 20 def inventory_counts @inventory_counts ||= InventoryCountQuery.new(self) end |
#request(ep, action, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/blastramp/session.rb', line 24 def request(ep, action, &block) self.endpoint = ep response = client.request :soap, action, &block response_hash = response.to_hash action = action.snake_case response_key = "#{action}_response".intern result_key = "#{action}_result".intern if response_hash[response_key] && response_hash[response_key][result_key] response_hash[response_key][result_key] else {} end end |