Class: DiscoApp::RollbarClient
- Inherits:
-
Object
- Object
- DiscoApp::RollbarClient
- Defined in:
- app/clients/disco_app/rollbar_client.rb
Constant Summary collapse
- API_URL =
'https://api.rollbar.com/api/1'- CREATE_PROJECT_ENDPOINT =
'/projects'- ACCESS_TOKEN_ENDPOINT =
'/project'- ACCESS_TOKEN_SCOPE =
'post_server_item'
Instance Method Summary collapse
-
#create_project(name) ⇒ Object
Create project on Rollbar, returns it new post server side access token.
-
#initialize(params) ⇒ RollbarClient
constructor
A new instance of RollbarClient.
Constructor Details
#initialize(params) ⇒ RollbarClient
Returns a new instance of RollbarClient.
10 11 12 13 |
# File 'app/clients/disco_app/rollbar_client.rb', line 10 def initialize(params) @write_access_token = params[:write_account_access_token] @read_access_token = params[:read_account_access_token] end |
Instance Method Details
#create_project(name) ⇒ Object
Create project on Rollbar, returns it new post server side access token
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/clients/disco_app/rollbar_client.rb', line 16 def create_project(name) begin response = RestClient::Request.execute( method: :post, headers: { content_type: :json }, url: create_api_url, payload: { name: name.parameterize }.to_json ) request_access_token(ActiveSupport::JSON.decode(response).dig('result', 'id')) rescue RestClient::BadRequest => e raise RollbarClientError.new(e.) end end |