uiza 1.0.0

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.
Files changed (48) 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 +41 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/CONTRIBUTORS.txt +3 -0
  8. data/Gemfile +6 -0
  9. data/Gemfile.lock +65 -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 +179 -0
  14. data/Rakefile +6 -0
  15. data/bin/console +14 -0
  16. data/bin/setup +8 -0
  17. data/doc/ANALYTIC.md +5 -0
  18. data/doc/CALLBACK.md +4 -0
  19. data/doc/CATEGORY.md +282 -0
  20. data/doc/EMBED_METADATA.md +4 -0
  21. data/doc/ENTITY.md +466 -0
  22. data/doc/ERRORS_CODE.md +60 -0
  23. data/doc/LIVE_STREAMING.md +6 -0
  24. data/doc/STORAGE.md +189 -0
  25. data/lib/uiza.rb +34 -0
  26. data/lib/uiza/api_operation/add.rb +16 -0
  27. data/lib/uiza/api_operation/create.rb +16 -0
  28. data/lib/uiza/api_operation/delete.rb +15 -0
  29. data/lib/uiza/api_operation/list.rb +14 -0
  30. data/lib/uiza/api_operation/remove.rb +15 -0
  31. data/lib/uiza/api_operation/retrieve.rb +15 -0
  32. data/lib/uiza/api_operation/update.rb +16 -0
  33. data/lib/uiza/category.rb +42 -0
  34. data/lib/uiza/entity.rb +68 -0
  35. data/lib/uiza/error/bad_request_error.rb +8 -0
  36. data/lib/uiza/error/client_error.rb +8 -0
  37. data/lib/uiza/error/internal_server_error.rb +8 -0
  38. data/lib/uiza/error/not_found_error.rb +8 -0
  39. data/lib/uiza/error/server_error.rb +8 -0
  40. data/lib/uiza/error/service_unavailable_error.rb +8 -0
  41. data/lib/uiza/error/uiza_error.rb +18 -0
  42. data/lib/uiza/error/unauthorized_error.rb +8 -0
  43. data/lib/uiza/error/unprocessable_error.rb +8 -0
  44. data/lib/uiza/storage.rb +17 -0
  45. data/lib/uiza/uiza_client.rb +74 -0
  46. data/lib/uiza/version.rb +3 -0
  47. data/uiza.gemspec +36 -0
  48. metadata +134 -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,6 @@
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).
@@ -0,0 +1,189 @@
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
+ require "json"
68
+
69
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
70
+ Uiza.authorization = "your-authorization"
71
+
72
+ begin
73
+ storage = Uiza::Storage.retrieve "your-storage-id"
74
+ puts storage.id
75
+ puts storage.name
76
+ rescue Uiza::Error::UizaError => e
77
+ puts "description_link: #{e.description_link}"
78
+ puts "code: #{e.code}"
79
+ puts "message: #{e.message}"
80
+ rescue StandardError => e
81
+ puts "message: #{e.message}"
82
+ end
83
+ ```
84
+
85
+ Example Response
86
+ ```ruby
87
+ {
88
+ "id": "cd003123-7ec9-4f3a-9d7c-f2de93e83e49",
89
+ "name": "FTP Uiza",
90
+ "description": "FTP of Uiza, use for transcode",
91
+ "storageType": "ftp",
92
+ "usageType": "input",
93
+ "bucket": null,
94
+ "prefix": null,
95
+ "host": "ftp-exemple.uiza.io",
96
+ "awsAccessKey": null,
97
+ "awsSecretKey": null,
98
+ "username": "uiza",
99
+ "password": "=5;9x@LPsd+w7qW",
100
+ "region": null,
101
+ "port": 21,
102
+ "createdAt": "2018-06-19T03:01:56.000Z",
103
+ "updatedAt": "2018-06-19T03:01:56.000Z"
104
+ }
105
+ ```
106
+
107
+ ## Update storage
108
+ Update storage's information.
109
+
110
+ See details [here](https://docs.uiza.io/#update-storage).
111
+
112
+ ```ruby
113
+ require "uiza"
114
+
115
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
116
+ Uiza.authorization = "your-authorization"
117
+
118
+ params = {
119
+ id: "your-storage-id",
120
+ name: "FTP Uiza edited",
121
+ host: "ftp-example.uiza.io",
122
+ port: 21,
123
+ storageType: "ftp"
124
+ }
125
+
126
+ begin
127
+ storage = Uiza::Storage.update params
128
+ puts storage.id
129
+ puts storage.name
130
+ rescue Uiza::Error::UizaError => e
131
+ puts "description_link: #{e.description_link}"
132
+ puts "code: #{e.code}"
133
+ puts "message: #{e.message}"
134
+ rescue StandardError => e
135
+ puts "message: #{e.message}"
136
+ end
137
+ ```
138
+
139
+ Example Response
140
+ ```ruby
141
+ {
142
+ "id": "cd003123-7ec9-4f3a-9d7c-f2de93e83e49",
143
+ "name": "FTP Uiza edited",
144
+ "description": "FTP of Uiza, use for transcode",
145
+ "storageType": "ftp",
146
+ "usageType": "input",
147
+ "bucket": null,
148
+ "prefix": null,
149
+ "host": "ftp-exemple.uiza.io",
150
+ "awsAccessKey": null,
151
+ "awsSecretKey": null,
152
+ "username": "uiza",
153
+ "password": "=5;9x@LPsd+w7qW",
154
+ "region": null,
155
+ "port": 21,
156
+ "createdAt": "2018-06-19T03:01:56.000Z",
157
+ "updatedAt": "2018-06-19T03:01:56.000Z"
158
+ }
159
+ ```
160
+
161
+ ## Remove storage
162
+ Remove storage that added to Uiza.
163
+
164
+ See details [here](https://docs.uiza.io/#remove-storage).
165
+
166
+ ```ruby
167
+ require "uiza"
168
+
169
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
170
+ Uiza.authorization = "your-authorization"
171
+
172
+ begin
173
+ storage = Uiza::Storage.remove "your-storage-id"
174
+ puts storage.id
175
+ rescue Uiza::Error::UizaError => e
176
+ puts "description_link: #{e.description_link}"
177
+ puts "code: #{e.code}"
178
+ puts "message: #{e.message}"
179
+ rescue StandardError => e
180
+ puts "message: #{e.message}"
181
+ end
182
+ ```
183
+
184
+ Example Response
185
+ ```ruby
186
+ {
187
+ "id": "cd003123-7ec9-4f3a-9d7c-f2de93e83e49"
188
+ }
189
+ ```
@@ -0,0 +1,34 @@
1
+ require "net/http"
2
+ require "net/https"
3
+ require "json"
4
+
5
+ require "uiza/version"
6
+ require "uiza/uiza_client"
7
+
8
+ require "uiza/error/uiza_error"
9
+ require "uiza/error/bad_request_error"
10
+ require "uiza/error/unauthorized_error"
11
+ require "uiza/error/not_found_error"
12
+ require "uiza/error/unprocessable_error"
13
+ require "uiza/error/internal_server_error"
14
+ require "uiza/error/service_unavailable_error"
15
+ require "uiza/error/client_error"
16
+ require "uiza/error/server_error"
17
+
18
+ require "uiza/api_operation/create"
19
+ require "uiza/api_operation/add"
20
+ require "uiza/api_operation/retrieve"
21
+ require "uiza/api_operation/list"
22
+ require "uiza/api_operation/update"
23
+ require "uiza/api_operation/delete"
24
+ require "uiza/api_operation/remove"
25
+
26
+ require "uiza/entity"
27
+ require "uiza/storage"
28
+ require "uiza/category"
29
+
30
+ module Uiza
31
+ class << self
32
+ attr_accessor :workspace_api_domain, :authorization
33
+ end
34
+ end
@@ -0,0 +1,16 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Add
4
+ def add params
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :post
7
+ headers = {"Authorization" => Uiza.authorization}
8
+
9
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:add]
10
+ response = uiza_client.execute_request
11
+
12
+ retrieve response.id
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Create
4
+ def create params
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :post
7
+ headers = {"Authorization" => Uiza.authorization}
8
+
9
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:create]
10
+ response = uiza_client.execute_request
11
+
12
+ retrieve response.id
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Delete
4
+ def delete id
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :delete
7
+ headers = {"Authorization" => Uiza.authorization}
8
+ params = {id: id}
9
+
10
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:delete]
11
+ uiza_client.execute_request
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module List
4
+ def list params = {}
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :get
7
+ headers = {"Authorization" => Uiza.authorization}
8
+
9
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:list]
10
+ uiza_client.execute_request
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Remove
4
+ def remove id
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :delete
7
+ headers = {"Authorization" => Uiza.authorization}
8
+ params = {id: id}
9
+
10
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:remove]
11
+ uiza_client.execute_request
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Retrieve
4
+ def retrieve id
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :get
7
+ headers = {"Authorization" => Uiza.authorization}
8
+ params = {id: id}
9
+
10
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:retrieve]
11
+ uiza_client.execute_request
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Update
4
+ def update params
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :put
7
+ headers = {"Authorization" => Uiza.authorization}
8
+
9
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:update]
10
+ response = uiza_client.execute_request
11
+
12
+ retrieve response.id
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,42 @@
1
+ module Uiza
2
+ class Category
3
+ extend Uiza::APIOperation::Create
4
+ extend Uiza::APIOperation::Retrieve
5
+ extend Uiza::APIOperation::Update
6
+ extend Uiza::APIOperation::Delete
7
+ extend Uiza::APIOperation::List
8
+
9
+ OBJECT_API_PATH = "media/metadata".freeze
10
+ OBJECT_API_DESCRIPTION_LINK = {
11
+ create: "https://docs.uiza.io/#create-category",
12
+ retrieve: "https://docs.uiza.io/#retrieve-category",
13
+ list: "https://docs.uiza.io/#retrieve-category-list",
14
+ update: "https://docs.uiza.io/#update-category",
15
+ delete: "https://docs.uiza.io/#delete-category",
16
+ create_relation: "https://docs.uiza.io/#create-category-relation",
17
+ delete_relation: "https://docs.uiza.io/#delete-category-relation"
18
+ }.freeze
19
+
20
+ class << self
21
+ def create_relation params
22
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/media/entity/related/metadata"
23
+ method = :post
24
+ headers = {"Authorization" => Uiza.authorization}
25
+ description_link = OBJECT_API_DESCRIPTION_LINK[:create_relation]
26
+
27
+ uiza_client = UizaClient.new url, method, headers, params, description_link
28
+ uiza_client.execute_request
29
+ end
30
+
31
+ def delete_relation params
32
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/media/entity/related/metadata"
33
+ method = :post
34
+ headers = {"Authorization" => Uiza.authorization}
35
+ description_link = OBJECT_API_DESCRIPTION_LINK[:delete_relation]
36
+
37
+ uiza_client = UizaClient.new url, method, headers, params, description_link
38
+ uiza_client.execute_request
39
+ end
40
+ end
41
+ end
42
+ end