badass 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ab95b2d4678a5c3700ff190aa6c7ff496c6a01b61623f2dcef876f6a1f1855e
4
- data.tar.gz: 360a3107f9d5211315f3e07eda902327971212965021856d14f2d015d8feb1b7
3
+ metadata.gz: e48b4cc6729c2e2b669be4c10796aa438da25c9b58eaee979c3d1e4dbae0f89a
4
+ data.tar.gz: f8b76cd02126f0d0696b8c169cd21f832ea1c51b8a3f16d79f9d845e18e291f1
5
5
  SHA512:
6
- metadata.gz: ae0e9040e652e7f7eb70f6c9aeb5f9b902055f5b8995f473e11834f0d34ce698b670fb3de93e07500a925f342c4b9fa3f634ae79000b944444a6cbd05d3b8251
7
- data.tar.gz: 29d60696eeaa0ef609bbe7f7dc83ea71524f835c909342948f8d829be43fd5d26bc25f905b691d64e1a2874ebf6dba0234428ad6a8bfe81dc6cdac6de3abd1c6
6
+ metadata.gz: 468602146563064d4755dda01ecc741a28615fa22fb2be25cad2778061baebe7a29bf8cac723e62f9419172d08ce1857229d283ffd5cc576109243ae5f71cea8
7
+ data.tar.gz: 857e993e52a020ea95b1f0d890a22fe8656a02514a122dfb20df8cb06a188996e058935f9f7656015d9318fb593afb8df785b6aaea68daa72f3da71c3835551f
@@ -2,13 +2,15 @@ require 'net/http'
2
2
  require 'json'
3
3
 
4
4
  module BadASS
5
- @api_root = 'https://bad-dragon.com/api'
5
+ FIRMNESSES = { '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
6
+ SIZES = { 'onesize' => 'One-Size', 'mini' => 'Mini', 'small' => 'Small', 'medium' => 'Medium', 'large' => 'Large', 'extralarge' => 'Extra Large' }.freeze
6
7
 
7
- def self.test
8
- return 'your gay lol'
8
+ @baddragon_skus = {}
9
+ JSON.parse(Net::HTTP.get(URI('https://bad-dragon.com/api/inventory-toy/product-list'))).each do |toy|
10
+ @baddragon_skus[toy['sku']] = toy['name']
9
11
  end
10
-
12
+ BAD_DRAGON_SKUS = @baddragon_skus.freeze
11
13
  end
12
14
 
13
15
  require 'badass/client'
14
- require 'badass/fast'
16
+ require 'badass/toy'
@@ -1,32 +1,25 @@
1
1
  class BadASS::Client
2
2
  # Creates a client to do operations.
3
+ # Takes a :refresh_time argument to define how often the toy list should be refreshed.
3
4
  def initialize(refresh_time: 600)
4
5
  Thread.new do
5
- @baddragon_skus = {}
6
- JSON.parse(Net::HTTP.get(URI('https://bad-dragon.com/api/inventory-toy/product-list'))).each do |toy|
7
- @baddragon_skus[toy['sku']] = toy['name']
8
- end
6
+ @toys = []
9
7
  loop do
10
- @toys_finished = false
11
8
  page = 1
12
- @toys = []
9
+ toy_list = []
13
10
  loop do
14
11
  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")))
12
+ page += 1
15
13
  newtoys['toys'].each do |toy|
16
- toy['name'] = @baddragon_skus[toy['sku']]
14
+ toy_list << BadASS::Toy.new(toy)
17
15
  end
18
- page += 1
19
- @toys.concat(newtoys['toys'])
20
16
  break if page > newtoys['totalPages']
21
17
  end
22
- @toys_finished = true
18
+ @toys = toy_list
23
19
  sleep(refresh_time)
24
20
  end
25
21
  end
26
22
  end
27
23
 
28
- def toys
29
- sleep(0.1) until @toys_finished
30
- @toys
31
- end
24
+ attr_reader :toys
32
25
  end
@@ -1,17 +1,40 @@
1
1
  class BadASS::Toy
2
+ # Create a Toy object using a hash from the API.
2
3
  def initialize(toy_hash)
3
- @id = toy_hash['id'] || 000000
4
- @title = video_hash[:title] || 'N/A'
5
- @url = video_hash[:webpage_url] || 'N/A'
6
- @thumbnail_url = video_hash[:thumbnail] || Bot::HBOT.profile.avatar_url
7
- @like_count = video_hash[:like_count] || 'N/A'
8
- @dislike_count = video_hash[:dislike_count] || 'N/A'
9
- @view_count = video_hash[:view_count] || 'N/A'
10
- @length = video_hash[:duration] || 0
11
- @location = video_hash[:filename] + '.mp4'
12
- @loop = false
13
- @event = event
14
- @skipped_time = 0
15
- @filters = video_hash[:filters] || []
4
+ @id = toy_hash['id']
5
+ @sku = toy_hash['sku']
6
+ @size = toy_hash['size']
7
+ @price = toy_hash['price']
8
+ @weight = toy_hash['weight']
9
+ @color = toy_hash['color']
10
+ @colors = [toy_hash['color1'], toy_hash['color2'], toy_hash['color3']]
11
+ @flop_reason = toy_hash['flop_reason'].capitalize
12
+ @type = toy_hash['type'].capitalize
13
+ @cumtube = toy_hash['cumtube']
14
+ @suction_cup = toy_hash['suction_cup']
15
+ @images = toy_hash['images'].map { |toy| toy['fullFilename'] }
16
16
  end
17
+
18
+ def name
19
+ BadASS::BAD_DRAGON_SKUS[sku]
20
+ end
21
+
22
+ def cumtube?
23
+ @cumtube == 1
24
+ end
25
+
26
+ def suction_cup?
27
+ @suction_cup == 1
28
+ end
29
+
30
+ attr_reader :id
31
+ attr_reader :sku
32
+ attr_reader :size
33
+ attr_reader :price
34
+ attr_reader :weight
35
+ attr_reader :color
36
+ attr_reader :colors
37
+ attr_reader :flop_reason
38
+ attr_reader :type
39
+ attr_reader :images
17
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - charagarlnad