uiza_minh_phong 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +535 -0
- data/.rubocop_disable.yml +78 -0
- data/.rubocop_enable.yml +786 -0
- data/CHANGELOG.md +50 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTORS.txt +3 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +73 -0
- data/History.txt +1 -0
- data/LICENSE.txt +21 -0
- data/PULL_REQUEST_TEMPLATE.md +44 -0
- data/README.md +248 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc/ANALYTIC.md +143 -0
- data/doc/CALLBACK.md +161 -0
- data/doc/CATEGORY.md +312 -0
- data/doc/EMBED_METADATA.md +4 -0
- data/doc/ENTITY.md +470 -0
- data/doc/ERRORS_CODE.md +60 -0
- data/doc/LIVE_STREAMING.md +452 -0
- data/doc/STORAGE.md +188 -0
- data/doc/USER.md +286 -0
- data/lib/uiza.rb +39 -0
- data/lib/uiza/analytic.rb +42 -0
- data/lib/uiza/api_operation/add.rb +16 -0
- data/lib/uiza/api_operation/create.rb +16 -0
- data/lib/uiza/api_operation/delete.rb +15 -0
- data/lib/uiza/api_operation/list.rb +14 -0
- data/lib/uiza/api_operation/remove.rb +15 -0
- data/lib/uiza/api_operation/retrieve.rb +15 -0
- data/lib/uiza/api_operation/update.rb +16 -0
- data/lib/uiza/callback.rb +16 -0
- data/lib/uiza/category.rb +42 -0
- data/lib/uiza/entity.rb +68 -0
- data/lib/uiza/error/bad_request_error.rb +8 -0
- data/lib/uiza/error/client_error.rb +8 -0
- data/lib/uiza/error/internal_server_error.rb +8 -0
- data/lib/uiza/error/not_found_error.rb +8 -0
- data/lib/uiza/error/server_error.rb +8 -0
- data/lib/uiza/error/service_unavailable_error.rb +8 -0
- data/lib/uiza/error/uiza_error.rb +18 -0
- data/lib/uiza/error/unauthorized_error.rb +8 -0
- data/lib/uiza/error/unprocessable_error.rb +8 -0
- data/lib/uiza/live.rb +86 -0
- data/lib/uiza/storage.rb +17 -0
- data/lib/uiza/uiza_client.rb +86 -0
- data/lib/uiza/uiza_open_struct.rb +18 -0
- data/lib/uiza/user.rb +41 -0
- data/lib/uiza/version.rb +3 -0
- data/uiza.gemspec +36 -0
- metadata +141 -0
data/lib/uiza/storage.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Uiza
|
2
|
+
class Storage
|
3
|
+
extend Uiza::APIOperation::Add
|
4
|
+
extend Uiza::APIOperation::Retrieve
|
5
|
+
extend Uiza::APIOperation::Update
|
6
|
+
extend Uiza::APIOperation::Remove
|
7
|
+
|
8
|
+
OBJECT_API_PATH = "media/storage".freeze
|
9
|
+
|
10
|
+
OBJECT_API_DESCRIPTION_LINK = {
|
11
|
+
add: "https://docs.uiza.io/#add-a-storage",
|
12
|
+
retrieve: "https://docs.uiza.io/#retrieve-a-storage",
|
13
|
+
update: "https://docs.uiza.io/#update-storage",
|
14
|
+
remove: "https://docs.uiza.io/#remove-storage"
|
15
|
+
}.freeze
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Uiza
|
2
|
+
class UizaClient
|
3
|
+
def initialize url, method, headers, params, description_link
|
4
|
+
@uri = URI.parse url
|
5
|
+
@description_link = description_link
|
6
|
+
|
7
|
+
params ||= {}
|
8
|
+
|
9
|
+
case method.to_s.downcase
|
10
|
+
when "get"
|
11
|
+
@uri.query = URI.encode_www_form params
|
12
|
+
@request = Net::HTTP::Get.new @uri
|
13
|
+
when "post"
|
14
|
+
@request = Net::HTTP::Post.new @uri
|
15
|
+
@request.body = JSON.dump params
|
16
|
+
when "put"
|
17
|
+
@request = Net::HTTP::Put.new @uri
|
18
|
+
@request.body = JSON.dump params
|
19
|
+
when "delete"
|
20
|
+
@request = Net::HTTP::Delete.new @uri
|
21
|
+
@request.body = JSON.dump params
|
22
|
+
end
|
23
|
+
|
24
|
+
@request.content_type = "application/json"
|
25
|
+
headers.each do |key, value|
|
26
|
+
@request[key] = value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def execute_request
|
31
|
+
@http = Net::HTTP.start @uri.host, @uri.port, use_ssl: true
|
32
|
+
@response = @http.request @request
|
33
|
+
@response = JSON.parse @response.body
|
34
|
+
|
35
|
+
code = @response["code"]
|
36
|
+
message = @response["message"]
|
37
|
+
check_and_raise_error code, message
|
38
|
+
|
39
|
+
data = @response["data"]
|
40
|
+
response = JSON.parse(data.to_json, object_class: Uiza::UizaOpenStruct)
|
41
|
+
|
42
|
+
return response unless response
|
43
|
+
|
44
|
+
if response.is_a?(Array)
|
45
|
+
response.each(&:define_methods)
|
46
|
+
else
|
47
|
+
response.define_methods
|
48
|
+
end
|
49
|
+
|
50
|
+
response
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def check_and_raise_error code, message
|
56
|
+
reg_2xx = /^2\d\d$/
|
57
|
+
reg_4xx = /^4\d\d$/
|
58
|
+
reg_5xx = /^5\d\d$/
|
59
|
+
|
60
|
+
return if code.to_s =~ reg_2xx
|
61
|
+
|
62
|
+
error = case code.to_s
|
63
|
+
when "400"
|
64
|
+
Uiza::Error::BadRequestError.new @description_link, message
|
65
|
+
when "401"
|
66
|
+
Uiza::Error::UnauthorizedError.new @description_link, message
|
67
|
+
when "404"
|
68
|
+
Uiza::Error::NotFoundError.new @description_link, message
|
69
|
+
when "422"
|
70
|
+
Uiza::Error::UnprocessableError.new @description_link, message
|
71
|
+
when "500"
|
72
|
+
Uiza::Error::InternalServerError.new @description_link, message
|
73
|
+
when "503"
|
74
|
+
Uiza::Error::ServiceUnavailableError.new @description_link, message
|
75
|
+
when reg_4xx
|
76
|
+
Uiza::Error::ClientError.new @description_link, message, code
|
77
|
+
when reg_5xx
|
78
|
+
Uiza::Error::ServerError.new @description_link, message, code
|
79
|
+
else
|
80
|
+
Uiza::Error::UizaError.new @description_link, message, code
|
81
|
+
end
|
82
|
+
|
83
|
+
raise error, message
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Uiza
|
2
|
+
class UizaOpenStruct < OpenStruct
|
3
|
+
def define_methods
|
4
|
+
data = to_h
|
5
|
+
data.each do |key, value|
|
6
|
+
if value.is_a?(Uiza::UizaOpenStruct)
|
7
|
+
value.define_methods
|
8
|
+
else
|
9
|
+
define_singleton_method(key) do |*args|
|
10
|
+
return super(*args) if args.any?
|
11
|
+
|
12
|
+
value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/uiza/user.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Uiza
|
2
|
+
class User
|
3
|
+
extend Uiza::APIOperation::Create
|
4
|
+
extend Uiza::APIOperation::Retrieve
|
5
|
+
extend Uiza::APIOperation::List
|
6
|
+
extend Uiza::APIOperation::Update
|
7
|
+
extend Uiza::APIOperation::Delete
|
8
|
+
|
9
|
+
OBJECT_API_PATH = "admin/user".freeze
|
10
|
+
OBJECT_API_DESCRIPTION_LINK = {
|
11
|
+
create: "https://docs.uiza.io/#create-an-user",
|
12
|
+
retrieve: "https://docs.uiza.io/#retrieve-an-user",
|
13
|
+
list: "https://docs.uiza.io/#list-all-users",
|
14
|
+
update: "https://docs.uiza.io/#update-an-user",
|
15
|
+
delete: "https://docs.uiza.io/#delete-an-user",
|
16
|
+
change_password: "https://docs.uiza.io/#update-password",
|
17
|
+
logout: "https://docs.uiza.io/#log-out"
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
class << self
|
21
|
+
def change_password params
|
22
|
+
url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{OBJECT_API_PATH}/changepassword"
|
23
|
+
method = :post
|
24
|
+
headers = {"Authorization" => Uiza.authorization}
|
25
|
+
|
26
|
+
uiza_client = UizaClient.new url, method, headers, params, OBJECT_API_DESCRIPTION_LINK[:change_password]
|
27
|
+
uiza_client.execute_request
|
28
|
+
end
|
29
|
+
|
30
|
+
def logout
|
31
|
+
url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{OBJECT_API_PATH}/logout"
|
32
|
+
method = :post
|
33
|
+
headers = {"Authorization" => Uiza.authorization}
|
34
|
+
params = {}
|
35
|
+
|
36
|
+
uiza_client = UizaClient.new url, method, headers, params, OBJECT_API_DESCRIPTION_LINK[:logout]
|
37
|
+
uiza_client.execute_request
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/uiza/version.rb
ADDED
data/uiza.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "uiza/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "uiza_minh_phong"
|
7
|
+
spec.version = "0.4.0"
|
8
|
+
spec.required_ruby_version = ">= 2.0.0"
|
9
|
+
spec.authors = ["Vo Khanh Toan"]
|
10
|
+
spec.email = ["toanvk@uiza.io"]
|
11
|
+
|
12
|
+
spec.summary = "Ruby wrapper library for Uiza API"
|
13
|
+
spec.description = "See https://docs.uiza.io for details"
|
14
|
+
spec.homepage = "https://docs.uiza.io"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/uizaio/api-wrapper-ruby"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uiza_minh_phong
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vo Khanh Toan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: See https://docs.uiza.io for details
|
56
|
+
email:
|
57
|
+
- toanvk@uiza.io
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".rubocop.yml"
|
63
|
+
- ".rubocop_disable.yml"
|
64
|
+
- ".rubocop_enable.yml"
|
65
|
+
- CHANGELOG.md
|
66
|
+
- CODE_OF_CONDUCT.md
|
67
|
+
- CONTRIBUTORS.txt
|
68
|
+
- Gemfile
|
69
|
+
- Gemfile.lock
|
70
|
+
- History.txt
|
71
|
+
- LICENSE.txt
|
72
|
+
- PULL_REQUEST_TEMPLATE.md
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- bin/console
|
76
|
+
- bin/setup
|
77
|
+
- doc/ANALYTIC.md
|
78
|
+
- doc/CALLBACK.md
|
79
|
+
- doc/CATEGORY.md
|
80
|
+
- doc/EMBED_METADATA.md
|
81
|
+
- doc/ENTITY.md
|
82
|
+
- doc/ERRORS_CODE.md
|
83
|
+
- doc/LIVE_STREAMING.md
|
84
|
+
- doc/STORAGE.md
|
85
|
+
- doc/USER.md
|
86
|
+
- lib/uiza.rb
|
87
|
+
- lib/uiza/analytic.rb
|
88
|
+
- lib/uiza/api_operation/add.rb
|
89
|
+
- lib/uiza/api_operation/create.rb
|
90
|
+
- lib/uiza/api_operation/delete.rb
|
91
|
+
- lib/uiza/api_operation/list.rb
|
92
|
+
- lib/uiza/api_operation/remove.rb
|
93
|
+
- lib/uiza/api_operation/retrieve.rb
|
94
|
+
- lib/uiza/api_operation/update.rb
|
95
|
+
- lib/uiza/callback.rb
|
96
|
+
- lib/uiza/category.rb
|
97
|
+
- lib/uiza/entity.rb
|
98
|
+
- lib/uiza/error/bad_request_error.rb
|
99
|
+
- lib/uiza/error/client_error.rb
|
100
|
+
- lib/uiza/error/internal_server_error.rb
|
101
|
+
- lib/uiza/error/not_found_error.rb
|
102
|
+
- lib/uiza/error/server_error.rb
|
103
|
+
- lib/uiza/error/service_unavailable_error.rb
|
104
|
+
- lib/uiza/error/uiza_error.rb
|
105
|
+
- lib/uiza/error/unauthorized_error.rb
|
106
|
+
- lib/uiza/error/unprocessable_error.rb
|
107
|
+
- lib/uiza/live.rb
|
108
|
+
- lib/uiza/storage.rb
|
109
|
+
- lib/uiza/uiza_client.rb
|
110
|
+
- lib/uiza/uiza_open_struct.rb
|
111
|
+
- lib/uiza/user.rb
|
112
|
+
- lib/uiza/version.rb
|
113
|
+
- uiza.gemspec
|
114
|
+
homepage: https://docs.uiza.io
|
115
|
+
licenses:
|
116
|
+
- MIT
|
117
|
+
metadata:
|
118
|
+
allowed_push_host: https://rubygems.org
|
119
|
+
homepage_uri: https://docs.uiza.io
|
120
|
+
source_code_uri: https://github.com/uizaio/api-wrapper-ruby
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: 2.0.0
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.6.13
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: Ruby wrapper library for Uiza API
|
141
|
+
test_files: []
|