Skip to content

Commit

Permalink
WIP - Create client for airbrake
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgeLAB committed May 20, 2022
1 parent dbcba9c commit 5e42e74
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/airbrake/api/live.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Airbrake
class API
class Live
AIRBRAKE_URL = "https://api.airbrake.io/api/v4".freeze

class << self
def list_projects
response = Faraday.get("#{AIRBRAKE_URL}/projects", airbrake_credentials)
normalize_reponse(response)
end

private

def airbrake_credentials
{
key: ENV['AIRBRAKE_KEY'],
content_type: 'application/json'
}
end

def normalize_reponse(response)
JSON.parse(response.body) || {}
rescue StandartError => e
return { errors: e.errors.messages}
end
end
end
end
end

0 comments on commit 5e42e74

Please sign in to comment.