Class: Eli::Admin::App
- Inherits:
-
Object
- Object
- Eli::Admin::App
- Defined in:
- lib/eli/admin/app.rb
Overview
Represents an App belonging to an organization and exposes the administrative endpoints to manage apps, their users and tokens.
Instances carry the attributes used by create and update:
app = Eli::Admin::App.new(
name: "New App Name",
description: "New App Description",
organization_id: "3d36fb7c-bbb6-4b27-8945-c7880de5484f",
unlock_sign_in_url: "http://localhost:4000"
)
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
-
#organization_id ⇒ Object
Returns the value of attribute organization_id.
-
#unlock_sign_in_url ⇒ Object
Returns the value of attribute unlock_sign_in_url.
Class Method Summary collapse
-
.add_app_user(session_token, organization_id, id, email, password) ⇒ Object
Add app user.
-
.create(session_token, app) ⇒ Object
Examples.
-
.create_token(session_token, organization_id, app_id) ⇒ Object
Create token.
-
.delete(session_token, organization_id, id) ⇒ Object
Examples.
-
.get(session_token, organization_id, id) ⇒ Object
Examples.
-
.get_token(session_token, organization_id, app_id, id) ⇒ Object
Show token.
-
.list(session_token, organization_id, page = 1, per_page = 20) ⇒ Object
Examples.
-
.list_app_users(session_token, organization_id, id, page = 1, per_page = 20) ⇒ Object
Examples.
-
.list_tokens(session_token, organization_id, app_id, page = 1, per_page = 20) ⇒ Object
List tokens.
-
.remove_app_user(session_token, organization_id, id, app_user_id) ⇒ Object
Remove app user.
-
.revoke_token(session_token, organization_id, app_id, id) ⇒ Object
Revoke a token.
-
.update(session_token, id, app) ⇒ Object
Examples.
Instance Method Summary collapse
-
#initialize(name: nil, description: nil, organization_id: nil, unlock_sign_in_url: nil) ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(name: nil, description: nil, organization_id: nil, unlock_sign_in_url: nil) ⇒ App
Returns a new instance of App.
19 20 21 22 23 24 |
# File 'lib/eli/admin/app.rb', line 19 def initialize(name: nil, description: nil, organization_id: nil, unlock_sign_in_url: nil) @name = name @description = description @organization_id = organization_id @unlock_sign_in_url = unlock_sign_in_url end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
17 18 19 |
# File 'lib/eli/admin/app.rb', line 17 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
17 18 19 |
# File 'lib/eli/admin/app.rb', line 17 def name @name end |
#organization_id ⇒ Object
Returns the value of attribute organization_id.
17 18 19 |
# File 'lib/eli/admin/app.rb', line 17 def organization_id @organization_id end |
#unlock_sign_in_url ⇒ Object
Returns the value of attribute unlock_sign_in_url.
17 18 19 |
# File 'lib/eli/admin/app.rb', line 17 def unlock_sign_in_url @unlock_sign_in_url end |
Class Method Details
.add_app_user(session_token, organization_id, id, email, password) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/eli/admin/app.rb', line 185 def add_app_user(session_token, organization_id, id, email, password) url = Eli::Config.base_url + "/rest/admin/organizations/" + organization_id + "/apps/" + id + "/users" = { params: { password: password, email: email }, headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.post(url, ) end |
.create(session_token, app) ⇒ Object
Examples
app = Eli::Admin::App.new(
name: "New App Name",
description: "New App Description",
organization_id: "3d36fb7c-bbb6-4b27-8945-c7880de5484f",
unlock_sign_in_url: "http://localhost:4000"
)
Eli::Admin::App.create("JWT session token", app)
# status: 201
# body: { "data" => { "description" => "New App Description",
# "id" => "319f3afa-69bd-4bcc-b168-f26613c9581f",
# "name" => "New App Name" } }
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/eli/admin/app.rb', line 41 def create(session_token, app) url = Eli::Config.base_url + "/rest/admin/organizations/" + app.organization_id + "/apps" = { params: { app: { name: app.name, description: app.description, unlock_sign_in_url: app.unlock_sign_in_url } }, headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.post(url, ) end |
.create_token(session_token, organization_id, app_id) ⇒ Object
235 236 237 238 239 240 241 242 243 244 |
# File 'lib/eli/admin/app.rb', line 235 def create_token(session_token, organization_id, app_id) url = Eli::Config.base_url + "/rest/admin/organizations/" + organization_id + "/apps/" + app_id + "/tokens" = { headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.post(url, ) end |
.delete(session_token, organization_id, id) ⇒ Object
138 139 140 141 142 143 144 145 146 |
# File 'lib/eli/admin/app.rb', line 138 def delete(session_token, organization_id, id) url = Eli::Config.base_url + "/rest/admin/organizations/" + organization_id + "/apps/" + id = { headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.delete(url, ) end |
.get(session_token, organization_id, id) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/eli/admin/app.rb', line 88 def get(session_token, organization_id, id) url = Eli::Config.base_url + "/rest/admin/organizations/" + organization_id + "/apps/" + id = { headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.get(url, ) end |
.get_token(session_token, organization_id, app_id, id) ⇒ Object
284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/eli/admin/app.rb', line 284 def get_token(session_token, organization_id, app_id, id) url = Eli::Config.base_url + "/rest/admin/organizations/" + organization_id + "/apps/" + app_id + "/tokens/" + id = { headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.get(url, ) end |
.list(session_token, organization_id, page = 1, per_page = 20) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/eli/admin/app.rb', line 63 def list(session_token, organization_id, page = 1, per_page = 20) url = Eli::Config.base_url + "/rest/admin/organizations/" + organization_id + "/apps" = { params: { page: page, per_page: per_page }, headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.get(url, ) end |
.list_app_users(session_token, organization_id, id, page = 1, per_page = 20) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/eli/admin/app.rb', line 157 def list_app_users(session_token, organization_id, id, page = 1, per_page = 20) url = Eli::Config.base_url + "/rest/admin/organizations/" + organization_id + "/apps/" + id + "/users" = { params: { page: page, per_page: per_page }, headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.get(url, ) end |
.list_tokens(session_token, organization_id, app_id, page = 1, per_page = 20) ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/eli/admin/app.rb', line 257 def list_tokens(session_token, organization_id, app_id, page = 1, per_page = 20) url = Eli::Config.base_url + "/rest/admin/organizations/" + organization_id + "/apps/" + app_id + "/tokens" = { params: { page: page, per_page: per_page }, headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.get(url, ) end |
.remove_app_user(session_token, organization_id, id, app_user_id) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/eli/admin/app.rb', line 212 def remove_app_user(session_token, organization_id, id, app_user_id) url = Eli::Config.base_url + "/rest/admin/organizations/" + organization_id + "/apps/" + id + "/users/" + app_user_id = { headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.delete(url, ) end |
.revoke_token(session_token, organization_id, app_id, id) ⇒ Object
308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/eli/admin/app.rb', line 308 def revoke_token(session_token, organization_id, app_id, id) url = Eli::Config.base_url + "/rest/admin/organizations/" + organization_id + "/apps/" + app_id + "/tokens/" + id = { headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.delete(url, ) end |
.update(session_token, id, app) ⇒ Object
Examples
app = Eli::Admin::App.new(
name: "Another App Name",
description: "Changed Description",
organization_id: "3d36fb7c-bbb6-4b27-8945-c7880de5484f",
unlock_sign_in_url: "http://localhost:4000"
)
Eli::Admin::App.update("JWT session token", "319f3afa-69bd-4bcc-b168-f26613c9581f", app)
# status: 200
# body: { "data" => { "description" => "Changed Description",
# "id" => "319f3afa-69bd-4bcc-b168-f26613c9581f",
# "name" => "Another App Name" } }
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/eli/admin/app.rb', line 112 def update(session_token, id, app) url = Eli::Config.base_url + "/rest/admin/organizations/" + app.organization_id + "/apps/" + id = { params: { app: { name: app.name, description: app.description, unlock_sign_in_url: app.unlock_sign_in_url } }, headers: { "authorization" => "Bearer #{session_token}" } } Eli::RestApi.put(url, ) end |