Class: Thron::Gateway::ContentList

Inherits:
Session show all
Defined in:
lib/thron/gateway/content_list.rb

Constant Summary collapse

PACKAGE =
Package.new(:xcontents, :resources, self.service_name)

Constants inherited from Base

Base::NO_ACTIVE_SESSION

Instance Attribute Summary

Attributes inherited from Base

#token_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Session

#initialize

Methods included from Pageable

included

Methods inherited from Base

#check_session, client_id, #client_id, service_name

Methods included from Routable

included, info, #route

Constructor Details

This class inherits a constructor from Thron::Gateway::Session

Class Method Details

.routesObject



11
12
13
14
15
# File 'lib/thron/gateway/content_list.rb', line 11

def self.routes
  @routes ||= {
    show_contents: Route::factory(name: 'showContents', package: PACKAGE, verb: Route::Verbs::GET)
  }
end

Instance Method Details

#show_contents(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/thron/gateway/content_list.rb', line 17

def show_contents(options = {})
  category_id = options[:category_id]
  locale = options[:locale]
  criteria = options.fetch(:criteria) { {} }
  recursive = options.fetch(:recursive) { true }
  order_by = options.fetch(:order_by) { 'contentName_A' }
  limit = options[:limit].to_i
  offset = options[:offset].to_i
  query = { 
    clientId: client_id,
    categoryId: category_id,
    locale: locale,
    searchOnSubCategories: recursive,
    orderBy: order_by,
    numberOfResult: limit,
    offset: offset
  }.merge(criteria)
  route(to: __callee__, query: query, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('contents') { [] })
  end
end