Class: Thron::Gateway::AppsAdmin

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

Constant Summary collapse

PACKAGE =
Package.new(:xadmin, :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



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/thron/gateway/apps_admin.rb', line 9

def self.routes
  @routes ||= {
    add_group_app: Route::factory(name: 'addGroupApp', package: PACKAGE),
    add_snippet: Route::factory(name: 'addSnippet', package: PACKAGE),
    add_user_app: Route::factory(name: 'addUserApp', package: PACKAGE),
    create_app: Route::factory(name: 'create', package: PACKAGE),
    remove_app: Route::factory(name: 'remove', package: PACKAGE),
    remove_group_app: Route::factory(name: 'removeGroupApp', package: PACKAGE),
    remove_snippet: Route::factory(name: 'removeSnippet', package: PACKAGE),
    remove_user_app: Route::factory(name: 'removeUserApp', package: PACKAGE),
    update_app: Route::factory(name: 'updateApp', package: PACKAGE),
    update_snippet: Route::factory(name: 'updateSnippet', package: PACKAGE)
  }
end

Instance Method Details

#add_group_app(options = {}) ⇒ Object



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

def add_group_app(options = {})
  app_id = options[:app_id]
  group_id = options[:group_id]
  capabilities = options[:capabilities]
  body = { 
    clientId: client_id,
    appId: app_id,
    groupId: group_id,
    userCaps: capabilities
  }
  route(to: __callee__, body: body, token_id: token_id)
end

#add_snippet(options = {}) ⇒ Object



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

def add_snippet(options = {})
  app_id = options[:app_id]
  data = options[:data]
  capabilities = options[:capabilities]
  body = { 
    clientId: client_id,
    appId: app_id,
    snippet: data,
    caps: capabilities
  }
  route(to: __callee__, body: body, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('snippet') { {} })
  end
end

#add_user_app(options = {}) ⇒ Object



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

def add_user_app(options = {})
  app_id = options[:app_id]
  username = options[:username]
  capabilities = options[:capabilities]
  body = { 
    clientId: client_id,
    appId: app_id,
    username: username,
    userCaps: capabilities
  }
  route(to: __callee__, body: body, token_id: token_id)
end

#create_app(options = {}) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/thron/gateway/apps_admin.rb', line 65

def create_app(options = {})
  data = options[:data]
  options = options.fetch(:options) { {} }
  body = { 
    clientId: client_id,
    app: data,
    options: options
  }
  route(to: __callee__, body: body, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('app') { {} })
  end
end

#remove_app(options = {}) ⇒ Object



78
79
80
81
82
83
84
85
# File 'lib/thron/gateway/apps_admin.rb', line 78

def remove_app(options = {})
  app_id = options[:app_id]
  body = { 
    clientId: client_id,
    appId: app_id
  }
  route(to: __callee__, body: body, token_id: token_id)
end

#remove_group_app(options = {}) ⇒ Object



87
88
89
90
91
92
93
94
95
96
# File 'lib/thron/gateway/apps_admin.rb', line 87

def remove_group_app(options = {})
  app_id = options[:app_id]
  group_id = options[:group_id]
  body = { 
    clientId: client_id,
    appId: app_id,
    groupId: group_id
  }
  route(to: __callee__, body: body, token_id: token_id)
end

#remove_snippet(options = {}) ⇒ Object



98
99
100
101
102
103
104
105
106
107
# File 'lib/thron/gateway/apps_admin.rb', line 98

def remove_snippet(options = {})
  app_id = options[:app_id]
  snippet_id = options[:snippet_id]
  body = { 
    clientId: client_id,
    appId: app_id,
    snippetId: snippet_id
  }
  route(to: __callee__, body: body, token_id: token_id)
end

#remove_user_app(options = {}) ⇒ Object



109
110
111
112
113
114
115
116
117
118
# File 'lib/thron/gateway/apps_admin.rb', line 109

def remove_user_app(options = {})
  app_id = options[:app_id]
  username = options[:username]
  body = { 
    clientId: client_id,
    appId: app_id,
    username: username
  }
  route(to: __callee__, body: body, token_id: token_id)
end

#update_app(options = {}) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/thron/gateway/apps_admin.rb', line 120

def update_app(options = {})
  app_id = options[:app_id]
  data = options[:data]
  capabilities = options[:capabilities]
  body = { 
    clientId: client_id,
    appId: app_id,
    update: data,
    caps: capabilities
  }
  route(to: __callee__, body: body, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('app') { {} })
  end
end

#update_snippet(options = {}) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/thron/gateway/apps_admin.rb', line 135

def update_snippet(options = {})
  app_id = options[:app_id]
  snippet_id = options[:snippet_id]
  data = options[:data]
  capabilities = options[:capabilities]
  body = { 
    clientId: client_id,
    appId: app_id,
    snippetId: snippet_id,
    snippet: data,
    caps: capabilities
  }
  route(to: __callee__, body: body, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('snippet') { {} })
  end
end