dd-api 0.0.2 → 0.0.5
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 +4 -4
- data/lib/dd-api/api.rb +46 -44
- data/lib/dd-api/classes.rb +38 -9
- data/lib/dd-api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90e17ce70d04772a693a0c07a48d388232c6ae65
|
4
|
+
data.tar.gz: 019f39e11e645dcd9db27955cc463436e312aa44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4133d57925590edf37d1d1747a8729a17250ecc32031e8fc267e829a48f66ed91c89cc7fea8f54d10eff3c7008ac84af0b6e07912b3e08b1e6a7e8856c43cc0
|
7
|
+
data.tar.gz: b693f6ec6d1dae3a934602312b728a0fd2a6180d87cc4df0f1a8fd388cdcf9f16e16e0c71970757f027cfd1d209d29179f8b1619a20b86e5ef951240881c0ab2
|
data/lib/dd-api/api.rb
CHANGED
@@ -3,49 +3,51 @@ require 'rest-client'
|
|
3
3
|
require 'dd-api/errors'
|
4
4
|
|
5
5
|
# List of methods representing endpoints in Discord Dungeons's API
|
6
|
-
module DDAPI
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
6
|
+
module DDAPI
|
7
|
+
module API
|
8
|
+
# Make an item image URL from the item image
|
9
|
+
def self.item_url(image)
|
10
|
+
"https://res.discorddungeons.me/images/"+image
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.rget(endpoint, api_key, user_agent)
|
14
|
+
JSON.parse(RestClient.get("http://api.discorddungeons.me/"+endpoint, :'X-Api-Key' => api_key, :'User-Agent' => user_agent))
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get(endpoint, app)
|
18
|
+
JSON.parse(RestClient.get("http://api.discorddungeons.me/"+endpoint, :'X-Api-Key' => app.api_key, :'User-Agent' => app.user_agent))
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.get_user(app, id)
|
22
|
+
get('user/'+id.to_s, app)['user']
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get_guild(app, id)
|
26
|
+
get('guild/'+id, app)['data']
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.get_items(app, id)
|
30
|
+
get('item/'+id, app)['data']
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.get_gitems(app, id)
|
34
|
+
get('gitem/'+id, app)['data']
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.all_guilds(app)
|
38
|
+
get('all/guilds', app)['data']
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.all_users(app)
|
42
|
+
get('all/users', app)['data']
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.all_items(app)
|
46
|
+
get('all/items', app)['data']
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.all_gitems(app)
|
50
|
+
get('all/gitems', app)['data']
|
51
|
+
end
|
50
52
|
end
|
51
53
|
end
|
data/lib/dd-api/classes.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'htmlentities'
|
3
3
|
|
4
|
-
require 'dd-api/api'
|
5
4
|
require 'dd-api/init'
|
6
5
|
|
7
6
|
# Objects essential to DRPG
|
@@ -47,7 +46,6 @@ module DDAPI
|
|
47
46
|
|
48
47
|
# @return [Integer] The level at that time, of the user.
|
49
48
|
attr_accessor :level
|
50
|
-
alias_method :lvl, :level
|
51
49
|
|
52
50
|
# @return [Integer] How much maximun health that user has
|
53
51
|
attr_accessor :max_hp
|
@@ -104,30 +102,63 @@ module DDAPI
|
|
104
102
|
attr_accessor :description
|
105
103
|
alias_method :desc, :description
|
106
104
|
|
105
|
+
# @return [true, false] Whether the guild is open.
|
106
|
+
attr_accessor :open
|
107
|
+
|
107
108
|
# @return [Integer] The amount gold in the guild.
|
108
109
|
attr_accessor :gold
|
109
110
|
|
111
|
+
# @return [Integer] The combined deaths by the guild members.
|
112
|
+
attr_accessor :deaths
|
113
|
+
alias_method :frags, :deaths
|
114
|
+
|
115
|
+
# @return [Integer] The combined enemies slain by the guild members.
|
116
|
+
attr_accessor :kills
|
117
|
+
alias_method :slain, :kills
|
118
|
+
|
119
|
+
# @return [Integer] The maximum amount of people that can be in the guild.
|
120
|
+
attr_accessor :max
|
121
|
+
|
110
122
|
# @return [Integer] The level of the guild.
|
111
123
|
attr_accessor :level
|
112
|
-
alias_method :lvl, :level
|
113
124
|
|
114
125
|
# @return [Integer] The ID of the guild.
|
115
126
|
attr_accessor :id
|
116
127
|
|
117
|
-
# @return [
|
128
|
+
# @return [Integer] The level requirement of the guild.
|
129
|
+
attr_accessor :level_requirement
|
130
|
+
|
131
|
+
# @return [String] The icon of the guild.
|
118
132
|
attr_accessor :icon
|
119
133
|
|
134
|
+
# @return [Array<String>] Array of icons the guild has bought.
|
135
|
+
attr_accessor :icons
|
136
|
+
|
137
|
+
# @return [String, nil] The Discord Role ID of the guild. `nil` if there is no role.
|
138
|
+
attr_accessor :role
|
139
|
+
|
140
|
+
# @return [String, nil] The Discord Channel ID of the guild. `nil` if there is no channel.
|
141
|
+
attr_accessor :channel
|
142
|
+
|
120
143
|
def initialize(data, app)
|
121
144
|
@data = data
|
122
|
-
|
145
|
+
gdata = data['guild']
|
123
146
|
@name = data['name']
|
147
|
+
@open = data['open']
|
124
148
|
@level = gdata['level']
|
125
149
|
@description = gdata['desc']
|
126
150
|
@gold = gdata['gold']
|
151
|
+
@kills = @data['slain']
|
152
|
+
@deaths = @data['deaths']
|
127
153
|
@icon = HTMLEntities.new.decode(gdata['icon'])
|
154
|
+
@icons = gdata['icons'].map {|icon| HTMLEntities.new.decode(icon) }
|
128
155
|
@id = data['id']
|
129
156
|
@members = gdata['members']
|
157
|
+
@level_requirement = gdata['levelreq']
|
158
|
+
@max = gdata['max']
|
130
159
|
@owner = @app.user(gdata['owner'])
|
160
|
+
@role = gdata['role'].empty? ? nil : gdata['role']
|
161
|
+
@channel = gdata['channel'].empty? ? nil : gdata['channel']
|
131
162
|
@app = app
|
132
163
|
end
|
133
164
|
|
@@ -162,7 +193,6 @@ module DDAPI
|
|
162
193
|
|
163
194
|
# @return [Integer] The level of the item.
|
164
195
|
attr_accessor :level
|
165
|
-
alias_method :lvl, :level
|
166
196
|
|
167
197
|
# @return [Integer] The ID of the item.
|
168
198
|
# attr_accessor :id
|
@@ -199,7 +229,7 @@ module DDAPI
|
|
199
229
|
end
|
200
230
|
end
|
201
231
|
# Represents a DRPG guild item.
|
202
|
-
class
|
232
|
+
class GuildItem
|
203
233
|
# @return [String] The name of the item.
|
204
234
|
attr_accessor :name
|
205
235
|
|
@@ -221,7 +251,6 @@ module DDAPI
|
|
221
251
|
|
222
252
|
# @return [Integer] The level of the item.
|
223
253
|
attr_accessor :level
|
224
|
-
alias_method :lvl, :level
|
225
254
|
|
226
255
|
# @return [Integer] The ID of the item.
|
227
256
|
# attr_accessor :id
|
@@ -241,7 +270,7 @@ module DDAPI
|
|
241
270
|
|
242
271
|
# The inspect method is overwritten to give more useful output
|
243
272
|
def inspect
|
244
|
-
"#<DDAPI::
|
273
|
+
"#<DDAPI::GuildItem name=#{@name} id=#{@id} level=#{@level}>"
|
245
274
|
end
|
246
275
|
end
|
247
276
|
end
|
data/lib/dd-api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dd-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Snazzah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -93,7 +93,7 @@ files:
|
|
93
93
|
- lib/dd-api/errors.rb
|
94
94
|
- lib/dd-api/init.rb
|
95
95
|
- lib/dd-api/version.rb
|
96
|
-
homepage:
|
96
|
+
homepage: https://github.com/DiscordDungeons/api/tree/ruby
|
97
97
|
licenses:
|
98
98
|
- MIT
|
99
99
|
metadata: {}
|