Class: SecondAmendmentWholesale::Inventory

Inherits:
Base
  • Object
show all
Includes:
API
Defined in:
lib/second_amendment_wholesale/inventory.rb

Constant Summary

Constants included from API

API::ROOT_API_URL

Class Method Summary collapse

Instance Method Summary collapse

Methods included from API

#delete_request, #get_request, #post_request, #put_request

Constructor Details

#initialize(options = {}) ⇒ Inventory

Returns a new instance of Inventory.



6
7
8
9
10
11
12
13
14
# File 'lib/second_amendment_wholesale/inventory.rb', line 6

def initialize(options = {})
  requires!(options, :token)

  @options = options
  @headers = [ 
    *auth_header(@options[:token]),
    *content_type_header('application/json'),
  ].to_h
end

Class Method Details

.all(options = {}) ⇒ Object



16
17
18
19
20
# File 'lib/second_amendment_wholesale/inventory.rb', line 16

def self.all(options = {})
  requires!(options, :token)

  new(options).all
end

.quantityObject



21
22
23
24
25
# File 'lib/second_amendment_wholesale/inventory.rb', line 21

def self.all(options = {})
  requires!(options, :token)

  new(options).all
end

Instance Method Details

#allObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/second_amendment_wholesale/inventory.rb', line 23

def all
  items = []

  response = get_request("feed/stockV2", @headers)

  response.body.each do |item|
    items << map_hash(item)
  end

  items
end