lws 0.4.2 → 6.1.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/lws/auth.rb CHANGED
@@ -20,11 +20,12 @@ module LWS::Auth
20
20
  end
21
21
  # :nocov:
22
22
 
23
- #@!visibility private
24
- def self.api
25
- LWS.setup_api(LWS.config.endpoints[:auth] ||
26
- ENDPOINT[LWS.config.environment])
23
+ # @!visibility private
24
+ class << self
25
+ attr_accessor :api
27
26
  end
27
+ @api = LWS.setup_api(LWS.config.endpoints[:auth] ||
28
+ ENDPOINT[LWS.config.environment])
28
29
 
29
30
  ### Generic classes
30
31
 
@@ -33,138 +34,263 @@ module LWS::Auth
33
34
  use_api LWS::Auth.api
34
35
  end
35
36
 
36
- # (see Generic::Task)
37
- class Task < LWS::Generic::Task
38
- use_api LWS::Auth.api
39
- end
40
-
41
37
  ### App specific classes
42
38
 
43
39
  # = The account class
44
40
  class Account < LWS::Generic::Model
45
41
  use_api LWS::Auth.api
46
42
 
47
- #@!attribute id [r]
48
- # @return [Fixnum] the (unique) ID of the account
43
+ # @!attribute id [r]
44
+ # @return [Fixnum] the (unique) ID of the account
45
+ attribute :id
49
46
 
50
- #@!attribute avatar_url
51
- # @return [String] the avatar URL of the account
47
+ # @!attribute avatar_url
48
+ # @return [String] the avatar URL of the account
49
+ attribute :avatar_url
52
50
 
53
- #@!attribute apps
54
- # @return [Array<App>] the apps that are assigned to the account
51
+ # @!attribute apps
52
+ # @return [Array<App>] the apps that are assigned to the account
55
53
  has_many :apps
56
54
 
57
- #@!attribute devices
58
- # @return [Array<Device>] the devices that are assigned to the account
55
+ # @!attribute company
56
+ # @return [Company] the company that the account belongs to
57
+ belongs_to :company
58
+
59
+ # @!attribute company_id
60
+ # @return [Fixnum] the ID of the company that the account belongs to
61
+ attribute :company_id
62
+
63
+ # @!attribute devices
64
+ # @return [Array<Device>] the devices that are assigned to the account
59
65
  has_many :devices
60
66
 
61
- #@!attribute users
62
- # @return [Array<User>] the users that are assigned to the account
63
- has_many :users
67
+ # @!attribute language
68
+ # @return [String] the language of the account
69
+ # (at least 2 characters long)
70
+ attribute :language
64
71
 
65
- #@!attribute company
66
- # @return [Company] the company that the account belongs to
67
- belongs_to :company
72
+ # @!attribute name
73
+ # @return [String] the name of the account
74
+ # (at least 8 characters long)
75
+ attribute :name
68
76
 
69
- #@!attribute company_id
70
- # @return [Fixnum] the ID of the company that the account belongs to
77
+ # @!attribute start_app
78
+ # @return [App, nil] the app to start with/open when logging in
79
+ belongs_to :start_app, class_name: "LWS::Auth::App"
71
80
 
72
- #@!attribute language
73
- # @return [String] the language of the account
81
+ # @!attribute start_app_id
82
+ # @return [Fixnum, nil] the ID of the app to start with/open when logging in
83
+ attribute :start_app_id
74
84
 
75
- #@!attribute name
76
- # @return [String] the name of the account
85
+ # @!attribute users
86
+ # @return [Array<User>] the users that are assigned to the account
87
+ has_many :users
77
88
 
78
- #@!attribute created_at
79
- # @return [String] the timestamp of when the account was created
89
+ # @!attribute created_at [r]
90
+ # @return [String] the timestamp of when the account was created
91
+ attribute :created_at
80
92
 
81
- #@!attribute updated_at
82
- # @return [String] the timestamp of when the account was last updated
93
+ # @!attribute updated_at [r]
94
+ # @return [String] the timestamp of when the account was last updated
95
+ attribute :updated_at
83
96
  end
84
97
 
