Module: OneLogin::Api::Util::Parser
- Included in:
- OneLogin::Api::Util
- Defined in:
- lib/onelogin/api/util/parser.rb
Instance Method Summary collapse
- #extract_error_attribute_from_response(response) ⇒ Object
- #extract_error_message_from_response(response) ⇒ Object
- #extract_status_code_from_response(response) ⇒ Object
Instance Method Details
#extract_error_attribute_from_response(response) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/onelogin/api/util/parser.rb', line 31 def extract_error_attribute_from_response(response) attribute = nil content = JSON.parse(response.body) if content && content.has_key?('status') status = content['status'] if status.has_key?('message') && status['message'].instance_of?(Hash) if status['message'].has_key?('attribute') attribute = status['message']['attribute'] end end end attribute end |
#extract_error_message_from_response(response) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/onelogin/api/util/parser.rb', line 5 def (response) = '' content = JSON.parse(response.body) if content if content.has_key?('status') status = content['status'] if status.has_key?('message') if status['message'].instance_of?(Hash) if status['message'].has_key?('description') = status['message']['description'] end else = status['message'] end elsif status.has_key?('type') = status['type'] end elsif content.has_key?('message') = content['message'] elsif content.has_key?('name') = content['name'] end end end |
#extract_status_code_from_response(response) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/onelogin/api/util/parser.rb', line 45 def extract_status_code_from_response(response) status_code = '' content = JSON.parse(response.body) if content && content.has_key?('statusCode') status_code = content['statusCode'] end status_code end |