dbiorb 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4b597f780c1f5b1c9487454604b48a13b6529c40670657afe01b6bab173ea340
4
+ data.tar.gz: 558a0217c77fcbbdfa1d281c9e4a3e7655224bbfdf23f4ec91372b98703457d0
5
+ SHA512:
6
+ metadata.gz: ba80a4298056afa7a89895f98fabf3235c6e5c72dead03a2d727373de66cdf4c52bfcc8b91e843e7c43cd2e183609e51ed81b9659f49ff25293e476a92573282
7
+ data.tar.gz: 7487b13123c5ae98c9a7540ccbbe2da85edfa1fd5bb94ede7eb0aaf0d1c474541a0c914501e8c2ce662162e6e00bf6cc752e2da841727ad68436e7375819fbe1
@@ -0,0 +1,29 @@
1
+ # Require external gems
2
+ require 'json'
3
+ require 'rest-client'
4
+
5
+ # All DBio functionality, whether extended or just here.
6
+ class DBio
7
+ # Initialize the API. Not much here really.
8
+ def initialize; end
9
+
10
+ # Load a user
11
+ # @param id [Integer, String] the user ID or name of the requested user.
12
+ # @raise [RestClient::NotFound] if the specified user does not exist
13
+ # @return [User] the new user object
14
+ def user(id)
15
+ user = JSON.parse(RestClient.get("https://api.discord.bio/v1/user/details/#{id}"))
16
+
17
+ User.new(user['payload'])
18
+ end
19
+
20
+ def top_upvoted
21
+
22
+ end
23
+ end
24
+
25
+ # Require files.
26
+ require 'dbio/discord_connection'
27
+ require 'dbio/discord_profile'
28
+ require 'dbio/user_connection'
29
+ require 'dbio/user'
@@ -0,0 +1,23 @@
1
+ # Find information about a Discord Connection.
2
+ class DBio::DiscordConnection
3
+ # Initialize the connection
4
+ def initialize(data)
5
+ @data = data
6
+ end
7
+
8
+ # The type of Discord connection, e.g. Twitter, YouTube, etc.
9
+ # @return [String] the type of connection
10
+ def type
11
+ @data['connection_type']
12
+ end
13
+
14
+ # @return [String] the name as it appears on the Discord profile
15
+ def name
16
+ @data['name']
17
+ end
18
+
19
+ # @return [String] the URL to the connection as it is on the Discord profile
20
+ def url
21
+ @data['url']
22
+ end
23
+ end
@@ -0,0 +1,38 @@
1
+ # Find information about a Discord Profile.
2
+ class DBio::DiscordProfile
3
+ # Initialize the profile
4
+ def initialize(data)
5
+ @data = data
6
+ end
7
+
8
+ # The id of the user.
9
+ # @return [Integer] User ID in integer form.
10
+ def id
11
+ @user['id'].to_i
12
+ end
13
+
14
+ # @return [String] the username as it appears on Discord
15
+ def username
16
+ @data['username']
17
+ end
18
+
19
+ # @return [String] the avatar hash of this user
20
+ def avatar_hash
21
+ @data['avatar_hash']
22
+ end
23
+
24
+ # @return [String] this user's discriminator
25
+ def discriminator
26
+ @data['discriminator']
27
+ end
28
+
29
+ # @return [Integer] public flags provided via Oauth, not useful on their own.
30
+ def public_flags
31
+ @data['public_flags']
32
+ end
33
+
34
+ # @return [String] the user's name+discriminator. Same as it is in discordrb
35
+ def distinct
36
+ "#{username}\##{discriminator}"
37
+ end
38
+ end
@@ -0,0 +1,18 @@
1
+ # A shorter version of a user's details
2
+ class DBio::SearchResult
3
+ # Initialize the result
4
+ def initialize(data)
5
+ @data = data
6
+ end
7
+
8
+ # The type of connection, e.g. Twitter, YouTube, etc.
9
+ # @return [String] the type of connection
10
+ def type
11
+ @data['type']
12
+ end
13
+
14
+ # @return [String] the name as it appears on the User profile
15
+ def name
16
+ @data['name']
17
+ end
18
+ end
@@ -0,0 +1,120 @@
1
+ # Find information about users.
2
+ class DBio::User
3
+ # Initialize the user
4
+ def initialize(data)
5
+ @user = data['user']['details']
6
+ @discord = data['discord']
7
+ @discord_connections = data['user']['discordConnections']
8
+ @user_connections = data['user']['user_connections']
9
+ end
10
+
11
+ # @return data in raw json form.
12
+ attr_reader :data
13
+
14
+ alias_method :to_s, :data
15
+
16
+ # The slug of this user. Use: dsc.bio/slug
17
+ # @see [User#profile_url]
18
+ # @return [String] the slug
19
+ def slug
20
+ @user['slug']
21
+ end
22
+
23
+ # The id of the user.
24
+ # @return [Integer] User ID in integer form.
25
+ def id
26
+ @user['user_id'].to_i
27
+ end
28
+
29
+ # The flags for this user. Not entirely sure what they mean, but they're there.
30
+ # @return [Integer] the flags for this user
31
+ def flags
32
+ @user['flags']
33
+ end
34
+
35
+ # @return [boolean] if this user is verified
36
+ def verified?
37
+ @user['verified'] == 1
38
+ end
39
+
40
+ # @return [Time] The time this user was created
41
+ def created
42
+ Time.parse(@user['created_at'])
43
+ end
44
+
45
+ # @return [String, nil] the description for this user, if one is set.
46
+ def description
47
+ @user['description']
48
+ end
49
+
50
+ # @return [String, nil] the location for this user, if one is set.
51
+ def location
52
+ @user['location']
53
+ end
54
+
55
+ # The API returns an integer, so this is converted to a String.
56
+ # @return [String, nil] the gender of this user in String form.
57
+ def gender
58
+ case @user['gender']
59
+ when 0
60
+ "Male"
61
+ when 1
62
+ "Female"
63
+ when 2
64
+ "Non-Binary"
65
+ when nil
66
+ "Undisclosed"
67
+ else
68
+ nil
69
+ end
70
+ end
71
+
72
+ # @return [Date, nil] the birthdate of this user, if one is set
73
+ def birthday
74
+ Date.parse(@user['birthday'])
75
+ end
76
+
77
+ # @return [String, nil] the user's email, if one is set
78
+ def email
79
+ @user['email']
80
+ end
81
+
82
+ # @return [String, nil] the user's occupation, if one is set
83
+ def occupation
84
+ @user['occupation']
85
+ end
86
+
87
+ # @return [String, nil] the user's banner, if one is set
88
+ def banner_url
89
+ @user['banner']
90
+ end
91
+
92
+ # @return [Boolean] the user's premium status
93
+ def premium?
94
+ @user['premium']
95
+ end
96
+
97
+ # @return [Boolean] the user's staff status
98
+ def staff?
99
+ @user['staff']
100
+ end
101
+
102
+ # This is the user's Discord connections as they appear on their Discord profile
103
+ # @return [Array<DiscordConnection>] the user's discord connections
104
+ def discord_connections
105
+ @discord_connections.map{ |e| DBio::DiscordConnection.new(e) }
106
+ end
107
+
108
+ # The user's Discord.Bio connections. Not as specific.
109
+ # @return [Array<UserConnection>] the user's discord.bio connections
110
+ def user_connections
111
+ @user_connections.map { |e, f| DBio::UserConnection.new({ "type": e, "name": f }) }
112
+ end
113
+
114
+ # The user's Discord profile information, not overly specific either.
115
+ # I instead recommend just getting it though your Discord Library with the ID
116
+ # @see [User#id]
117
+ def discord_profile
118
+ DBio::DiscordProfile.new(@discord)
119
+ end
120
+ end
@@ -0,0 +1,18 @@
1
+ # Find information about a Discord.Bio Connection.
2
+ class DBio::UserConnection
3
+ # Initialize the connection
4
+ def initialize(data)
5
+ @data = data
6
+ end
7
+
8
+ # The type of connection, e.g. Twitter, YouTube, etc.
9
+ # @return [String] the type of connection
10
+ def type
11
+ @data['type']
12
+ end
13
+
14
+ # @return [String] the name as it appears on the User profile
15
+ def name
16
+ @data['name']
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dbiorb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chew
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.1.0
41
+ description: A Ruby library for the Discord Bio (https://discord.bio) API.
42
+ email: chew@chew.pw
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/dbio.rb
48
+ - lib/dbio/discord_connection.rb
49
+ - lib/dbio/discord_profile.rb
50
+ - lib/dbio/search_result.rb
51
+ - lib/dbio/user.rb
52
+ - lib/dbio/user_connection.rb
53
+ homepage: https://github.com/Chew/dbiorb
54
+ licenses:
55
+ - MIT
56
+ metadata:
57
+ bug_tracker_uri: https://github.com/Chew/dbiorb/issues
58
+ changelog_uri: https://github.com/Chew/dbiorb/releases
59
+ homepage_uri: http://github.com/Chew/dbiorb
60
+ source_code_uri: http://github.com/Chew/dbiorb
61
+ wiki_uri: http://github.com/Chew/dbiorb/wiki
62
+ documentation_uri: https://rubydocs.chew.pro/docs/dbiorb
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 2.2.4
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubygems_version: 3.0.6
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Discord Bio API for Ruby
82
+ test_files: []