85
98
  # = The app class
86
99
  class App < LWS::Generic::Model
87
100
  use_api LWS::Auth.api
88
101
 
89
- #@!attribute id [r]
90
- # @return [Fixnum] the (unique) ID of the account
102
+ # @!attribute id [r]
103
+ # @return [Fixnum] the (unique) ID of the account
104
+ attribute :id
105
+
106
+ # @!attribute accounts
107
+ # @return [Array<Account>] the accounts using the app
108
+ has_many :accounts
109
+
110
+ # @!attribute app_key
111
+ # @return [String] the (unique) internal key used for the app
112
+ attribute :app_key
91
113
 
92
- #@!attribute name
93
- # @return [String] the name of the app
114
+ # @!attribute autoassign
115
+ # @return [Boolean] whether the app is automatically assigned to
116
+ # a newly created account and/or company
117
+ attribute :autoassign
94
118
 
95
- #@!attribute app_key
96
- # @return [String] the internal key used for the app
119
+ # @!attribute companies
120
+ # @return [Array<Company>] the companies using the app
121
+ has_many :companies
97
122
 
98
- #@!attribute url
99
- # @return [String] the web location of the app
123
+ # @!attribute icon
124
+ # @return [String] the icon ID/name of the app
125
+ attribute :icon
100
126
 
101
- #@!attribute secret
102
- # @return [String] the shared secred used for logging in to the app
127
+ # @!attribute licenses
128
+ # @return [Array<License>] the licenses that provide access to the app
129
+ has_many :licenses
103
130
 
104
- #@!attribute icon
105
- # @return [String] the icon ID/name of the app
131
+ # @!attribute order_priority
132
+ # @return [Fixnum, nil] the order priority of the app with respect to the
133
+ # other apps
134
+ attribute :order_priority
106
135
 
107
- #@!attribute created_at
108
- # @return [String] the timestamp of when the app was created
136
+ # @!attribute name
137
+ # @return [String] the name of the app
138
+ attribute :name
109
139
 
110
- #@!attribute updated_at
111
- # @return [String] the timestamp of when the app was last updated
140
+ # @!attribute secret
141
+ # @return [String] the shared secred used for logging in to the app
142
+ attribute :secret
112
143
 
113
- self # To ensure that YARD does not skip the attributes of this class
144
+ # @!attribute url
145
+ # @return [String] the web location (URL) of the app
146
+ attribute :url
147
+
148
+ # @!attribute created_at [r]
149
+ # @return [String] the timestamp of when the app was created
150
+ attribute :created_at
151
+
152
+ # @!attribute updated_at [r]
153
+ # @return [String] the timestamp of when the app was last updated
154
+ attribute :updated_at
114
155
  end
115
156
 
116
157
  # = The company class
117
158
  class Company < LWS::Generic::Model
118
159
  use_api LWS::Auth.api
119
160
 
120
- #@!attribute id [r]
121
- # @return [Fixnum] the (unique) ID of the company
122
-
123
- #@!attribute apps
124
- # @return [Array<App>] the apps that are assigned to the company
125
- has_many :apps
161
+ # @!attribute id [r]
162
+ # @return [Fixnum] the (unique) ID of the company
163
+ attribute :id
126
164
 
127
- #@!attribute accounts
128
- # @return [Array<Account>] the accounts that are assigned to the company
165
+ # @!attribute accounts
166
+ # @return [Array<Account>] the accounts that are assigned to the company
129
167
  has_many :accounts
130
168
 
131
- #@!attribute address
132
- # @return [String] the address of the company
133
-
134
- #@!attribute city
135
- # @return [String] the city of the company
169
+ # @!attribute activated
170
+ # @return [Boolean] whether the company has been activated
171
+ attribute :activated
136
172
 
137
- #@!attribute contact_person
138
- # @return [Account] the contact person of the company
139
- belongs_to :contact_person, class_name: "Account"
173
+ # @!attribute apps
174
+ # @return [Array<App>] the apps that are assigned to the company
175
+ has_many :apps
140
176
 
