Class: ConstantContact::Components::ResultSet
- Inherits:
-
Object
- Object
- ConstantContact::Components::ResultSet
- Defined in:
- lib/constantcontact/components/result_set.rb
Instance Attribute Summary collapse
-
#next ⇒ Object
Returns the value of attribute next.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize(results, meta, component = nil) ⇒ ResultSet
constructor
Constructor to create a ResultSet from the results/meta response when performing a get on a collection.
- #next_results ⇒ Object
Constructor Details
#initialize(results, meta, component = nil) ⇒ ResultSet
Constructor to create a ResultSet from the results/meta response when performing a get on a collection
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/constantcontact/components/result_set.rb', line 16 def initialize(results, , component = nil) @results = results if component.present? @component = component end if .has_key?('pagination') and ['pagination'].has_key?('next_link') @next_link = ['pagination']['next_link'] @next = @next_link[@next_link.index('?'), @next_link.length] end end |
Instance Attribute Details
#next ⇒ Object
Returns the value of attribute next.
10 11 12 |
# File 'lib/constantcontact/components/result_set.rb', line 10 def next @next end |
#results ⇒ Object
Returns the value of attribute results.
10 11 12 |
# File 'lib/constantcontact/components/result_set.rb', line 10 def results @results end |
Instance Method Details
#next_results ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/constantcontact/components/result_set.rb', line 28 def next_results if @next_link.present? and @component.present? url = Util::Config.get('endpoints.api_url') + @next_link url = url.gsub(@next, "") url = Services::BaseService.build_url(url, { :next => @next.split("next=")[1] }) response = RestClient.get(url, Services::BaseService.get_headers()) body = JSON.parse(response.body) events = body['results'].collect do |event| @component.create_summary(event) end return Components::ResultSet.new(events, body['meta'], @component) else return nil end end |