Class: SoapyCake::Client
- Inherits:
-
Object
show all
- Defined in:
- lib/soapy_cake/client.rb
Constant Summary
collapse
{ 'Content-Type' => 'application/soap+xml;charset=UTF-8' }.freeze
Instance Method Summary
collapse
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
11
12
13
14
15
16
17
18
|
# File 'lib/soapy_cake/client.rb', line 11
def initialize(opts = {})
@opts = opts
@domain = fetch_opt(:domain) || raise(Error, 'Cake domain missing')
@api_key = fetch_opt(:api_key) || raise(Error, 'Cake API key missing')
@retry_count = fetch_opt(:retry_count, 4)
@write_enabled = ['yes', true].include?(fetch_opt(:write_enabled))
@time_converter = TimeConverter.new(fetch_opt(:time_zone))
end
|
Instance Method Details
#read_only? ⇒ Boolean
24
25
26
|
# File 'lib/soapy_cake/client.rb', line 24
def read_only?
!write_enabled
end
|
#run(request) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/soapy_cake/client.rb', line 28
def run(request)
check_write_enabled!(request)
request.api_key = api_key
request.time_converter = time_converter
with_retries do
response = Response.new(response_body(request), request.short_response?, time_converter)
xml_response? ? response.to_xml : response.to_enum
rescue RequestFailed => e
raise RequestFailed.new(
e.message,
request_path: request.path,
request_body: request.xml,
response_body: e.response_body || response.body
)
end
end
|
#xml_response? ⇒ Boolean
20
21
22
|
# File 'lib/soapy_cake/client.rb', line 20
def xml_response?
opts[:xml_response] == true
end
|