Class: HabitRPG_API
Instance Method Summary
collapse
Methods included from Groups
#get_group_chat, #get_groups
Methods included from Tasks
#create_task, #get_task, #list_tasks, #score_task
Constructor Details
#initialize(api_user, api_token) ⇒ HabitRPG_API
Returns a new instance of HabitRPG_API.
11
12
13
14
|
# File 'lib/habitrpg.rb', line 11
def initialize(api_user, api_token)
@api_user = api_user
@api_token = api_token
end
|
Instance Method Details
#delete(url, params = nil) ⇒ Object
16
17
18
|
# File 'lib/habitrpg.rb', line 16
def delete(url, params = nil)
JSON.parse(RestClient.delete("https://habitrpg.com/api/v2/#{url}", { 'x-api-key' => @api_token, 'x-api-user' => @api_user }))
end
|
#get(url, params = nil) ⇒ Object
28
29
30
|
# File 'lib/habitrpg.rb', line 28
def get(url, params = nil)
JSON.parse(RestClient.get("https://habitrpg.com/api/v2/#{url}", { 'x-api-key' => @api_token, 'x-api-user' => @api_user }))
end
|
#post(url, params = nil) ⇒ Object
20
21
22
|
# File 'lib/habitrpg.rb', line 20
def post(url, params = nil)
JSON.parse(RestClient.put("https://habitrpg.com/api/v2/#{url}", params, { 'x-api-key' => @api_token, 'x-api-user' => @api_user }))
end
|