Class: MgeWholesale::Inventory
- Defined in:
- lib/mge_wholesale/inventory.rb
Constant Summary collapse
- INVENTORY_FILENAME =
'exportXML_cq_barcodeFFL.csv'.freeze
- FULL_INVENTORY_FILENAME =
'exportXML_cq_barcodeFFL_all.csv'.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(options = {}) ⇒ Inventory
constructor
A new instance of Inventory.
- #quantity ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ Inventory
Returns a new instance of Inventory.
7 8 9 10 |
# File 'lib/mge_wholesale/inventory.rb', line 7 def initialize( = {}) requires!(, :username, :password) @options = end |
Class Method Details
.all(options = {}) ⇒ Object
12 13 14 15 |
# File 'lib/mge_wholesale/inventory.rb', line 12 def self.all( = {}) requires!(, :username, :password) new().all end |
.quantity(options = {}) ⇒ Object
17 18 19 20 |
# File 'lib/mge_wholesale/inventory.rb', line 17 def self.quantity( = {}) requires!(, :username, :password) new().quantity end |
Instance Method Details
#all ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mge_wholesale/inventory.rb', line 22 def all items = [] tempfile = get_file(INVENTORY_FILENAME) CSV.foreach(tempfile, { headers: :first_row }).each do |row| item = { item_identifier: row['id'], quantity: row['qty'].to_i, price: row['cost'], } items << item end tempfile.unlink items end |
#quantity ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mge_wholesale/inventory.rb', line 41 def quantity items = [] tempfile = get_file(FULL_INVENTORY_FILENAME) CSV.foreach(tempfile, { headers: :first_row }).each do |row| item = { item_identifier: row['id'], quantity: row['qty'].to_i, } items << item end tempfile.unlink items end |