dbiorb 0.1.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fc93ac9fc1e4a99dd8f3ee921bf47a8ab9c80acb2826ad75b9c01982bd68fbc
4
- data.tar.gz: 2c8c500a671a4b17b03a69544307e6735722e37999ecaa31bceab435631ffe1b
3
+ metadata.gz: 3565ccefb9e1eb0dc274b71be6fdeb2c454c70621911505e7f2d6fcbf5cb065b
4
+ data.tar.gz: 0b911b55c964887470ba13c8d232717a0b65b5408f00967aca1168f87217bb01
5
5
  SHA512:
6
- metadata.gz: e636b2cbe0d4916da8db6240c8dc89beeaf413f2bf9fdd40b3d3c53c0abedb03309c44dc739c13cc1fd196e573792d779febe6da34bb9ecb5265d5fc10f2d10a
7
- data.tar.gz: 03d7850c5258d270acafb11a9b601f34c1828e00b09ac8866182521f83e474df1cf9fbd965c77b46d231534908273589bb58dd5484c6dad66c29b811f4f093fe
6
+ metadata.gz: cfeada1f447ce82cf783f9349c10e881549ed1e1c9aa5caabc15042c4237329f9bc1f7c016a1d22b7b4e35f32e08a648955d6e032670405d5d7e4bb6c30d03b7
7
+ data.tar.gz: f5c58be8e8f15664e2b0428e8827fc85ca15ff0a6555773058e54d9b6dea7b8c6833570b46c65e6d0b0c108a7cba28964c9c90e64ff9748bbfe13f60ac04a2e5
@@ -12,17 +12,24 @@ class DBio
12
12
  # @raise [RestClient::NotFound] if the specified user does not exist
13
13
  # @return [User] the new user object
14
14
  def user(id)
15
- user = JSON.parse(RestClient.get("https://api.discord.bio/v1/user/details/#{id}"))
15
+ user = JSON.parse(RestClient.get("https://api.discord.bio/user/details/#{id}"))
16
16
 
17
17
  User.new(user['payload'])
18
18
  end
19
19
 
20
- # Returns the top upvoted users.
20
+ # Returns the users by most likes.
21
21
  # Their data is short, so it's not really worth storing a lot of data
22
22
  # @see [SearchResult#user]
23
23
  # @return [Array<SearchResult>] the response
24
- def top_upvoted
25
- JSON.parse(RestClient.get("https://api.discord.bio/v1/topUpvoted"))['payload'].map { |e| SearchResult.new(e) }
24
+ def top_likes
25
+ JSON.parse(RestClient.get("https://api.discord.bio/topLikes"))['payload'].map { |e| SearchResult.new(e) }
26
+ end
27
+
28
+ # Searches for a user
29
+ # This API is not publicly documented and can break at any time. Be careful!
30
+ # @return [Array<SearchResult>] the response
31
+ def search(user)
32
+ JSON.parse(RestClient.get("https://api.discord.bio/user/search/#{user}"))['payload'].map { |e| SearchResult.new(e) }
26
33
  end
27
34
  end
28
35
 
@@ -20,4 +20,14 @@ class DBio::DiscordConnection
20
20
  def url
21
21
  @data['url']
22
22
  end
23
+
24
+ # The icon is used on the website, it's a Font Awesome icon code.
25
+ # Not really useful unless you're making a site with the gem, in which case you'd probably do:
26
+ # <a href="<%= @connection.url %>"><i class="<%= @connection.icon %>"></i> <%= @connection.name %></a>
27
+ # Which could return:
28
+ # <a href="https://twitter.com/twitter"><i class="fab fa-twitter"></i> Twitter</a>
29
+ # @return [String] the font awesome icon code for this connection
30
+ def icon
31
+ @data['icon']
32
+ end
23
33
  end
@@ -10,6 +10,51 @@ class DBio::SearchResult
10
10
  @data['user']['slug']
11
11
  end
12
12
 
