class Apillary

Public Class Methods

new(email, password) click to toggle source
# 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

Public Instance Methods

create_message(sender, recipient_id, message, subject) click to toggle source
# 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) click to toggle source
# File lib/apillary.rb, line 40
def create_submission(id, checkpoint_id, branch = nil, commit_link = nil, comment = 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: comment }, headers: { "authorization" => @auth_token })
end
get_me() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/apillary.rb, line 44
def update_checkpoint(id, enrollment_id, checkpoint_id, branch = nil, commit_link = nil, comment = 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: comment }, headers: { "authorization" => @auth_token })
end