141
- #@!attribute contact_person_id
142
- # @return [Fixnum] the ID of the contact person of the company
177
+ # @!attribute address
178
+ # @return [String] the address of the company
179
+ # (at least 2 characters long)
180
+ attribute :address
181
+
182
+ # @!attribute city
183
+ # @return [String] the city of the company
184
+ # (at least 2 characters long)
185
+ attribute :city
186
+
187
+ # @!attribute contact_person
188
+ # @return [Account] the contact person of the company
189
+ belongs_to :contact_person, class_name: "LWS::Auth::Account",
190
+ foreign_key: :contact_person_id,
191
+ uri: "accounts/:id"
192
+
193
+ # @!attribute contact_person_id
194
+ # @return [Fixnum] the ID of the contact person of the company
195
+ attribute :contact_person_id
196
+
197
+ # @!attribute contracts
198
+ # @return [Array<Contract>] the contracts of the company
199
+ has_many :contracts
200
+
201
+ # @!attribute country
202
+ # @return [String] the country of the company
203
+ # (at least 2 characters long)
204
+ attribute :country
205
+
206
+ # @!attribute expire
207
+ # @return [Boolean] whether the company is planned to be discontinued
208
+ # after the contract ends
209
+ attribute :expire
210
+
211
+ # @!attribute licenses
212
+ # @return [Array<License>] the licenses of the company
213
+ has_many :licenses
214
+
215
+ # @!attribute name
216
+ # @return [String] the name of the company
217
+ # (at least 2 characters long)
218
+ attribute :name
219
+
220
+ # @!attribute number
221
+ # @return [String] the street address number of the company
222
+ # (at least 1 character long)
223
+ attribute :number
224
+
225
+ # @!attribute parent
226
+ # @return [Company, nil] the parenty company
227
+ belongs_to :parent, class_name: "LWS::Auth::Company",
228
+ foreign_key: :parent_id,
229
+ uri: "companies/:id"
230
+
231
+ # @!attribute parent_id
232
+ # @return [Fixnum, nil] the ID of the parenty company
233
+ attribute :parent_id
234
+
235
+ # @!attribute telephone_number
236
+ # @return [String] the telephone number of the company
237
+ # (at least 2 characters long)
238
+ attribute :telephone_number
239
+
240
+ # @!attribute usage_reports
241
+ # @return [Array<UsageReport>] the usage reports available/generated
242
+ # for the company
243
+ has_many :usage_reports, uri: "company/:company_id/reports"
244
+
245
+ # @!attribute uuid
246
+ # @return [String] the UUID of the company
247
+ attribute :uuid
248
+
249
+ # @!attribute zip_code
250
+ # @return [String] the zip code of the company
251
+ # (at least 2 characters long)
252
+ attribute :zip_code
253
+
254
+ # @!attribute created_at [r]
255
+ # @return [String] the timestamp of when the company was created
256
+ attribute :created_at
257
+
258
+ # @!attribute updated_at [r]
259
+ # @return [String] the timestamp of when the company was last updated
260
+ attribute :updated_at
261
+ end
143
262
 
144
- #@!attribute country
145
- # @return [String] the country of the company
263
+ # = The contract class
264
+ class Contract < LWS::Generic::Model
265
+ use_api LWS::Auth.api
146
266
 
147
- #@!attribute name
148
- # @return [String] the name of the company
267
+ # @!attribute id [r]
268
+ # @return [Fixnum] the (unique) ID of the contract
269
+ attribute :id
149
270
 
150
- #@!attribute number
151
- # @return [String] the street address number of the company
271
+ # @!attribute company
272
+ # @return [Company] the company that has the contract
273
+ belongs_to :company
152
274
 
153
- #@!attribute parent
154
- # @return [Company] the parenty company
155
- belongs_to :parent, class_name: "Company"
275
+ # @!attribute company_id
276
+ # @return [Fixnum] the ID of the company that has the contract
277
+ attribute :company_id
156
278
 
157
- #@!attribute parent_id
158
- # @return [Fixnum] the ID of the parenty company
279
+ # @!attribute end_date
280
+ # @return [String] the end date of the contract (date/time string)
281
+ attribute :end_date
159
282
 
