Module: BadASS

Defined in:
lib/badass.rb

Overview

Contains a few constants used across BD's site, and a few helper methods.

Defined Under Namespace

Classes: Client, Sale, Toy

Constant Summary collapse

FIRMNESSES =

A hash of API mappings of number to firmness.

{ '2' => 'Extra Soft', '3' => 'Soft', '5' => 'Medium', '8' => 'Firm', '3/5' => 'Soft Shaft, Med Base', '5/3' => 'Soft Shaft, Med Base', '3/8' => 'Soft Shaft, Firm Base', '8/3' => 'Soft Shaft, Firm Base', '5/8' => 'Med Shaft, Firm Base', '8/5' => 'Med Shaft, Firm Base' }.freeze
SIZES =

A hash of API mappings to correctly capitalize a size.

{ 'onesize' => 'One-Size', 'mini' => 'Mini', 'small' => 'Small', 'medium' => 'Medium', 'large' => 'Large', 'extralarge' => 'Extra Large' }.freeze
BAD_DRAGON_SKUS =

A hash of API mappings of toy SKU to toy name.

JSON.parse(Net::HTTP.get(URI('https://bad-dragon.com/api/inventory-toy/product-list'))).map { |toy| { toy['sku'] => toy['name'] } }.reduce({}, :update)

Class Method Summary collapse

Class Method Details

.salesHash{String => BadASS::Sale}

Get the current sales on the site.

Returns:


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

def self.sales
  JSON.parse(Net::HTTP.get(URI('https://bad-dragon.com/api/sales'))).map do |sale|
    BadASS::Sale.new(sale)
  end
end