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

.dropsArray<BadASS::Toy>

Get the current drops on the site.

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/badass.rb', line 24

def self.drops
  page = 1
  toy_list = []
  loop do
    newtoys = JSON.parse(Net::HTTP.get(URI("https://bad-dragon.com/api/inventory-toys?price[min]=0&price[max]=300&noAccessories=false&cumtube=false&suctionCup=false&sort[field]=price&&sort[direction]=asc&page=#{page}&limit=60")))
    page += 1
    newtoys['toys'].each do |toy|
      toy_list << BadASS::Toy.new(toy)
    end
    break if page > newtoys['totalPages']
  end
  toy_list
end

.salesArray<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