Module: Spree::Api::V2::CollectionOptionsHelpers

Included in:
Storefront::Account::OrdersController, Storefront::CountriesController, Storefront::ProductsController, Storefront::TaxonsController
Defined in:
app/helpers/spree/api/v2/collection_options_helpers.rb

Instance Method Summary collapse

Instance Method Details



5
6
7
8
9
10
11
12
13
# File 'app/helpers/spree/api/v2/collection_options_helpers.rb', line 5

def collection_links(collection)
  {
    self: request.original_url,
    next: pagination_url(collection.next_page || collection.total_pages),
    prev: pagination_url(collection.prev_page || 1),
    last: pagination_url(collection.total_pages),
    first: pagination_url(1)
  }
end

#collection_meta(collection) ⇒ Object



15
16
17
18
19
20
21
# File 'app/helpers/spree/api/v2/collection_options_helpers.rb', line 15

def collection_meta(collection)
  {
    count: collection.size,
    total_count: collection.total_count,
    total_pages: collection.total_pages
  }
end

#collection_permitted_paramsObject

leaving this method in public scope so it’s still possible to modify those params to support non-standard non-JSON API parameters



25
26
27
# File 'app/helpers/spree/api/v2/collection_options_helpers.rb', line 25

def collection_permitted_params
  params.permit(:format, :page, :per_page, :sort, :include, :fields, filter: {})
end