true-conf 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: af44dfdee426776472986c5684072a342240bf4e304f501994bf17b284d55501
4
+ data.tar.gz: 9ab5d23ea17e273da2754ca0f910ce2e3a39b9294da2a17c0f53ab13634dc0d7
5
+ SHA512:
6
+ metadata.gz: 532ef4af546348f2cdc524b8cb0dda34379bd1821bcf57770c97d26c1b6fc6156ff13f9cce0570d268d29a9d909dc297cb921b86072a444e86c266494dbe29ae
7
+ data.tar.gz: ed4fb9343861dd2bbdda9b3ce4ddf7df8dd66db310721e58b061a776309d767e10d9b88bcc2bceee273cf5feba615fadaa7729aade2072b272d212a720700876
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Andrey Paderin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,167 @@
1
+ # TrueConf Server API Client
2
+
3
+ [![TrueConf](https://circleci.com/gh/paderinandrey/true-conf.svg?style=svg)](https://circleci.com/gh/paderinandrey/true-conf)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'true-conf'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install true-conf
20
+
21
+ ## Usage
22
+ Initialize a client with `client_id` and `client_secret`:
23
+
24
+ ```ruby
25
+ client = TrueConf::Client.new client_id: '<client_id>', # required
26
+ client_secret: '<client_secret>', # required
27
+ api_server: '<server_name>', # required
28
+ version: '3.2' # optional, default: 3.2
29
+ ```
30
+
31
+ ```ruby
32
+ client.success?
33
+ client.error?
34
+ ```
35
+
36
+ ### Conferences
37
+
38
+
39
+ ### Users
40
+ https://developers.trueconf.ru/api/server/#api-Users
41
+
42
+ **Entities**
43
+
44
+ ```ruby
45
+ TrueConf::Entity::User
46
+
47
+ user = client.by_user(id: "andy").get
48
+ user.disabled? # false
49
+ user.enabled? # true
50
+ user.not_active? # false
51
+ user.invalid? # false
52
+ user.offline? # false
53
+ user.online? # true
54
+ user.busy? # false
55
+ user.multihost? # false
56
+
57
+ ```
58
+ ```ruby
59
+ TrueConf::Entity::UserList
60
+
61
+ ```
62
+
63
+ ```ruby
64
+ TrueConf::Entity::UserSimple
65
+
66
+ ```
67
+ **Actions**
68
+ ```ruby
69
+ users = client.users.all url_type: "dynamic", # optional
70
+ page_id: 1, # optional
71
+ page_size: 10, # optional
72
+ login_name: "Andy", # optional
73
+ display_name: "Andy", # optional
74
+ first_name: "", # optional
75
+ last_name: "", # optional
76
+ email: "andy@tb.com" # optional
77
+ # => TrueConf::Entity::UserList
78
+
79
+ user = client.users.create(**params)
80
+ # => TrueConf::Entity::User
81
+
82
+ user = client.by_user(id: "andy").get
83
+ # => TrueConf::Entity::User
84
+
85
+ user = client.by_user(id: "andy").update(**params)
86
+ # => TrueConf::Entity::User
87
+
88
+ user = client.by_user(id: "andy").delete
89
+ # => TrueConf::Entity::UserSimple
90
+
91
+ user = client.by_user(id: "andy").disconnect
92
+ # => TrueConf::Entity::UserSimple
93
+ ```
94
+
95
+ ### Invitations
96
+ https://developers.trueconf.ru/api/server/#api-Conferences_Invitations
97
+
98
+ **Entities**
99
+
100
+ ```ruby
101
+ TrueConf::Entity::Invitation
102
+
103
+ invitation = client.by_conference(conference_id: "3390770247")
104
+ .by_invitation(id: "user")
105
+ .get
106
+
107
+ invitation.owner? # true
108
+ invitation.user? # true
109
+ invitation.custom? # false
110
+
111
+ ```
112
+ ```ruby
113
+ TrueConf::Entity::InvitationList
114
+ ```
115
+
116
+ ```ruby
117
+ TrueConf::Entity::InvitationSimple
118
+ ```
119
+
120
+ **Actions**
121
+ ```ruby
122
+ # Add Invitation
123
+ invitation = client.by_conference(conference_id: "3390770247")
124
+ .invitations
125
+ .create(id: "user", display_name: "user")
126
+ # => TrueConf::Entity::Invitation
127
+
128
+ # Get Invitation List
129
+ invitations = client.by_conference(conference_id: "3390770247")
130
+ .invitations
131
+ .all
132
+ # => TrueConf::Entity::InvitationList
133
+
134
+ # Get Invitation
135
+ invitation = client.by_conference(conference_id: "3390770247")
136
+ .by_invitation(id: "user")
137
+ .get
138
+ # => TrueConf::Entity::Invitation
139
+
140
+ # Update Invitation
141
+ invitation = client.by_conference(conference_id: "3390770247")
142
+ .by_invitation(id: "user")
143
+ .update(display_name: "andy")
144
+ # => TrueConf::Entity::Invitation
145
+
146
+ # Delete Invitation
147
+ invitation = client.by_conference(conference_id: "3390770247")
148
+ .by_invitation(id: "user")
149
+ .delete
150
+ # => TrueConf::Entity::InvitationSimple
151
+ ```
152
+
153
+ ### Error
154
+
155
+
156
+
157
+ ## Contributing
158
+
159
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/true-conf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
160
+
161
+ ## License
162
+
163
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
164
+
165
+ ## Code of Conduct
166
+
167
+ Everyone interacting in the True::Conf project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/true-conf/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "evil/client"
4
+ require "tempfile"
5
+
6
+ require "true-conf/client"
7
+ require "true-conf/conference"
8
+ require "true-conf/invitation"
9
+ require "true-conf/participant"
10
+ require "true-conf/record"
11
+ require "true-conf/user"
12
+ require "true-conf/version"
13
+ require "true-conf/response"
14
+ require "true-conf/callable"
15
+ require "true-conf/optional"
16
+ require "true-conf/error"
17
+ require "true-conf/error_detail"
18
+ require "true-conf/entity/conference"
19
+ require "true-conf/entity/conference_simple"
20
+ require "true-conf/entity/participant"
21
+ require "true-conf/entity/user"
22
+ require "true-conf/entity/user_simple"
23
+ require "true-conf/entity/user_list"
24
+ require "true-conf/entity/invitation"
25
+ require "true-conf/entity/invitation_simple"
26
+ require "true-conf/entity/invitation_list"
27
+ require "true-conf/entity/record"
28
+ require "true-conf/entity/record_list"
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Callable
5
+ def call(*args)
6
+ new(*args)
7
+ end
8
+ alias_method :[], :call
9
+ end
10
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "oauth2"
4
+ require "pry"
5
+
6
+ module TrueConf
7
+ class Client < Evil::Client
8
+ option :client_id, proc(&:to_s)
9
+ option :client_secret, proc(&:to_s)
10
+ option :api_server, proc(&:to_s)
11
+ option :token_url, proc(&:to_s), default: -> { "/oauth2/v1/token" }
12
+ option :version, proc(&:to_s), default: -> { "v3.1" }
13
+
14
+ format "json"
15
+ path { "https://#{api_server}/api/#{version}" }
16
+
17
+ class Resolver::Security < Resolver
18
+ def access_token(client_id, client_secret)
19
+ client = OAuth2::Client.new(
20
+ client_id,
21
+ client_secret,
22
+ site: "https://#{api_server}",
23
+ token_url: token_url
24
+ )
25
+ client.client_credentials.get_token.token
26
+ end
27
+ end
28
+
29
+ security do
30
+ token_auth(access_token(client_id, client_secret), inside: :query)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ Client.scope :conferences do
5
+ path { "/conferences" }
6
+ format "json"
7
+
8
+ operation :create do
9
+ option :id, proc(&:to_s), optional: true
10
+ option :topic, proc(&:to_s), optional: true
11
+ option :description, proc(&:to_s), optional: true
12
+ option :owner, proc(&:to_s), optional: true
13
+ option :type, proc(&:to_i), optional: true
14
+ option :schedule, optional: true
15
+ option :allow_guests, optional: true
16
+ option :auto_invite, proc(&:to_i), optional: true
17
+ option :tags, optional: true
18
+ option :max_participants, proc(&:to_i), optional: true
19
+ option :rights, optional: true
20
+ option :url, proc(&:to_s), optional: true
21
+ option :webclient_url, proc(&:to_s), optional: true
22
+ option :state, proc(&:to_s), optional: true
23
+ option :recording, proc(&:to_i), optional: true
24
+
25
+ http_method :post
26
+ body do
27
+ options.slice(:id, :topic, :description, :owner, :type, :schedule, :max_participants,
28
+ :rights, :allow_guests, :auto_invite, :tags, :url, :webclient_url, :state,
29
+ :recording)
30
+ end
31
+
32
+ response(200) { |*res| Entity::Conference.build(*res) }
33
+ response(400, 403, 404) { |*res| Error.build(*res) }
34
+ end
35
+ end
36
+
37
+ Client.scope :by_conference do
38
+ option :conference_id, proc(&:to_s)
39
+ path { "/conferences/#{conference_id}" }
40
+ format "json"
41
+
42
+ operation :get do
43
+ http_method :get
44
+
45
+ response(200) { |*res| Entity::Conference.build(*res) }
46
+ response(403, 404) { |*res| Error.build(*res) }
47
+ end
48
+
49
+ operation :update do
50
+ option :conference_id, proc(&:to_s)
51
+ option :id, proc(&:to_s), optional: true
52
+ option :topic, proc(&:to_s)
53
+ option :description, proc(&:to_s)
54
+ option :owner, proc(&:to_s)
55
+ option :type, proc(&:to_i)
56
+ option :schedule, optional: true
57
+ option :allow_guests, optional: true
58
+ option :auto_invite, proc(&:to_i), optional: true
59
+ option :tags, optional: true
60
+ option :max_participants, proc(&:to_i), optional: true
61
+ option :rights, optional: true
62
+ option :url, proc(&:to_s), optional: true
63
+ option :webclient_url, proc(&:to_s), optional: true
64
+ option :state, proc(&:to_s), optional: true
65
+ option :recording, proc(&:to_i), optional: true
66
+
67
+ http_method :put
68
+ body do
69
+ options.slice(:id, :topic, :description, :owner, :type, :schedule, :max_participants,
70
+ :rights, :allow_guests, :auto_invite, :tags, :url, :webclient_url, :state,
71
+ :recording)
72
+ end
73
+
74
+ response(200) { |*res| Entity::Conference.build(*res) }
75
+ response(400, 403, 404) { |*res| Error.build(*res) }
76
+ end
77
+
78
+ operation :delete do
79
+ http_method :delete
80
+
81
+ response(200) { |*res| Entity::ConferenceSimple.build(*res) }
82
+ response(400, 403, 404) { |*res| Error.build(*res) }
83
+ end
84
+
85
+ operation :run do
86
+ http_method :post
87
+ path { "/run" }
88
+
89
+ response(200) { |*res| Entity::ConferenceSimple.build(*res) }
90
+ response(400, 403, 404) { |*res| Error.build(*res) }
91
+ end
92
+
93
+ operation :stop do
94
+ http_method :post
95
+ path { "/stop" }
96
+
97
+ response(200) { |*res| Entity::ConferenceSimple.build(*res) }
98
+ response(400, 403, 404) { |*res| Error.build(*res) }
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./schedule"
4
+
5
+ module TrueConf
6
+ module Entity
7
+ class Conference < TrueConf::Response
8
+ CONFERENCE_TYPE = {
9
+ symmetric: 0,
10
+ asymmetric: 1,
11
+ role_based: 3
12
+ }.freeze
13
+
14
+ option :id, proc(&:to_s)
15
+ option :topic, proc(&:to_s)
16
+ option :description, proc(&:to_s)
17
+ option :owner, proc(&:to_s)
18
+ option :type, proc(&:to_i)
19
+ option :invitations, method(:Array), optional: true
20
+ option :max_podiums, proc(&:to_i)
21
+ option :max_participants, proc(&:to_i)
22
+ option :schedule, Entity::Schedule
23
+ option :allow_guests
24
+ option :rights
25
+ option :auto_invite, proc(&:to_i)
26
+ option :url, proc(&:to_s)
27
+ option :webclient_url, proc(&:to_s)
28
+ option :state, proc(&:to_s)
29
+ option :tags
30
+ option :recording, proc(&:to_i)
31
+
32
+ %w[running stopped].each do |method|
33
+ define_method("#{method}?") do
34
+ state == method
35
+ end
36
+ end
37
+
38
+ CONFERENCE_TYPE.each do |method_name, value|
39
+ define_method("#{method_name}?") do
40
+ type == value
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Entity
5
+ class ConferenceSimple < TrueConf::Response
6
+ option :id, proc(&:to_s), optional: true
7
+ option :owner, proc(&:to_s), optional: true
8
+ option :state, proc(&:to_s), optional: true
9
+
10
+ %w[running stopped].each do |method|
11
+ define_method("#{method}?") do
12
+ !state.nil? && state == method
13
+ end
14
+ end
15
+
16
+ class << self
17
+ def build(*res)
18
+ body = res.last
19
+ new JSON.parse(body.first)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Entity
5
+ class Invitation < TrueConf::Response
6
+ extend TrueConf::Callable
7
+
8
+ option :id, proc(&:to_s)
9
+ option :uid, proc(&:to_s)
10
+ option :avatar
11
+ option :login_name, proc(&:to_s)
12
+ option :email, proc(&:to_s)
13
+ option :display_name, proc(&:to_s)
14
+ option :first_name, proc(&:to_s)
15
+ option :last_name, proc(&:to_s)
16
+ option :company, proc(&:to_s)
17
+ option :groups, method(:Array)
18
+ option :mobile_phone, proc(&:to_s)
19
+ option :work_phone, proc(&:to_s)
20
+ option :home_phone, proc(&:to_s)
21
+ option :is_active, proc(&:to_i)
22
+ option :status, proc(&:to_i)
23
+ option :is_owner
24
+ option :type, proc(&:to_s)
25
+
26
+ def owner?
27
+ is_owner == 1
28
+ end
29
+
30
+ %w[user custom].each do |method|
31
+ define_method("#{method}?") do
32
+ type == method
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Entity
5
+ class InvitationList < TrueConf::Response
6
+ option :invitations, [Entity::Invitation], as: :data
7
+
8
+ class << self
9
+ def build(*res)
10
+ body = res.last
11
+ new JSON.parse(body.first)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Entity
5
+ class InvitationSimple < TrueConf::Response
6
+ option :id, proc(&:to_s), optional: true
7
+
8
+ class << self
9
+ def build(*res)
10
+ body = res.last
11
+ new JSON.parse(body.first)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Entity
5
+ class Participant < TrueConf::Response
6
+ option :id, proc(&:to_s)
7
+ option :uid, proc(&:to_s), optional: true
8
+ option :avatar, proc(&:to_s), optional: true
9
+ option :login_name, proc(&:to_s), optional: true
10
+ option :email, proc(&:to_s), optional: true
11
+ option :display_name, proc(&:to_s), optional: true
12
+ option :first_name, proc(&:to_s), optional: true
13
+ option :last_name, proc(&:to_s), optional: true
14
+ option :company, proc(&:to_s), optional: true
15
+ option :groups, method(:Array), optional: true
16
+ option :mobile_phone, proc(&:to_s), optional: true
17
+ option :work_phone, proc(&:to_s), optional: true
18
+ option :home_phone, proc(&:to_s), optional: true
19
+ option :is_active, proc(&:to_i), optional: true
20
+ option :status, proc(&:to_i), optional: true
21
+ option :join_time, proc(&:to_i), optional: true
22
+ option :is_owner, optional: true
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Entity
5
+ class Record < TrueConf::Response
6
+ extend TrueConf::Callable
7
+
8
+ option :name, proc(&:to_s)
9
+ option :size, proc(&:to_s)
10
+ option :created, proc(&:to_i)
11
+ option :download_url, proc(&:to_s)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Entity
5
+ class RecordList < TrueConf::Response
6
+ option :records, [Entity::Record], as: :data
7
+
8
+ class << self
9
+ def build(*res)
10
+ body = res.last
11
+ new JSON.parse(body.first)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Entity
5
+ class Schedule
6
+ extend Dry::Initializer
7
+ extend TrueConf::Callable
8
+ include TrueConf::Optional
9
+
10
+ SCHEDULE_TYPE = {
11
+ none: -1,
12
+ weekly: 0,
13
+ one_time: 1
14
+ }.freeze
15
+
16
+ option :type, proc(&:to_i)
17
+ option :start_time, proc(&:to_i), optional: true
18
+ option :duration, proc(&:to_i), optional: true
19
+
20
+ option :days, [proc(&:to_s)], optional: true
21
+ option :time, proc(&:to_s), optional: true
22
+ option :time_offset, proc(&:to_i), optional: true
23
+
24
+ SCHEDULE_TYPE.each do |method_name, value|
25
+ define_method("#{method_name}?") do
26
+ type == value
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Entity
5
+ class User < TrueConf::Response
6
+ extend TrueConf::Callable
7
+
8
+ STATUSES = {
9
+ not_active: -2,
10
+ invalid: -1,
11
+ offline: 0,
12
+ online: 1,
13
+ busy: 2,
14
+ multihost: 3
15
+ }.freeze
16
+
17
+ ACTIVITIES = {
18
+ disabled: 0,
19
+ enabled: 1
20
+ }.freeze
21
+
22
+ option :id, proc(&:to_s)
23
+ option :uid, proc(&:to_s)
24
+ option :avatar
25
+ option :login_name, proc(&:to_s)
26
+ option :email, proc(&:to_s)
27
+ option :display_name, proc(&:to_s)
28
+ option :first_name, proc(&:to_s)
29
+ option :last_name, proc(&:to_s)
30
+ option :company, proc(&:to_s)
31
+ option :groups, method(:Array)
32
+ option :mobile_phone, proc(&:to_s)
33
+ option :work_phone, proc(&:to_s)
34
+ option :home_phone, proc(&:to_s)
35
+ option :is_active, proc(&:to_i)
36
+ option :status, proc(&:to_i)
37
+
38
+ STATUSES.each do |method_name, value|
39
+ define_method("#{method_name}?") do
40
+ status == value
41
+ end
42
+ end
43
+
44
+ ACTIVITIES.each do |method_name, value|
45
+ define_method("#{method_name}?") do
46
+ is_active == value
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Entity
5
+ class UserList < TrueConf::Response
6
+ option :next_page_id, proc(&:to_i), optional: true
7
+ option :users, [Entity::User], as: :data
8
+
9
+ class << self
10
+ def build(*res)
11
+ body = res.last
12
+ new JSON.parse(body.first)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Entity
5
+ class UserSimple < TrueConf::Response
6
+ option :id, proc(&:to_s), optional: true
7
+ option :state, proc(&:to_s), optional: true
8
+
9
+ class << self
10
+ def build(*res)
11
+ body = res.last
12
+ new JSON.parse(body.first)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./error_detail"
4
+
5
+ module TrueConf
6
+ class Error < TrueConf::Response
7
+ extend Dry::Initializer
8
+ extend TrueConf::Callable
9
+ include TrueConf::Optional
10
+
11
+ option :code, proc(&:to_i)
12
+ option :message, proc(&:to_s)
13
+ option :errors, [TrueConf::ErrorDetail], optional: true
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ class ErrorDetail
5
+ extend Dry::Initializer
6
+ extend TrueConf::Callable
7
+ include TrueConf::Optional
8
+
9
+ option :reason, proc(&:to_s)
10
+ option :message, proc(&:to_s)
11
+ option :locationType, proc(&:to_s), optional: true, as: :location_type
12
+ option :location, proc(&:to_s), optional: true
13
+ end
14
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ Client.scope :by_conference do
5
+ scope :invitations do
6
+ path { "/invitations" }
7
+
8
+ operation :all do
9
+ http_method :get
10
+
11
+ response(200) { |*res| Entity::InvitationList.build(*res).data }
12
+ response(403, 404) { |*res| Error.build(*res) }
13
+ end
14
+
15
+ operation :create do
16
+ option :id, proc(&:to_s)
17
+ option :display_name, proc(&:to_s), optional: true
18
+ option :url_type, proc(&:to_s), optional: true
19
+
20
+ http_method :post
21
+ body { options.slice(:id, :display_name, :url_type) }
22
+
23
+ response(200) { |*res| Entity::Invitation.build(*res) }
24
+ response(400, 403, 404) { |*res| Error.build(*res) }
25
+ end
26
+ end
27
+
28
+ scope :by_invitation do
29
+ option :id, proc(&:to_s)
30
+ path { "/invitations/#{id}" }
31
+ format "json"
32
+
33
+ operation :get do
34
+ http_method :get
35
+
36
+ response(200) { |*res| Entity::Invitation.build(*res) }
37
+ response(403, 404) { |*res| Error.build(*res) }
38
+ end
39
+
40
+ operation :update do
41
+ option :display_name, proc(&:to_s), optional: true
42
+ option :url_type, proc(&:to_s), optional: true
43
+
44
+ http_method :put
45
+ body { options.slice(:display_name, :url_type) }
46
+
47
+ response(200) { |*res| Entity::Invitation.build(*res) }
48
+ response(400, 403, 404) { |*res| Error.build(*res) }
49
+ end
50
+
51
+ operation :delete do
52
+ http_method :delete
53
+
54
+ response(200) { |*res| Entity::InvitationSimple.build(*res) }
55
+ response(400, 403, 404) { |*res| Error.build(*res) }
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ module Optional
5
+ private
6
+
7
+ def initialize(opts)
8
+ super opts.each_with_object({}) { |(key, val), obj| obj[key.to_sym] = val }
9
+ end
10
+
11
+ def __options__
12
+ @__options__ ||= self.class.dry_initializer.attributes(self)
13
+ end
14
+
15
+ def respond_to_missing?(name, *)
16
+ __options__.respond_to? name
17
+ end
18
+
19
+ def method_missing(*args, &block)
20
+ respond_to_missing?(*args) ? __options__.send(*args, &block) : super
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ Client.scope :by_conference do
5
+ option :conference_id, proc(&:to_s)
6
+
7
+ scope :participants do
8
+ operation :list do
9
+ http_method :get
10
+ path { "/conferences/#{conference_id}/participants" }
11
+
12
+ response(200) { |*res| Entity::Participant.build(*res) }
13
+ response(403, 404) { |*res| Error.build(*res) }
14
+ end
15
+
16
+ operation :get do
17
+ option :participant_id, proc(&:to_s)
18
+
19
+ http_method :get
20
+ path { "/conferences/#{conference_id}/participants/#{participant_id}" }
21
+
22
+ response(200) { |*res| Entity::Participant.build(*res) }
23
+ response(403, 404) { |*res| Error.build(*res) }
24
+ end
25
+
26
+ operation :invite do
27
+ option :participant_id, proc(&:to_s)
28
+
29
+ http_method :post
30
+ path { "/conferences/#{conference_id}/participants" }
31
+ format "json"
32
+ body { {participant_id: participant_id} }
33
+
34
+ response(200) { |*res| Entity::Participant.build(*res) }
35
+ response(400, 403, 404) { |*res| Error.build(*res) }
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ Client.scope :by_conference do
5
+ scope :records do
6
+ path { "/records" }
7
+ format "json"
8
+
9
+ operation :all do
10
+ option :url_type, proc(&:to_s), optional: true
11
+
12
+ http_method :get
13
+ query { options.slice(:url_type) }
14
+
15
+ response(200) { |*res| Entity::RecordList.build(*res).data }
16
+ response(400, 403) { |*res| Error.build(*res) }
17
+ end
18
+ end
19
+
20
+ scope :by_record do
21
+ option :id, proc(&:to_s)
22
+
23
+ path { "/records/#{id}" }
24
+ format "json"
25
+
26
+ operation :get do
27
+ option :url_type, proc(&:to_s), optional: true
28
+
29
+ http_method :get
30
+ query { options.slice(:url_type) }
31
+
32
+ response(200) { |*res| Entity::Record.build(*res) }
33
+ response(403, 404) { |*res| Error.build(*res) }
34
+ end
35
+
36
+ operation :download do
37
+ path { "/download" }
38
+ option :url_type, proc(&:to_s), optional: true
39
+
40
+ http_method :get
41
+ query { options.slice(:url_type) }
42
+
43
+ response(200) do |_, _, body|
44
+ file = Tempfile.new([File.basename(id, ".*"), File.extname(id)])
45
+ file.write(*body)
46
+ file.close
47
+ file.path
48
+ end
49
+ response(403, 404) { |*res| Error.build(*res) }
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ class Response
5
+ extend Dry::Initializer
6
+
7
+ def error?
8
+ is_a?(TrueConf::Error)
9
+ end
10
+
11
+ def success?
12
+ !error?
13
+ end
14
+
15
+ class << self
16
+ def build(*res)
17
+ body = res.last
18
+ attr = name.split("::").last.downcase
19
+ new JSON.parse(body.first)[attr]
20
+ end
21
+
22
+ def new(opts)
23
+ super opts.each_with_object({}) { |(key, val), obj| obj[key.to_sym] = val }
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ Client.scope :users do
5
+ path { "/users" }
6
+ format "json"
7
+
8
+ operation :all do
9
+ option :url_type, proc(&:to_s), optional: true
10
+ option :page_id, proc(&:to_i), optional: true
11
+ option :page_size, proc(&:to_i), optional: true
12
+ option :login_name, proc(&:to_s), optional: true
13
+ option :display_name, proc(&:to_s), optional: true
14
+ option :first_name, proc(&:to_s), optional: true
15
+ option :last_name, proc(&:to_s), optional: true
16
+ option :email, proc(&:to_s), optional: true
17
+
18
+ http_method :get
19
+ query do
20
+ options.slice(:url_type, :page_id, :page_size, :login_name,
21
+ :display_name, :first_name, :last_name, :email)
22
+ end
23
+
24
+ response(200) { |*res| Entity::UserList.build(*res) }
25
+ response(400, 403) { |*res| Error.build(*res) }
26
+ end
27
+
28
+ operation :create do
29
+ option :login_name, proc(&:to_s)
30
+ option :email, proc(&:to_s)
31
+ option :password, proc(&:to_s)
32
+ option :display_name, proc(&:to_s), optional: true
33
+ option :first_name, proc(&:to_s), optional: true
34
+ option :last_name, proc(&:to_s), optional: true
35
+ option :company, proc(&:to_s), optional: true
36
+ option :mobile_phone, proc(&:to_s), optional: true
37
+ option :work_phone, proc(&:to_s), optional: true
38
+ option :home_phone, proc(&:to_s), optional: true
39
+ option :is_active, proc(&:to_i), optional: true
40
+
41
+ http_method :post
42
+ body do
43
+ options.slice(:login_name, :email, :password, :display_name, :first_name, :last_name,
44
+ :company, :mobile_phone, :work_phone, :home_phone, :is_active)
45
+ end
46
+
47
+ response(200) { |*res| Entity::User.build(*res) }
48
+ response(400, 403) { |*res| Error.build(*res) }
49
+ end
50
+ end
51
+
52
+ Client.scope :by_user do
53
+ option :id, proc(&:to_s)
54
+ path { "/users/#{id}" }
55
+ format "json"
56
+
57
+ operation :get do
58
+ option :url_type, proc(&:to_s), optional: true
59
+
60
+ http_method :get
61
+ query { options.slice(:url_type) }
62
+
63
+ response(200) { |*res| Entity::User.build(*res) }
64
+ response(403, 404) { |*res| Error.build(*res) }
65
+ end
66
+
67
+ operation :update do
68
+ option :url_type, proc(&:to_s), optional: true
69
+ option :email, proc(&:to_s), optional: true
70
+ option :password, proc(&:to_s), optional: true
71
+ option :display_name, proc(&:to_s), optional: true
72
+ option :first_name, proc(&:to_s), optional: true
73
+ option :last_name, proc(&:to_s), optional: true
74
+ option :company, proc(&:to_s), optional: true
75
+ option :mobile_phone, proc(&:to_s), optional: true
76
+ option :work_phone, proc(&:to_s), optional: true
77
+ option :home_phone, proc(&:to_s), optional: true
78
+ option :is_active, proc(&:to_i), optional: true
79
+
80
+ http_method :put
81
+ query { options.slice(:url_type) }
82
+ body do
83
+ options.slice(:login_name, :email, :password, :display_name, :first_name, :last_name,
84
+ :company, :mobile_phone, :work_phone, :home_phone, :is_active)
85
+ end
86
+
87
+ response(200) { |*res| Entity::User.build(*res) }
88
+ response(400, 403, 404) { |*res| Error.build(*res) }
89
+ end
90
+
91
+ operation :delete do
92
+ http_method :delete
93
+
94
+ response(200) { |*res| Entity::UserSimple.build(*res) }
95
+ response(403, 404) { |*res| Error.build(*res) }
96
+ end
97
+
98
+ operation :disconnect do
99
+ http_method :post
100
+ path { "/disconnect" }
101
+
102
+ response(200) { |*res| Entity::UserSimple.build(*res) }
103
+ response(400, 403, 404) { |*res| Error.build(*res) }
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrueConf
4
+ VERSION = "0.1.0"
5
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: true-conf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrey Paderin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-11-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: evil-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.17'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.17'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '13.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '13.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.92.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.92.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.19'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.19'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.5'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.5'
125
+ description:
126
+ email: andy.paderin@gmail.com
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - LICENSE.txt
132
+ - README.md
133
+ - lib/true-conf.rb
134
+ - lib/true-conf/callable.rb
135
+ - lib/true-conf/client.rb
136
+ - lib/true-conf/conference.rb
137
+ - lib/true-conf/entity/conference.rb
138
+ - lib/true-conf/entity/conference_simple.rb
139
+ - lib/true-conf/entity/invitation.rb
140
+ - lib/true-conf/entity/invitation_list.rb
141
+ - lib/true-conf/entity/invitation_simple.rb
142
+ - lib/true-conf/entity/participant.rb
143
+ - lib/true-conf/entity/record.rb
144
+ - lib/true-conf/entity/record_list.rb
145
+ - lib/true-conf/entity/schedule.rb
146
+ - lib/true-conf/entity/user.rb
147
+ - lib/true-conf/entity/user_list.rb
148
+ - lib/true-conf/entity/user_simple.rb
149
+ - lib/true-conf/error.rb
150
+ - lib/true-conf/error_detail.rb
151
+ - lib/true-conf/invitation.rb
152
+ - lib/true-conf/optional.rb
153
+ - lib/true-conf/participant.rb
154
+ - lib/true-conf/record.rb
155
+ - lib/true-conf/response.rb
156
+ - lib/true-conf/user.rb
157
+ - lib/true-conf/version.rb
158
+ homepage: https://github.com/paderinandrey/true-conf
159
+ licenses:
160
+ - MIT
161
+ metadata: {}
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '2.5'
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ requirements: []
177
+ rubygems_version: 3.0.6
178
+ signing_key:
179
+ specification_version: 4
180
+ summary: TrueConf Server API client
181
+ test_files: []