alucma 1.0.4
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/lib/alucma/client.rb +43 -0
- data/lib/alucma/http.rb +24 -0
- data/lib/alucma.rb +29 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2428ca957935488b539453cc903f87b13e348e3b
|
4
|
+
data.tar.gz: 62b1ad3ef3dd6dd63ffce2f2d3a1e5f4d0ab5d6a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 285a07c0c697b0c9a0643a035ca0465b724779018ef5c2b2c6d6dec7ac665e2a5d45bb3694201bbb91976891a076d5846681dc80731877cbd680c10a94e3853b
|
7
|
+
data.tar.gz: 88a4632e02266ac9f1ce5032234305098e33771c39bf6f38fe65a7008f72bd44e3ce6e1e13c50f32925aa57ee217f2d6206b210119e20fbd8d81673d7af4191b
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Client
|
2
|
+
attr_accessor :headers
|
3
|
+
|
4
|
+
def initialize(args={})
|
5
|
+
self.headers = {
|
6
|
+
"Authorization" => "Bearer #{args["access_token"]}",
|
7
|
+
"Content-Type" => "application/json"
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def make_call(phonenumber,displayname)
|
12
|
+
return Http.post("http://api.foundry.att.net:9001/a1/nca/callcontrol/call/#{phonenumber}", self.headers, {
|
13
|
+
"p1_displayName" => "#{displayname}",
|
14
|
+
"announcement" => "http://www.freshsupercool.com/wp-content/uploads/2015/11/Silent.wav"
|
15
|
+
}.to_json)
|
16
|
+
end
|
17
|
+
|
18
|
+
def subscribe_to_call(session_id,callback_url)
|
19
|
+
return Http.post("http://api.foundry.att.net:9001/a1/nca/interaction/subscribe", self.headers, {
|
20
|
+
"sessionId": session_id,
|
21
|
+
"notifyURL": callback_url,
|
22
|
+
"type": "play"
|
23
|
+
}.to_json)
|
24
|
+
end
|
25
|
+
|
26
|
+
def play_recording_to_call_participant(session_id,party_phonenumber,recording)
|
27
|
+
return Http.post("http://api.foundry.att.net:9001/a1/nca/interaction/play", self.headers, {
|
28
|
+
"sessionId":session_id,
|
29
|
+
"callPartyL": [party_phonenumber],
|
30
|
+
"playURL": recording,
|
31
|
+
"playFormat": "audio"
|
32
|
+
}.to_json)
|
33
|
+
end
|
34
|
+
|
35
|
+
def call_and_ask_numeric_input(phonenumber,displayname,recording,callback_url)
|
36
|
+
resp = make_call(phonenumber,displayname)
|
37
|
+
sleep 6
|
38
|
+
if resp["sessionId"]
|
39
|
+
resp2 = subscribe_to_call(resp["sessionId"],callback_url)
|
40
|
+
resp3 = play_recording_to_call_participant(phonenumber,recording)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/alucma/http.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
class Http
|
2
|
+
def self.post(url, headers, payload)
|
3
|
+
begin
|
4
|
+
uri = URI.parse(url)
|
5
|
+
http = Net::HTTP.new(uri.host,uri.port)
|
6
|
+
|
7
|
+
path = uri.path
|
8
|
+
path = "#{path}?#{uri.query}" if uri.query
|
9
|
+
|
10
|
+
req = Net::HTTP::Post.new(path)
|
11
|
+
req.body = payload
|
12
|
+
|
13
|
+
headers.each do |k,v|
|
14
|
+
req[k] = v
|
15
|
+
end
|
16
|
+
|
17
|
+
res = http.request(req)
|
18
|
+
return res.body
|
19
|
+
rescue => e
|
20
|
+
puts e.to_s
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/alucma.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'alucma/http'
|
4
|
+
require 'alucma/client'
|
5
|
+
|
6
|
+
class ALUCMA
|
7
|
+
def self.init(hash)
|
8
|
+
if !hash.class == "Hash"
|
9
|
+
return { :error => "Invalid input. Input must be a hash." }
|
10
|
+
end
|
11
|
+
|
12
|
+
if !hash[:client_id] || !hash[:client_secret]
|
13
|
+
return { :error => "Missing parameters. Must Client ID and Client Secret" }
|
14
|
+
end
|
15
|
+
|
16
|
+
url = "http://api.foundry.att.net:9001/oauth/client_credential/accesstoken?grant_type=client_credentials"
|
17
|
+
headers = { "Content-Type" => "application/x-www-form-urlencoded" }
|
18
|
+
payload = "client_id=#{hash[:client_id]}&client_secret=#{hash[:client_secret]}"
|
19
|
+
|
20
|
+
resp = Http.post(url,headers,payload)
|
21
|
+
auth = JSON.parse(resp) || {}
|
22
|
+
if auth["status"] == "approved"
|
23
|
+
return Client.new(auth)
|
24
|
+
else
|
25
|
+
return { :error => "OAuth not approved." }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alucma
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pulak Khurana (Nick)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Wrapper for alcatel-lucent call management APIs
|
14
|
+
email: khurananick@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/alucma.rb
|
20
|
+
- lib/alucma/client.rb
|
21
|
+
- lib/alucma/http.rb
|
22
|
+
homepage: https://github.com/khurananick/alucma
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.4.6
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Wrapper for alcatel-lucent call management APIs
|
46
|
+
test_files: []
|