module Watchdocs::Rails::Recordings::Exporter
Constants
- DEFAULT_ERROR
Public Class Methods
export(payload)
click to toggle source
# File lib/watchdocs/rails/recordings/exporter.rb, line 12 def export(payload) response = HTTParty.post( api_url, body: payload.to_json, headers: { 'Content-Type' => 'application/json' }, basic_auth: api_auth ) check_response(response) end
Private Class Methods
api_auth()
click to toggle source
# File lib/watchdocs/rails/recordings/exporter.rb, line 45 def api_auth { username: Watchdocs::Rails.configuration.app_id, password: Watchdocs::Rails.configuration.app_secret } end
api_url()
click to toggle source
# File lib/watchdocs/rails/recordings/exporter.rb, line 41 def api_url Watchdocs::Rails.configuration.export_url end
check_response(response)
click to toggle source
# File lib/watchdocs/rails/recordings/exporter.rb, line 24 def check_response(response) case response.code.to_s.chars.first when '2' true when '4', '5' raise WatchdocsApiError, get_error(response.body) else raise WatchdocsApiError, DEFAULT_ERROR end end
get_error(response_body)
click to toggle source
# File lib/watchdocs/rails/recordings/exporter.rb, line 35 def get_error(response_body) response_body rescue DEFAULT_ERROR end