class Crashbreak::ExceptionsRepository

Public Instance Methods

create(error_report_hash) click to toggle source
# File lib/crashbreak/repositories/exceptions_repository.rb, line 3
def create(error_report_hash)
  JSON.parse(post_request(error_report_hash).body)
end
resolve(error_id) click to toggle source
# File lib/crashbreak/repositories/exceptions_repository.rb, line 7
def resolve(error_id)
  resolve_request error_id
end
update(error_id, hash) click to toggle source
# File lib/crashbreak/repositories/exceptions_repository.rb, line 11
def update(error_id, hash)
  update_request(error_id, hash)
end

Private Instance Methods

connection() click to toggle source
# File lib/crashbreak/repositories/exceptions_repository.rb, line 37
def connection
  Faraday.new
end
create_request_url() click to toggle source
# File lib/crashbreak/repositories/exceptions_repository.rb, line 41
def create_request_url
  "#{BASE_URL}/projects/#{project_token}/errors"
end
post_request(error_report_hash) click to toggle source
# File lib/crashbreak/repositories/exceptions_repository.rb, line 17
def post_request(error_report_hash)
  connection.post do |req|
    req.url create_request_url
    req.body = error_report_hash.to_json
    req.headers['Content-Type'] = 'application/json'
  end
end
resolve_request(error_id) click to toggle source
# File lib/crashbreak/repositories/exceptions_repository.rb, line 25
def resolve_request(error_id)
  update_request(error_id, status: :resolved)
end
resolve_request_url(error_id) click to toggle source
# File lib/crashbreak/repositories/exceptions_repository.rb, line 45
def resolve_request_url(error_id)
  "#{BASE_URL}/projects/#{project_token}/errors/#{error_id}"
end
update_request(error_id, body) click to toggle source
# File lib/crashbreak/repositories/exceptions_repository.rb, line 29
def update_request(error_id, body)
  connection.put do |req|
    req.url resolve_request_url(error_id)
    req.body = { error_report: body }.to_json
    req.headers['Content-Type'] = 'application/json'
  end
end