Class: ClientApi::Api
Constant Summary
Constants included
from ClientApi
VERSION
Instance Method Summary
collapse
Methods included from ClientApi
#base_url, #basic_auth, configuration, configure, #datatype, #deep_traverse, #headers, #is_num?, #json_output, #payload, #time_out, #validate, #validate_json, #validate_schema
Methods inherited from Request
#basic_encode, #connect, #delete_request, #get_request, #header, #patch_request, #post_request, #pre_logger, #put_request, #uri
Instance Method Details
#body ⇒ Object
Also known as:
resp
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/client-api/base.rb', line 38
def body
if [200, 201, 202, 204].include? status
unless json_output['Dirname'] == nil
FileUtils.mkdir_p "#{json_output['Dirname']}"
File.open("./output/#{json_output['Filename']}.json", "wb") {|file| file.puts JSON.pretty_generate(JSON.parse(@output.body))}
end
JSON.parse(@output.body)
else
JSON.parse(@output.message)
end
end
|
#delete(url, headers = nil) ⇒ Object
19
20
21
22
|
# File 'lib/client-api/base.rb', line 19
def delete(url, = nil)
@output = delete_request(url, :headers => )
post_logger if $logger
end
|
#get(url, headers = nil) ⇒ Object
9
10
11
12
|
# File 'lib/client-api/base.rb', line 9
def get(url, = nil)
@output = get_request(url, :headers => )
post_logger if $logger
end
|
#message ⇒ Object
50
51
52
|
# File 'lib/client-api/base.rb', line 50
def message
@output.message
end
|
#patch(url, body, headers = nil) ⇒ Object
29
30
31
32
|
# File 'lib/client-api/base.rb', line 29
def patch(url, body, = nil)
@output = patch_request(url, :body => body, :headers => )
post_logger if $logger
end
|
#post(url, body, headers = nil) ⇒ Object
14
15
16
17
|
# File 'lib/client-api/base.rb', line 14
def post(url, body, = nil)
@output = post_request(url, :body => body, :headers => )
post_logger if $logger
end
|
#post_logger ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/client-api/base.rb', line 54
def post_logger
(@output.body.nil? || @output.body == "{}") ? res_body = 'empty response body' : res_body = body
$logger.debug("Response code == #{@output.code.to_i}")
$logger.debug("Response body == #{res_body}")
$logger.debug("=====================================================================================")
end
|
#put(url, body, headers = nil) ⇒ Object
24
25
26
27
|
# File 'lib/client-api/base.rb', line 24
def put(url, body, = nil)
@output = put_request(url, :body => body, :headers => )
post_logger if $logger
end
|
#status ⇒ Object
Also known as:
code
34
35
36
|
# File 'lib/client-api/base.rb', line 34
def status
@output.code.to_i
end
|