Class: SecondAmendmentWholesale::Category

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

Constant Summary collapse

EXCLUDED_CATEGORY_IDS =

Excludes brands and other non-categories returned from 2AW’s Categories endpoint

[3, 26, 27]

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 = {}) ⇒ Category

Returns a new instance of Category.



9
10
11
12
13
# File 'lib/second_amendment_wholesale/category.rb', line 9

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

  @options = options
end

Class Method Details

.all(options = {}) ⇒ Object



15
16
17
18
19
# File 'lib/second_amendment_wholesale/category.rb', line 15

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

  new(options).all
end

Instance Method Details

#allObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/second_amendment_wholesale/category.rb', line 21

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

  response = get_request('categories', headers)

  extract_categories(response.body[:children_data])
end