thron 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.example +4 -0
- data/.gitignore +13 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/README.md +182 -0
- data/Rakefile +10 -0
- data/Vagrantfile +80 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/thron.yml +10 -0
- data/lib/thron.rb +3 -0
- data/lib/thron/circuit_breaker.rb +46 -0
- data/lib/thron/config.rb +35 -0
- data/lib/thron/entity/base.rb +78 -0
- data/lib/thron/entity/image.rb +30 -0
- data/lib/thron/gateway/access_manager.rb +69 -0
- data/lib/thron/gateway/apps.rb +91 -0
- data/lib/thron/gateway/apps_admin.rb +153 -0
- data/lib/thron/gateway/base.rb +41 -0
- data/lib/thron/gateway/category.rb +210 -0
- data/lib/thron/gateway/client.rb +59 -0
- data/lib/thron/gateway/comment.rb +76 -0
- data/lib/thron/gateway/contact.rb +120 -0
- data/lib/thron/gateway/content.rb +267 -0
- data/lib/thron/gateway/content_category.rb +32 -0
- data/lib/thron/gateway/content_list.rb +40 -0
- data/lib/thron/gateway/dashboard.rb +120 -0
- data/lib/thron/gateway/delivery.rb +122 -0
- data/lib/thron/gateway/device.rb +58 -0
- data/lib/thron/gateway/metadata.rb +68 -0
- data/lib/thron/gateway/publish_in_weebo_express.rb +39 -0
- data/lib/thron/gateway/publishing_process.rb +141 -0
- data/lib/thron/gateway/repository.rb +111 -0
- data/lib/thron/gateway/session.rb +15 -0
- data/lib/thron/gateway/users_group_manager.rb +117 -0
- data/lib/thron/gateway/v_user_manager.rb +195 -0
- data/lib/thron/logger.rb +25 -0
- data/lib/thron/pageable.rb +26 -0
- data/lib/thron/paginator.rb +82 -0
- data/lib/thron/response.rb +48 -0
- data/lib/thron/root.rb +9 -0
- data/lib/thron/routable.rb +80 -0
- data/lib/thron/route.rb +102 -0
- data/lib/thron/string_extensions.rb +23 -0
- data/lib/thron/user.rb +77 -0
- data/lib/thron/version.rb +3 -0
- data/log/.gitignore +4 -0
- data/thron.gemspec +26 -0
- metadata +176 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
module Thron
|
2
|
+
module Entity
|
3
|
+
class Image < Base
|
4
|
+
def initialize(hash = {})
|
5
|
+
super
|
6
|
+
@path = hash.delete(:path)
|
7
|
+
if valid_path?
|
8
|
+
fetch_mime_type
|
9
|
+
fetch_buffer
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def valid_path?
|
16
|
+
File.readable?(@path.to_s)
|
17
|
+
end
|
18
|
+
|
19
|
+
def fetch_mime_type
|
20
|
+
@table[:mime_type] ||= `file -b --mime-type #{@path}`.to_s.chomp
|
21
|
+
new_ostruct_member(:mime_type)
|
22
|
+
end
|
23
|
+
|
24
|
+
def fetch_buffer
|
25
|
+
@table[:buffer] ||= File.binread(@path).unpack('c*')
|
26
|
+
new_ostruct_member(:buffer)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'thron/gateway/base'
|
2
|
+
|
3
|
+
module Thron
|
4
|
+
module Gateway
|
5
|
+
class AccessManager < Base
|
6
|
+
|
7
|
+
PACKAGE = Package.new(:xsso, :resources, self.service_name)
|
8
|
+
|
9
|
+
def self.routes
|
10
|
+
@routes ||= {
|
11
|
+
login: Route::factory(name: 'login', package: PACKAGE, params: [client_id]),
|
12
|
+
logout: Route::factory(name: 'logout', package: PACKAGE, params: [client_id], type: Route::Types::PLAIN, accept: Route::Types::PLAIN),
|
13
|
+
validate_capabilities: Route::factory(name: 'validateCapability', package: PACKAGE, params: [client_id], type: Route::Types::PLAIN, accept: Route::Types::PLAIN),
|
14
|
+
validate_roles: Route::factory(name: 'validateRole', package: PACKAGE, params: [client_id], type: Route::Types::PLAIN, accept: Route::Types::PLAIN),
|
15
|
+
validate_token: Route::factory(name: 'validateToken', package: PACKAGE, params: [client_id])
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def login(options = {})
|
20
|
+
query = {
|
21
|
+
username: options[:username],
|
22
|
+
password: options[:password]
|
23
|
+
}
|
24
|
+
route(to: __callee__, query: query, dash: false) do |response|
|
25
|
+
response.body = Entity::Base::factory(response.body)
|
26
|
+
@token_id = response.body.token_id
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def logout
|
31
|
+
check_session
|
32
|
+
route(to: __callee__, token_id: token_id, dash: false) do |response|
|
33
|
+
@token_id = nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def validate_capabilities(options = {})
|
38
|
+
capabilities = options.fetch(:capabilities) { [] }
|
39
|
+
check_session
|
40
|
+
query = {
|
41
|
+
capabilities: capabilities.join(',')
|
42
|
+
}
|
43
|
+
route(to: __callee__, query: query, token_id: @token_id, dash: false)
|
44
|
+
end
|
45
|
+
|
46
|
+
def validate_roles(options = {})
|
47
|
+
roles = options.fetch(:roles) { [] }
|
48
|
+
xor = options.fetch(:xor) { false }
|
49
|
+
check_session
|
50
|
+
separator = xor ? '|' : ','
|
51
|
+
query = {
|
52
|
+
role: roles.join(separator)
|
53
|
+
}
|
54
|
+
route(to: __callee__, query: query, token_id: @token_id, dash: false)
|
55
|
+
end
|
56
|
+
|
57
|
+
def validate_token(options = {})
|
58
|
+
username = options[:username]
|
59
|
+
check_session
|
60
|
+
query = {
|
61
|
+
username: username
|
62
|
+
}
|
63
|
+
route(to: __callee__, query: query, token_id: @token_id, dash: false) do |response|
|
64
|
+
response.body = Entity::Base::factory(response.body)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'thron/gateway/session'
|
2
|
+
|
3
|
+
module Thron
|
4
|
+
module Gateway
|
5
|
+
class Apps < Session
|
6
|
+
|
7
|
+
PACKAGE = Package.new(:xadmin, :resources, self.service_name)
|
8
|
+
|
9
|
+
def self.routes
|
10
|
+
@routes ||= {
|
11
|
+
app_detail: Route::factory(name: 'appDetail', package: PACKAGE),
|
12
|
+
list_apps: Route::factory(name: 'appsList', package: PACKAGE),
|
13
|
+
find_apps: Route::factory(name: 'findByProperties', package: PACKAGE),
|
14
|
+
login_app: Route::factory(name: 'loginApp', package: PACKAGE, verb: Route::Verbs::GET),
|
15
|
+
login_snippet: Route::factory(name: 'loginSnippet', package: PACKAGE, verb: Route::Verbs::GET),
|
16
|
+
su: Route::factory(name: 'su', package: PACKAGE, accept: Route::Types::PLAIN)
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def app_detail(options = {})
|
21
|
+
app_id = options[:app_id]
|
22
|
+
body = {
|
23
|
+
clientId: client_id,
|
24
|
+
appId: app_id
|
25
|
+
}
|
26
|
+
route(to: __callee__, body: body, token_id: token_id) do |response|
|
27
|
+
response.body = Entity::Base::factory(response.body.fetch('app') { {} })
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def list_apps(options = {})
|
32
|
+
criteria = options.fetch(:criteria) { {} }
|
33
|
+
body = {
|
34
|
+
clientId: client_id,
|
35
|
+
criteria: criteria
|
36
|
+
}
|
37
|
+
route(to: __callee__, body: body, token_id: token_id) do |response|
|
38
|
+
response.body = Entity::Base::factory(response.body.fetch('apps') { [] })
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def find_apps(options = {})
|
43
|
+
criteria = options.fetch(:criteria) { {} }
|
44
|
+
body = {
|
45
|
+
clientId: client_id,
|
46
|
+
criteria: criteria
|
47
|
+
}
|
48
|
+
route(to: __callee__, body: body, token_id: token_id) do |response|
|
49
|
+
response.body = Entity::Base::factory(response.body.fetch('apps') { [] })
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def login_app(options = {})
|
54
|
+
app_id = options[:app_id]
|
55
|
+
query = {
|
56
|
+
clientId: client_id,
|
57
|
+
appId: app_id
|
58
|
+
}
|
59
|
+
route(to: __callee__, query: query, token_id: token_id, dash: false) do |response|
|
60
|
+
response.body = Entity::Base::factory(response.body.fetch('app') { {} })
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def login_snippet(options = {})
|
65
|
+
app_id = options[:app_id]
|
66
|
+
snippet_id = options[:snippet_id]
|
67
|
+
query = {
|
68
|
+
clientId: client_id,
|
69
|
+
appId: app_id,
|
70
|
+
snippetId: snippet_id,
|
71
|
+
}
|
72
|
+
route(to: __callee__, query: query, token_id: token_id, dash: false) do |response|
|
73
|
+
response.body = Entity::Base::factory(response.body.fetch('snippet') { {} })
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def su(options = {})
|
78
|
+
app_id = options[:app_id]
|
79
|
+
username = options[:username]
|
80
|
+
body = {
|
81
|
+
clientId: client_id,
|
82
|
+
appId: app_id,
|
83
|
+
username: username
|
84
|
+
}
|
85
|
+
route(to: __callee__, body: body, token_id: token_id) do |response|
|
86
|
+
response.body = Entity::Base::factory(response.body)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require 'thron/gateway/session'
|
2
|
+
|
3
|
+
module Thron
|
4
|
+
module Gateway
|
5
|
+
class AppsAdmin < Session
|
6
|
+
|
7
|
+
PACKAGE = Package.new(:xadmin, :resources, self.service_name)
|
8
|
+
|
9
|
+
def self.routes
|
10
|
+
@routes ||= {
|
11
|
+
add_group_app: Route::factory(name: 'addGroupApp', package: PACKAGE),
|
12
|
+
add_snippet: Route::factory(name: 'addSnippet', package: PACKAGE),
|
13
|
+
add_user_app: Route::factory(name: 'addUserApp', package: PACKAGE),
|
14
|
+
create_app: Route::factory(name: 'create', package: PACKAGE),
|
15
|
+
remove_app: Route::factory(name: 'remove', package: PACKAGE),
|
16
|
+
remove_group_app: Route::factory(name: 'removeGroupApp', package: PACKAGE),
|
17
|
+
remove_snippet: Route::factory(name: 'removeSnippet', package: PACKAGE),
|
18
|
+
remove_user_app: Route::factory(name: 'removeUserApp', package: PACKAGE),
|
19
|
+
update_app: Route::factory(name: 'updateApp', package: PACKAGE),
|
20
|
+
update_snippet: Route::factory(name: 'updateSnippet', package: PACKAGE)
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_group_app(options = {})
|
25
|
+
app_id = options[:app_id]
|
26
|
+
group_id = options[:group_id]
|
27
|
+
capabilities = options[:capabilities]
|
28
|
+
body = {
|
29
|
+
clientId: client_id,
|
30
|
+
appId: app_id,
|
31
|
+
groupId: group_id,
|
32
|
+
userCaps: capabilities
|
33
|
+
}
|
34
|
+
route(to: __callee__, body: body, token_id: token_id)
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_snippet(options = {})
|
38
|
+
app_id = options[:app_id]
|
39
|
+
data = options[:data]
|
40
|
+
capabilities = options[:capabilities]
|
41
|
+
body = {
|
42
|
+
clientId: client_id,
|
43
|
+
appId: app_id,
|
44
|
+
snippet: data,
|
45
|
+
caps: capabilities
|
46
|
+
}
|
47
|
+
route(to: __callee__, body: body, token_id: token_id) do |response|
|
48
|
+
response.body = Entity::Base::factory(response.body.fetch('snippet') { {} })
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_user_app(options = {})
|
53
|
+
app_id = options[:app_id]
|
54
|
+
username = options[:username]
|
55
|
+
capabilities = options[:capabilities]
|
56
|
+
body = {
|
57
|
+
clientId: client_id,
|
58
|
+
appId: app_id,
|
59
|
+
username: username,
|
60
|
+
userCaps: capabilities
|
61
|
+
}
|
62
|
+
route(to: __callee__, body: body, token_id: token_id)
|
63
|
+
end
|
64
|
+
|
65
|
+
def create_app(options = {})
|
66
|
+
data = options[:data]
|
67
|
+
options = options.fetch(:options) { {} }
|
68
|
+
body = {
|
69
|
+
clientId: client_id,
|
70
|
+
app: data,
|
71
|
+
options: options
|
72
|
+
}
|
73
|
+
route(to: __callee__, body: body, token_id: token_id) do |response|
|
74
|
+
response.body = Entity::Base::factory(response.body.fetch('app') { {} })
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def remove_app(options = {})
|
79
|
+
app_id = options[:app_id]
|
80
|
+
body = {
|
81
|
+
clientId: client_id,
|
82
|
+
appId: app_id
|
83
|
+
}
|
84
|
+
route(to: __callee__, body: body, token_id: token_id)
|
85
|
+
end
|
86
|
+
|
87
|
+
def remove_group_app(options = {})
|
88
|
+
app_id = options[:app_id]
|
89
|
+
group_id = options[:group_id]
|
90
|
+
body = {
|
91
|
+
clientId: client_id,
|
92
|
+
appId: app_id,
|
93
|
+
groupId: group_id
|
94
|
+
}
|
95
|
+
route(to: __callee__, body: body, token_id: token_id)
|
96
|
+
end
|
97
|
+
|
98
|
+
def remove_snippet(options = {})
|
99
|
+
app_id = options[:app_id]
|
100
|
+
snippet_id = options[:snippet_id]
|
101
|
+
body = {
|
102
|
+
clientId: client_id,
|
103
|
+
appId: app_id,
|
104
|
+
snippetId: snippet_id
|
105
|
+
}
|
106
|
+
route(to: __callee__, body: body, token_id: token_id)
|
107
|
+
end
|
108
|
+
|
109
|
+
def remove_user_app(options = {})
|
110
|
+
app_id = options[:app_id]
|
111
|
+
username = options[:username]
|
112
|
+
body = {
|
113
|
+
clientId: client_id,
|
114
|
+
appId: app_id,
|
115
|
+
username: username
|
116
|
+
}
|
117
|
+
route(to: __callee__, body: body, token_id: token_id)
|
118
|
+
end
|
119
|
+
|
120
|
+
def update_app(options = {})
|
121
|
+
app_id = options[:app_id]
|
122
|
+
data = options[:data]
|
123
|
+
capabilities = options[:capabilities]
|
124
|
+
body = {
|
125
|
+
clientId: client_id,
|
126
|
+
appId: app_id,
|
127
|
+
update: data,
|
128
|
+
caps: capabilities
|
129
|
+
}
|
130
|
+
route(to: __callee__, body: body, token_id: token_id) do |response|
|
131
|
+
response.body = Entity::Base::factory(response.body.fetch('app') { {} })
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def update_snippet(options = {})
|
136
|
+
app_id = options[:app_id]
|
137
|
+
snippet_id = options[:snippet_id]
|
138
|
+
data = options[:data]
|
139
|
+
capabilities = options[:capabilities]
|
140
|
+
body = {
|
141
|
+
clientId: client_id,
|
142
|
+
appId: app_id,
|
143
|
+
snippetId: snippet_id,
|
144
|
+
snippet: data,
|
145
|
+
caps: capabilities
|
146
|
+
}
|
147
|
+
route(to: __callee__, body: body, token_id: token_id) do |response|
|
148
|
+
response.body = Entity::Base::factory(response.body.fetch('snippet') { {} })
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'thron/entity/base'
|
3
|
+
require 'thron/routable'
|
4
|
+
|
5
|
+
module Thron
|
6
|
+
module Gateway
|
7
|
+
Package = Struct::new(:name, :domain, :service) do
|
8
|
+
def to_s
|
9
|
+
"#{name}/#{domain}/#{service}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class NoActiveSessionError < StandardError; end
|
14
|
+
|
15
|
+
class Base
|
16
|
+
include Routable
|
17
|
+
|
18
|
+
base_uri "#{Config::thron::protocol}://#{Config::thron.client_id}-view.4me.it/api"
|
19
|
+
|
20
|
+
NO_ACTIVE_SESSION = "Please provide a valid token ID"
|
21
|
+
|
22
|
+
def self.service_name
|
23
|
+
self.name.split('::').last.downcase
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.client_id
|
27
|
+
@client_id ||= Config.thron.client_id
|
28
|
+
end
|
29
|
+
|
30
|
+
attr_accessor :token_id
|
31
|
+
|
32
|
+
def client_id
|
33
|
+
self.class.client_id
|
34
|
+
end
|
35
|
+
|
36
|
+
def check_session
|
37
|
+
fail NoActiveSessionError, NO_ACTIVE_SESSION unless token_id
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,210 @@
|
|
1
|
+
require 'thron/gateway/session'
|
2
|
+
|
3
|
+
module Thron
|
4
|
+
module Gateway
|
5
|
+
class Category < Session
|
6
|
+
|
7
|
+
PACKAGE = Package.new(:xcontents, :resources, self.service_name)
|
8
|
+
|
9
|
+
paginate :find_categories
|
10
|
+
|
11
|
+
def self.routes
|
12
|
+
@routes ||= {
|
13
|
+
create_category: Route::factory(name: 'createCategory', package: PACKAGE),
|
14
|
+
create_system_category: Route::factory(name: 'createSystemCategory', package: PACKAGE),
|
15
|
+
add_category_for_locale: Route::factory(name: 'addCategory4Locale', package: PACKAGE),
|
16
|
+
add_category_pretty_id: Route::factory(name: 'addCategoryPrettyId', package: PACKAGE),
|
17
|
+
find_categories: Route::factory(name: 'findByProperties2', package: PACKAGE),
|
18
|
+
category_detail: Route::factory(name: 'getCategory', package: PACKAGE, verb: Route::Verbs::GET),
|
19
|
+
remove_category: Route::factory(name: 'removeCategory', package: PACKAGE),
|
20
|
+
remove_category_for_locale: Route::factory(name: 'removeCategory4Locale', package: PACKAGE),
|
21
|
+
remove_category_pretty_id: Route::factory(name: 'removeCategoryPrettyId', package: PACKAGE),
|
22
|
+
set_parent_category: Route::factory(name: 'setParentId', package: PACKAGE),
|
23
|
+
update_category: Route::factory(name: 'updateCategory', package: PACKAGE),
|
24
|
+
update_category_for_locale: Route::factory(name: 'updateCategory4Locale', package: PACKAGE),
|
25
|
+
update_category_pretty_id: Route::factory(name: 'updateCategoryPrettyId', package: PACKAGE)
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_category(options = {})
|
30
|
+
parent_id = options[:parent_id]
|
31
|
+
locale = options[:locale]
|
32
|
+
is_private = options.fetch(:is_private) { false }
|
33
|
+
solution = options[:solution]
|
34
|
+
data = options[:data]
|
35
|
+
body = {
|
36
|
+
client: {
|
37
|
+
clientId: client_id
|
38
|
+
},
|
39
|
+
upCatId: parent_id,
|
40
|
+
catLocales: locale,
|
41
|
+
isPrivate: is_private,
|
42
|
+
private: is_private,
|
43
|
+
solution: solution,
|
44
|
+
options: data
|
45
|
+
}
|
46
|
+
route(to: __callee__, body: body, token_id: token_id)
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_system_category(options = {})
|
50
|
+
category_id = options[:category_id]
|
51
|
+
parent_id = options[:parent_id]
|
52
|
+
locale = options[:locale]
|
53
|
+
data = options[:data]
|
54
|
+
body = {
|
55
|
+
client: {
|
56
|
+
clientId: client_id
|
57
|
+
},
|
58
|
+
newCategoryId: category_id,
|
59
|
+
upCatId: parent_id,
|
60
|
+
catLocales: locale,
|
61
|
+
options: data
|
62
|
+
}
|
63
|
+
route(to: __callee__, body: body, token_id: token_id)
|
64
|
+
end
|
65
|
+
|
66
|
+
def add_category_for_locale(options = {})
|
67
|
+
category_id = options[:category_id]
|
68
|
+
locale = options[:locale]
|
69
|
+
body = {
|
70
|
+
client: {
|
71
|
+
clientId: client_id
|
72
|
+
},
|
73
|
+
catId: category_id,
|
74
|
+
catLocale: locale
|
75
|
+
}
|
76
|
+
route(to: __callee__, body: body, token_id: token_id)
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_category_pretty_id(options = {})
|
80
|
+
category_id = options[:category_id]
|
81
|
+
pretty_id = options[:pretty_id]
|
82
|
+
body = {
|
83
|
+
clientId: client_id,
|
84
|
+
categoryId: category_id,
|
85
|
+
prettyId: pretty_id
|
86
|
+
}
|
87
|
+
route(to: __callee__, body: body, token_id: token_id)
|
88
|
+
end
|
89
|
+
|
90
|
+
def find_categories(options = {})
|
91
|
+
criteria = options.fetch(:criteria) { {} }
|
92
|
+
locale = options[:locale]
|
93
|
+
order_by = options[:order_by]
|
94
|
+
offset = options[:offset].to_i
|
95
|
+
limit = options[:limit].to_i
|
96
|
+
body = {
|
97
|
+
client: {
|
98
|
+
clientId: client_id
|
99
|
+
},
|
100
|
+
properties: criteria,
|
101
|
+
locale: locale,
|
102
|
+
orderBy: order_by,
|
103
|
+
offset: offset.to_i,
|
104
|
+
numberOfResult: limit.to_i
|
105
|
+
}
|
106
|
+
route(to: __callee__, body: body, token_id: token_id) do |response|
|
107
|
+
response.body = Entity::Base::factory(response.body.fetch('categories') { [] })
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def category_detail(options = {})
|
112
|
+
category_id = options[:category_id]
|
113
|
+
recursive = options.fetch(:recursive) { false }
|
114
|
+
locale = options[:locale]
|
115
|
+
query = {
|
116
|
+
clientId: client_id,
|
117
|
+
categoryId: category_id,
|
118
|
+
cascade: recursive,
|
119
|
+
locale: locale
|
120
|
+
}
|
121
|
+
route(to: __callee__, query: query, token_id: token_id) do |response|
|
122
|
+
response.body = Entity::Base::factory(response.body.fetch('category') { {} })
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def remove_category(options = {})
|
127
|
+
category_id = options[:category_id]
|
128
|
+
recursive = options.fetch(:recursive) { false }
|
129
|
+
query = {
|
130
|
+
clientId: client_id,
|
131
|
+
catId: category_id,
|
132
|
+
cascade: recursive
|
133
|
+
}
|
134
|
+
route(to: __callee__, query: query, token_id: token_id, dash: false)
|
135
|
+
end
|
136
|
+
|
137
|
+
def remove_category_for_locale(options = {})
|
138
|
+
category_id = options[:category_id]
|
139
|
+
locale = options[:locale]
|
140
|
+
body = {
|
141
|
+
client: {
|
142
|
+
clientId: client_id
|
143
|
+
},
|
144
|
+
catId: category_id,
|
145
|
+
locale: locale
|
146
|
+
}
|
147
|
+
route(to: __callee__, body: body, token_id: token_id)
|
148
|
+
end
|
149
|
+
|
150
|
+
def remove_category_pretty_id(options = {})
|
151
|
+
category_id = options[:category_id]
|
152
|
+
locale = options[:locale]
|
153
|
+
body = {
|
154
|
+
clientId: client_id,
|
155
|
+
categoryId: category_id,
|
156
|
+
locale: locale
|
157
|
+
}
|
158
|
+
route(to: __callee__, body: body, token_id: token_id)
|
159
|
+
end
|
160
|
+
|
161
|
+
def set_parent_category(options = {})
|
162
|
+
category_id = options[:category_id]
|
163
|
+
parent_id = options[:parent_id]
|
164
|
+
query = {
|
165
|
+
clientId: client_id,
|
166
|
+
categoryId: category_id,
|
167
|
+
categoryParentId: parent_id
|
168
|
+
}
|
169
|
+
route(to: __callee__, query: query, token_id: token_id, dash: false)
|
170
|
+
end
|
171
|
+
|
172
|
+
def update_category(options = {})
|
173
|
+
category_id = options[:category_id]
|
174
|
+
data = options[:data]
|
175
|
+
body = {
|
176
|
+
client: {
|
177
|
+
clientId: client_id
|
178
|
+
},
|
179
|
+
categoryId: category_id,
|
180
|
+
update: data
|
181
|
+
}
|
182
|
+
route(to: __callee__, body: body, token_id: token_id)
|
183
|
+
end
|
184
|
+
|
185
|
+
def update_category_for_locale(options = {})
|
186
|
+
category_id = options[:category_id]
|
187
|
+
locale = options[:locale]
|
188
|
+
body = {
|
189
|
+
client: {
|
190
|
+
clientId: client_id
|
191
|
+
},
|
192
|
+
catId: category_id,
|
193
|
+
property: locale
|
194
|
+
}
|
195
|
+
route(to: __callee__, body: body, token_id: token_id)
|
196
|
+
end
|
197
|
+
|
198
|
+
def update_category_pretty_id(options = {})
|
199
|
+
category_id = options[:category_id]
|
200
|
+
pretty_id = options[:pretty_id]
|
201
|
+
body = {
|
202
|
+
clientId: client_id,
|
203
|
+
categoryId: category_id,
|
204
|
+
prettyId: pretty_id
|
205
|
+
}
|
206
|
+
route(to: __callee__, body: body, token_id: token_id)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|