Class: TFSO::Product
Constant Summary collapse
- URL =
'https://api.24sevenoffice.com/Logistics/Product/V001/ProductService.asmx?WSDL'
Instance Method Summary collapse
- #find(search_params) ⇒ Object
- #find_by_id(id) ⇒ Object
-
#initialize(auth) ⇒ Product
constructor
A new instance of Product.
Methods included from Helpers
#ensure_authenticated, #intialize_savon_client, #savon_client, #session_id, #session_id=
Constructor Details
#initialize(auth) ⇒ Product
Returns a new instance of Product.
8 9 10 11 12 |
# File 'lib/tfso/product.rb', line 8 def initialize(auth) ensure_authenticated(auth) self.session_id = auth.session_id intialize_savon_client end |
Instance Method Details
#find(search_params) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tfso/product.rb', line 14 def find(search_params) response = savon_client.call(:get_products, message: {searchParams: search_params, returnProperties: {string: ['Id', 'Name', 'Price'] } }, cookies: @cookies) result = response.body[:get_products_response][:get_products_result] if result if result[:product].class == Hash [result[:product]] else result[:product] end else [] end end |
#find_by_id(id) ⇒ Object
28 29 30 31 32 |
# File 'lib/tfso/product.rb', line 28 def find_by_id(id) if product = find(Id: id) product.first end end |