Module: DDAPI::API
- Defined in:
- lib/dd-api/api.rb
Overview
List of methods representing endpoints in Discord Dungeons’s API
Instance Method Summary collapse
- #all_gitems(app) ⇒ Object
- #all_guilds(app) ⇒ Object
- #all_items(app) ⇒ Object
- #all_users(app) ⇒ Object
- #get(endpoint, app) ⇒ Object
- #get_gitems(app, id) ⇒ Object
- #get_guild(app, id) ⇒ Object
- #get_items(app, id) ⇒ Object
- #get_user(app, id) ⇒ Object
-
#item_url(image) ⇒ Object
Make an item image URL from the item image.
- #rget(endpoint, api_key, user_agent) ⇒ Object
Instance Method Details
#all_gitems(app) ⇒ Object
48 49 50 |
# File 'lib/dd-api/api.rb', line 48 def all_gitems(app) get('all/gitems', app)['data'] end |
#all_guilds(app) ⇒ Object
36 37 38 |
# File 'lib/dd-api/api.rb', line 36 def all_guilds(app) get('all/guilds', app)['data'] end |
#all_items(app) ⇒ Object
44 45 46 |
# File 'lib/dd-api/api.rb', line 44 def all_items(app) get('all/items', app)['data'] end |
#all_users(app) ⇒ Object
40 41 42 |
# File 'lib/dd-api/api.rb', line 40 def all_users(app) get('all/users', app)['data'] end |
#get(endpoint, app) ⇒ Object
16 17 18 |
# File 'lib/dd-api/api.rb', line 16 def get(endpoint, app) JSON.parse(RestClient.get("http://api.discorddungeons.me/#{endpoint}", :'X-Api-Key' => app.api_key, :'User-Agent' => app.user_agent)) end |
#get_gitems(app, id) ⇒ Object
32 33 34 |
# File 'lib/dd-api/api.rb', line 32 def get_gitems(app, id) get('gitem/'+id, app)['data'] end |
#get_guild(app, id) ⇒ Object
24 25 26 |
# File 'lib/dd-api/api.rb', line 24 def get_guild(app, id) get('guild/'+id, app)['data'] end |
#get_items(app, id) ⇒ Object
28 29 30 |
# File 'lib/dd-api/api.rb', line 28 def get_items(app, id) get('item/'+id, app)['data'] end |
#get_user(app, id) ⇒ Object
20 21 22 |
# File 'lib/dd-api/api.rb', line 20 def get_user(app, id) get('user/'+id.to_s, app)['user'] end |
#item_url(image) ⇒ Object
Make an item image URL from the item image
8 9 10 |
# File 'lib/dd-api/api.rb', line 8 def item_url(image) "https://res.discorddungeons.me/images/#{image}" end |
#rget(endpoint, api_key, user_agent) ⇒ Object
12 13 14 |
# File 'lib/dd-api/api.rb', line 12 def rget(endpoint, api_key, user_agent) JSON.parse(RestClient.get("http://api.discorddungeons.me/#{endpoint}", :'X-Api-Key' => api_key, :'User-Agent' => user_agent)) end |