Class: Apillary
- Inherits:
-
Object
show all
- Includes:
- HTTParty, JSON, Roadmap
- Defined in:
- lib/apillary.rb
Instance Method Summary
collapse
-
#create_message(sender, recipient_id, message, subject) ⇒ Object
-
#create_submission(id, checkpoint_id, branch = nil, commit_link = nil, comment = nil) ⇒ Object
-
#get_me ⇒ Object
-
#get_meme(pageIndex, pageSize, key) ⇒ Object
-
#get_mentor_availability(id) ⇒ Object
-
#get_messages(page = nil) ⇒ Object
-
#initialize(email, password) ⇒ Apillary
constructor
A new instance of Apillary.
-
#star_wars(category, id) ⇒ Object
-
#update_checkpoint(id, enrollment_id, checkpoint_id, branch = nil, commit_link = nil, comment = nil) ⇒ Object
Methods included from Roadmap
#get_checkpoints, #get_roadmap
Constructor Details
#initialize(email, password) ⇒ Apillary
Returns a new instance of Apillary.
10
11
12
13
|
# File 'lib/apillary.rb', line 10
def initialize(email, password)
response = self.class.post("https://www.bloc.io/api/v1/sessions", body: {"email": email, "password": password})
@auth_token = response["auth_token"]
end
|
Instance Method Details
#create_message(sender, recipient_id, message, subject) ⇒ Object
35
36
37
38
|
# File 'lib/apillary.rb', line 35
def create_message(sender, recipient_id, message, subject)
response = self.class.post("https://www.bloc.io/api/v1/messages", headers: { "authorization" => @auth_token }, body: { sender: sender, recipient_id: recipient_id, stripped_text: message, subject: subject})
body = JSON.parse(response.body)
end
|
#create_submission(id, checkpoint_id, branch = nil, commit_link = nil, comment = nil) ⇒ Object
40
41
42
|
# File 'lib/apillary.rb', line 40
def create_submission(id, checkpoint_id, branch = nil, commit_link = nil, = nil)
response = self.class.post("https://www.bloc.io/api/v1/checkpoint_submissions", body: { enrollment_id: id, checkpoint_id: checkpoint_id, assignment_branch: branch, assignment_commit_link: commit_link, comment: }, headers: { "authorization" => @auth_token })
end
|
#get_me ⇒ Object
15
16
17
18
|
# File 'lib/apillary.rb', line 15
def get_me
response = self.class.get("https://www.bloc.io/api/v1/users/me", headers: { "authorization" => @auth_token })
body = JSON.parse(response.body)
end
|
#get_meme(pageIndex, pageSize, key) ⇒ Object
53
54
55
56
|
# File 'lib/apillary.rb', line 53
def get_meme(pageIndex, pageSize, key)
response = self.class.get("https://version1.api.memegenerator.net//Generators_Select_ByNew?pageIndex=#{pageIndex}&pageSize=#{pageSize}&apiKey=#{key}")
body = JSON.parse(response.body)
end
|
#get_mentor_availability(id) ⇒ Object
20
21
22
23
|
# File 'lib/apillary.rb', line 20
def get_mentor_availability(id)
response = self.class.get("https://www.bloc.io/api/v1/mentors/#{id}/student_availability", headers: { "authorization" => @auth_token })
body = JSON.parse(response.body)
end
|
#get_messages(page = nil) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/apillary.rb', line 25
def get_messages(page = nil)
if page
response = self.class.get("https://www.bloc.io/api/v1/message_threads", body: { page: page }, headers: { "authorization" => @auth_token })
body = JSON.parse(response.body)
else
response = self.class.get("https://www.bloc.io/api/v1/message_threads", headers: { "authorization" => @auth_token })
body = JSON.parse(response.body)
end
end
|
#star_wars(category, id) ⇒ Object
48
49
50
51
|
# File 'lib/apillary.rb', line 48
def star_wars(category, id)
response = self.class.get("https://swapi.co/api/#{category}/#{id}")
body = JSON.parse(response.body)
end
|
#update_checkpoint(id, enrollment_id, checkpoint_id, branch = nil, commit_link = nil, comment = nil) ⇒ Object
44
45
46
|
# File 'lib/apillary.rb', line 44
def update_checkpoint(id, enrollment_id, checkpoint_id, branch = nil, commit_link = nil, = nil)
response = self.class.put("https://www.bloc.io/api/v1/checkpoint_submissions/:#{id}", body: { enrollment_id: enrollment_id, checkpoint_id: checkpoint_id, assignment_branch: branch, assignment_commit_link: commit_link, comment: }, headers: { "authorization" => @auth_token })
end
|