Class: PigCI::Api::Reports

Inherits:
PigCI::Api show all
Defined in:
lib/pig_ci/api/reports.rb

Instance Method Summary collapse

Methods inherited from PigCI::Api

#headers

Constructor Details

#initialize(reports: []) ⇒ Reports

Returns a new instance of Reports.


2
3
4
# File 'lib/pig_ci/api/reports.rb', line 2

def initialize(reports: [])
  @reports = reports
end

Instance Method Details

#share!Object


6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/pig_ci/api/reports.rb', line 6

def share!
  response = post_payload
  return if response.success?

  puts I18n.t('pig_ci.api.reports.error', error: JSON.parse(response.parsed_response || '{}')['error'])
rescue JSON::ParserError => _e
  puts I18n.t('pig_ci.api.reports.api_error')
rescue SocketError => e
  puts I18n.t('pig_ci.api.reports.error', error: e)
rescue Net::OpenTimeout => e
  puts I18n.t('pig_ci.api.reports.error', error: e.inspect)
end