Class: Lipseys::Inventory
Constant Summary collapse
- API_URL =
'https://www.lipseys.com/API/pricequantitycatalog.ashx'
Class Method Summary collapse
- .all(options = {}) ⇒ Object
- .get_quantity_file(options = {}) ⇒ Object
- .quantity(options = {}) ⇒ Object
Instance Method Summary collapse
- #all ⇒ 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 = {}) ⇒ Object
12 13 14 |
# File 'lib/lipseys/inventory.rb', line 12 def self.all( = {}) new().all 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 = {}) ⇒ Object
16 17 18 |
# File 'lib/lipseys/inventory.rb', line 16 def self.quantity( = {}) new().all end |
Instance Method Details
#all ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lipseys/inventory.rb', line 24 def all items = [] tempfile = stream_to_tempfile(API_URL, @options) Lipseys::Parser.parse(tempfile, 'Item') do |node| _map_hash = map_hash(node) items << _map_hash unless _map_hash.nil? end tempfile.unlink items end |
#get_quantity_file ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lipseys/inventory.rb', line 39 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 |