uiza_minh_phong 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +535 -0
  3. data/.rubocop_disable.yml +78 -0
  4. data/.rubocop_enable.yml +786 -0
  5. data/CHANGELOG.md +50 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/CONTRIBUTORS.txt +3 -0
  8. data/Gemfile +7 -0
  9. data/Gemfile.lock +73 -0
  10. data/History.txt +1 -0
  11. data/LICENSE.txt +21 -0
  12. data/PULL_REQUEST_TEMPLATE.md +44 -0
  13. data/README.md +248 -0
  14. data/Rakefile +6 -0
  15. data/bin/console +14 -0
  16. data/bin/setup +8 -0
  17. data/doc/ANALYTIC.md +143 -0
  18. data/doc/CALLBACK.md +161 -0
  19. data/doc/CATEGORY.md +312 -0
  20. data/doc/EMBED_METADATA.md +4 -0
  21. data/doc/ENTITY.md +470 -0
  22. data/doc/ERRORS_CODE.md +60 -0
  23. data/doc/LIVE_STREAMING.md +452 -0
  24. data/doc/STORAGE.md +188 -0
  25. data/doc/USER.md +286 -0
  26. data/lib/uiza.rb +39 -0
  27. data/lib/uiza/analytic.rb +42 -0
  28. data/lib/uiza/api_operation/add.rb +16 -0
  29. data/lib/uiza/api_operation/create.rb +16 -0
  30. data/lib/uiza/api_operation/delete.rb +15 -0
  31. data/lib/uiza/api_operation/list.rb +14 -0
  32. data/lib/uiza/api_operation/remove.rb +15 -0
  33. data/lib/uiza/api_operation/retrieve.rb +15 -0
  34. data/lib/uiza/api_operation/update.rb +16 -0
  35. data/lib/uiza/callback.rb +16 -0
  36. data/lib/uiza/category.rb +42 -0
  37. data/lib/uiza/entity.rb +68 -0
  38. data/lib/uiza/error/bad_request_error.rb +8 -0
  39. data/lib/uiza/error/client_error.rb +8 -0
  40. data/lib/uiza/error/internal_server_error.rb +8 -0
  41. data/lib/uiza/error/not_found_error.rb +8 -0
  42. data/lib/uiza/error/server_error.rb +8 -0
  43. data/lib/uiza/error/service_unavailable_error.rb +8 -0
  44. data/lib/uiza/error/uiza_error.rb +18 -0
  45. data/lib/uiza/error/unauthorized_error.rb +8 -0
  46. data/lib/uiza/error/unprocessable_error.rb +8 -0
  47. data/lib/uiza/live.rb +86 -0
  48. data/lib/uiza/storage.rb +17 -0
  49. data/lib/uiza/uiza_client.rb +86 -0
  50. data/lib/uiza/uiza_open_struct.rb +18 -0
  51. data/lib/uiza/user.rb +41 -0
  52. data/lib/uiza/version.rb +3 -0
  53. data/uiza.gemspec +36 -0
  54. metadata +141 -0
