Class: Thron::Gateway::Delivery

Inherits:
Session show all
Defined in:
lib/thron/gateway/delivery.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
16
17
18
19
20
21
# File 'lib/thron/gateway/delivery.rb', line 11

def self.routes
  @routes ||= {
    content_metadata: Route::factory(name: 'getContentDetail', package: PACKAGE, verb: Route::Verbs::GET),
    content_cuepoints: Route::factory(name: 'getCuePoints', package: PACKAGE, verb: Route::Verbs::GET),
    downloadable_contents: Route::factory(name: 'getDownloadableContents', package: PACKAGE, verb: Route::Verbs::GET),
    playlist_contents: Route::factory(name: 'getPlaylistContents', package: PACKAGE, verb: Route::Verbs::GET),
    recommended_contents: Route::factory(name: 'getRecommendedContents', package: PACKAGE, verb: Route::Verbs::GET),
    content_subtitles: Route::factory(name: 'getSubTitles', package: PACKAGE, verb: Route::Verbs::GET, accept: Route::Types::PLAIN),
    content_thumbnail: Route::lazy_factory(name: 'getThumbnail', package: PACKAGE, verb: Route::Verbs::GET)
  }
end

Instance Method Details

#content_cuepoints(options = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/thron/gateway/delivery.rb', line 35

def content_cuepoints(options = {})
  content_id = options[:content_id]
  criteria = options.fetch(:criteria) { {} }
  offset = options[:offset].to_i
  limit = options[:limit].to_i
  query = { 
    clientId: client_id,
    xcontentId: content_id,
    offset: offset,
    numberOfResult: limit
  }.merge!(criteria)
  route(to: __callee__, query: query, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('cuePoints') { [] })
  end
end

#content_metadata(options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/thron/gateway/delivery.rb', line 23

def (options = {})
  content_id = options[:content_id]
  criteria = options.fetch(:criteria) { {} }
  query = { 
    clientId: client_id,
    xcontentId: content_id
  }.merge!(criteria)
  route(to: __callee__, query: query, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body)
  end
end

#content_subtitles(options = {}) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/thron/gateway/delivery.rb', line 101

def content_subtitles(options = {})
  content_id = options[:content_id]
  locale = options[:locale]
  criteria = options.fetch(:criteria) { {} }
  query = { 
    clientId: client_id,
    xcontentId: content_id,
    locale: locale
  }.merge!(criteria)
  route(to: __callee__, query: query, token_id: token_id)
end

#content_thumbnail(options = {}) ⇒ Object



113
114
115
116
117
118
119
# File 'lib/thron/gateway/delivery.rb', line 113

def content_thumbnail(options = {})
  content_id = options[:content_id]
  div_area = options[:div_area]
  route(to: __callee__, token_id: token_id, params: [client_id, div_area, content_id]) do |response|
    response.body = Entity::Base::factory(response.body)
  end
end

#downloadable_contents(options = {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/thron/gateway/delivery.rb', line 51

def downloadable_contents(options = {})
  content_id = options[:content_id]
  criteria = options.fetch(:criteria) { {} }
  offset = options[:offset].to_i
  limit = options[:limit].to_i
  query = { 
    clientId: client_id,
    xcontentId: content_id,
    offset: offset,
    numberOfResult: limit
  }.merge!(criteria)
  route(to: __callee__, query: query, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('contents') { [] })
  end
end

#playlist_contents(options = {}) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/thron/gateway/delivery.rb', line 67

def playlist_contents(options = {})
  content_id = options[:content_id]
  criteria = options.fetch(:criteria) { {} }
  offset = options[:offset].to_i
  limit = options[:limit].to_i
  query = { 
    clientId: client_id,
    xcontentId: content_id,
    offset: offset,
    numberOfResult: limit
  }.merge!(criteria)
  route(to: __callee__, query: query, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('contents') { [] })
  end
end


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/thron/gateway/delivery.rb', line 83

def recommended_contents(options = {})
  content_id = options[:content_id]
  pkey = options[:pkey]
  criteria = options.fetch(:criteria) { { admin: true } }
  offset = options[:offset].to_i
  limit = options[:limit].to_i
  query = { 
    clientId: client_id,
    xcontentId: content_id,
    pkey: pkey,
    offset: offset,
    numberOfResult: limit
  }.merge!(criteria)
  route(to: __callee__, query: query, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('contents') { [] })
  end
end