Class: OyenCov::APIConnection
- Inherits:
-
Faraday::Connection
- Object
- Faraday::Connection
- OyenCov::APIConnection
- Includes:
- Singleton
- Defined in:
- lib/oyencov/api_connection.rb
Instance Method Summary collapse
-
#get_data_submission_clearance ⇒ Object
Used in ‘background.rb` to determine whether to start background.
-
#initialize ⇒ APIConnection
constructor
A new instance of APIConnection.
- #post_runtime_report(body) ⇒ Object
- #post_test_report(body) ⇒ Object
Constructor Details
#initialize ⇒ APIConnection
Returns a new instance of APIConnection.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/oyencov/api_connection.rb', line 10 def initialize super({ url: (ENV["OYENCOV_API_URL"] || "https://telemetry-api.oyencov.com"), headers: { "Authorization" => "Bearer #{ENV["OYENCOV_API_KEY"]}", "Content-Type" => "application/json", "User-Agent" => "oyencov-ruby #{OyenCov::VERSION}" } }) do |f| f.request :json f.response :json end end |
Instance Method Details
#get_data_submission_clearance ⇒ Object
Used in ‘background.rb` to determine whether to start background
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/oyencov/api_connection.rb', line 25 def get_data_submission_clearance attempts = 3 begin response = get("/v1/data_submission_clearance") rescue Faraday::Error => e OyenCov::Logger.log(e, 2) if attempts > 0 attempts -= 1 sleep(5) retry end nil end response end |
#post_runtime_report(body) ⇒ Object
43 44 45 46 47 |
# File 'lib/oyencov/api_connection.rb', line 43 def post_runtime_report(body) post("/v1/runtime_reports", body) rescue Faraday::Error false end |
#post_test_report(body) ⇒ Object
49 50 51 |
# File 'lib/oyencov/api_connection.rb', line 49 def post_test_report(body) post("/v1/test_reports", body) end |