Class: SonyCiClient

Inherits:
Object
  • Object
show all
Defined in:
lib/sony_ci_api/sony_ci_client.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#add_headers(curl, mime = nil) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/sony_ci_api/sony_ci_client.rb', line 2

def add_headers(curl, mime = nil)
  # on_missing and on_failure exist...
  # but any exceptions are caught and turned into warnings:
  # You need to check the response code at the end
  # if you want the execution path to change.
  curl.verbose = @ci.verbose
  curl.headers['Authorization'] = "Bearer #{@ci.access_token}"
  curl.headers['Content-Type'] = mime if mime
end

#handle_errors(curl) ⇒ Object



12
13
14
# File 'lib/sony_ci_api/sony_ci_client.rb', line 12

def handle_errors(curl)
  fail "#{curl.status}: #{curl.url}\nHEADERS: #{curl.headers}\nPOST: #{curl.post_body}\nRESPONSE: #{curl.body}" if curl.response_code.to_s !~ /^2../
end