alula-ruby 0.50.1
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.
- 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,229 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Alula
|
|
4
|
+
class User < 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 'users'
|
|
12
|
+
type 'users'
|
|
13
|
+
|
|
14
|
+
relationship :devices, type: 'devices', cardinality: 'To-many'
|
|
15
|
+
relationship :dealer, type: 'dealers', cardinality: 'To-one'
|
|
16
|
+
relationship :phone, type: 'users-phones', cardinality: 'To-one'
|
|
17
|
+
relationship :address, type: 'users-addresses', cardinality: 'To-one'
|
|
18
|
+
relationship :pushtokens, type: 'users-pushtokens', cardinality: 'To-many'
|
|
19
|
+
relationship :preferences, type: 'users-preferences', cardinality: 'To-one'
|
|
20
|
+
relationship :videoprofiles, type: 'users-videoprofiles', cardinality: 'To-many'
|
|
21
|
+
|
|
22
|
+
# Resource Fields
|
|
23
|
+
# Not all params are used at the moment. See Alula::ResourceAttributes for details
|
|
24
|
+
# on how params are parsed,
|
|
25
|
+
field :id,
|
|
26
|
+
type: :string,
|
|
27
|
+
sortable: false,
|
|
28
|
+
filterable: false,
|
|
29
|
+
creatable_by: [],
|
|
30
|
+
patchable_by: []
|
|
31
|
+
|
|
32
|
+
field :username,
|
|
33
|
+
type: :string,
|
|
34
|
+
sortable: true,
|
|
35
|
+
filterable: true,
|
|
36
|
+
creatable_by: %i[system station dealer technician user],
|
|
37
|
+
patchable_by: %i[system station dealer technician user sub_user]
|
|
38
|
+
|
|
39
|
+
field :password,
|
|
40
|
+
type: :string,
|
|
41
|
+
sortable: false,
|
|
42
|
+
filterable: false,
|
|
43
|
+
creatable_by: %i[system station dealer technician user],
|
|
44
|
+
patchable_by: []
|
|
45
|
+
|
|
46
|
+
field :u_type,
|
|
47
|
+
type: :string,
|
|
48
|
+
sortable: false,
|
|
49
|
+
filterable: true,
|
|
50
|
+
creatable_by: %i[system station dealer technician user],
|
|
51
|
+
patchable_by: []
|
|
52
|
+
|
|
53
|
+
field :user_type,
|
|
54
|
+
type: :string,
|
|
55
|
+
sortable: false,
|
|
56
|
+
filterable: true,
|
|
57
|
+
creatable_by: %i[system station dealer technician user],
|
|
58
|
+
patchable_by: [],
|
|
59
|
+
symbolize: true
|
|
60
|
+
|
|
61
|
+
field :u_level,
|
|
62
|
+
type: :string,
|
|
63
|
+
sortable: false,
|
|
64
|
+
filterable: false,
|
|
65
|
+
creatable_by: [],
|
|
66
|
+
patchable_by: []
|
|
67
|
+
|
|
68
|
+
field :parent_id,
|
|
69
|
+
type: :string,
|
|
70
|
+
sortable: false,
|
|
71
|
+
filterable: true,
|
|
72
|
+
creatable_by: %i[system station dealer technician user],
|
|
73
|
+
patchable_by: []
|
|
74
|
+
|
|
75
|
+
field :dealer_id,
|
|
76
|
+
type: :string,
|
|
77
|
+
sortable: false,
|
|
78
|
+
filterable: true,
|
|
79
|
+
creatable_by: %i[system station dealer technician user],
|
|
80
|
+
patchable_by: []
|
|
81
|
+
|
|
82
|
+
field :station_id,
|
|
83
|
+
type: :string,
|
|
84
|
+
sortable: false,
|
|
85
|
+
filterable: true,
|
|
86
|
+
creatable_by: [:system],
|
|
87
|
+
patchable_by: []
|
|
88
|
+
|
|
89
|
+
field :last_login,
|
|
90
|
+
type: :string,
|
|
91
|
+
sortable: false,
|
|
92
|
+
filterable: false,
|
|
93
|
+
creatable_by: [],
|
|
94
|
+
patchable_by: []
|
|
95
|
+
|
|
96
|
+
field :date_entered,
|
|
97
|
+
type: :date,
|
|
98
|
+
sortable: true,
|
|
99
|
+
filterable: true,
|
|
100
|
+
creatable_by: [],
|
|
101
|
+
patchable_by: []
|
|
102
|
+
|
|
103
|
+
field :date_modified,
|
|
104
|
+
type: :date,
|
|
105
|
+
sortable: true,
|
|
106
|
+
filterable: true,
|
|
107
|
+
creatable_by: [],
|
|
108
|
+
patchable_by: []
|
|
109
|
+
|
|
110
|
+
field :entered_by,
|
|
111
|
+
type: :string,
|
|
112
|
+
sortable: false,
|
|
113
|
+
filterable: false,
|
|
114
|
+
creatable_by: [],
|
|
115
|
+
patchable_by: []
|
|
116
|
+
|
|
117
|
+
field :modified_by,
|
|
118
|
+
type: :string,
|
|
119
|
+
sortable: false,
|
|
120
|
+
filterable: false,
|
|
121
|
+
creatable_by: [],
|
|
122
|
+
patchable_by: []
|
|
123
|
+
|
|
124
|
+
field :pwch,
|
|
125
|
+
type: :string,
|
|
126
|
+
sortable: false,
|
|
127
|
+
filterable: false,
|
|
128
|
+
creatable_by: [],
|
|
129
|
+
patchable_by: []
|
|
130
|
+
|
|
131
|
+
field :features_selected,
|
|
132
|
+
type: :object,
|
|
133
|
+
sortable: false,
|
|
134
|
+
filterable: false,
|
|
135
|
+
creatable_by: %i[system station dealer technician],
|
|
136
|
+
patchable_by: %i[system station dealer technician]
|
|
137
|
+
|
|
138
|
+
field :eula,
|
|
139
|
+
type: :string,
|
|
140
|
+
sortable: false,
|
|
141
|
+
filterable: false,
|
|
142
|
+
creatable_by: [],
|
|
143
|
+
patchable_by: %i[system station dealer technician user sub_user]
|
|
144
|
+
|
|
145
|
+
field :def_mod,
|
|
146
|
+
type: :string,
|
|
147
|
+
sortable: false,
|
|
148
|
+
filterable: false,
|
|
149
|
+
creatable_by: [],
|
|
150
|
+
patchable_by: []
|
|
151
|
+
|
|
152
|
+
field :rg_activated,
|
|
153
|
+
type: :string,
|
|
154
|
+
sortable: false,
|
|
155
|
+
filterable: false,
|
|
156
|
+
creatable_by: [],
|
|
157
|
+
patchable_by: []
|
|
158
|
+
|
|
159
|
+
field :company_name,
|
|
160
|
+
type: :string,
|
|
161
|
+
sortable: false,
|
|
162
|
+
filterable: false,
|
|
163
|
+
creatable_by: [],
|
|
164
|
+
patchable_by: []
|
|
165
|
+
|
|
166
|
+
field :name_first,
|
|
167
|
+
type: :string,
|
|
168
|
+
sortable: true,
|
|
169
|
+
filterable: true,
|
|
170
|
+
creatable_by: %i[system station dealer technician user],
|
|
171
|
+
patchable_by: %i[system station dealer technician user sub_user]
|
|
172
|
+
|
|
173
|
+
field :name_last,
|
|
174
|
+
type: :string,
|
|
175
|
+
sortable: true,
|
|
176
|
+
filterable: true,
|
|
177
|
+
creatable_by: %i[system station dealer technician user],
|
|
178
|
+
patchable_by: %i[system station dealer technician user sub_user]
|
|
179
|
+
|
|
180
|
+
field :email,
|
|
181
|
+
type: :string,
|
|
182
|
+
sortable: true,
|
|
183
|
+
filterable: true,
|
|
184
|
+
creatable_by: %i[system station dealer technician user],
|
|
185
|
+
patchable_by: %i[system station dealer technician user sub_user]
|
|
186
|
+
|
|
187
|
+
field :time_offset,
|
|
188
|
+
type: :string,
|
|
189
|
+
sortable: false,
|
|
190
|
+
filterable: false,
|
|
191
|
+
creatable_by: [],
|
|
192
|
+
patchable_by: []
|
|
193
|
+
|
|
194
|
+
field :timezone,
|
|
195
|
+
type: :string,
|
|
196
|
+
sortable: false,
|
|
197
|
+
filterable: false,
|
|
198
|
+
creatable_by: %i[system station dealer technician user],
|
|
199
|
+
patchable_by: %i[system station dealer technician user sub_user]
|
|
200
|
+
|
|
201
|
+
def user_role
|
|
202
|
+
# pre-alula api users will be u_type 32, newer ones are 96. need to differentiate
|
|
203
|
+
# between account users and account owners by checking if they own themselves
|
|
204
|
+
{
|
|
205
|
+
2 => :system,
|
|
206
|
+
4 => :station,
|
|
207
|
+
8 => :dealer,
|
|
208
|
+
16 => :technician,
|
|
209
|
+
32 => :user,
|
|
210
|
+
64 => :sub_user,
|
|
211
|
+
96 => :account_user,
|
|
212
|
+
320 => :local_access_user
|
|
213
|
+
}[(u_type == 96 && parent_id == id ? 32 : u_type)]
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def user_role_name
|
|
217
|
+
{
|
|
218
|
+
system: 'System',
|
|
219
|
+
station: 'Station',
|
|
220
|
+
dealer: 'Dealer',
|
|
221
|
+
technician: 'Technician',
|
|
222
|
+
user: 'Account Owner',
|
|
223
|
+
sub_user: 'Sub-User',
|
|
224
|
+
account_user: 'Account User',
|
|
225
|
+
local_access_user: 'Local Access User'
|
|
226
|
+
}[user_role]
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
end
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
##
|
|
2
|
+
# Create, view, and configure users’ and sub-users’ address contact information.
|
|
3
|
+
module Alula
|
|
4
|
+
class UserAddress < 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
|
+
# You should update this to be a slash-separated, literal path to the resource
|
|
12
|
+
# without the prefix /api/v1 or the suffix of an ID
|
|
13
|
+
resource_path 'users/addresses'
|
|
14
|
+
type 'users-addresses'
|
|
15
|
+
|
|
16
|
+
# Relationships
|
|
17
|
+
relationship :user, type: 'users', 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 :username,
|
|
30
|
+
type: :string,
|
|
31
|
+
sortable: true,
|
|
32
|
+
filterable: true,
|
|
33
|
+
creatable_by: [],
|
|
34
|
+
patchable_by: []
|
|
35
|
+
|
|
36
|
+
field :address1,
|
|
37
|
+
type: :string,
|
|
38
|
+
sortable: false,
|
|
39
|
+
filterable: true,
|
|
40
|
+
creatable_by: [],
|
|
41
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
42
|
+
|
|
43
|
+
field :address2,
|
|
44
|
+
type: :string,
|
|
45
|
+
sortable: false,
|
|
46
|
+
filterable: true,
|
|
47
|
+
creatable_by: [],
|
|
48
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
49
|
+
|
|
50
|
+
field :st_number,
|
|
51
|
+
type: :string,
|
|
52
|
+
sortable: false,
|
|
53
|
+
filterable: true,
|
|
54
|
+
creatable_by: [],
|
|
55
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
56
|
+
|
|
57
|
+
field :st_name,
|
|
58
|
+
type: :string,
|
|
59
|
+
sortable: false,
|
|
60
|
+
filterable: true,
|
|
61
|
+
creatable_by: [],
|
|
62
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
63
|
+
|
|
64
|
+
field :st_direction,
|
|
65
|
+
type: :string,
|
|
66
|
+
sortable: false,
|
|
67
|
+
filterable: true,
|
|
68
|
+
creatable_by: [],
|
|
69
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
70
|
+
|
|
71
|
+
field :city,
|
|
72
|
+
type: :string,
|
|
73
|
+
sortable: false,
|
|
74
|
+
filterable: true,
|
|
75
|
+
creatable_by: [],
|
|
76
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
77
|
+
|
|
78
|
+
field :state,
|
|
79
|
+
type: :string,
|
|
80
|
+
sortable: false,
|
|
81
|
+
filterable: true,
|
|
82
|
+
creatable_by: [],
|
|
83
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
84
|
+
|
|
85
|
+
field :zip_code,
|
|
86
|
+
type: :string,
|
|
87
|
+
sortable: false,
|
|
88
|
+
filterable: true,
|
|
89
|
+
creatable_by: [],
|
|
90
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
91
|
+
|
|
92
|
+
field :country,
|
|
93
|
+
type: :string,
|
|
94
|
+
sortable: false,
|
|
95
|
+
filterable: true,
|
|
96
|
+
creatable_by: [],
|
|
97
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
98
|
+
|
|
99
|
+
field :time_offset,
|
|
100
|
+
type: :string,
|
|
101
|
+
sortable: false,
|
|
102
|
+
filterable: false,
|
|
103
|
+
creatable_by: [],
|
|
104
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
105
|
+
|
|
106
|
+
field :timezone,
|
|
107
|
+
type: :string,
|
|
108
|
+
sortable: false,
|
|
109
|
+
filterable: false,
|
|
110
|
+
creatable_by: [],
|
|
111
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
112
|
+
|
|
113
|
+
field :company_name,
|
|
114
|
+
type: :string,
|
|
115
|
+
sortable: false,
|
|
116
|
+
filterable: false,
|
|
117
|
+
creatable_by: [],
|
|
118
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
module Alula
|
|
2
|
+
class UserPhone < 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 'users/phones'
|
|
10
|
+
type 'users-phones'
|
|
11
|
+
|
|
12
|
+
# Relationships
|
|
13
|
+
# None
|
|
14
|
+
|
|
15
|
+
# Resource Fields
|
|
16
|
+
# Not all params are used at the moment. See Alula::ResourceAttributes for details
|
|
17
|
+
# on how params are parsed,
|
|
18
|
+
field :id,
|
|
19
|
+
type: :string,
|
|
20
|
+
sortable: false,
|
|
21
|
+
filterable: false,
|
|
22
|
+
creatable_by: [],
|
|
23
|
+
patchable_by: []
|
|
24
|
+
|
|
25
|
+
field :username,
|
|
26
|
+
type: :string,
|
|
27
|
+
sortable: true,
|
|
28
|
+
filterable: true,
|
|
29
|
+
creatable_by: [],
|
|
30
|
+
patchable_by: []
|
|
31
|
+
|
|
32
|
+
field :phone_pri_contact,
|
|
33
|
+
type: :string,
|
|
34
|
+
sortable: false,
|
|
35
|
+
filterable: false,
|
|
36
|
+
creatable_by: [],
|
|
37
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
38
|
+
|
|
39
|
+
field :phone_pri_ct,
|
|
40
|
+
type: :string,
|
|
41
|
+
sortable: false,
|
|
42
|
+
filterable: false,
|
|
43
|
+
creatable_by: [],
|
|
44
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
45
|
+
|
|
46
|
+
field :phone_sec_contact,
|
|
47
|
+
type: :string,
|
|
48
|
+
sortable: false,
|
|
49
|
+
filterable: false,
|
|
50
|
+
creatable_by: [],
|
|
51
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
52
|
+
|
|
53
|
+
field :phone_sec_ct,
|
|
54
|
+
type: :string,
|
|
55
|
+
sortable: false,
|
|
56
|
+
filterable: false,
|
|
57
|
+
creatable_by: [],
|
|
58
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
59
|
+
|
|
60
|
+
field :contact_type,
|
|
61
|
+
type: :string,
|
|
62
|
+
sortable: false,
|
|
63
|
+
filterable: false,
|
|
64
|
+
creatable_by: [],
|
|
65
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
66
|
+
|
|
67
|
+
field :co_ph_pri,
|
|
68
|
+
type: :string,
|
|
69
|
+
sortable: false,
|
|
70
|
+
filterable: false,
|
|
71
|
+
creatable_by: [],
|
|
72
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
73
|
+
|
|
74
|
+
field :co_ph_sec,
|
|
75
|
+
type: :string,
|
|
76
|
+
sortable: false,
|
|
77
|
+
filterable: false,
|
|
78
|
+
creatable_by: [],
|
|
79
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
80
|
+
|
|
81
|
+
field :co_ph_sales,
|
|
82
|
+
type: :string,
|
|
83
|
+
sortable: false,
|
|
84
|
+
filterable: false,
|
|
85
|
+
creatable_by: [],
|
|
86
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
87
|
+
|
|
88
|
+
field :co_ph_service,
|
|
89
|
+
type: :string,
|
|
90
|
+
sortable: false,
|
|
91
|
+
filterable: false,
|
|
92
|
+
creatable_by: [],
|
|
93
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
94
|
+
|
|
95
|
+
field :co_ph_billing,
|
|
96
|
+
type: :string,
|
|
97
|
+
sortable: false,
|
|
98
|
+
filterable: false,
|
|
99
|
+
creatable_by: [],
|
|
100
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
101
|
+
|
|
102
|
+
field :cell_text,
|
|
103
|
+
type: :string,
|
|
104
|
+
sortable: false,
|
|
105
|
+
filterable: false,
|
|
106
|
+
creatable_by: [],
|
|
107
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
108
|
+
|
|
109
|
+
field :company_name,
|
|
110
|
+
type: :string,
|
|
111
|
+
sortable: false,
|
|
112
|
+
filterable: false,
|
|
113
|
+
creatable_by: [],
|
|
114
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module Alula
|
|
2
|
+
# The Generic Preferences for a User
|
|
3
|
+
class UserPreferences < Alula::RestResource
|
|
4
|
+
extend Alula::ResourceAttributes
|
|
5
|
+
extend Alula::RelationshipAttributes
|
|
6
|
+
extend Alula::ApiOperations::Request
|
|
7
|
+
extend Alula::ApiOperations::List
|
|
8
|
+
|
|
9
|
+
resource_path 'users/preferences'
|
|
10
|
+
type 'users-preferences'
|
|
11
|
+
|
|
12
|
+
# Resource Fields
|
|
13
|
+
# Not all params are used at the moment. See Alula::ResourceAttributes for details
|
|
14
|
+
# on how params are parsed,
|
|
15
|
+
field :id,
|
|
16
|
+
type: :string,
|
|
17
|
+
sortable: false,
|
|
18
|
+
filterable: false,
|
|
19
|
+
creatable_by: [],
|
|
20
|
+
patchable_by: []
|
|
21
|
+
|
|
22
|
+
field :user_id,
|
|
23
|
+
type: :string,
|
|
24
|
+
sortable: true,
|
|
25
|
+
filterable: true,
|
|
26
|
+
creatable_by: [],
|
|
27
|
+
patchable_by: []
|
|
28
|
+
|
|
29
|
+
field :key,
|
|
30
|
+
type: :string,
|
|
31
|
+
sortable: false,
|
|
32
|
+
filterable: false,
|
|
33
|
+
creatable_by: [],
|
|
34
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
35
|
+
|
|
36
|
+
field :value,
|
|
37
|
+
type: :string,
|
|
38
|
+
sortable: false,
|
|
39
|
+
filterable: false,
|
|
40
|
+
creatable_by: [],
|
|
41
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
42
|
+
|
|
43
|
+
field :data,
|
|
44
|
+
type: :string,
|
|
45
|
+
sortable: false,
|
|
46
|
+
filterable: false,
|
|
47
|
+
creatable_by: [],
|
|
48
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
49
|
+
|
|
50
|
+
field :inherited,
|
|
51
|
+
type: :string,
|
|
52
|
+
sortable: false,
|
|
53
|
+
filterable: false,
|
|
54
|
+
creatable_by: [],
|
|
55
|
+
patchable_by: [:system, :station, :dealer, :technician, :user, :subuser]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# The Push Tokens for a User
|
|
2
|
+
module Alula
|
|
3
|
+
# The Push Tokens for a User
|
|
4
|
+
class UserPushtoken < Alula::RestResource
|
|
5
|
+
extend Alula::ResourceAttributes
|
|
6
|
+
extend Alula::RelationshipAttributes
|
|
7
|
+
extend Alula::ApiOperations::Request
|
|
8
|
+
extend Alula::ApiOperations::List
|
|
9
|
+
|
|
10
|
+
resource_path 'users/pushtokens'
|
|
11
|
+
type 'users-pushtokens'
|
|
12
|
+
|
|
13
|
+
# Relationships
|
|
14
|
+
relationship :user, type: :users, cardinality: 'To-one'
|
|
15
|
+
|
|
16
|
+
# Resource Fields
|
|
17
|
+
# Not all params are used at the moment. See Alula::ResourceAttributes for details
|
|
18
|
+
# on how params are parsed,
|
|
19
|
+
field :id,
|
|
20
|
+
type: :string,
|
|
21
|
+
sortable: false,
|
|
22
|
+
filterable: false,
|
|
23
|
+
creatable_by: %i[system user subuser],
|
|
24
|
+
patchable_by: []
|
|
25
|
+
|
|
26
|
+
field :user_id,
|
|
27
|
+
type: :string,
|
|
28
|
+
sortable: false,
|
|
29
|
+
filterable: true,
|
|
30
|
+
creatable_by: %i[system user subuser],
|
|
31
|
+
patchable_by: []
|
|
32
|
+
|
|
33
|
+
field :key,
|
|
34
|
+
type: :string,
|
|
35
|
+
sortable: false,
|
|
36
|
+
filterable: true,
|
|
37
|
+
creatable_by: %i[system user subuser],
|
|
38
|
+
patchable_by: %i[system user subuser]
|
|
39
|
+
|
|
40
|
+
field :type,
|
|
41
|
+
type: :string,
|
|
42
|
+
sortable: true,
|
|
43
|
+
filterable: true,
|
|
44
|
+
creatable_by: %i[system user subuser],
|
|
45
|
+
patchable_by: %i[system user subuser]
|
|
46
|
+
|
|
47
|
+
field :version,
|
|
48
|
+
type: :string,
|
|
49
|
+
sortable: true,
|
|
50
|
+
filterable: true,
|
|
51
|
+
creatable_by: %i[system user subuser],
|
|
52
|
+
patchable_by: %i[system user subuser]
|
|
53
|
+
|
|
54
|
+
field :video,
|
|
55
|
+
type: :string,
|
|
56
|
+
sortable: false,
|
|
57
|
+
filterable: false,
|
|
58
|
+
creatable_by: %i[system user subuser],
|
|
59
|
+
patchable_by: %i[system user subuser]
|
|
60
|
+
|
|
61
|
+
field :doorbell,
|
|
62
|
+
type: :string,
|
|
63
|
+
sortable: false,
|
|
64
|
+
filterable: false,
|
|
65
|
+
creatable_by: %i[system user subuser],
|
|
66
|
+
patchable_by: %i[system user subuser]
|
|
67
|
+
|
|
68
|
+
field :security,
|
|
69
|
+
type: :string,
|
|
70
|
+
sortable: false,
|
|
71
|
+
filterable: false,
|
|
72
|
+
creatable_by: %i[system user subuser],
|
|
73
|
+
patchable_by: %i[system user subuser]
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Alula
|
|
2
|
+
class UserVideoProfile < 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 'users/videoprofiles'
|
|
10
|
+
type 'users-videoprofiles'
|
|
11
|
+
|
|
12
|
+
relationship :user, type: :users, cardinality: 'To-one'
|
|
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 :camera_plan_count,
|
|
25
|
+
type: :number,
|
|
26
|
+
sortable: true,
|
|
27
|
+
filterable: false,
|
|
28
|
+
creatable_by: [:system, :station, :dealer, :technician],
|
|
29
|
+
patchable_by: [:system, :station, :dealer, :technician]
|
|
30
|
+
|
|
31
|
+
field :clip_plan_count,
|
|
32
|
+
type: :number,
|
|
33
|
+
sortable: false,
|
|
34
|
+
filterable: false,
|
|
35
|
+
creatable_by: [:system, :station, :dealer, :technician],
|
|
36
|
+
patchable_by: [:system, :station, :dealer, :technician]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Alula
|
|
2
|
+
class RestResource < ApiResource
|
|
3
|
+
# TODO: Not sure if the period replace is applicatble to our use
|
|
4
|
+
# determine as we add child resources
|
|
5
|
+
def self.resource_url(id = nil)
|
|
6
|
+
if self == RestResource
|
|
7
|
+
raise NotImplementedError, "Cannot call resource_url on a RestResource. Try using Device or Customer instead."
|
|
8
|
+
end
|
|
9
|
+
"/rest/v1/#{self.get_resource_path(id)}"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def resource_url(param_id = nil)
|
|
13
|
+
our_id = [id, param_id].compact.first
|
|
14
|
+
self.class.resource_url(our_id)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Alula
|
|
2
|
+
class RpcResource
|
|
3
|
+
def self.request(http_method:, path:, payload:, handler:, wrap: true, opts: {})
|
|
4
|
+
response = Alula::Client.request(http_method, path, wrap ? wrap_payload(payload) : payload, opts)
|
|
5
|
+
|
|
6
|
+
unless response.ok? && ok?(response)
|
|
7
|
+
error = Alula::AlulaError.for_response(response)
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# Some error classifications are critical and should be raised for visibility
|
|
11
|
+
# These errors do not contain meaningful data that an end-user can use to correct
|
|
12
|
+
# the error.
|
|
13
|
+
raise error if [Alula::RateLimitError, Alula::BadRequestError, Alula::ForbiddenError,
|
|
14
|
+
Alula::UnknownError, Alula::InsufficientScopeError].include?(error.class)
|
|
15
|
+
|
|
16
|
+
return error
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
handler.new(response)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
##
|
|
23
|
+
# RPC endpoints tend to return a 200 OK even if the response failed. Examine
|
|
24
|
+
# the response body to determine if there was an error.
|
|
25
|
+
def self.ok?(response)
|
|
26
|
+
error = response.data['error'] && !response.data['error'].empty?
|
|
27
|
+
errors = response.data['errors'] && !response.data['errors'].empty?
|
|
28
|
+
|
|
29
|
+
!(error || errors)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.wrap_payload(payload)
|
|
33
|
+
{
|
|
34
|
+
id: SecureRandom.uuid,
|
|
35
|
+
jsonrpc: '2.0',
|
|
36
|
+
params: payload
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|