Class: Markety::Response::GetLeadResponse
- Inherits:
-
GenericResponse
- Object
- GenericResponse
- Markety::Response::GetLeadResponse
- Defined in:
- lib/markety/response/get_lead_response.rb
Overview
Response class for Command::GetLead calls.
Instance Attribute Summary collapse
-
#leads ⇒ Object
readonly
Array of leads returned by the GetLead command.
Attributes inherited from GenericResponse
Instance Method Summary collapse
-
#initialize(response) ⇒ GetLeadResponse
constructor
A new instance of GetLeadResponse.
-
#lead ⇒ Object
Convenience shortcut to get first element of #leads (or nil if none).
Methods inherited from GenericResponse
Constructor Details
#initialize(response) ⇒ GetLeadResponse
Returns a new instance of GetLeadResponse.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/markety/response/get_lead_response.rb', line 11 def initialize(response) super(:get_lead_response,response) h = self.to_hash @leads = [] if self.success? count = h[:success_get_lead][:result][:count].to_i lead_hashes = h[:success_get_lead][:result][:lead_record_list][:lead_record] lead_hashes = [lead_hashes] if count==1 lead_hashes.each {|leadhash| @leads << ::Markety::Lead.from_hash(leadhash) } else # overwrite super's crap error message with useful one @error_message = h[:fault][:detail][:service_exception][:message] end end |
Instance Attribute Details
#leads ⇒ Object (readonly)
Array of leads returned by the GetLead command
9 10 11 |
# File 'lib/markety/response/get_lead_response.rb', line 9 def leads @leads end |
Instance Method Details
#lead ⇒ Object
Convenience shortcut to get first element of #leads (or nil if none). Appropriate for responses to Command::GetLead#get_lead_by_idnum, which cannot result in more than one lead.
30 31 32 |
# File 'lib/markety/response/get_lead_response.rb', line 30 def lead @leads.first end |