160
- #@!attribute zip_code
161
- # @return [String] the zip code of the company
283
+ # @!attribute start_date
284
+ # @return [String] the start date of the contract (date/time string)
285
+ attribute :start_date
162
286
 
163
- #@!attribute created_at
164
- # @return [String] the timestamp of when the company was created
287
+ # @!attribute created_at [r]
288
+ # @return [String] the timestamp of when the contract was created
289
+ attribute :created_at
165
290
 
166
- #@!attribute updated_at
167
- # @return [String] the timestamp of when the company was last updated
291
+ # @!attribute updated_at [r]
292
+ # @return [String] the timestamp of when the contract was last updated
293
+ attribute :updated_at
168
294
  end
169
295
 
170
296
  # = The device class
@@ -174,80 +300,195 @@ module LWS::Auth
174
300
  class Device < LWS::Generic::Model
175
301
  use_api LWS::Auth.api
176
302
 
177
- #@!attribute id [r]
178
- # @return [Fixnum] the (unique) ID of the device
303
+ # @!attribute id [r]
304
+ # @return [Fixnum] the (unique) ID of the device
305
+ attribute :id
179
306
 
180
- #@!attribute name
181
- # @return [String] the name of the device
182
-
183
- #@!attribute account
184
- # @return [Account] the account that the device belongs to
307
+ # @!attribute account
308
+ # @return [Account] the account that the device belongs to
185
309
  belongs_to :account
186
310
 
187
- #@!attribute account_id
188
- # @return [Fixnum] the ID of the account that the device belongs to
311
+ # @!attribute account_id
312
+ # @return [Fixnum] the ID of the account that the device belongs to
313
+ attribute :account_id
314
+
315
+ # @!attribute name
316
+ # @return [String] the name of the device
317
+ attribute :name
318
+
319
+ # @!attribute tokens
320
+ # @return [Array<Token>] the tokens available for the device
321
+ attribute :tokens
322
+
323
+ # @!attribute created_at [r]
324
+ # @return [String] the timestamp of when the device was created
325
+ attribute :created_at
326
+
327
+ # @!attribute updated_at [r]
328
+ # @return [String] the timestamp of when the device was last updated
329
+ attribute :updated_at
330
+ end
331
+
332
+ # = The license class
333
+ class License < LWS::Generic::Model
334
+ use_api LWS::Auth.api
335
+
336
+ # @!attribute id [r]
337
+ # @return [Fixnum] the (unique) ID of the license
338
+ attribute :id
189
339
 
190
- #@!attribute created_at
191
- # @return [String] the timestamp of when the device was created
340
+ # @!attribute app
341
+ # @return [App] the app the license is for
342
+ belongs_to :app
192
343
 
193
- #@!attribute updated_at
194
- # @return [String] the timestamp of when the device was last updated
344
+ # @!attribute app_id
345
+ # @return [Fixnum] the ID of the app the license is for
346
+ attribute :app_id
347
+
348
+ # @!attribute company
349
+ # @return [Company] the company that has the license
350
+ belongs_to :company
351
+
352
+ # @!attribute company_id
353
+ # @return [Fixnum] the ID of the company that has the license
354
+ attribute :company_id
355
+
356
+ # @!attribute count
357
+ # @return [Fixnum] the number of items the license provides
358
+ attribute :count
359
+
360
+ # @!attribute desc
361
+ # @return [String] the description of the license
362
+ attribute :desc
363
+
364
+ # @!attribute key
365
+ # @return [String] the key of the license
366
+ attribute :key
367
+
368
+ # @!attribute license_type
369
+ # @return [String] the type of the license
370
+ attribute :license_type
371
+
372
+ # @!attribute name
373
+ # @return [String] the name of the license
374
+ attribute :name
375
+
376
+ # @!attribute sku
377
+ # @return [String] the stock-keeping unit of the license
378
+ attribute :sku
379
+
380
+ # @!attribute created_at [r]
381
+ # @return [String] the timestamp of when the license was created
382
+ attribute :created_at
383
+
384
+ # @!attribute updated_at [r]
385
+ # @return [String] the timestamp of when the license was last updated
386
+ attribute :updated_at
195
387
  end