13
+ # @return [String] this result's discord username
14
+ def discord_username
15
+ @data['discord']['username']
16
+ end
17
+
18
+ # @return [String] this result's discord discriminator
19
+ def discord_discriminator
20
+ @data['discord']['discriminator']
21
+ end
22
+
23
+ # @return [Integer] this result's discord ID
24
+ def discord_id
25
+ @data['discord']['id'].to_i
26
+ end
27
+
28
+ # @return [String] this result's discord avatar hash
29
+ def discord_avatar
30
+ @data['discord']['avatar']
31
+ end
32
+
33
+ # @return [Boolean] if this user is verified
34
+ def verified?
35
+ @data['user']['verified'] == 1
36
+ end
37
+
38
+ # @return [Boolean] if this user is a discord.bio staff member
39
+ def staff?
40
+ @data['user']['staff']
41
+ end
42
+
43
+ # @return [Boolean] if this user is a premium user
44
+ def premium?
45
+ @data['user']['premium']
46
+ end
47
+
48
+ # @return [Integer] this user's upvotes
49
+ def upvotes
50
+ @data['user']['upvotes']
51
+ end
52
+
53
+ # @return [String] this user's description
54
+ def description
55
+ @data['user']['description']
56
+ end
57
+
13
58
  # The user itself, for more detail
14
59
  # @return [User] the user
15
60
  def user
@@ -14,24 +14,36 @@ class DBio::User
14
14
  alias_method :to_s, :data
15
15
 
16
16
  # The slug of this user. Use: dsc.bio/slug
17
- # @see [User#profile_url]
17
+ # @see User#profile_url
18
18
  # @return [String] the slug
19
19
  def slug
20
20
  @user['slug']
21
21
  end
22
22
 
23
+ # The link to this user's profile
24
+ # @return [String] this user's profile
25
+ def profile_url
26
+ "https://dsc.bio/#{slug}"
27
+ end
28
+
23
29
  # The id of the user.
24
30
  # @return [Integer] User ID in integer form.
25
31
  def id
26
32
  @user['user_id'].to_i
27
33
  end
28
34
 
29
- # @return [Integer] the amount of upvotes this user has.
30
- def upvotes
31
- @user['upvotes']
35
+ # @return [Integer] the amount of likes this user has.
36
+ def likes
37
+ @user['likes']
32
38
  end
33
39
 
34
- # The flags for this user. Not entirely sure what they mean, but they're there.
40
+ # This simply returns the likes, switch to likes.
41
+ # @deprecated
42
+ # @see [likes]
43
+ alias_method :upvotes, :likes
44
+
45
+ # The oauth flags for this user. Not useful on their own.
46
+ # @see DBio::DiscordProfile#public_flags
35
47
  # @return [Integer] the flags for this user
36
48
  def flags
37
49
  @user['flags']
@@ -39,7 +51,7 @@ class DBio::User
39
51
 
40
52
  # @return [boolean] if this user is verified
41
53
  def verified?
42
- @user['verified'] == 1
54
+ @user['verified']
43
55
  end
44
56
 
45
57
  # @return [Time] The time this user was created
@@ -104,10 +116,18 @@ class DBio::User
104
116
  @user['staff']
105
117
  end
106
118
 
119
+ # The premium type as found on Discord.
120
+ # ezpz way to see if they're Nitro.
121
+ # For Types, see https://discord.com/developers/docs/resources/user#user-object-premium-types
122
+ # @return [Integer] this user's premium type
123
+ def premium_type
124
+ @user['premium_type']
125
+ end
126
+
107
127
  # This is the user's Discord connections as they appear on their Discord profile
108
128
  # @return [Array<DiscordConnection>] the user's discord connections
109
129
  def discord_connections
110
- @discord_connections.map{ |e| DBio::DiscordConnection.new(e) }
130
+ @discord_connections.map { |e| DBio::DiscordConnection.new(e) }
111
131
  end
112
132
 
113
133
  # The user's Discord.Bio connections. Not as specific.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbiorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chew
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-09 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json