Class: Lipseys::Inventory
Constant Summary collapse
- API_URL =
'https://www.lipseys.com/API/pricequantitycatalog.ashx'
Class Method Summary collapse
- .all(options = {}, &block) ⇒ Object
- .get_quantity_file(options = {}) ⇒ Object
- .quantity(options = {}, &block) ⇒ Object
Instance Method Summary collapse
- #all(&block) ⇒ Object
- #get_quantity_file ⇒ Object
-
#initialize(options = {}) ⇒ Inventory
constructor
A new instance of Inventory.
Constructor Details
#initialize(options = {}) ⇒ Inventory
Returns a new instance of Inventory.
6 7 8 9 10 |
# File 'lib/lipseys/inventory.rb', line 6 def initialize( = {}) requires!(, :username, :password) @options = end |
Class Method Details
.all(options = {}, &block) ⇒ Object
12 13 14 |
# File 'lib/lipseys/inventory.rb', line 12 def self.all( = {}, &block) new().all &block end |
.get_quantity_file(options = {}) ⇒ Object
20 21 22 |
# File 'lib/lipseys/inventory.rb', line 20 def self.get_quantity_file( = {}) new().get_quantity_file end |
.quantity(options = {}, &block) ⇒ Object
16 17 18 |
# File 'lib/lipseys/inventory.rb', line 16 def self.quantity( = {}, &block) new().all &block end |
Instance Method Details
#all(&block) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/lipseys/inventory.rb', line 24 def all(&block) tempfile = stream_to_tempfile(API_URL, @options) Lipseys::Parser.parse(tempfile, 'Item') do |node| yield map_hash(node) end tempfile.unlink end |
#get_quantity_file ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/lipseys/inventory.rb', line 34 def get_quantity_file quantity_tempfile = stream_to_tempfile(API_URL, @options) tempfile = Tempfile.new Lipseys::Parser.parse(quantity_tempfile, 'Item') do |node| tempfile.puts("#{content_for(node, 'ItemNo')},#{content_for(node, 'QtyOnHand')}") end quantity_tempfile.unlink tempfile.close tempfile.path end |