asterisk-ari-client 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +68 -13
- data/.travis.yml +8 -0
- data/README.md +2 -0
- data/Rakefile +7 -0
- data/asterisk-ari-client.gemspec +1 -1
- data/lib/ari/client.rb +3 -1
- data/lib/asterisk/ari/client/version.rb +1 -1
- data/test/fixtures/channel_originate_with_channel_vars.json +144 -0
- data/test/lib/asterisk-ari-client/channel_test.rb +18 -0
- metadata +6 -5
- data/test/lib/asterisk-ari-client/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 913eef1e5760c777527e334f409d67c1750c51e5
|
4
|
+
data.tar.gz: 351129e33ec99c3252593725ede8c71fd0928246
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42c535bf79eff0b97a6477e88dff76de43bc5e5c2bceffff4d553c7ff926365b7e9d434cbf4649a8a72c026da85db4dd43f4a50c874a5f4fd27265e3d3b305f1
|
7
|
+
data.tar.gz: 4bcc3f65c9057cb5f2a9c79c314c1e5e77dfc2be9fa04bc3e1957aed9781e1f96662013cc128122948e2279d8d24d199d9a60b5e60ca39ea4e68217e68245a72
|
data/.gitignore
CHANGED
@@ -1,14 +1,69 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
/pkg/
|
8
|
-
/spec/reports/
|
9
|
-
/tmp/
|
10
|
-
*.bundle
|
11
|
-
*.so
|
1
|
+
# Compiled source #
|
2
|
+
###################
|
3
|
+
*.com
|
4
|
+
*.class
|
5
|
+
*.dll
|
6
|
+
*.exe
|
12
7
|
*.o
|
13
|
-
*.
|
14
|
-
|
8
|
+
*.so
|
9
|
+
|
10
|
+
# Packages #
|
11
|
+
############
|
12
|
+
# it's better to unpack these files and commit the raw source
|
13
|
+
# git has its own built in compression methods
|
14
|
+
*.7z
|
15
|
+
*.dmg
|
16
|
+
*.gz
|
17
|
+
*.iso
|
18
|
+
*.jar
|
19
|
+
*.rar
|
20
|
+
*.tar
|
21
|
+
*.zip
|
22
|
+
|
23
|
+
# Logs and databases #
|
24
|
+
######################
|
25
|
+
*.log
|
26
|
+
*.sql
|
27
|
+
*.sqlite
|
28
|
+
*.sqlite3
|
29
|
+
|
30
|
+
# OS generated files #
|
31
|
+
######################
|
32
|
+
.DS_Store
|
33
|
+
.DS_Store?
|
34
|
+
._*
|
35
|
+
.Spotlight-V100
|
36
|
+
.Trashes
|
37
|
+
ehthumbs.db
|
38
|
+
Thumbs.db
|
39
|
+
|
40
|
+
# Rails
|
41
|
+
*.rbc
|
42
|
+
*.sassc
|
43
|
+
.sass-cache
|
44
|
+
capybara-*.html
|
45
|
+
.rspec
|
46
|
+
/log
|
47
|
+
/tmp
|
48
|
+
/db/*.sqlite3
|
49
|
+
/public/system
|
50
|
+
/coverage/
|
51
|
+
/spec/tmp
|
52
|
+
**.orig
|
53
|
+
rerun.txt
|
54
|
+
pickle-email-*.html
|
55
|
+
config/initializers/secret_token.rb
|
56
|
+
config/secrets.yml
|
57
|
+
|
58
|
+
## Environment normalisation:
|
59
|
+
/.bundle
|
60
|
+
/vendor/bundle
|
61
|
+
|
62
|
+
# these should all be checked in to normalise the environment:
|
63
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
64
|
+
|
65
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
66
|
+
.rvmrc
|
67
|
+
|
68
|
+
pkg/*
|
69
|
+
Gemfile.lock
|
data/.travis.yml
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/asterisk-ari-client.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "vcr", "~> 2.9.3"
|
26
26
|
spec.add_development_dependency "webmock", "~> 1.19.0"
|
27
27
|
|
28
|
-
spec.add_development_dependency "
|
28
|
+
spec.add_development_dependency "activesupport", "~> 4.1.6"
|
29
29
|
|
30
30
|
spec.add_dependency "websocket-client-simple", "~> 0.2.0"
|
31
31
|
spec.add_dependency "event_emitter", "~> 0.2.5"
|
data/lib/ari/client.rb
CHANGED
@@ -16,7 +16,7 @@ module Ari
|
|
16
16
|
}
|
17
17
|
|
18
18
|
HTTP_HEADERS = {
|
19
|
-
'Content-Type' => 'json',
|
19
|
+
'Content-Type' => 'application/json',
|
20
20
|
'Accept' => 'application/json',
|
21
21
|
'Accept-Charset' => 'utf-8',
|
22
22
|
'User-Agent' => "asterisk-ari-client/#{::Asterisk::Ari::Client::VERSION} ruby/#{RUBY_VERSION}"
|
@@ -31,10 +31,12 @@ module Ari
|
|
31
31
|
%w{ get put post delete }.each do |http_method|
|
32
32
|
method_klass = Net::HTTP.const_get http_method.to_s.capitalize
|
33
33
|
define_method http_method do |path, params = {}|
|
34
|
+
request_body = params.delete(:body)
|
34
35
|
params.merge!({ api_key: @options[:api_key], app: @options[:app] })
|
35
36
|
query_string = URI.encode_www_form params
|
36
37
|
request_path = "#{@uri.path}#{path}?#{query_string}"
|
37
38
|
request = method_klass.new request_path, HTTP_HEADERS
|
39
|
+
request.body = request_body.is_a?(Hash) ? MultiJson.dump(request_body) : request_body
|
38
40
|
send_request request
|
39
41
|
end
|
40
42
|
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
{
|
2
|
+
"http_interactions": [
|
3
|
+
{
|
4
|
+
"request": {
|
5
|
+
"method": "post",
|
6
|
+
"uri": "http://192.168.1.23:8088/ari/channels?api_key=asterisk:asterisk&app=dialplan&client=%23%3CAri::Client:0x007fe2092d9d88%3E&endpoint=PJSIP/1ca410-mac&extension=11",
|
7
|
+
"body": {
|
8
|
+
"encoding": "UTF-8",
|
9
|
+
"string": "{\"variables\":{\"my_var\":\"my_value\"}}"
|
10
|
+
},
|
11
|
+
"headers": {
|
12
|
+
"Content-Type": [
|
13
|
+
"application/json"
|
14
|
+
],
|
15
|
+
"Accept": [
|
16
|
+
"application/json"
|
17
|
+
],
|
18
|
+
"Accept-Charset": [
|
19
|
+
"utf-8"
|
20
|
+
],
|
21
|
+
"User-Agent": [
|
22
|
+
"asterisk-ari-client/0.0.1 ruby/2.2.0"
|
23
|
+
],
|
24
|
+
"Accept-Encoding": [
|
25
|
+
"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
|
26
|
+
]
|
27
|
+
}
|
28
|
+
},
|
29
|
+
"response": {
|
30
|
+
"status": {
|
31
|
+
"code": 200,
|
32
|
+
"message": "OK"
|
33
|
+
},
|
34
|
+
"headers": {
|
35
|
+
"Server": [
|
36
|
+
"Asterisk/12.5.0"
|
37
|
+
],
|
38
|
+
"Date": [
|
39
|
+
"Mon, 13 Oct 2014 00:20:01 GMT"
|
40
|
+
],
|
41
|
+
"Connection": [
|
42
|
+
"close"
|
43
|
+
],
|
44
|
+
"Cache-Control": [
|
45
|
+
"no-cache, no-store"
|
46
|
+
],
|
47
|
+
"Content-Type": [
|
48
|
+
"application/json"
|
49
|
+
],
|
50
|
+
"Content-Length": [
|
51
|
+
"299"
|
52
|
+
]
|
53
|
+
},
|
54
|
+
"body": {
|
55
|
+
"encoding": "UTF-8",
|
56
|
+
"string": {
|
57
|
+
"id": "1413159601.264",
|
58
|
+
"state": "Down",
|
59
|
+
"name": "PJSIP/1ca410-mac-00000059",
|
60
|
+
"caller": {
|
61
|
+
"name": "",
|
62
|
+
"number": ""
|
63
|
+
},
|
64
|
+
"connected": {
|
65
|
+
"name": "",
|
66
|
+
"number": ""
|
67
|
+
},
|
68
|
+
"accountcode": "1ca4106c-20b2-11e4-9f50-03cba5fbf325",
|
69
|
+
"dialplan": {
|
70
|
+
"context": "default",
|
71
|
+
"exten": "s",
|
72
|
+
"priority": 1
|
73
|
+
},
|
74
|
+
"creationtime": "2014-10-13T00:20:01.629+0000"
|
75
|
+
}
|
76
|
+
},
|
77
|
+
"http_version": null
|
78
|
+
},
|
79
|
+
"recorded_at": "Wed, 15 Oct 2014 22:33:37 GMT"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"request": {
|
83
|
+
"method": "get",
|
84
|
+
"uri": "http://192.168.1.23:8088/ari/channels/1413159601.264/variable?api_key=asterisk:asterisk&app=dialplan&channelId=1413159601.264&client=%23%3CAri::Client:0x007fe2092d9d88%3E&variable=my_var",
|
85
|
+
"body": {
|
86
|
+
"encoding": "US-ASCII",
|
87
|
+
"string": ""
|
88
|
+
},
|
89
|
+
"headers": {
|
90
|
+
"Content-Type": [
|
91
|
+
"application/json"
|
92
|
+
],
|
93
|
+
"Accept": [
|
94
|
+
"application/json"
|
95
|
+
],
|
96
|
+
"Accept-Charset": [
|
97
|
+
"utf-8"
|
98
|
+
],
|
99
|
+
"User-Agent": [
|
100
|
+
"asterisk-ari-client/0.0.1 ruby/2.2.0"
|
101
|
+
],
|
102
|
+
"Accept-Encoding": [
|
103
|
+
"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
|
104
|
+
]
|
105
|
+
}
|
106
|
+
},
|
107
|
+
"response": {
|
108
|
+
"status": {
|
109
|
+
"code": 200,
|
110
|
+
"message": "OK"
|
111
|
+
},
|
112
|
+
"headers": {
|
113
|
+
"Server": [
|
114
|
+
"Asterisk/12.5.0"
|
115
|
+
],
|
116
|
+
"Date": [
|
117
|
+
"Mon, 13 Oct 2014 00:20:05 GMT"
|
118
|
+
],
|
119
|
+
"Connection": [
|
120
|
+
"close"
|
121
|
+
],
|
122
|
+
"Cache-Control": [
|
123
|
+
"no-cache, no-store"
|
124
|
+
],
|
125
|
+
"Content-Type": [
|
126
|
+
"application/json"
|
127
|
+
],
|
128
|
+
"Content-Length": [
|
129
|
+
"20"
|
130
|
+
]
|
131
|
+
},
|
132
|
+
"body": {
|
133
|
+
"encoding": "UTF-8",
|
134
|
+
"string": {
|
135
|
+
"value": "my_value"
|
136
|
+
}
|
137
|
+
},
|
138
|
+
"http_version": null
|
139
|
+
},
|
140
|
+
"recorded_at": "Wed, 15 Oct 2014 22:33:41 GMT"
|
141
|
+
}
|
142
|
+
],
|
143
|
+
"recorded_with": "VCR 2.9.3"
|
144
|
+
}
|
@@ -56,4 +56,22 @@ class TestChannel < Minitest::Test
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
def test_originate_with_channel_vars
|
60
|
+
VCR.use_cassette 'channel_originate_with_channel_vars' do
|
61
|
+
channel = @client.channels.originate({
|
62
|
+
endpoint: 'PJSIP/1ca410-mac',
|
63
|
+
extension: 11,
|
64
|
+
body: { variables: { my_var: 'my_value' } }
|
65
|
+
})
|
66
|
+
|
67
|
+
assert_kind_of Ari::Channel, channel
|
68
|
+
|
69
|
+
# TODO here channel needs to be in Stasis app (answered)
|
70
|
+
|
71
|
+
channel_var = channel.get_channel_var variable: 'my_var'
|
72
|
+
|
73
|
+
assert_equal 'my_value', channel_var.value
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
59
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asterisk-ari-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Svoboda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.19.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: activesupport
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
@@ -130,6 +130,7 @@ extensions: []
|
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
132
|
- ".gitignore"
|
133
|
+
- ".travis.yml"
|
133
134
|
- Gemfile
|
134
135
|
- LICENSE.txt
|
135
136
|
- README.md
|
@@ -221,9 +222,9 @@ files:
|
|
221
222
|
- test/fixtures/bridges_list.json
|
222
223
|
- test/fixtures/channel_get.json
|
223
224
|
- test/fixtures/channel_originate.json
|
225
|
+
- test/fixtures/channel_originate_with_channel_vars.json
|
224
226
|
- test/fixtures/channel_originate_with_id.json
|
225
227
|
- test/fixtures/channels_list.json
|
226
|
-
- test/lib/asterisk-ari-client/.DS_Store
|
227
228
|
- test/lib/asterisk-ari-client/bridge_test.rb
|
228
229
|
- test/lib/asterisk-ari-client/channel_test.rb
|
229
230
|
- test/test_helper.rb
|
@@ -257,9 +258,9 @@ test_files:
|
|
257
258
|
- test/fixtures/bridges_list.json
|
258
259
|
- test/fixtures/channel_get.json
|
259
260
|
- test/fixtures/channel_originate.json
|
261
|
+
- test/fixtures/channel_originate_with_channel_vars.json
|
260
262
|
- test/fixtures/channel_originate_with_id.json
|
261
263
|
- test/fixtures/channels_list.json
|
262
|
-
- test/lib/asterisk-ari-client/.DS_Store
|
263
264
|
- test/lib/asterisk-ari-client/bridge_test.rb
|
264
265
|
- test/lib/asterisk-ari-client/channel_test.rb
|
265
266
|
- test/test_helper.rb
|
Binary file
|