dd-api 0.0.2 → 0.0.5

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
  SHA1:
3
- metadata.gz: 735af5fcc3da32f5a0e0c5b87f45253e70aa279f
4
- data.tar.gz: 57e945702c70f0fdd10f8d2e01a62c4508d5c4d2
3
+ metadata.gz: 90e17ce70d04772a693a0c07a48d388232c6ae65
4
+ data.tar.gz: 019f39e11e645dcd9db27955cc463436e312aa44
5
5
  SHA512:
6
- metadata.gz: e5dd4938aec1ff0fda3cf046ad69c57650bd64f36de54d556ed17f147ca4da6b03bbec253aa7e18ae17858a046cda7e6dc0ffc820ea3009a6b4d7a262c3db75b
7
- data.tar.gz: 094fb4ce8bed631a638cde92639216fdb1fc7e5d2ca2312f80bcb9fd027f5c81312353f55f5ea499587c25934f876207c1844e7b2578aa213197dcf61db7b4af
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::API
7
- # Make an item image URL from the item image
8
- def item_url(image)
9
- "https://res.discorddungeons.me/images/#{image}"
10
- end
11
-
12
- def rget(endpoint, api_key, user_agent)
13
- JSON.parse(RestClient.get("http://api.discorddungeons.me/#{endpoint}", :'X-Api-Key' => api_key, :'User-Agent' => user_agent))
14
- end
15
-
16
- def get(endpoint, app)
17
- JSON.parse(RestClient.get("http://api.discorddungeons.me/#{endpoint}", :'X-Api-Key' => app.api_key, :'User-Agent' => app.user_agent))
18
- end
19
-
20
- def get_user(app, id)
21
- get('user/'+id.to_s, app)['user']
22
- end
23
-
24
- def get_guild(app, id)
25
- get('guild/'+id, app)['data']
26
- end
27
-
28
- def get_items(app, id)
29
- get('item/'+id, app)['data']
30
- end
31
-
32
- def get_gitems(app, id)
33
- get('gitem/'+id, app)['data']
34
- end
35
-
36
- def all_guilds(app)
37
- get('all/guilds', app)['data']
38
- end
39
-
40
- def all_users(app)
41
- get('all/users', app)['data']
42
- end
43
-
44
- def all_items(app)
45
- get('all/items', app)['data']
46
- end
47
-
48
- def all_gitems(app)
49
- get('all/gitems', app)['data']
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
@@ -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 [true, false] The icon of the guild.
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
- @gdata = data['guild']
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 Item
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::Item name=#{@name} id=#{@id} level=#{@level}>"
273
+ "#<DDAPI::GuildItem name=#{@name} id=#{@id} level=#{@level}>"
245
274
  end
246
275
  end
247
276
  end
@@ -1,3 +1,3 @@
1
1
  module DDAPI
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.5'.freeze
3
3
  end
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.2
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-18 00:00:00.000000000 Z
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: http://api.discorddungeons.me/docs/
96
+ homepage: https://github.com/DiscordDungeons/api/tree/ruby
97
97
  licenses:
98
98
  - MIT
99
99
  metadata: {}