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
@@ -0,0 +1,60 @@
1
+ ## Errors Code
2
+ Uiza uses conventional HTTP response codes to indicate the success or failure of an API request.
3
+ In general: Codes in the `2xx` range indicate success.
4
+ Codes in the `4xx` range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.).
5
+ Codes in the `5xx` range indicate an error with Uiza's servers.
6
+
7
+ See details [here](https://docs.uiza.io/#errors-code).
8
+
9
+ ## HTTP status code summary
10
+ | Error Code | Detail |
11
+ | ---------------------------:|:--------------------------------------------------------------------------|
12
+ | 200 - OK | Everything worked as expected. |
13
+ | 400 - Bad Request | The request was unacceptable, often due to missing a required parameter. |
14
+ | 401 - Unauthorized | No valid API key provided. |
15
+ | 404 - Not Found | The requested resource doesn't exist. |
16
+ | 422 - Unprocessable | The syntax of the request is correct (often cause of wrong parameter). |
17
+ | 500 - Internal Server Error | We had a problem with our server. Try again later. |
18
+ | 503 - Service Unavailable | The server is overloaded or down for maintenance. |
19
+
20
+ ## Error types
21
+ | Error Type | Detail |
22
+ | -------------------------------:|:--------------------------------------------------------------------------|
23
+ | 400 - BadRequestError | The request was unacceptable, often due to missing a required parameter. |
24
+ | 401 - UnauthorizedError | No valid API key provided. |
25
+ | 404 - NotFoundError | The requested resource doesn't exist. |
26
+ | 422 - UnprocessableError | The syntax of the request is correct (often cause of wrong parameter). |
27
+ | 500 - InternalServerErrorError | We had a problem with our server. Try again later. |
28
+ | 503 - ServiceUnavailableError | The server is overloaded or down for maintenance. |
29
+ | 4xx - ClientError | The error seems to have been caused by the client. |
30
+ | 5xx - ServerError | The server is aware that it has encountered an error. |
31
+
32
+ ## Example Request
33
+ ```ruby
34
+ begin
35
+ # use Uiza's library to make requests ...
36
+ rescue Uiza::Error::BadRequestError => e
37
+ # BadRequestError
38
+ puts "#description_link: {e.description_link}"
39
+ puts "message: #{e.message}"
40
+ puts "code: #{e.code}"
41
+ rescue Uiza::Error::UnauthorizedError => e
42
+ # UnauthorizedError
43
+ rescue Uiza::Error::NotFoundError => e
44
+ # NotFoundError
45
+ rescue Uiza::Error::UnprocessableError => e
46
+ # UnprocessableError
47
+ rescue Uiza::Error::InternalServerErrorError => e
48
+ # InternalServerErrorError
49
+ rescue Uiza::Error::ServiceUnavailableError => e
50
+ # ServiceUnavailableError
51
+ rescue Uiza::Error::ClientError => e
52
+ # ClientError
53
+ rescue Uiza::Error::ServerError => e
54
+ # ServerError
55
+ rescue Uiza::Error::UizaError => e
56
+ # UizaError
57
+ rescue => e
58
+ # Something else happened, completely unrelated to Uiza
59
+ end
60
+ ```
@@ -0,0 +1,452 @@
1
+ ## Live Streaming
2
+ These APIs used to create and manage live streaming event.
3
+ * When a Live is not start : it's named as `Event`.
4
+ * When have an Event , you can start it : it's named as `Feed`.
5
+
6
+ See details [here](https://docs.uiza.io/#live-streaming).
7
+
8
+ ## Create a live event
9
+ These APIs use to create a live streaming and manage the live streaming input (output).
10
+ A live stream can be set up and start later or start right after set up.
11
+ Live Channel Minutes counts when the event starts.
12
+
13
+ See details [here](https://docs.uiza.io/#create-a-live-event).
14
+
15
+ ```ruby
16
+ require "uiza"
17
+
18
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
19
+ Uiza.authorization = "your-authorization"
20
+
21
+ params = {
22
+ name: "test event",
23
+ mode: "push",
24
+ encode: 1,
25
+ dvr: 1,
26
+ description: "This is for test event",
27
+ poster: "https://example.com/poster.jpeg",
28
+ thumbnail: "https://example.com/poster.jpeg",
29
+ linkStream: [
30
+ "https://playlist.m3u8"
31
+ ],
32
+ resourceMode: "single"
33
+ }
34
+
35
+ begin
36
+ live = Uiza::Live.create params
37
+ puts live.id
38
+ puts live.name
39
+ rescue Uiza::Error::UizaError => e
40
+ puts "description_link: #{e.description_link}"
41
+ puts "code: #{e.code}"
42
+ puts "message: #{e.message}"
43
+ rescue StandardError => e
44
+ puts "message: #{e.message}"
45
+ end
46
+ ```
47
+
48
+ Example Response
49
+ ```ruby
50
+ {
51
+ "id": "8b83886e-9cc3-4eab-9258-ebb16c0c73de",
52
+ "name": "checking 01",
53
+ "description": "checking",
54
+ "mode": "pull",
55
+ "resourceMode": "single",
56
+ "encode": 0,
57
+ "channelName": "checking-01",
58
+ "lastPresetId": null,
59
+ "lastFeedId": null,
60
+ "poster": "https://example.com/poster.jpeg",
61
+ "thumbnail": "https://example.com/thumbnail.jpeg",
62
+ "linkPublishSocial": null,
63
+ "linkStream": "[\"https://www.youtube.com/watch?v=pQzaHPoNX1I\"]",
64
+ "lastPullInfo": null,
65
+ "lastPushInfo": null,
66
+ "lastProcess": null,
67
+ "eventType": null,
68
+ "createdAt": "2018-06-21T14:33:36.000Z",
69
+ "updatedAt": "2018-06-21T14:33:36.000Z"
70
+ }
71
+ ```
72
+
73
+ ## Retrieve a live event
74
+ Retrieves the details of an existing event.
75
+ You need only provide the unique identifier of event that was returned upon Live event creation.
76
+
77
+ See details [here](https://docs.uiza.io/#retrieve-a-live-event).
78
+
79
+ ```ruby
80
+ require "uiza"
81
+
82
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
83
+ Uiza.authorization = "your-authorization"
84
+
85
+ begin
86
+ live = Uiza::Live.retrieve "your-live-id"
87
+ puts live.id
88
+ puts live.name
89
+ rescue Uiza::Error::UizaError => e
90
+ puts "description_link: #{e.description_link}"
91
+ puts "code: #{e.code}"
92
+ puts "message: #{e.message}"
93
+ rescue StandardError => e
94
+ puts "message: #{e.message}"
95
+ end
96
+ ```
97
+
98
+ Example Response
99
+ ```ruby
100
+ {
101
+ "id": "8b83886e-9cc3-4eab-9258-ebb16c0c73de",
102
+ "name": "checking 01",
103
+ "description": "checking",
104
+ "mode": "pull",
105
+ "resourceMode": "single",
106
+ "encode": 0,
107
+ "channelName": "checking-01",
108
+ "lastPresetId": null,
109
+ "lastFeedId": null,
110
+ "poster": "https://example.com/poster.jpeg",
111
+ "thumbnail": "https://example.com/thumbnail.jpeg",
112
+ "linkPublishSocial": null,
113
+ "linkStream": "[\"https://www.youtube.com/watch?v=pQzaHPoNX1I\"]",
114
+ "lastPullInfo": null,
115
+ "lastPushInfo": null,
116
+ "lastProcess": null,
117
+ "eventType": null,
118
+ "createdAt": "2018-06-21T14:33:36.000Z",
119
+ "updatedAt": "2018-06-21T14:33:36.000Z"
120
+ }
121
+ ```
122
+
123
+ ## Update a live event
124
+ Update the specific Live event by edit values of parameters.
125
+
126
+ See details [here](https://docs.uiza.io/#update-a-live-event).
127
+
128
+ ```ruby
129
+ require "uiza"
130
+
131
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
132
+ Uiza.authorization = "your-authorization"
133
+
134
+ params = {
135
+ id: "your-live-id",
136
+ name: "live test",
137
+ mode: "pull",
138
+ encode: 0,
139
+ dvr: 1
140
+ resourceMode: "single"
141
+ }
142
+
143
+ begin
144
+ live = Uiza::Live.update params
145
+ puts live.id
146
+ puts live.name
147
+ rescue Uiza::Error::UizaError => e
148
+ puts "description_link: #{e.description_link}"
149
+ puts "code: #{e.code}"
150
+ puts "message: #{e.message}"
151
+ rescue StandardError => e
152
+ puts "message: #{e.message}"
153
+ end
154
+ ```
155
+
156
+ Example Response
157
+ ```ruby
158
+ {
159
+ "id": "8b83886e-9cc3-4eab-9258-ebb16c0c73de",
160
+ "name": "checking 01",
161
+ "description": "checking",
162
+ "mode": "pull",
163
+ "resourceMode": "single",
164
+ "encode": 0,
165
+ "channelName": "checking-01",
166
+ "lastPresetId": null,
167
+ "lastFeedId": null,
168
+ "poster": "https://example.com/poster.jpeg",
169
+ "thumbnail": "https://example.com/thumbnail.jpeg",
170
+ "linkPublishSocial": null,
171
+ "linkStream": "[\"https://www.youtube.com/watch?v=pQzaHPoNX1I\"]",
172
+ "lastPullInfo": null,
173
+ "lastPushInfo": null,
174
+ "lastProcess": null,
175
+ "eventType": null,
176
+ "createdAt": "2018-06-21T14:33:36.000Z",
177
+ "updatedAt": "2018-06-21T14:33:36.000Z"
178
+ }
179
+ ```
180
+
181
+ ## Start a live feed
182
+ These API use to start a live event that has been create success.
183
+ The Live channel minute start count whenever the event start success
184
+
185
+ See details [here](https://docs.uiza.io/#start-a-live-feed).
186
+
187
+ ```ruby
188
+ require "uiza"
189
+
190
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
191
+ Uiza.authorization = "your-authorization"
192
+
193
+ params = {
194
+ id: "your-live-id",
195
+ name: "live test",
196
+ mode: "pull",
197
+ encode: 0,
198
+ dvr: 1
199
+ resourceMode: "single"
200
+ }
201
+
202
+ begin
203
+ live = Uiza::Live.start_feed "your-live-id"
204
+ puts live.id
205
+ puts live.name
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
+ ```ruby
217
+ {
218
+ "id": "8b83886e-9cc3-4eab-9258-ebb16c0c73de",
219
+ "name": "checking 01",
220
+ "description": "checking",
221
+ "mode": "pull",
222
+ "resourceMode": "single",
223
+ "encode": 0,
224
+ "channelName": "checking-01",
225
+ "lastPresetId": null,
226
+ "lastFeedId": null,
227
+ "poster": "https://example.com/poster.jpeg",
228
+ "thumbnail": "https://example.com/thumbnail.jpeg",
229
+ "linkPublishSocial": null,
230
+ "linkStream": "[\"https://www.youtube.com/watch?v=pQzaHPoNX1I\"]",
231
+ "lastPullInfo": null,
232
+ "lastPushInfo": null,
233
+ "lastProcess": null,
234
+ "eventType": null,
235
+ "createdAt": "2018-06-21T14:33:36.000Z",
236
+ "updatedAt": "2018-06-21T14:33:36.000Z"
237
+ }
238
+ ```
239
+
240
+ ## Get view of live feed
241
+ This API use to get a live view status . This view only show when event has been started and being processing.
242
+
243
+ See details [here](https://docs.uiza.io/#get-view-of-live-feed).
244
+
245
+ ```ruby
246
+ require "uiza"
247
+
248
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
249
+ Uiza.authorization = "your-authorization"
250
+
251
+ begin
252
+ response = Uiza::Live.get_view "your-live-id"
253
+ puts response.stream_name
254
+ puts response.watchnow
255
+ puts response.day
256
+ rescue Uiza::Error::UizaError => e
257
+ puts "description_link: #{e.description_link}"
258
+ puts "code: #{e.code}"
259
+ puts "message: #{e.message}"
260
+ rescue StandardError => e
261
+ puts "message: #{e.message}"
262
+ end
263
+ ```
264
+
265
+ Example Response
266
+ ```ruby
267
+ {
268
+ "stream_name": "peppa-pig-english-episodes",
269
+ "watchnow": 1,
270
+ "day": 1533271205999
271
+ }
272
+ ```
273
+
274
+ ## Stop a live feed
275
+ Stop live event
276
+
277
+ See details [here](https://docs.uiza.io/#stop-a-live-feed).
278
+
279
+ ```ruby
280
+ require "uiza"
281
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
282
+ Uiza.authorization = "your-authorization"
283
+ params = {
284
+ id: "your-live-id",
285
+ name: "live test",
286
+ mode: "pull",
287
+ encode: 0,
288
+ dvr: 1,
289
+ resourceMode: "single"
290
+ }
291
+
292
+ begin
293
+ live = Uiza::Live.stop_feed "your-live-id"
294
+ puts live.id
295
+ puts live.name
296
+ rescue Uiza::Error::UizaError => e
297
+ puts "description_link: #{e.description_link}"
298
+ puts "code: #{e.code}"
299
+ puts "message: #{e.message}"
300
+ rescue StandardError => e
301
+ puts "message: #{e.message}"
302
+ end
303
+ ```
304
+
305
+ Example Response
306
+ ```ruby
307
+ {
308
+ "id": "8b83886e-9cc3-4eab-9258-ebb16c0c73de",
309
+ "name": "checking 01",
310
+ "description": "checking",
311
+ "mode": "pull",
312
+ "resourceMode": "single",
313
+ "encode": 0,
314
+ "channelName": "checking-01",
315
+ "lastPresetId": null,
316
+ "lastFeedId": null,
317
+ "poster": "https://example.com/poster.jpeg",
318
+ "thumbnail": "https://example.com/thumbnail.jpeg",
319
+ "linkPublishSocial": null,
320
+ "linkStream": "[\"https://www.youtube.com/watch?v=pQzaHPoNX1I\"]",
321
+ "lastPullInfo": null,
322
+ "lastPushInfo": null,
323
+ "lastProcess": null,
324
+ "eventType": null,
325
+ "createdAt": "2018-06-21T14:33:36.000Z",
326
+ "updatedAt": "2018-06-21T14:33:36.000Z"
327
+ }
328
+ ```
329
+
330
+ ## List all recorded files
331
+ Retrieves list of recorded file after streamed (only available when your live event has turned on Record feature)
332
+
333
+ See details [here](https://docs.uiza.io/#list-all-recorded-files).
334
+
335
+ ```ruby
336
+ require "uiza"
337
+
338
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
339
+ Uiza.authorization = "your-authorization"
340
+
341
+ begin
342
+ live = Uiza::Live.list_recorded limit: 2
343
+ # limit is optional
344
+ # or live = Uiza::Live.list_recorded
345
+ puts live.first.id
346
+ puts live.first.entityId
347
+ rescue Uiza::Error::UizaError => e
348
+ puts "description_link: #{e.description_link}"
349
+ puts "code: #{e.code}"
350
+ puts "message: #{e.message}"
351
+ rescue StandardError => e
352
+ puts "message: #{e.message}"
353
+ end
354
+ ```
355
+
356
+ Example Response
357
+ ```ruby
358
+ [
359
+ {
360
+ "id": "040df935-61c4-46f7-a41f-0a899ebaa2cc",
361
+ "entityId": "ee122e85-553f-4621-bc77-1396191d5846",
362
+ "channelName": "dcb8686f-d0f8-4a0f-8b92-22db339eb315",
363
+ "feedId": "3e3b75df-e6fa-471c-b386-8f44b8a34b6c",
364
+ "eventType": "pull",
365
+ "startTime": "2018-12-13T16:28:29.000Z",
366
+ "endTime": "2018-12-13T18:28:29.000Z",
367
+ "length": "7200",
368
+ "fileSize": "9276182",
369
+ "extraInfo": null,
370
+ "endpointConfig": "s3-uiza-dvr",
371
+ "createdAt": "2018-12-13T19:28:43.000Z",
372
+ "updatedAt": "2018-12-13T19:28:43.000Z",
373
+ "entityName": "Christmas 2018 Holidays Special | Best Christmas Songs & Cartoons for Kids & Babies on Baby First TV"
374
+ },
375
+ {
376
+ "id": "3fec45e9-932b-4efe-b97f-dc3053acaa05",
377
+ "entityId": "47e804bc-d4e5-4442-8f1f-20341a156a70",
378
+ "channelName": "e9034eac-4905-4f9a-8e79-c0bd67e49dd5",
379
+ "feedId": "12830696-87e3-4209-a877-954f8f008964",
380
+ "eventType": "pull",
381
+ "startTime": "2018-12-13T14:14:14.000Z",
382
+ "endTime": "2018-12-13T16:14:14.000Z",
383
+ "length": "7200",
384
+ "fileSize": "439858038",
385
+ "extraInfo": null,
386
+ "endpointConfig": "s3-uiza-dvr",
387
+ "createdAt": "2018-12-13T17:30:42.000Z",
388
+ "updatedAt": "2018-12-13T17:30:42.000Z",
389
+ "entityName": "WATCH: SpaceX to Launch Falcon 9 Rocket #Spaceflight CRS16 @1:16pm EST"
390
+ }
391
+ ]
392
+ ```
393
+
394
+ ## Delete a record file
395
+ Delete a recorded file
396
+
397
+ See details [here](https://docs.uiza.io/#delete-a-record-file).
398
+
399
+ ```ruby
400
+ require "uiza"
401
+
402
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
403
+ Uiza.authorization = "your-authorization"
404
+
405
+ begin
406
+ live = Uiza::Live.delete "your-record-id" #Identifier of record (get from list record)
407
+ puts live.id
408
+ rescue Uiza::Error::UizaError => e
409
+ puts "description_link: #{e.description_link}"
410
+ puts "code: #{e.code}"
411
+ puts "message: #{e.message}"
412
+ rescue StandardError => e
413
+ puts "message: #{e.message}"
414
+ end
415
+ ```
416
+
417
+ Example Response
418
+ ```ruby
419
+ {
420
+ "id": "040df935-61c4-46f7-a41f-0a899ebaa2cc"
421
+ }
422
+ ```
423
+
424
+ ## Convert into VOD
425
+ Convert recorded file into VOD entity. After converted, your file can be stream via Uiza's CDN.
426
+
427
+ See details [here](https://docs.uiza.io/#convert-into-vod).
428
+
429
+ ```ruby
430
+ require "uiza"
431
+
432
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
433
+ Uiza.authorization = "your-authorization"
434
+
435
+ begin
436
+ live = Uiza::Live.convert_to_vod "your-record-id" #Identifier of record (get from list record)
437
+ puts live.id
438
+ rescue Uiza::Error::UizaError => e
439
+ puts "description_link: #{e.description_link}"
440
+ puts "code: #{e.code}"
441
+ puts "message: #{e.message}"
442
+ rescue StandardError => e
443
+ puts "message: #{e.message}"
444
+ end
445
+ ```
446
+
447
+ Example Response
448
+ ```ruby
449
+ {
450
+ "id": "03739912-d781-4d5a-aaf8-7262691a5d0c"
451
+ }
452
+ ```