dbiorb 0.1.0 → 0.4.0

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: 4b597f780c1f5b1c9487454604b48a13b6529c40670657afe01b6bab173ea340
4
- data.tar.gz: 558a0217c77fcbbdfa1d281c9e4a3e7655224bbfdf23f4ec91372b98703457d0
3
+ metadata.gz: 0f740860860737d6b7cc450fb0c27dbdc08756daadeac6248902b0ddbae17c38
4
+ data.tar.gz: e88c2abc140fee0524897602ff0db19501873a0838aa764b6b43b60e100f79fe
5
5
  SHA512:
6
- metadata.gz: ba80a4298056afa7a89895f98fabf3235c6e5c72dead03a2d727373de66cdf4c52bfcc8b91e843e7c43cd2e183609e51ed81b9659f49ff25293e476a92573282
7
- data.tar.gz: 7487b13123c5ae98c9a7540ccbbe2da85edfa1fd5bb94ede7eb0aaf0d1c474541a0c914501e8c2ce662162e6e00bf6cc752e2da841727ad68436e7375819fbe1
6
+ metadata.gz: 70af506bd80c55418eeb8fdf2dd71f03948b3b4bf3bf421ba7ec3140a115fb354d75d111b5c1e0bc439c9bcb69a80c5137cebb69a8110c57c5c9487d5092403c
7
+ data.tar.gz: e92b20fcd04d64bf476210da620c6b43d42dab7d5c20054e623097df9d4d5d94a15c9688875135a030a0c065a7ac7686ea282ea31d6e3e353d06f5a047c99b3c
@@ -12,18 +12,30 @@ 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
- def top_upvoted
20
+ # Returns the users by most likes.
21
+ # Their data is short, so it's not really worth storing a lot of data
22
+ # @see [SearchResult#user]
23
+ # @return [Array<SearchResult>] the response
24
+ def top_likes
25
+ JSON.parse(RestClient.get("https://api.discord.bio/topLikes"))['payload'].map { |e| SearchResult.new(e) }
26
+ end
21
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) }
22
33
  end
23
34
  end
24
35
 
25
36
  # Require files.
26
37
  require 'dbio/discord_connection'
27
38
  require 'dbio/discord_profile'
39
+ require 'dbio/search_result'
28
40
  require 'dbio/user_connection'
29
41
  require 'dbio/user'
@@ -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
@@ -5,14 +5,61 @@ class DBio::SearchResult
5
5
  @data = data
6
6
  end
7
7
 
8
- # The type of connection, e.g. Twitter, YouTube, etc.
9
- # @return [String] the type of connection
10
- def type
11
- @data['type']
8
+ # The slug of this result's user.
9
+ def slug
10
+ @data['user']['slug']
12
11
  end
13
12
 
14
- # @return [String] the name as it appears on the User profile
15
- def name
16
- @data['name']
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
+
58
+ # The user itself, for more detail
59
+ # @return [User] the user
60
+ def user
61
+ user = JSON.parse(RestClient.get("https://api.discord.bio/v1/user/details/#{slug}"))
62
+
63
+ DBio::User.new(user['payload'])
17
64
  end
18
65
  end
@@ -14,19 +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/#{profile_url}"
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
- # The flags for this user. Not entirely sure what they mean, but they're there.
35
+ # @return [Integer] the amount of likes this user has.
36
+ def likes
37
+ @user['likes']
38
+ end
39
+
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
30
47
  # @return [Integer] the flags for this user
31
48
  def flags
32
49
  @user['flags']
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.0
4
+ version: 0.4.0
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-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json