Class: GlobalSign::Response
- Inherits:
-
Object
- Object
- GlobalSign::Response
show all
- Defined in:
- lib/global_sign/response.rb
Constant Summary
collapse
- SUCCESS_CODE =
'0'.freeze
- WARNING_CODE =
'1'.freeze
Instance Method Summary
collapse
Constructor Details
#initialize(body) ⇒ Response
Returns a new instance of Response.
8
9
10
|
# File 'lib/global_sign/response.rb', line 8
def initialize(body)
@xml = Nokogiri::XML(body)
end
|
Instance Method Details
#error? ⇒ Boolean
28
29
30
|
# File 'lib/global_sign/response.rb', line 28
def error?
!success? && !warning?
end
|
#error_code ⇒ Object
32
33
34
|
# File 'lib/global_sign/response.rb', line 32
def error_code
errors.at('ErrorCode').try(:text)
end
|
#error_field ⇒ Object
36
37
38
|
# File 'lib/global_sign/response.rb', line 36
def error_field
errors.at('ErrorField').try(:text)
end
|
#error_message ⇒ Object
40
41
42
|
# File 'lib/global_sign/response.rb', line 40
def error_message
errors.at('ErrorMessage').try(:text)
end
|
#success? ⇒ Boolean
20
21
22
|
# File 'lib/global_sign/response.rb', line 20
def success?
@xml.xpath(xpath_result).text == SUCCESS_CODE
end
|
#warning? ⇒ Boolean
24
25
26
|
# File 'lib/global_sign/response.rb', line 24
def warning?
@xml.xpath(xpath_result).text == WARNING_CODE
end
|
#xpath_errors ⇒ Object
16
17
18
|
# File 'lib/global_sign/response.rb', line 16
def xpath_errors
"//Response/#{}/Errors"
end
|
#xpath_result ⇒ Object
12
13
14
|
# File 'lib/global_sign/response.rb', line 12
def xpath_result
"//Response/#{}/SuccessCode"
end
|