Class: Harvesting::Models::Invoices
- Inherits:
-
HarvestRecordCollection
- Object
- Base
- HarvestRecordCollection
- Harvesting::Models::Invoices
- Defined in:
- lib/harvesting/models/invoices.rb
Instance Attribute Summary
Attributes inherited from HarvestRecordCollection
Attributes inherited from Base
Instance Method Summary collapse
- #fetch_next_page ⇒ Object
-
#initialize(attrs, query_opts = {}, opts = {}) ⇒ Invoices
constructor
A new instance of Invoices.
Methods inherited from HarvestRecordCollection
#next_page_query_opts, #page, #size
Methods included from Enumerable
Methods inherited from Base
#create, #delete, #fetch, get, #save, #to_hash, #update
Constructor Details
#initialize(attrs, query_opts = {}, opts = {}) ⇒ Invoices
Returns a new instance of Invoices.
4 5 6 7 8 9 |
# File 'lib/harvesting/models/invoices.rb', line 4 def initialize(attrs, query_opts = {}, opts = {}) super(attrs.reject {|k,v| k == "invoices" }, query_opts, opts) @entries = attrs["invoices"].map do |entry| Invoice.new(entry, harvest_client: opts[:harvest_client]) end end |
Instance Method Details
#fetch_next_page ⇒ Object
11 12 13 14 |
# File 'lib/harvesting/models/invoices.rb', line 11 def fetch_next_page @entries += harvest_client.invoices(next_page_query_opts).entries @attributes['page'] = page + 1 end |