verboice 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/verboice.rb +44 -2
- metadata +5 -5
data/lib/verboice.rb
CHANGED
@@ -12,6 +12,7 @@ require 'net/http'
|
|
12
12
|
require 'json'
|
13
13
|
require 'rest_client'
|
14
14
|
require 'cgi'
|
15
|
+
require 'time'
|
15
16
|
require File.expand_path('../verboice/exception', __FILE__)
|
16
17
|
|
17
18
|
# Provides access to the Verboice Public API.
|
@@ -29,8 +30,12 @@ class Verboice
|
|
29
30
|
}
|
30
31
|
end
|
31
32
|
|
32
|
-
def call address,
|
33
|
-
args = {:
|
33
|
+
def call address, options = {}
|
34
|
+
args = {:address => address}
|
35
|
+
|
36
|
+
args[:channel] = options[:channel] || @default_channel
|
37
|
+
args[:not_before] = options[:not_before].iso8601 if options[:not_before]
|
38
|
+
args[:queue] = options[:queue] if options[:queue]
|
34
39
|
|
35
40
|
if options[:flow]
|
36
41
|
post "/api/call?#{self.class.to_query args}", options[:flow] do |response, error|
|
@@ -66,6 +71,35 @@ class Verboice
|
|
66
71
|
response
|
67
72
|
end
|
68
73
|
end
|
74
|
+
|
75
|
+
def call_queues
|
76
|
+
get_json "/api/call_queues.json"
|
77
|
+
end
|
78
|
+
|
79
|
+
def call_queue(name)
|
80
|
+
get_json "/api/call_queues/#{name}.json"
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_call_queue(call_queue)
|
84
|
+
post "/api/call_queues", call_queue.to_json do |response, error|
|
85
|
+
raise Verboice::Exception.new error.message if error
|
86
|
+
response
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def update_call_queue(name, call_queue)
|
91
|
+
put "/api/call_queues/#{name}", call_queue.to_json do |response, error|
|
92
|
+
raise Verboice::Exception.new error.message if error
|
93
|
+
response
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def delete_call_queue(name)
|
98
|
+
delete "/api/call_queues/#{name}" do |response, error|
|
99
|
+
raise Verboice::Exception.new error.message if error
|
100
|
+
response
|
101
|
+
end
|
102
|
+
end
|
69
103
|
|
70
104
|
private
|
71
105
|
|
@@ -94,6 +128,14 @@ class Verboice
|
|
94
128
|
rescue => ex
|
95
129
|
yield nil, ex
|
96
130
|
end
|
131
|
+
|
132
|
+
def put(path, data)
|
133
|
+
resource = RestClient::Resource.new @url, @options
|
134
|
+
resource = resource[path].put(data)
|
135
|
+
yield resource, nil
|
136
|
+
rescue => ex
|
137
|
+
yield nil, ex
|
138
|
+
end
|
97
139
|
|
98
140
|
def delete(path)
|
99
141
|
resource = RestClient::Resource.new @url, @options
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: verboice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
16
|
-
requirement: &
|
16
|
+
requirement: &70194475148860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70194475148860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70194475147460 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70194475147460
|
36
36
|
description: Access the Verboice API in ruby.
|
37
37
|
email: aromero@manas.com.ar
|
38
38
|
executables: []
|