Class: Thron::Gateway::Category
- Defined in:
- lib/thron/gateway/category.rb
Constant Summary collapse
- PACKAGE =
Package.new(:xcontents, :resources, self.service_name)
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #add_category_for_locale(options = {}) ⇒ Object
- #add_category_pretty_id(options = {}) ⇒ Object
- #category_detail(options = {}) ⇒ Object
- #create_category(options = {}) ⇒ Object
- #create_system_category(options = {}) ⇒ Object
- #find_categories(options = {}) ⇒ Object
- #remove_category(options = {}) ⇒ Object
- #remove_category_for_locale(options = {}) ⇒ Object
- #remove_category_pretty_id(options = {}) ⇒ Object
- #set_parent_category(options = {}) ⇒ Object
- #update_category(options = {}) ⇒ Object
- #update_category_for_locale(options = {}) ⇒ Object
- #update_category_pretty_id(options = {}) ⇒ Object
Methods inherited from Session
Methods included from Pageable
Methods inherited from Base
#check_session, client_id, #client_id, service_name
Methods included from Routable
Constructor Details
This class inherits a constructor from Thron::Gateway::Session
Class Method Details
.routes ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/thron/gateway/category.rb', line 11 def self.routes @routes ||= { create_category: Route::factory(name: 'createCategory', package: PACKAGE), create_system_category: Route::factory(name: 'createSystemCategory', package: PACKAGE), add_category_for_locale: Route::factory(name: 'addCategory4Locale', package: PACKAGE), add_category_pretty_id: Route::factory(name: 'addCategoryPrettyId', package: PACKAGE), find_categories: Route::factory(name: 'findByProperties2', package: PACKAGE), category_detail: Route::factory(name: 'getCategory', package: PACKAGE, verb: Route::Verbs::GET), remove_category: Route::factory(name: 'removeCategory', package: PACKAGE), remove_category_for_locale: Route::factory(name: 'removeCategory4Locale', package: PACKAGE), remove_category_pretty_id: Route::factory(name: 'removeCategoryPrettyId', package: PACKAGE), set_parent_category: Route::factory(name: 'setParentId', package: PACKAGE), update_category: Route::factory(name: 'updateCategory', package: PACKAGE), update_category_for_locale: Route::factory(name: 'updateCategory4Locale', package: PACKAGE), update_category_pretty_id: Route::factory(name: 'updateCategoryPrettyId', package: PACKAGE) } end |
Instance Method Details
#add_category_for_locale(options = {}) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/thron/gateway/category.rb', line 66 def add_category_for_locale( = {}) category_id = [:category_id] locale = [:locale] body = { client: { clientId: client_id }, catId: category_id, catLocale: locale } route(to: __callee__, body: body, token_id: token_id) end |
#add_category_pretty_id(options = {}) ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/thron/gateway/category.rb', line 79 def add_category_pretty_id( = {}) category_id = [:category_id] pretty_id = [:pretty_id] body = { clientId: client_id, categoryId: category_id, prettyId: pretty_id } route(to: __callee__, body: body, token_id: token_id) end |
#category_detail(options = {}) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/thron/gateway/category.rb', line 111 def category_detail( = {}) category_id = [:category_id] recursive = .fetch(:recursive) { false } locale = [:locale] query = { clientId: client_id, categoryId: category_id, cascade: recursive, locale: locale } route(to: __callee__, query: query, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('category') { {} }) end end |
#create_category(options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/thron/gateway/category.rb', line 29 def create_category( = {}) parent_id = [:parent_id] locale = [:locale] is_private = .fetch(:is_private) { false } solution = [:solution] data = [:data] body = { client: { clientId: client_id }, upCatId: parent_id, catLocales: locale, isPrivate: is_private, private: is_private, solution: solution, options: data } route(to: __callee__, body: body, token_id: token_id) end |
#create_system_category(options = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/thron/gateway/category.rb', line 49 def create_system_category( = {}) category_id = [:category_id] parent_id = [:parent_id] locale = [:locale] data = [:data] body = { client: { clientId: client_id }, newCategoryId: category_id, upCatId: parent_id, catLocales: locale, options: data } route(to: __callee__, body: body, token_id: token_id) end |
#find_categories(options = {}) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/thron/gateway/category.rb', line 90 def find_categories( = {}) criteria = .fetch(:criteria) { {} } locale = [:locale] order_by = [:order_by] offset = [:offset].to_i limit = [:limit].to_i body = { client: { clientId: client_id }, properties: criteria, locale: locale, orderBy: order_by, offset: offset.to_i, numberOfResult: limit.to_i } route(to: __callee__, body: body, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('categories') { [] }) end end |
#remove_category(options = {}) ⇒ Object
126 127 128 129 130 131 132 133 134 135 |
# File 'lib/thron/gateway/category.rb', line 126 def remove_category( = {}) category_id = [:category_id] recursive = .fetch(:recursive) { false } query = { clientId: client_id, catId: category_id, cascade: recursive } route(to: __callee__, query: query, token_id: token_id, dash: false) end |
#remove_category_for_locale(options = {}) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/thron/gateway/category.rb', line 137 def remove_category_for_locale( = {}) category_id = [:category_id] locale = [:locale] body = { client: { clientId: client_id }, catId: category_id, locale: locale } route(to: __callee__, body: body, token_id: token_id) end |
#remove_category_pretty_id(options = {}) ⇒ Object
150 151 152 153 154 155 156 157 158 159 |
# File 'lib/thron/gateway/category.rb', line 150 def remove_category_pretty_id( = {}) category_id = [:category_id] locale = [:locale] body = { clientId: client_id, categoryId: category_id, locale: locale } route(to: __callee__, body: body, token_id: token_id) end |
#set_parent_category(options = {}) ⇒ Object
161 162 163 164 165 166 167 168 169 170 |
# File 'lib/thron/gateway/category.rb', line 161 def set_parent_category( = {}) category_id = [:category_id] parent_id = [:parent_id] query = { clientId: client_id, categoryId: category_id, categoryParentId: parent_id } route(to: __callee__, query: query, token_id: token_id, dash: false) end |
#update_category(options = {}) ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/thron/gateway/category.rb', line 172 def update_category( = {}) category_id = [:category_id] data = [:data] body = { client: { clientId: client_id }, categoryId: category_id, update: data } route(to: __callee__, body: body, token_id: token_id) end |
#update_category_for_locale(options = {}) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/thron/gateway/category.rb', line 185 def update_category_for_locale( = {}) category_id = [:category_id] locale = [:locale] body = { client: { clientId: client_id }, catId: category_id, property: locale } route(to: __callee__, body: body, token_id: token_id) end |
#update_category_pretty_id(options = {}) ⇒ Object
198 199 200 201 202 203 204 205 206 207 |
# File 'lib/thron/gateway/category.rb', line 198 def update_category_pretty_id( = {}) category_id = [:category_id] pretty_id = [:pretty_id] body = { clientId: client_id, categoryId: category_id, prettyId: pretty_id } route(to: __callee__, body: body, token_id: token_id) end |