data/doc/STORAGE.md ADDED
@@ -0,0 +1,188 @@
1
+ ## Storage
2
+ You can add your storage (FTP, AWS S3) with UIZA.
3
+ After synced, you can select your content easier from your storage to [create entity](https://docs.uiza.io/#create-entity).
4
+
5
+ See details [here](https://docs.uiza.io/#storage).
6
+
7
+ ## Add a storage
8
+ You can sync your storage (FTP, AWS S3) with UIZA.
9
+ After synced, you can select your content easier from your storage to [create entity](https://docs.uiza.io/#create-entity).
10
+
11
+ See details [here](https://docs.uiza.io/#add-a-storage).
12
+
13
+ ```ruby
14
+ require "uiza"
15
+
16
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
17
+ Uiza.authorization = "your-authorization"
18
+
19
+ params = {
20
+ name: "FTP Uiza",
21
+ description: "FTP of Uiza, use for transcode",
22
+ storageType: "ftp",
23
+ host: "ftp-example.uiza.io"
24
+ }
25
+
26
+ begin
27
+ storage = Uiza::Storage.add params
28
+ puts storage.id
29
+ puts storage.name
30
+ rescue Uiza::Error::UizaError => e
31
+ puts "description_link: #{e.description_link}"
32
+ puts "code: #{e.code}"
33
+ puts "message: #{e.message}"
34
+ rescue StandardError => e
35
+ puts "message: #{e.message}"
36
+ end
37
+ ```
38
+
39
+ Example Response
40
+ ```ruby
41
+ {
42
+ "id": "cd003123-7ec9-4f3a-9d7c-f2de93e83e49",
43
+ "name": "FTP Uiza",
44
+ "description": "FTP of Uiza, use for transcode",
45
+ "storageType": "ftp",
46
+ "usageType": "input",
47
+ "bucket": null,
48
+ "prefix": null,
49
+ "host": "ftp-exemple.uiza.io",
50
+ "awsAccessKey": null,
51
+ "awsSecretKey": null,
52
+ "username": "uiza",
53
+ "password": "=5;9x@LPsd+w7qW",
54
+ "region": null,
55
+ "port": 21,
56
+ "createdAt": "2018-06-19T03:01:56.000Z",
57
+ "updatedAt": "2018-06-19T03:01:56.000Z"
58
+ }
59
+ ```
60
+
61
+ ## Retrieve a storage
62
+ Get information of your added storage (`FTP` or `AWS S3`).
63
+
64
+ See details [here](https://docs.uiza.io/#retrieve-a-storage).
65
+
66
+ ```ruby
67
+
68
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
69
+ Uiza.authorization = "your-authorization"
70
+
71
+ begin
72
+ storage = Uiza::Storage.retrieve "your-storage-id"
73
+ puts storage.id
74
+ puts storage.name
75
+ rescue Uiza::Error::UizaError => e
76
+ puts "description_link: #{e.description_link}"
77
+ puts "code: #{e.code}"
78
+ puts "message: #{e.message}"
79
+ rescue StandardError => e
80
+ puts "message: #{e.message}"
81
+ end
82
+ ```
83
+
84
+ Example Response
85
+ ```ruby
86
+ {
87
+ "id": "cd003123-7ec9-4f3a-9d7c-f2de93e83e49",
88
+ "name": "FTP Uiza",
89
+ "description": "FTP of Uiza, use for transcode",
90
+ "storageType": "ftp",
91
+ "usageType": "input",
92
+ "bucket": null,
93
+ "prefix": null,
94
+ "host": "ftp-exemple.uiza.io",
95
+ "awsAccessKey": null,
96
+ "awsSecretKey": null,
97
+ "username": "uiza",
98
+ "password": "=5;9x@LPsd+w7qW",
99
+ "region": null,
100
+ "port": 21,
101
+ "createdAt": "2018-06-19T03:01:56.000Z",
102
+ "updatedAt": "2018-06-19T03:01:56.000Z"
103
+ }
104
+ ```
105
+
106
+ ## Update storage
107
+ Update storage's information.
108
+
109
+ See details [here](https://docs.uiza.io/#update-storage).
110
+
111
+ ```ruby
112
+ require "uiza"
113
+
114
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
115
+ Uiza.authorization = "your-authorization"
116
+
117
+ params = {
118
+ id: "your-storage-id",
119
+ name: "FTP Uiza edited",
120
+ host: "ftp-example.uiza.io",
121
+ port: 21,
122
+ storageType: "ftp"
123
+ }
124
+
125
+ begin
126
+ storage = Uiza::Storage.update params
127
+ puts storage.id
128
+ puts storage.name
129
+ rescue Uiza::Error::UizaError => e
130
+ puts "description_link: #{e.description_link}"
131
+ puts "code: #{e.code}"
132
+ puts "message: #{e.message}"
133
+ rescue StandardError => e
134
+ puts "message: #{e.message}"
135
+ end
136
+ ```
137
+
138
+ Example Response
139
+ ```ruby
140
+ {
141
+ "id": "cd003123-7ec9-4f3a-9d7c-f2de93e83e49",
142
+ "name": "FTP Uiza edited",
143
+ "description": "FTP of Uiza, use for transcode",
144
+ "storageType": "ftp",
145
+ "usageType": "input",
146
+ "bucket": null,
147
+ "prefix": null,
148
+ "host": "ftp-exemple.uiza.io",
149
+ "awsAccessKey": null,
150
+ "awsSecretKey": null,
151
+ "username": "uiza",
152
+ "password": "=5;9x@LPsd+w7qW",
153
+ "region": null,
154
+ "port": 21,
155
+ "createdAt": "2018-06-19T03:01:56.000Z",
156
+ "updatedAt": "2018-06-19T03:01:56.000Z"
157
+ }
158
+ ```
159
+
160
+ ## Remove storage
161
+ Remove storage that added to Uiza.
162
+
163
+ See details [here](https://docs.uiza.io/#remove-storage).
164
+
165
+ ```ruby
166
+ require "uiza"
167
+
168
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
169
+ Uiza.authorization = "your-authorization"
170
+
171
+ begin
172
+ storage = Uiza::Storage.remove "your-storage-id"
173
+ puts storage.id
174
+ rescue Uiza::Error::UizaError => e
175
+ puts "description_link: #{e.description_link}"
176
+ puts "code: #{e.code}"
177
+ puts "message: #{e.message}"
178
+ rescue StandardError => e
179
+ puts "message: #{e.message}"
180
+ end
181
+ ```
182
+
183
+ Example Response
184
+ ```ruby
185
+ {
186
+ "id": "cd003123-7ec9-4f3a-9d7c-f2de93e83e49"
187
+ }
188
+ ```
data/doc/USER.md ADDED
@@ -0,0 +1,286 @@
1
+ ## User Management
2
+ You can manage user with APIs user. Uiza have 2 levels of user:
3
+ Admin - This account will have the highest priority, can have permission to create & manage users.
4
+ User - This account level is under Admin level. It only manages APIs that relates to this account.
5
+
6
+ See details [here](https://docs.uiza.io/#user-management).
7
+
8
+ ## Create an user
9
+ Create an user account for workspace
10
+
11
+ See details [here](https://docs.uiza.io/#create-an-user).
12
+
13
+ ```ruby
14
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
15
+ Uiza.authorization = "your-authorization"
16
+
17
+ params = {
18
+ status: 1,
19
+ username: "user_test",
20
+ email: "user_test@uiza.io",
21
+ password: "FMpsr<4[dGPu?B#u",
22
+ gender: 0,
23
+ dob: "05/15/2018",
24
+ avatar: "https://exemple.com/avatar.jpeg",
25
+ fullname: "User Test",
26
+ isAdmin: 0
27
+ }
28
+
29
+ begin
30
+ user = Uiza::User.create params
31
+ puts user.id
32
+ puts user.username
33
+ rescue Uiza::Error::UizaError => e
34
+ puts "description_link: #{e.description_link}"
35
+ puts "code: #{e.code}"
36
+ puts "message: #{e.message}"
37
+ rescue StandardError => e
38
+ puts "message: #{e.message}"
39
+ end
40
+ ```
41
+
42
+ Example Response
43
+ ```ruby
44
+ {
45
+ "id": "37d6706e-be91-463e-b3b3-b69451dd4752",
46
+ "isAdmin": 0,
47
+ "username": "user_test",
48
+ "email": "user_test@uiza.io",
49
+ "avatar": "https://exemple.com/avatar.jpeg",
50
+ "fullname": "User Test",
51
+ "updatedAt": "2018-06-22T18:05:47.000Z",
52
+ "createdAt": "2018-06-22T18:05:47.000Z"
53
+ }
54
+ ```
55
+
56
+ ## Retrieve an user
57
+ Retrieves the details of an existing user.
58
+ You need only supply the unique userId that was returned upon user creation.
59
+
60
+ See details [here](https://docs.uiza.io/#retrieve-an-user).
61
+
62
+ ```ruby
63
+
64
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
65
+ Uiza.authorization = "your-authorization"
66
+
67
+ begin
68
+ user = Uiza::User.retrieve "your-user-id"
69
+ puts user.id
70
+ puts user.username
71
+ rescue Uiza::Error::UizaError => e
72
+ puts "description_link: #{e.description_link}"
73
+ puts "code: #{e.code}"
74
+ puts "message: #{e.message}"
75
+ rescue StandardError => e
76
+ puts "message: #{e.message}"
77
+ end
78
+ ```
79
+
80
+ Example Response
81
+ ```ruby
82
+ {
83
+ "id": "37d6706e-be91-463e-b3b3-b69451dd4752",
84
+ "isAdmin": 0,
85
+ "username": "user_test",
86
+ "email": "user_test@uiza.io",
87
+ "avatar": "https://exemple.com/avatar.jpeg",
88
+ "fullname": "User Test",
89
+ "updatedAt": "2018-06-22T18:05:47.000Z",
90
+ "createdAt": "2018-06-22T18:05:47.000Z"
91
+ }
92
+ ```
93
+
94
+ ## List all users
95
+ Returns a list of your user. The users are returned sorted by creation date, with the most recent user appearing first.
96
+ If you use Admin token, you will get all the user.
97
+ If you use User token, you can only get the information of that user
98
+
99
+ See details [here](https://docs.uiza.io/#list-all-users).
100
+
101
+ ```ruby
102
+ require "uiza"
103
+
104
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
105
+ Uiza.authorization = "your-authorization"
106
+
107
+ begin
108
+ users = Uiza::User.list
109
+ # or users = Uiza::User.list limit: 2, page: 2
110
+ puts users.first.id
111
+ puts users.first.username
112
+ rescue Uiza::Error::UizaError => e
113
+ puts "description_link: #{e.description_link}"
114
+ puts "code: #{e.code}"
115
+ puts "message: #{e.message}"
116
+ rescue StandardError => e
117
+ puts "message: #{e.message}"
118
+ end
119
+ ```
120
+
121
+ Example Response
122
+ ```ruby
123
+ {
124
+ "id": "1a95f752-19e0-4a2e-9951-6d1fc0adbeaf",
125
+ "isAdmin": 0,
126
+ "username": "user_test",
127
+ "email": "user_test@uiza.io",
128
+ "updatedAt": "2018-06-22T02:31:14.000Z",
129
+ "createdAt": "2018-06-22T02:31:14.000Z"
130
+ },
131
+ {
132
+ "id": "95c1229a-73e6-4ef7-98eb-e64a765c32d5",
133
+ "isAdmin": 1,
134
+ "username": "user_admin",
135
+ "email": "user_admin@uiza.io",
136
+ "updatedAt": "2018-06-22T00:00:00.000Z",
137
+ "createdAt": "2018-06-22T02:32:29.000Z"
138
+ }
139
+ ```
140
+
141
+ ## Update an user
142
+ Updates the specified user by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
143
+
144
+ See details [here](https://docs.uiza.io/#update-an-user).
145
+
146
+ ```ruby
147
+ require "uiza"
148
+
149
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
150
+ Uiza.authorization = "your-authorization"
151
+
152
+ params = {
153
+ id: "37d6706e-be91-463e-b3b3-b69451dd4752"
154
+ status: 1,
155
+ username: "user_test",
156
+ email: "user_test@uiza.io",
157
+ password: "FMpsr<4[dGPu?B#u",
158
+ gender: 0,
159
+ dob: "05/15/2018",
160
+ avatar: "https://exemple.com/avatar.jpeg",
161
+ fullname: "User Test",
162
+ isAdmin: 0
163
+ }
164
+
165
+ begin
166
+ user = Uiza::User.update params
167
+ puts user.id
168
+ puts user.username
169
+ rescue Uiza::Error::UizaError => e
170
+ puts "description_link: #{e.description_link}"
171
+ puts "code: #{e.code}"
172
+ puts "message: #{e.message}"
173
+ rescue StandardError => e
174
+ puts "message: #{e.message}"
175
+ end
176
+ ```
177
+
178
+ Example Response
179
+ ```ruby
180
+ {
181
+ "id": "37d6706e-be91-463e-b3b3-b69451dd4752",
182
+ "isAdmin": 0,
183
+ "username": "user_test",
184
+ "email": "user_test@uiza.io",
185
+ "avatar": "https://exemple.com/avatar.jpeg",
186
+ "fullname": "User Test",
187
+ "updatedAt": "2018-06-22T18:05:47.000Z",
188
+ "createdAt": "2018-06-22T18:05:47.000Z"
189
+ }
190
+ ```
191
+
192
+ ## Delete an user
193
+ Permanently deletes an user. It cannot be undone. Also immediately cancels all token & information of this user.
194
+
195
+ See details [here](https://docs.uiza.io/#delete-an-user).
196
+
197
+ ```ruby
198
+ require "uiza"
199
+
200
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
201
+ Uiza.authorization = "your-authorization"
202
+
203
+ begin
204
+ user = Uiza::User.delete "your-user-id"
205
+ puts user.id
206
+ rescue Uiza::Error::UizaError => e
207
+ puts "description_link: #{e.description_link}"
208
+ puts "code: #{e.code}"
209
+ puts "message: #{e.message}"
210
+ rescue StandardError => e
211
+ puts "message: #{e.message}"
212
+ end
213
+ ```
214
+
215
+ Example Response
216
+ ```
217
+ {
218
+ "id": "2c98b4d5-7d7f-4a0f-9258-5689f90fd28c"
219
+ }
220
+ ```
221
+
222
+ ## Update password
223
+ Update password allows Admin or User update their current password.
224
+
225
+ See details [here](https://docs.uiza.io/#update-password).
226
+
227
+ ```ruby
228
+ require "uiza"
229
+
230
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
231
+ Uiza.authorization = "your-authorization"
232
+
233
+ params = {
234
+ id: "your-user-id",
235
+ oldPassword: "FMpsr<4[dGPu?B#u",
236
+ newPassword: "S57Eb{:aMZhW=)G$"
237
+ }
238
+
239
+ begin
240
+ response = Uiza::User.change_password params
241
+ puts response.result
242
+ rescue Uiza::Error::UizaError => e
243
+ puts "description_link: #{e.description_link}"
244
+ puts "code: #{e.code}"
245
+ puts "message: #{e.message}"
246
+ rescue StandardError => e
247
+ puts "message: #{e.message}"
248
+ end
249
+ ```
250
+
251
+ Example Response
252
+ ```ruby
253
+ {
254
+ "result": "ok"
255
+ }
256
+ ```
257
+
258
+ ## Log Out
259
+ This API use to log out an user. After logged out, token will be removed.
260
+
261
+ See details [here](https://docs.uiza.io/#log-out).
262
+
263
+ ```ruby
264
+ require "uiza"
265
+
266
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
267
+ Uiza.authorization = "your-authorization"
268
+
269
+ begin
270
+ response = Uiza::User.logout
271
+ puts response.message
272
+ rescue Uiza::Error::UizaError => e
273
+ puts "description_link: #{e.description_link}"
274
+ puts "code: #{e.code}"
275
+ puts "message: #{e.message}"
276
+ rescue StandardError => e
277
+ puts "message: #{e.message}"
278
+ end
279
+ ```
280
+
281
+ Example Response
282
+ ```ruby
283
+ {
284
+ "message": "Logout success"
285
+ }
286
+ ```