alula-ruby 0.50.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +14 -0
- data/.env.example +8 -0
- data/.github/workflows/gem-push.yml +45 -0
- data/.gitignore +23 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Dockerfile +6 -0
- data/Gemfile +12 -0
- data/Guardfile +42 -0
- data/README.md +423 -0
- data/Rakefile +6 -0
- data/VERSION.md +84 -0
- data/alula-docker-compose.yml +80 -0
- data/alula.gemspec +38 -0
- data/bin/console +15 -0
- data/bin/docparse +36 -0
- data/bin/genresource +79 -0
- data/bin/setup +8 -0
- data/bin/testauth +24 -0
- data/bin/testprep +9 -0
- data/data/docs/Alula_API_Documentation_2021-04-06.html +16240 -0
- data/docker-compose.yml +11 -0
- data/lib/alula/alula_response.rb +20 -0
- data/lib/alula/api_operations/delete.rb +52 -0
- data/lib/alula/api_operations/list.rb +45 -0
- data/lib/alula/api_operations/request.rb +44 -0
- data/lib/alula/api_operations/save.rb +81 -0
- data/lib/alula/api_resource.rb +196 -0
- data/lib/alula/client.rb +142 -0
- data/lib/alula/errors.rb +169 -0
- data/lib/alula/filter_builder.rb +271 -0
- data/lib/alula/helpers/device_attribute_translations.rb +68 -0
- data/lib/alula/list_object.rb +64 -0
- data/lib/alula/meta.rb +16 -0
- data/lib/alula/monkey_patches.rb +24 -0
- data/lib/alula/oauth.rb +118 -0
- data/lib/alula/pagination.rb +25 -0
- data/lib/alula/procedures/dealer_device_stats_proc.rb +16 -0
- data/lib/alula/procedures/dealer_restore_proc.rb +25 -0
- data/lib/alula/procedures/dealer_suspend_proc.rb +25 -0
- data/lib/alula/procedures/device_assign_proc.rb +23 -0
- data/lib/alula/procedures/device_cellular_history_proc.rb +33 -0
- data/lib/alula/procedures/device_rateplan_get_proc.rb +21 -0
- data/lib/alula/procedures/device_register_proc.rb +31 -0
- data/lib/alula/procedures/device_signal_add_proc.rb +42 -0
- data/lib/alula/procedures/device_signal_delivered_proc.rb +31 -0
- data/lib/alula/procedures/device_signal_update_proc.rb +32 -0
- data/lib/alula/procedures/device_unassign_proc.rb +16 -0
- data/lib/alula/procedures/device_unregister_proc.rb +21 -0
- data/lib/alula/procedures/upload_touchpad_branding_proc.rb +24 -0
- data/lib/alula/procedures/user_plansvideo_price_get.rb +21 -0
- data/lib/alula/procedures/user_transfer_accept.rb +19 -0
- data/lib/alula/procedures/user_transfer_authorize.rb +18 -0
- data/lib/alula/procedures/user_transfer_cancel.rb +18 -0
- data/lib/alula/procedures/user_transfer_deny.rb +19 -0
- data/lib/alula/procedures/user_transfer_reject.rb +19 -0
- data/lib/alula/procedures/user_transfer_request.rb +19 -0
- data/lib/alula/query_interface.rb +142 -0
- data/lib/alula/rate_limit.rb +11 -0
- data/lib/alula/relationship_attributes.rb +107 -0
- data/lib/alula/resource_attributes.rb +206 -0
- data/lib/alula/resources/admin_user.rb +207 -0
- data/lib/alula/resources/billing_program.rb +41 -0
- data/lib/alula/resources/dealer.rb +218 -0
- data/lib/alula/resources/dealer_account_transfer.rb +172 -0
- data/lib/alula/resources/dealer_address.rb +89 -0
- data/lib/alula/resources/dealer_branding.rb +226 -0
- data/lib/alula/resources/dealer_program.rb +75 -0
- data/lib/alula/resources/dealer_suspension_log.rb +49 -0
- data/lib/alula/resources/device.rb +716 -0
- data/lib/alula/resources/device_cellular_status.rb +134 -0
- data/lib/alula/resources/device_charge.rb +70 -0
- data/lib/alula/resources/device_event_log.rb +167 -0
- data/lib/alula/resources/device_program.rb +54 -0
- data/lib/alula/resources/event_trigger.rb +75 -0
- data/lib/alula/resources/event_webhook.rb +47 -0
- data/lib/alula/resources/feature_bysubject.rb +74 -0
- data/lib/alula/resources/feature_plan.rb +57 -0
- data/lib/alula/resources/feature_planvideo.rb +54 -0
- data/lib/alula/resources/feature_price.rb +46 -0
- data/lib/alula/resources/receiver_connection.rb +95 -0
- data/lib/alula/resources/receiver_group.rb +74 -0
- data/lib/alula/resources/revision.rb +91 -0
- data/lib/alula/resources/self.rb +61 -0
- data/lib/alula/resources/station.rb +130 -0
- data/lib/alula/resources/token_exchange.rb +34 -0
- data/lib/alula/resources/user.rb +229 -0
- data/lib/alula/resources/user_address.rb +121 -0
- data/lib/alula/resources/user_phone.rb +116 -0
- data/lib/alula/resources/user_preferences.rb +57 -0
- data/lib/alula/resources/user_pushtoken.rb +75 -0
- data/lib/alula/resources/user_videoprofile.rb +38 -0
- data/lib/alula/rest_resource.rb +17 -0
- data/lib/alula/rpc_resource.rb +40 -0
- data/lib/alula/rpc_response.rb +14 -0
- data/lib/alula/singleton_rest_resource.rb +26 -0
- data/lib/alula/util.rb +107 -0
- data/lib/alula/version.rb +5 -0
- data/lib/alula.rb +135 -0
- data/lib/parser.rb +199 -0
- metadata +282 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
module Alula
|
2
|
+
class FeaturePlanVideo < Alula::RestResource
|
3
|
+
extend Alula::ResourceAttributes
|
4
|
+
extend Alula::ApiOperations::Request
|
5
|
+
extend Alula::ApiOperations::List
|
6
|
+
extend Alula::ApiOperations::Save
|
7
|
+
extend Alula::ApiOperations::Delete
|
8
|
+
|
9
|
+
resource_path 'features/plansvideo'
|
10
|
+
type 'feature-plansvideo'
|
11
|
+
|
12
|
+
field :id,
|
13
|
+
type: :string,
|
14
|
+
sortable: false,
|
15
|
+
filterable: false,
|
16
|
+
creatable_by: [:system],
|
17
|
+
patchable_by: []
|
18
|
+
|
19
|
+
field :gp_id,
|
20
|
+
type: :string,
|
21
|
+
sortable: true,
|
22
|
+
filterable: true,
|
23
|
+
creatable_by: [:system],
|
24
|
+
patchable_by: []
|
25
|
+
|
26
|
+
field :item,
|
27
|
+
type: :string,
|
28
|
+
sortable: true,
|
29
|
+
filterable: false,
|
30
|
+
creatable_by: [:system],
|
31
|
+
patchable_by: []
|
32
|
+
|
33
|
+
field :overflow,
|
34
|
+
type: :string,
|
35
|
+
sortable: true,
|
36
|
+
filterable: true,
|
37
|
+
creatable_by: [:system],
|
38
|
+
patchable_by: []
|
39
|
+
|
40
|
+
field :count,
|
41
|
+
type: :string,
|
42
|
+
sortable: true,
|
43
|
+
filterable: false,
|
44
|
+
creatable_by: [:system],
|
45
|
+
patchable_by: [:system]
|
46
|
+
|
47
|
+
field :price,
|
48
|
+
type: :string,
|
49
|
+
sortable: true,
|
50
|
+
filterable: false,
|
51
|
+
creatable_by: [:system],
|
52
|
+
patchable_by: [:system]
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Alula
|
2
|
+
class FeaturePrice < Alula::RestResource
|
3
|
+
extend Alula::ResourceAttributes
|
4
|
+
extend Alula::ApiOperations::Request
|
5
|
+
extend Alula::ApiOperations::List
|
6
|
+
extend Alula::ApiOperations::Save
|
7
|
+
|
8
|
+
resource_path 'features/prices'
|
9
|
+
type 'feature-prices'
|
10
|
+
|
11
|
+
field :id,
|
12
|
+
type: :string,
|
13
|
+
sortable: true,
|
14
|
+
filterable: true,
|
15
|
+
creatable_by: [],
|
16
|
+
patchable_by: []
|
17
|
+
|
18
|
+
field :gp_id,
|
19
|
+
type: :string,
|
20
|
+
sortable: true,
|
21
|
+
filterable: true,
|
22
|
+
creatable_by: [:system],
|
23
|
+
patchable_by: []
|
24
|
+
|
25
|
+
field :feature_name,
|
26
|
+
type: :string,
|
27
|
+
sortable: true,
|
28
|
+
filterable: true,
|
29
|
+
creatable_by: [:system],
|
30
|
+
patchable_by: []
|
31
|
+
|
32
|
+
field :device_type,
|
33
|
+
type: :string,
|
34
|
+
sortable: true,
|
35
|
+
filterable: true,
|
36
|
+
creatable_by: [:system],
|
37
|
+
patchable_by: []
|
38
|
+
|
39
|
+
field :price,
|
40
|
+
type: :string,
|
41
|
+
sortable: true,
|
42
|
+
filterable: true,
|
43
|
+
creatable_by: [:system],
|
44
|
+
patchable_by: [:system]
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Alula
|
2
|
+
class ReceiverConnection < Alula::RestResource
|
3
|
+
extend Alula::ResourceAttributes
|
4
|
+
extend Alula::ApiOperations::List
|
5
|
+
|
6
|
+
# You should update this to be a slash-separated, literal path to the resource
|
7
|
+
# without the prefix /api/v1 or the suffix of an ID
|
8
|
+
resource_path 'receivers/connections'
|
9
|
+
type 'receivers-connections'
|
10
|
+
|
11
|
+
# Relationships
|
12
|
+
# None
|
13
|
+
|
14
|
+
# Resource Fields
|
15
|
+
# Not all params are used at the moment. See Alula::ResourceAttributes for details
|
16
|
+
# on how params are parsed,
|
17
|
+
field :id,
|
18
|
+
type: :string,
|
19
|
+
sortable: false,
|
20
|
+
filterable: false,
|
21
|
+
creatable_by: [],
|
22
|
+
patchable_by: []
|
23
|
+
|
24
|
+
field :path,
|
25
|
+
type: :string,
|
26
|
+
sortable: true,
|
27
|
+
filterable: true,
|
28
|
+
creatable_by: [],
|
29
|
+
patchable_by: []
|
30
|
+
|
31
|
+
field :name,
|
32
|
+
type: :string,
|
33
|
+
sortable: false,
|
34
|
+
filterable: false,
|
35
|
+
creatable_by: [],
|
36
|
+
patchable_by: []
|
37
|
+
|
38
|
+
field :station_id,
|
39
|
+
type: :string,
|
40
|
+
sortable: false,
|
41
|
+
filterable: false,
|
42
|
+
creatable_by: [],
|
43
|
+
patchable_by: []
|
44
|
+
|
45
|
+
field :success_count,
|
46
|
+
type: :number,
|
47
|
+
sortable: false,
|
48
|
+
filterable: false,
|
49
|
+
creatable_by: [],
|
50
|
+
patchable_by: []
|
51
|
+
|
52
|
+
field :fail_count,
|
53
|
+
type: :number,
|
54
|
+
sortable: false,
|
55
|
+
filterable: false,
|
56
|
+
creatable_by: [],
|
57
|
+
patchable_by: []
|
58
|
+
|
59
|
+
field :last_success,
|
60
|
+
type: :date,
|
61
|
+
sortable: false,
|
62
|
+
filterable: false,
|
63
|
+
creatable_by: [],
|
64
|
+
patchable_by: []
|
65
|
+
|
66
|
+
field :last_fail,
|
67
|
+
type: :date,
|
68
|
+
sortable: false,
|
69
|
+
filterable: false,
|
70
|
+
creatable_by: [],
|
71
|
+
patchable_by: []
|
72
|
+
|
73
|
+
field :status,
|
74
|
+
type: :string,
|
75
|
+
sortable: false,
|
76
|
+
filterable: true,
|
77
|
+
creatable_by: [],
|
78
|
+
patchable_by: []
|
79
|
+
|
80
|
+
field :type,
|
81
|
+
type: :string,
|
82
|
+
sortable: false,
|
83
|
+
filterable: true,
|
84
|
+
creatable_by: [],
|
85
|
+
patchable_by: []
|
86
|
+
|
87
|
+
field :status_date,
|
88
|
+
type: :date,
|
89
|
+
sortable: true,
|
90
|
+
filterable: true,
|
91
|
+
creatable_by: [],
|
92
|
+
patchable_by: []
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Alula
|
2
|
+
class ReceiverGroup < Alula::RestResource
|
3
|
+
extend Alula::ResourceAttributes
|
4
|
+
extend Alula::RelationshipAttributes
|
5
|
+
extend Alula::ApiOperations::Request
|
6
|
+
extend Alula::ApiOperations::List
|
7
|
+
extend Alula::ApiOperations::Save
|
8
|
+
|
9
|
+
resource_path 'receivers/groups'
|
10
|
+
type 'receivers-groups'
|
11
|
+
|
12
|
+
# Relationships
|
13
|
+
relationship :dealer, type: 'dealers', cardinality: 'To-one'
|
14
|
+
relationship :devices, type: 'devices', cardinality: 'To-many'
|
15
|
+
|
16
|
+
# Resource Fields
|
17
|
+
field :id,
|
18
|
+
type: :string,
|
19
|
+
sortable: false,
|
20
|
+
filterable: false,
|
21
|
+
creatable_by: [],
|
22
|
+
patchable_by: []
|
23
|
+
|
24
|
+
field :dealer_id,
|
25
|
+
type: :string,
|
26
|
+
sortable: false,
|
27
|
+
filterable: true,
|
28
|
+
creatable_by: [:system, :station, :dealer],
|
29
|
+
patchable_by: []
|
30
|
+
|
31
|
+
field :name,
|
32
|
+
type: :string,
|
33
|
+
sortable: true,
|
34
|
+
filterable: true,
|
35
|
+
creatable_by: [:system, :station, :dealer],
|
36
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :sub_user]
|
37
|
+
|
38
|
+
field :description,
|
39
|
+
type: :string,
|
40
|
+
sortable: false,
|
41
|
+
filterable: false,
|
42
|
+
creatable_by: [:system, :station, :dealer],
|
43
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :sub_user]
|
44
|
+
|
45
|
+
field :date_modified,
|
46
|
+
type: :date,
|
47
|
+
sortable: true,
|
48
|
+
filterable: true,
|
49
|
+
creatable_by: [],
|
50
|
+
patchable_by: []
|
51
|
+
|
52
|
+
field :date_entered,
|
53
|
+
type: :date,
|
54
|
+
sortable: true,
|
55
|
+
filterable: true,
|
56
|
+
creatable_by: [],
|
57
|
+
patchable_by: []
|
58
|
+
|
59
|
+
field :created_by,
|
60
|
+
type: :string,
|
61
|
+
sortable: false,
|
62
|
+
filterable: false,
|
63
|
+
creatable_by: [],
|
64
|
+
patchable_by: []
|
65
|
+
|
66
|
+
field :modified_by,
|
67
|
+
type: :string,
|
68
|
+
sortable: false,
|
69
|
+
filterable: false,
|
70
|
+
creatable_by: [],
|
71
|
+
patchable_by: []
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Alula
|
2
|
+
class Revision < Alula::RestResource
|
3
|
+
extend Alula::ResourceAttributes
|
4
|
+
extend Alula::RelationshipAttributes
|
5
|
+
extend Alula::ApiOperations::Request
|
6
|
+
extend Alula::ApiOperations::List
|
7
|
+
|
8
|
+
# You should update this to be a slash-separated, literal path to the resource
|
9
|
+
# without the prefix /api/v1 or the suffix of an ID
|
10
|
+
resource_path 'revisions'
|
11
|
+
type 'revisions'
|
12
|
+
|
13
|
+
# Relationships
|
14
|
+
relationship :creator, type: 'users', cardinality: 'To-one'
|
15
|
+
relationship :device, type: 'devices', cardinality: 'To-one'
|
16
|
+
relationship :user, type: 'users', cardinality: 'To-one'
|
17
|
+
relationship :dealer, type: 'dealers', cardinality: 'To-one'
|
18
|
+
|
19
|
+
# Resource Fields
|
20
|
+
# Not all params are used at the moment. See Alula::ResourceAttributes for details
|
21
|
+
# on how params are parsed,
|
22
|
+
field :id,
|
23
|
+
type: :string,
|
24
|
+
sortable: false,
|
25
|
+
filterable: false,
|
26
|
+
creatable_by: [],
|
27
|
+
patchable_by: []
|
28
|
+
|
29
|
+
field :model,
|
30
|
+
type: :string,
|
31
|
+
sortable: false,
|
32
|
+
filterable: false,
|
33
|
+
creatable_by: [],
|
34
|
+
patchable_by: []
|
35
|
+
|
36
|
+
field :document,
|
37
|
+
type: :object,
|
38
|
+
sortable: false,
|
39
|
+
filterable: false,
|
40
|
+
creatable_by: [],
|
41
|
+
patchable_by: []
|
42
|
+
|
43
|
+
field :operation,
|
44
|
+
type: :string,
|
45
|
+
sortable: false,
|
46
|
+
filterable: false,
|
47
|
+
creatable_by: [],
|
48
|
+
patchable_by: []
|
49
|
+
|
50
|
+
field :document_id,
|
51
|
+
type: :string,
|
52
|
+
sortable: false,
|
53
|
+
filterable: true,
|
54
|
+
creatable_by: [],
|
55
|
+
patchable_by: []
|
56
|
+
|
57
|
+
field :revision,
|
58
|
+
type: :string,
|
59
|
+
sortable: true,
|
60
|
+
filterable: false,
|
61
|
+
creatable_by: [],
|
62
|
+
patchable_by: []
|
63
|
+
|
64
|
+
field :created_at,
|
65
|
+
type: :date,
|
66
|
+
sortable: true,
|
67
|
+
filterable: true,
|
68
|
+
creatable_by: [],
|
69
|
+
patchable_by: []
|
70
|
+
|
71
|
+
field :updated_at,
|
72
|
+
type: :date,
|
73
|
+
sortable: true,
|
74
|
+
filterable: false,
|
75
|
+
creatable_by: [],
|
76
|
+
patchable_by: []
|
77
|
+
|
78
|
+
field :user_id,
|
79
|
+
type: :string,
|
80
|
+
sortable: false,
|
81
|
+
filterable: true,
|
82
|
+
creatable_by: [],
|
83
|
+
patchable_by: []
|
84
|
+
|
85
|
+
|
86
|
+
def document
|
87
|
+
JSON.parse(@values['document'])
|
88
|
+
.with_indifferent_access
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Alula
|
2
|
+
class Self < Alula::SingletonRestResource
|
3
|
+
extend Alula::ResourceAttributes
|
4
|
+
extend Alula::RelationshipAttributes
|
5
|
+
|
6
|
+
# You should update this to be a slash-separated, literal path to the resource
|
7
|
+
# without the prefix /api/v1 or the suffix of an ID
|
8
|
+
resource_path 'self'
|
9
|
+
type 'self'
|
10
|
+
|
11
|
+
# Relationships
|
12
|
+
# None
|
13
|
+
|
14
|
+
# Resource Fields
|
15
|
+
# Not all params are used at the moment. See Alula::ResourceAttributes for details
|
16
|
+
# on how params are parsed,
|
17
|
+
field :id,
|
18
|
+
type: :string,
|
19
|
+
sortable: false,
|
20
|
+
filterable: false,
|
21
|
+
creatable_by: [],
|
22
|
+
patchable_by: []
|
23
|
+
|
24
|
+
field :dealer_id,
|
25
|
+
type: :string,
|
26
|
+
sortable: false,
|
27
|
+
filterable: false,
|
28
|
+
creatable_by: [],
|
29
|
+
patchable_by: []
|
30
|
+
|
31
|
+
field :parent_id,
|
32
|
+
type: :string,
|
33
|
+
sortable: false,
|
34
|
+
filterable: false,
|
35
|
+
creatable_by: [],
|
36
|
+
patchable_by: []
|
37
|
+
|
38
|
+
field :u_type,
|
39
|
+
type: :string,
|
40
|
+
sortable: false,
|
41
|
+
filterable: false,
|
42
|
+
creatable_by: [],
|
43
|
+
patchable_by: []
|
44
|
+
|
45
|
+
field :user_type,
|
46
|
+
type: :string,
|
47
|
+
sortable: false,
|
48
|
+
filterable: false,
|
49
|
+
creatable_by: [],
|
50
|
+
patchable_by: [],
|
51
|
+
symbolize: true
|
52
|
+
|
53
|
+
field :impersonator,
|
54
|
+
type: :string,
|
55
|
+
sortable: false,
|
56
|
+
filterable: false,
|
57
|
+
creatable_by: [],
|
58
|
+
patchable_by: []
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Alula
|
4
|
+
class Station < Alula::RestResource
|
5
|
+
extend Alula::ResourceAttributes
|
6
|
+
extend Alula::RelationshipAttributes
|
7
|
+
extend Alula::ApiOperations::Request
|
8
|
+
extend Alula::ApiOperations::List
|
9
|
+
extend Alula::ApiOperations::Save
|
10
|
+
|
11
|
+
resource_path 'stations'
|
12
|
+
|
13
|
+
# Relationships
|
14
|
+
relationship :dealers, type: 'dealers', cardinality: 'To-many'
|
15
|
+
|
16
|
+
# Resource Fields
|
17
|
+
field :id,
|
18
|
+
type: :string,
|
19
|
+
sortable: false,
|
20
|
+
filterable: false,
|
21
|
+
creatable_by: [],
|
22
|
+
patchable_by: []
|
23
|
+
|
24
|
+
field :company_name,
|
25
|
+
type: :string,
|
26
|
+
sortable: true,
|
27
|
+
filterable: true,
|
28
|
+
creatable_by: [:system],
|
29
|
+
patchable_by: %i[system station dealer]
|
30
|
+
|
31
|
+
field :date_entered,
|
32
|
+
type: :date,
|
33
|
+
sortable: true,
|
34
|
+
filterable: true,
|
35
|
+
creatable_by: [],
|
36
|
+
patchable_by: []
|
37
|
+
|
38
|
+
field :date_modified,
|
39
|
+
type: :date,
|
40
|
+
sortable: true,
|
41
|
+
filterable: true,
|
42
|
+
creatable_by: [],
|
43
|
+
patchable_by: %i[system station dealer]
|
44
|
+
|
45
|
+
field :modified_by,
|
46
|
+
type: :string,
|
47
|
+
sortable: false,
|
48
|
+
filterable: false,
|
49
|
+
creatable_by: [],
|
50
|
+
patchable_by: %i[system station dealer]
|
51
|
+
|
52
|
+
field :entered_by,
|
53
|
+
type: :string,
|
54
|
+
sortable: false,
|
55
|
+
filterable: false,
|
56
|
+
creatable_by: [],
|
57
|
+
patchable_by: []
|
58
|
+
|
59
|
+
field :acnt_no,
|
60
|
+
type: :string,
|
61
|
+
sortable: false,
|
62
|
+
filterable: true,
|
63
|
+
creatable_by: [:system],
|
64
|
+
patchable_by: %i[system station dealer]
|
65
|
+
|
66
|
+
field :email,
|
67
|
+
type: :string,
|
68
|
+
sortable: false,
|
69
|
+
filterable: false,
|
70
|
+
creatable_by: [:system],
|
71
|
+
patchable_by: %i[system station dealer]
|
72
|
+
|
73
|
+
field :username,
|
74
|
+
type: :string,
|
75
|
+
sortable: false,
|
76
|
+
filterable: false,
|
77
|
+
creatable_by: [:system],
|
78
|
+
patchable_by: []
|
79
|
+
|
80
|
+
field :password,
|
81
|
+
type: :string,
|
82
|
+
sortable: false,
|
83
|
+
filterable: false,
|
84
|
+
creatable_by: [:system],
|
85
|
+
patchable_by: []
|
86
|
+
|
87
|
+
field :name_last,
|
88
|
+
type: :string,
|
89
|
+
sortable: false,
|
90
|
+
filterable: false,
|
91
|
+
creatable_by: [:system],
|
92
|
+
patchable_by: []
|
93
|
+
|
94
|
+
field :name_first,
|
95
|
+
type: :string,
|
96
|
+
sortable: false,
|
97
|
+
filterable: false,
|
98
|
+
creatable_by: [:system],
|
99
|
+
patchable_by: []
|
100
|
+
|
101
|
+
field :u_type,
|
102
|
+
type: :string,
|
103
|
+
sortable: false,
|
104
|
+
filterable: false,
|
105
|
+
creatable_by: [:system],
|
106
|
+
patchable_by: []
|
107
|
+
|
108
|
+
field :timezone,
|
109
|
+
type: :string,
|
110
|
+
sortable: false,
|
111
|
+
filterable: false,
|
112
|
+
creatable_by: [:system],
|
113
|
+
patchable_by: []
|
114
|
+
|
115
|
+
field :hidden,
|
116
|
+
type: :string,
|
117
|
+
sortable: false,
|
118
|
+
filterable: false,
|
119
|
+
creatable_by: [],
|
120
|
+
patchable_by: [:system]
|
121
|
+
|
122
|
+
field :station_id,
|
123
|
+
type: :string,
|
124
|
+
sortable: false,
|
125
|
+
filterable: false,
|
126
|
+
creatable_by: [:system],
|
127
|
+
patchable_by: []
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Alula
|
2
|
+
class TokenExchange
|
3
|
+
def self.token_for_user(user_id)
|
4
|
+
url = '/rest/v1/oauth/accesstokens'
|
5
|
+
payload = { data: { attributes: { userId: user_id } } }
|
6
|
+
opts = {}
|
7
|
+
|
8
|
+
response = Alula::Client.request(:post, url, payload, opts)
|
9
|
+
|
10
|
+
if response.ok?
|
11
|
+
ImpersonatedToken.new(response.data['data']['attributes'])
|
12
|
+
else
|
13
|
+
error_class = AlulaError.for_response(response)
|
14
|
+
raise error_class
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class ImpersonatedToken
|
19
|
+
# Simple Oauth::Response reader object
|
20
|
+
attr_reader :date_created, :access_token, :expires_in, :expires_at, :refresh_token, :scope
|
21
|
+
|
22
|
+
def initialize(attributes)
|
23
|
+
@raw_response = attributes
|
24
|
+
|
25
|
+
@date_created = Time.parse(attributes['dateCreated'])
|
26
|
+
@access_token = attributes['accessToken']
|
27
|
+
@expires_at = Time.parse(attributes['expires'])
|
28
|
+
@expires_in = (@expires_at - Time.now.utc).to_i
|
29
|
+
@refresh_token = attributes['refresh_token']
|
30
|
+
@scope = attributes['scope']
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|