Class: Spear::Structure::Base
- Inherits:
-
Object
- Object
- Spear::Structure::Base
- Defined in:
- lib/spear/structure/base.rb
Direct Known Subclasses
Application::Blank, Application::Create, Application::History, Application::State, Application::Submit, Job::Retrieve, Job::Search, Resume::Create, Resume::Edit, Resume::Ownall, Resume::Parse, Resume::Retrieve, Resume::Upload, TalentNetwork::CreateMember, TalentNetwork::JoinFormQuestion, User::CheckExisting, User::Create, User::Retrieve, User::TokenAuthenticate
Instance Attribute Summary collapse
-
#error_message ⇒ Object
readonly
response is an instance of Httparty::Response.
-
#response ⇒ Object
readonly
response is an instance of Httparty::Response.
-
#root ⇒ Object
readonly
response is an instance of Httparty::Response.
-
#status ⇒ Object
readonly
response is an instance of Httparty::Response.
Instance Method Summary collapse
-
#initialize(response) ⇒ Base
constructor
A new instance of Base.
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/spear/structure/base.rb', line 7 def initialize(response) raise Spear::ParametersRequired.new('Response') if response.nil? @response = response # Note: <b>Application Form API</b> return html string. if response.kind_of?(Hash) # get the root keyvalue of the hash if response.to_h.has_key?('Errors') @root = response.to_h else @root = response.to_h.first.last end # Note: <b>Application Status API</b> is different. @status = @root["Status"] || @root['ApplicationStatus'] @error_message = (@root) end end |
Instance Attribute Details
#error_message ⇒ Object (readonly)
response is an instance of Httparty::Response
5 6 7 |
# File 'lib/spear/structure/base.rb', line 5 def @error_message end |
#response ⇒ Object (readonly)
response is an instance of Httparty::Response
5 6 7 |
# File 'lib/spear/structure/base.rb', line 5 def response @response end |
#root ⇒ Object (readonly)
response is an instance of Httparty::Response
5 6 7 |
# File 'lib/spear/structure/base.rb', line 5 def root @root end |
#status ⇒ Object (readonly)
response is an instance of Httparty::Response
5 6 7 |
# File 'lib/spear/structure/base.rb', line 5 def status @status end |
Instance Method Details
#success? ⇒ Boolean
28 29 30 |
# File 'lib/spear/structure/base.rb', line 28 def success? @status.nil? ? @error_message.nil? : (@status.include?('Success') or @status.include?('Complete')) end |