196
388
 
389
+
197
390
  # = The token class
198
391
  class Token < LWS::Generic::Model
199
392
  use_api LWS::Auth.api
200
393
 
201
- #@!attribute id [r]
202
- # @return [Fixnum] the (unique) ID of the token
394
+ # @!attribute id [r]
395
+ # @return [Fixnum] the (unique) ID of the token
396
+ attribute :id
203
397
 
204
- #@!attribute name
205
- # @return [String] the name of the token
398
+ # @!attribute account
399
+ # @return [Account] the account the token belongs to (through either
400
+ # the user or the device)
401
+ belongs_to :account, uri: nil
206
402
 
207
- #@!attribute token
208
- # @return [String] the actual token string
403
+ # @!attribute account_id
404
+ # @return [Fixnum] the ID of the account the token belongs to
405
+ attribute :account_id
209
406
 
210
- #@!attribute used_on
211
- # @return [String] the timestamp the token was last used
407
+ # @!attribute device
408
+ # @note Each token is associated to either a user or a device.
409
+ # @return [Device, nil] the device the token belongs to
410
+ belongs_to :device, uri: nil
212
411
 
213
- #@!attribute ip_address
214
- # @return [String] the location/IP address the token is used on
412
+ # @!attribute device_id
413
+ # @return [Fixnum, nil] the ID of the device the token belongs to
414
+ attribute :device_id
215
415
 
216
- #@!attribute user_agent
217
- # @return [String] the user agent/browser string when the token was used
416
+ # @!attribute created_on [r]
417
+ # @deprecated This is an old alias of {#created_at}.
418
+ # @return [String] the timestamp of when the token was created
419
+ attribute :created_on
218
420
 
219
- #@!attribute account
220
- # @return [Account] the account the token belongs to (through either
221
- # the user or the device)
222
- belongs_to :account
421
+ # @!attribute expires_on
422
+ # @return [String] the timestamp the token will (or has) expire(d)
423
+ attribute :expires_on
223
424
 
224
- #@!attribute account_id
225
- # @return [Fixnum] the ID of the account the token belongs to
425
+ # @!attribute ip_address
426
+ # @return [String] the location/IP address the token is used on
427
+ attribute :ip_address
226
428
 
227
- #@!attribute user
228
- # @note Each token is associated to either a user or a device.
229
- # @return [User] the user the token belongs to
230
- belongs_to :user
429
+ # @!attribute name
430
+ # @return [String, nil] the name of the token
431
+ attribute :name
231
432
 
232
- #@!attribute user_id
233
- # @return [Fixnum] the ID of the user the token belongs to
433
+ # @!attribute token
434
+ # @return [String] the actual token string
435
+ attribute :token
234
436
 
235
- #@!attribute device
236
- # @note Each token is associated to either a user or a device.
237
- # @return [Device] the device the token belongs to
238
- belongs_to :device
437
+ # @!attribute used_on
438
+ # @return [String, nil] the timestamp the token was last used
439
+ attribute :used_on
239
440
 
240
- #@!attribute device_id
241
- # @return [Fixnum] the ID of the device the token belongs to
441
+ # @!attribute user_agent
442
+ # @return [String, nil] the user agent/browser string when the token
443
+ # was used
444
+ attribute :user_agent
242
445
 
243
- #@!attribute expires_on
244
- # @return [String] the timestamp the token will (or has) expire(d)
446
+ # @!attribute user
447
+ # @note Each token is associated to either a user or a device.
448
+ # @return [User, nil] the user the token belongs to
449
+ belongs_to :user, uri: nil
245
450
 
246
- #@!attribute created_at
247
- # @return [String] the timestamp of when the token was created
451
+ # @!attribute user_id
452
+ # @return [Fixnum, nil] the ID of the user the token belongs to
453
+ attribute :user_id
248
454
 
