readytalk 0.6.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.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +117 -0
- data/lib/readytalk.rb +36 -0
- data/lib/readytalk/account.rb +19 -0
- data/lib/readytalk/error.rb +18 -0
- data/lib/readytalk/list.rb +48 -0
- data/lib/readytalk/meeting.rb +64 -0
- data/lib/readytalk/object.rb +64 -0
- data/lib/readytalk/operations.rb +36 -0
- data/lib/readytalk/railtie.rb +8 -0
- data/lib/readytalk/recording.rb +25 -0
- data/lib/readytalk/util.rb +86 -0
- data/readytalk.gemspec +16 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b99b09a6d1d970fa24632e49608045c9202e5386
|
4
|
+
data.tar.gz: c282affb91f6f6ec5b736358e10dd39521f3380f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ffc13e91140e1b17b27acc311d83617b7fd8af54404699fc0e5482900402d6ed2b47ff78ef9035dbe8620ba6e0540917b0fb1063e18079df3e9a7d337ed6f1c9
|
7
|
+
data.tar.gz: 1f9ce897181e879b0a64470c1af8322653da5b10806346b2993a9f8a14bc31d69ab9d7449155245772ba70965723a1b7099bab9b5a32f6efe626953bfba0f01c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 ellevate
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
# ReadyTalk
|
2
|
+
A Ruby wrapper for the ReadyTalk API. It provides a set of
|
3
|
+
classes that map to API endpoints and data structures.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
Include this line to your application's Gemfile:
|
7
|
+
```
|
8
|
+
gem 'readytalk'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
```
|
13
|
+
$ bundle install
|
14
|
+
```
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
```
|
18
|
+
$ gem install readytalk
|
19
|
+
```
|
20
|
+
|
21
|
+
## Documentation
|
22
|
+
[ReadyTalk API Docs](https://cc.readytalk.com/api/1.3/rest)
|
23
|
+
|
24
|
+
## Configuration
|
25
|
+
If you are using Rails, the readytalk gem can be configured in an initializer or
|
26
|
+
environment file.
|
27
|
+
|
28
|
+
Configuration options can be passed as a block or set as a Hash.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
ReadyTalk.configure do |config|
|
32
|
+
config.tollfree = 0000000000 # your toll free number
|
33
|
+
config.accesscode = 1212121 # your access code
|
34
|
+
config.passcode = 1234 # your passcode
|
35
|
+
config.test_mode = true # if true, operate in sandbox mode: https://apidev-cc.readytalk.com
|
36
|
+
end
|
37
|
+
```
|
38
|
+
Outside the Rails environment configuration options can be set directly on the
|
39
|
+
`ReadyTalk` module.
|
40
|
+
```ruby
|
41
|
+
ReadyTalk.config.tollfree = 0000000000
|
42
|
+
ReadyTalk.config.accesscode = 1212121
|
43
|
+
ReadyTalk.config.passcode = 1234
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
## Usage
|
48
|
+
All ReadyTalk API endpoints have an equivalent method call. Consult API documentation
|
49
|
+
for list of required and optional input parameters.
|
50
|
+
|
51
|
+
* `ReadyTalk::Account`
|
52
|
+
* `self.get_option(option_name)` - [Get Account Option](https://cc.readytalk.com/api/1.3/rest#AccountService-getAccountOption)
|
53
|
+
* `self.list_international_numbers()` - [List International Numbers](https://cc.readytalk.com/api/1.3/rest#AccountService-listInternationalNumbers)
|
54
|
+
* `self.list_questions(input_params)` - [List Poll Questions](https://cc.readytalk.com/api/1.3/rest#RegistrationService-listPollQuestions)
|
55
|
+
|
56
|
+
* `ReadyTalk::Meeting`
|
57
|
+
* `self.create(input_params)` - [Create Meetings](https://cc.readytalk.com/api/1.3/rest#MeetingService-createMeeting)
|
58
|
+
* `self.list(input_params)` - [List Meetings](https://cc.readytalk.com/api/1.3/rest#MeetingService-listMeetings)
|
59
|
+
* `self.details(id)` - [Meeting Details](https://cc.readytalk.com/api/1.3/rest#MeetingService-meetingDetails)
|
60
|
+
* `details()` - [Meeting Details](https://cc.readytalk.com/api/1.3/rest#MeetingService-meetingDetails)
|
61
|
+
* `cancel(input_params)` - [Cancel Meeting](https://cc.readytalk.com/api/1.3/rest#MeetingService-cancelMeeting)
|
62
|
+
* `update(input_params)` - [Update Meeting](https://cc.readytalk.com/api/1.3/rest#MeetingService-updateMeeting)
|
63
|
+
* `create_registration(input_params)` - [Create Registration](https://cc.readytalk.com/api/1.3/rest#RegistrationService-createRegistration)
|
64
|
+
* `create_invitations(input_params)` - [Create Invitations](https://cc.readytalk.com/api/1.3/rest#RegistrationService-createInvitations)
|
65
|
+
* `list_registrations(input_params)` - [List Registrations](https://cc.readytalk.com/api/1.3/rest#RegistrationService-listRegistrations)
|
66
|
+
* `list_surveys(input_params)` - [List Post Event Surveys](https://cc.readytalk.com/api/1.3/rest#RegistrationService-listPostEventSurveys)
|
67
|
+
* `list_chats()` - [List Chats](https://cc.readytalk.com/api/1.3/rest#ChatService-listChats)
|
68
|
+
|
69
|
+
* `ReadyTalk::Recording`
|
70
|
+
* `self.list(input_params)` - [List Recordings](https://cc.readytalk.com/api/1.3/rest#RecordingService-listRecordings)
|
71
|
+
* `self.details(id, input_params)` - [Recording Details](https://cc.readytalk.com/api/1.3/rest#RecordingService-recordingDetails)
|
72
|
+
* `details(input_params)` - [Recording Details](https://cc.readytalk.com/api/1.3/rest#RecordingService-recordingDetails)
|
73
|
+
* `list_registrations(input_params)` - [List Recording Registrations](https://cc.readytalk.com/api/1.3/rest#RecordingRegistrationService-listRegistrations)
|
74
|
+
|
75
|
+
An example API call might resemble the following:
|
76
|
+
```ruby
|
77
|
+
ReadyTalk::Meeting.create(
|
78
|
+
title: 'Test Meeting',
|
79
|
+
host_name: 'Stevie Tester',
|
80
|
+
from_email: 'sevetester@example.com',
|
81
|
+
start_date_iso8601: '2016-01-30T08:00:00-05:00',
|
82
|
+
duration_in_seconds: '3600',
|
83
|
+
time_zone: 'EST',
|
84
|
+
registration: 'PRE_REG_AUTOMATIC_CONFIRMATION_NO_NOTIFICATION',
|
85
|
+
type: 'WEB_AND_AUDIO',
|
86
|
+
audio: {on_demand: 'DISPLAY_TOLLFREE_DISPLAY_TOLL'}
|
87
|
+
)
|
88
|
+
```
|
89
|
+
|
90
|
+
The documented [API Data Types](https://cc.readytalk.com/api/1.3/rest#data-types)
|
91
|
+
have equivalent `ReadyTalk` namespaced classes. All attributes are accessible via
|
92
|
+
method calls.
|
93
|
+
|
94
|
+
```
|
95
|
+
> meeting = ReadyTalk::Meeting.details(012345)
|
96
|
+
=> #<ReadyTalk::Meeting @data={"id"=>"012345"...}>
|
97
|
+
> meeting.id
|
98
|
+
=> 012345
|
99
|
+
> meeting.meeting_details
|
100
|
+
=> #<ReadyTalk::MeetingDetails @data={"meetingType"=>"WEB_AND_AUDIO"...}>
|
101
|
+
> meeting.meeting_details.meeting_type
|
102
|
+
=> "WEB_AND_AUDIO"
|
103
|
+
```
|
104
|
+
|
105
|
+
API list endpoints return `ReadyTalk::ReadyTalkList` objects, which respond
|
106
|
+
to `[]`, `first`, `last`, `size`, `each`, and `empty?`.
|
107
|
+
|
108
|
+
Any additional attributes returned by a list endpoint, such as `paging_criteria`,
|
109
|
+
are also available via method calls on the list object.
|
110
|
+
|
111
|
+
## Handling Errors
|
112
|
+
Errors returned by the API are raised as `ReadyTalk::ReadyTalkError`. It is possible
|
113
|
+
for multiple errors to be returned for a given request. raw API errors are accessible
|
114
|
+
via the `errors` method on `ReadyTalk::ReadyTalkError`.
|
115
|
+
|
116
|
+
Additionally, the `full_messages` method will return an Array containing the messages
|
117
|
+
for each error.
|
data/lib/readytalk.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'json'
|
3
|
+
require 'rest-client'
|
4
|
+
|
5
|
+
require 'readytalk/railtie'
|
6
|
+
require 'readytalk/operations'
|
7
|
+
require 'readytalk/util'
|
8
|
+
require 'readytalk/object'
|
9
|
+
require 'readytalk/list'
|
10
|
+
|
11
|
+
require 'readytalk/account'
|
12
|
+
require 'readytalk/error'
|
13
|
+
require 'readytalk/meeting'
|
14
|
+
require 'readytalk/recording'
|
15
|
+
|
16
|
+
|
17
|
+
module ReadyTalk
|
18
|
+
if defined?(Rails)
|
19
|
+
def self.configure(&block)
|
20
|
+
if block_given?
|
21
|
+
block.call(ReadyTalk::Railtie.config.readytalk)
|
22
|
+
else
|
23
|
+
ReadyTalk::Railtie.config.readytalk
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.config
|
28
|
+
ReadyTalk::Railtie.config.readytalk
|
29
|
+
end
|
30
|
+
else
|
31
|
+
def self.config
|
32
|
+
@@config ||= OpenStruct.new
|
33
|
+
@@config
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ReadyTalk
|
2
|
+
class Account < ReadyTalkObject
|
3
|
+
|
4
|
+
def self.get_option(option_name)
|
5
|
+
response = request(:get, "/accounts/option/#{option_name}", :get_account_option)
|
6
|
+
Util.new_helper_object(response, :option)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.list_international_numbers
|
10
|
+
response = request(:get, '/accounts/internationalNumbers', :list_international_numbers)
|
11
|
+
Util.new_list_object(response, :international_number)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.list_questions(opts = {})
|
15
|
+
response = request(:get, '/registrations/pollQuestions', opts, :list_poll_questions)
|
16
|
+
Util.new_list_object(response, :poll_question, :paging_criteria)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ReadyTalk
|
2
|
+
class ReadyTalkError < StandardError
|
3
|
+
attr_reader :errors
|
4
|
+
|
5
|
+
def initialize(errors_data = {})
|
6
|
+
@errors = errors_data['error'] || []
|
7
|
+
end
|
8
|
+
|
9
|
+
def full_messages
|
10
|
+
@errors.map { |e| e['message'] }
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
"#{@errors.size} error(s): #{@errors.map { |e| "#{e['code']}: #{e['message']}" }}"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module ReadyTalk
|
2
|
+
class ReadyTalkList
|
3
|
+
def initialize(data, list_key, klass, data_keys = nil)
|
4
|
+
@klass = klass
|
5
|
+
@list_data = data[ReadyTalk::Util.camelize(list_key)] || []
|
6
|
+
@list_data = @list_data.map { |d| klass.new(d) }
|
7
|
+
|
8
|
+
unless data_keys.nil?
|
9
|
+
data_keys.each do |key|
|
10
|
+
key_data = data[ReadyTalk::Util.camelize(key)]
|
11
|
+
if key_data.is_a?(Hash)
|
12
|
+
key_data = ReadyTalk::Util.new_helper_object(data, key)
|
13
|
+
end
|
14
|
+
|
15
|
+
self.class.send(:attr_reader, key)
|
16
|
+
self.instance_variable_set("@#{key.to_s}", key_data)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def [](value)
|
22
|
+
@list_data[value]
|
23
|
+
end
|
24
|
+
|
25
|
+
def first(*args)
|
26
|
+
@list_data.send(:first, *args)
|
27
|
+
end
|
28
|
+
|
29
|
+
def last(*args)
|
30
|
+
@list_data.send(:last, *args)
|
31
|
+
end
|
32
|
+
|
33
|
+
def size
|
34
|
+
@list_data.size
|
35
|
+
end
|
36
|
+
|
37
|
+
def each(&block)
|
38
|
+
@list_data.each(&block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def empty?
|
42
|
+
@list_data.empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
alias_method :count, :size
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module ReadyTalk
|
2
|
+
class Meeting < ReadyTalkObject
|
3
|
+
|
4
|
+
def self.create(opts = {})
|
5
|
+
response = request(:post, '/meetings', opts, :create_meeting)
|
6
|
+
self.new(response, :meeting)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.list(opts = {})
|
10
|
+
response = request(:get, '/meetings', opts, :list_meetings)
|
11
|
+
Util.new_list_object(response, :meeting, :paging_criteria)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.details(id)
|
15
|
+
response = request(:get, "/meetings/#{id}", :meeting_details)
|
16
|
+
self.new(response, :meeting)
|
17
|
+
end
|
18
|
+
|
19
|
+
def details
|
20
|
+
self.class.details(self.id)
|
21
|
+
end
|
22
|
+
|
23
|
+
def cancel(opts = {})
|
24
|
+
response = request(:delete, "/meetings/#{id}", opts, :cancel_meeting)
|
25
|
+
Util.parameterize_hash(response)
|
26
|
+
end
|
27
|
+
|
28
|
+
def update(opts = {})
|
29
|
+
response = request(:put, "/meetings/#{id}", opts, :update_meeting)
|
30
|
+
update_data(response, :meeting)
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_registration(opts = {})
|
34
|
+
opts = opts.merge(meeting_id: self.id)
|
35
|
+
response = request(:post, '/registrations', opts, :create_registration)
|
36
|
+
Util.new_helper_object(response, :registration)
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_invitations(opts = {})
|
40
|
+
opts = opts.merge(meeting_id: self.id)
|
41
|
+
opts[:email] = opts.fetch(:email, []).join(',')
|
42
|
+
response = request(:post, '/invites', opts, :create_invitations)
|
43
|
+
Util.new_list_object(response, :invite, :opt_out_email)
|
44
|
+
end
|
45
|
+
|
46
|
+
def list_registrations(opts = {})
|
47
|
+
opts = opts.merge(meeting_id: self.id)
|
48
|
+
response = request(:get, '/registrations', opts, :list_registrations)
|
49
|
+
Util.new_list_object(response, :registration, :paging_criteria)
|
50
|
+
end
|
51
|
+
|
52
|
+
def list_surveys(opts = {})
|
53
|
+
opts = opts.merge(meeting_id: self.id)
|
54
|
+
response = request(:get, '/registrations/surveys', opts, :list_post_event_surveys)
|
55
|
+
Util.new_list_object(response, :survey, :paging_criteria, :custom_link)
|
56
|
+
end
|
57
|
+
|
58
|
+
def list_chats
|
59
|
+
response = request(:get, '/chats', {id: self.id}, :list_chats)
|
60
|
+
Util.new_list_object(response, :chat)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module ReadyTalk
|
2
|
+
class ReadyTalkObject
|
3
|
+
|
4
|
+
def initialize(data, object_key = nil)
|
5
|
+
if object_key.nil?
|
6
|
+
@data = data
|
7
|
+
else
|
8
|
+
@data = data[Util.camelize(object_key)]
|
9
|
+
end
|
10
|
+
|
11
|
+
unless @data.nil?
|
12
|
+
@data.each do |key, _value|
|
13
|
+
name = Util.parameterize(key)
|
14
|
+
self.class.send(:define_method, "#{name}") do
|
15
|
+
value = @data[key]
|
16
|
+
case value
|
17
|
+
when Array
|
18
|
+
value = Util.new_list_object({key => value}, key)
|
19
|
+
@data[key] = value
|
20
|
+
when Hash
|
21
|
+
value = Util.new_helper_object({key => value}, key)
|
22
|
+
@data[key] = value
|
23
|
+
end
|
24
|
+
|
25
|
+
value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
def update_data(data, object_key = nil)
|
33
|
+
if object_key.nil?
|
34
|
+
@data = data
|
35
|
+
else
|
36
|
+
@data = data[Util.camelize(object_key)]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def request(*args)
|
41
|
+
self.class.request(*args)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.request(*args)
|
45
|
+
verb = args.first
|
46
|
+
path = args[1]
|
47
|
+
end_point = args.last
|
48
|
+
opts = args.size == 4 ? args[2] : {}
|
49
|
+
|
50
|
+
opts = Util.format_hash(opts)
|
51
|
+
end_point = Util.camelize(end_point)
|
52
|
+
|
53
|
+
begin
|
54
|
+
response = Operations.request(verb, path, opts)
|
55
|
+
JSON.parse(response)["#{end_point}Result"]
|
56
|
+
rescue => e
|
57
|
+
response = e.response
|
58
|
+
error_data = JSON.parse(response)['errorsResult']
|
59
|
+
raise ReadyTalkError.new(error_data)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module ReadyTalk
|
2
|
+
module Operations
|
3
|
+
|
4
|
+
def self.request(verb, path, params)
|
5
|
+
opts = {
|
6
|
+
method: verb,
|
7
|
+
url: url(path),
|
8
|
+
headers: {
|
9
|
+
Authorization: authorization
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
case verb
|
14
|
+
when :post
|
15
|
+
opts[:payload] = params
|
16
|
+
else
|
17
|
+
opts[:headers][:params] = params
|
18
|
+
end
|
19
|
+
|
20
|
+
RestClient::Request.execute(opts)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def self.url(path)
|
25
|
+
domain = ReadyTalk.config.test_mode ? 'apidev-cc.readytalk.com' : 'cc.readytalk.com'
|
26
|
+
"https://#{domain}/api/1.3/svc/rs#{path}.json"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.authorization
|
30
|
+
config = ReadyTalk.config
|
31
|
+
credentials = "#{config.tollfree}:#{config.accesscode}:#{config.passcode}"
|
32
|
+
encoded_credentials = Base64.strict_encode64(credentials)
|
33
|
+
"Basic #{encoded_credentials}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ReadyTalk
|
2
|
+
class Recording < ReadyTalkObject
|
3
|
+
|
4
|
+
def self.list(opts = {})
|
5
|
+
response = request(:get, '/recordings', opts, :list_recordings)
|
6
|
+
ReadyTalk::Util.new_list_object(response, :recording, :paging_criteria)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.details(id, opts = {})
|
10
|
+
response = request(:get, "/recordings/#{id}", opts, :recording_details)
|
11
|
+
self.new(response, :recording)
|
12
|
+
end
|
13
|
+
|
14
|
+
def details(opts = {})
|
15
|
+
self.class.details(self.id, opts)
|
16
|
+
end
|
17
|
+
|
18
|
+
def list_registrations(opts = {})
|
19
|
+
opts = opts.merge(recording_id: self.id)
|
20
|
+
response = request(:get, '/recording/registrations', opts, :list_registrations)
|
21
|
+
ReadyTalk::Util.new_list_object(response, :registration, :paging_criteria)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module ReadyTalk
|
2
|
+
module Util
|
3
|
+
|
4
|
+
def self.format_hash(hash)
|
5
|
+
return {} if hash.nil?
|
6
|
+
rv = {}
|
7
|
+
hash.each do |k, v|
|
8
|
+
if v.is_a?(Hash)
|
9
|
+
nested = format_hash(v)
|
10
|
+
nested.each { |kn, vn| rv["#{camelize(k)}.#{kn}"] = vn }
|
11
|
+
else
|
12
|
+
rv[camelize(k)] = v
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
return rv
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.camelize_hash(hash)
|
20
|
+
return {} if hash.nil?
|
21
|
+
|
22
|
+
Hash[hash.map { |k, v| [camelize(k), v] }]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.parameterize_hash(hash)
|
26
|
+
return {} if hash.nil?
|
27
|
+
|
28
|
+
Hash[hash.map { |k, v| [parameterize(k), v] }]
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.parameterize(key)
|
32
|
+
str = key.to_s
|
33
|
+
return str if str.include?('_')
|
34
|
+
|
35
|
+
str.gsub(/([A-Z])/) { "_#{$1.downcase}" }
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.camelize(key)
|
39
|
+
str = key.to_s
|
40
|
+
return str unless str.include?('_')
|
41
|
+
|
42
|
+
str.downcase.gsub!(/(?:_|(\/))([a-z\d]*)/) { $2.capitalize }
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.create_helper_object(name, *args)
|
46
|
+
klass = Class.new(ReadyTalkObject)
|
47
|
+
Object.const_set(name, klass)
|
48
|
+
klass.send(:new, *args)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.new_helper_object(data, object_key)
|
52
|
+
klass = get_object_class(object_key)
|
53
|
+
klass.send(:new, data, object_key)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.new_list_object(data, list_key, *data_keys)
|
57
|
+
klass = get_object_class(list_key)
|
58
|
+
ReadyTalkList.new(data, list_key, klass, data_keys)
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
def self.get_object_class(key)
|
63
|
+
@@object_classes ||= {
|
64
|
+
recording: Recording,
|
65
|
+
meeting: Meeting
|
66
|
+
}
|
67
|
+
klass = @@object_classes[key]
|
68
|
+
if klass.nil?
|
69
|
+
klass = create_object_class(key)
|
70
|
+
@@object_classes[key] = klass
|
71
|
+
end
|
72
|
+
|
73
|
+
return klass
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.create_object_class(key)
|
77
|
+
name = camelize(key)
|
78
|
+
name = "#{name[0].upcase}#{name[1..-1]}"
|
79
|
+
klass = Class.new(ReadyTalkObject)
|
80
|
+
|
81
|
+
ReadyTalk.const_set(name, klass)
|
82
|
+
return klass
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
data/readytalk.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'readytalk'
|
3
|
+
s.version = '0.6.0'
|
4
|
+
s.date = '2016-01-19'
|
5
|
+
s.summary = "Ruby binding for the ReadyTalk API"
|
6
|
+
s.description = "Ruby binding for the ReadyTalk - A web conferencing platform."
|
7
|
+
s.authors = ["Mike Pogran"]
|
8
|
+
s.email = ['mike@ellevatenetwork.com']
|
9
|
+
s.license = 'MIT'
|
10
|
+
s.homepage = 'https://github.com/ellevate/readytalk'
|
11
|
+
|
12
|
+
s.add_dependency('rest-client', '~> 1.4')
|
13
|
+
s.add_dependency('json', '~> 1.8')
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: readytalk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Pogran
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
description: Ruby binding for the ReadyTalk - A web conferencing platform.
|
42
|
+
email:
|
43
|
+
- mike@ellevatenetwork.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- lib/readytalk.rb
|
53
|
+
- lib/readytalk/account.rb
|
54
|
+
- lib/readytalk/error.rb
|
55
|
+
- lib/readytalk/list.rb
|
56
|
+
- lib/readytalk/meeting.rb
|
57
|
+
- lib/readytalk/object.rb
|
58
|
+
- lib/readytalk/operations.rb
|
59
|
+
- lib/readytalk/railtie.rb
|
60
|
+
- lib/readytalk/recording.rb
|
61
|
+
- lib/readytalk/util.rb
|
62
|
+
- readytalk.gemspec
|
63
|
+
homepage: https://github.com/ellevate/readytalk
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.4.6
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Ruby binding for the ReadyTalk API
|
87
|
+
test_files: []
|