class MyRecords

Public Class Methods

new(email, password) click to toggle source
# File lib/records.rb, line 9
def initialize(email, password)
  @base_url = 'https://www.bloc.io/api/v1'
  response = self.class.post(@base_url + '/sessions', body:
  {"email": email, "password": password})
  raise "Invalid credentials." if response.code != 200
  @auth_token = response["auth_token"]
end

Public Instance Methods

create_message(sender, recipient_id, token = nil, subject = nil, stripped_text) click to toggle source
# File lib/records.rb, line 40
def create_message(sender, recipient_id, token = nil, subject = nil, stripped_text)
  response = self.class.post(@base_url + '/messages', body:
  {"sender": sender, "recipient_id": recipient_id, "token": token,
  "subject": subject, "stripped-text": stripped_text}, headers:
  { "authorization" => @auth_token})
  response
end
create_submission(assignment_branch, assignment_commit_link, checkpoint_id, comment, enrollment_id) click to toggle source
# File lib/records.rb, line 48
def create_submission(assignment_branch, assignment_commit_link, checkpoint_id, comment, enrollment_id)
  response = self.class.post(@base_url + '/checkpoint_submissions', body:
  {"assignment_branch": assignment_branch, "assignment_commit_link": assignment_commit_link,
   "checkpoint_id": checkpoint_id, "comment": comment, "enrollment_id": enrollment_id}, headers:
   { "authorization" => @auth_token })
  response
end
get_me() click to toggle source
# File lib/records.rb, line 17
def get_me
  response = self.class.get(@base_url + '/users/me', headers:
  { "authorization" => @auth_token })
  data = JSON.parse(response.body)
  data
end
get_mentor_availability(mentor_id) click to toggle source
# File lib/records.rb, line 24
def get_mentor_availability(mentor_id)
  id = mentor_id.to_s
  response = self.class.get(@base_url + '/mentors/' + id +
  '/student_availability', headers: { "authorization" => @auth_token })
  slots = JSON.parse(response.body)
  slots
end
get_messages(page = nil) click to toggle source
# File lib/records.rb, line 32
def get_messages(page = nil)
  page.nil? ? page = '' : page = page.to_s
  response = self.class.get(@base_url + '/message_threads' + page,
  headers: { "authorization" => @auth_token })
  messages = JSON.parse(response.body)
  messages
end
update_submission(id, assignment_branch, assignment_commit_link, checkpoint_id, comment, enrollment_id) click to toggle source
# File lib/records.rb, line 56
def update_submission(id, assignment_branch, assignment_commit_link, checkpoint_id, comment, enrollment_id)
  response = self.class.put(@base_url + '/checkpoint_submissions/' + id, body:
  {"id": id, "assignment_branch": assignment_branch, "assignment_commit_link": assignment_commit_link,
   "checkpoint_id": checkpoint_id, "comment": comment, "enrollment_id": enrollment_id}, headers:
  { "authorization" => @auth_token })
  response
end