249
- #@!attribute updated_at
250
- # @return [String] the timestamp of when the token was last updated
455
+ # @!attribute created_at [r]
456
+ # @return [String] the timestamp of when the token was created
457
+ attribute :created_at
458
+
459
+ # @!attribute updated_at [r]
460
+ # @return [String] the timestamp of when the token was last updated
461
+ attribute :updated_at
462
+ end
463
+
464
+ # = The usage report class
465
+ class UsageReport < LWS::Generic::Model
466
+ use_api LWS::Auth.api
467
+
468
+ # @!attribute id [r]
469
+ # @return [Fixnum] the (unique) ID of the usage report
470
+ attribute :id
471
+
472
+ # @!attribute company
473
+ # @return [Company] the company that the usage report is for
474
+ belongs_to :company
475
+
476
+ # @!attribute company_id
477
+ # @return [Fixnum] the ID of the company that the usage report is for
478
+ attribute :company_id
479
+
480
+ # @!attribute object
481
+ # @return [String, nil] the (partial) HTML document of the usage report.
482
+ # (The value is +nil+ until the report has been successfully generated.)
483
+ attribute :object
484
+
485
+ # @!attribute created_at [r]
486
+ # @return [String] the timestamp of when the usage report was created
487
+ attribute :created_at
488
+
489
+ # @!attribute updated_at [r]
490
+ # @return [String] the timestamp of when the usage report was last updated
491
+ attribute :updated_at
251
492
  end
252
493
 
253
494
  # = The user class
@@ -257,27 +498,59 @@ module LWS::Auth
257
498
  class User < LWS::Generic::Model
258
499
  use_api LWS::Auth.api
259
500
 
260
- #@!attribute id [r]
261
- # @return [Fixnum] the (unique) ID of the user
262
-
263
- #@!attribute email
264
- # @return [String] the email address of the user
501
+ # @!attribute id [r]
502
+ # @return [Fixnum] the (unique) ID of the user
503
+ attribute :id
265
504
 
266
- #@!attribute password_digest
267
- # @return [String] the digested version of the password of the user
268
-
269
- #@!attribute account
270
- # @return [Account] the account that the user belongs to
505
+ # @!attribute account
506
+ # @return [Account] the account that the user belongs to
271
507
  belongs_to :account
272
508
 
273
- #@!attribute account_id
274
- # @return [Fixnum] the ID of the account that the user belongs to
275
-
276
- #@!attribute created_at
277
- # @return [String] the timestamp of when the user was created
278
-
279
- #@!attribute updated_at
280
- # @return [String] the timestamp of when the user was last updated
509
+ # @!attribute account_id
510
+ # @return [Fixnum] the ID of the account that the user belongs to
511
+ attribute :account_id
512
+
513
+ # @!attribute auth_provider
514
+ # @return [String] the name of the authentication provider
515
+ attribute :auth_provider
516
+
517
+ # @!attribute email
518
+ # @return [String] the email address of the user
519
+ attribute :email
520
+
521
+ # @!attribute mfa_enabled
522
+ # @return [Boolean] whether MFA (multi-factor authentication) is
523
+ # enabled for the user
524
+ attribute :mfa_enabled
525
+
526
+ # @!attribute mfa_verified
527
+ # @return [Boolean] whether MFA (multi-factor authentication) has
528
+ # been verified for the user
529
+ attribute :mfa_verified
530
+
531
+ # @!attribute oauth_expires_at
532
+ # @return [String, nil] the timestamp of when the OAuth token of the
533
+ # user expires
534
+ attribute :oauth_expires_at
535
+
536
+ # @!attribute password_digest
537
+ # @return [String, nil] the digested version of the password of the user.
538
+ # (Can be +nil+ if the authentication provider (see {#auth_provider})
539
+ # is not +"lws"+.)
540
+ attribute :password_digest
541
+
542
+ # @!attribute use_for_communication
543
+ # @return [Boolean] whether the email address (see {#email}) of
544
+ # the user is/will be used to send messages/announcements
545
+ attribute :use_for_communication
546
+
547
+ # @!attribute created_at [r]
548
+ # @return [String] the timestamp of when the user was created
549
+ attribute :created_at
550
+
551
+ # @!attribute updated_at [r]
552
+ # @return [String] the timestamp of when the user was last updated
553
+ attribute :updated_at
281
554
  end
282
555
 
283
556
  end