twilreapi-active_call_router-unicef_io 0.1.1
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 +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +11 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/twilreapi/active_call_router/unicef_io.rb +10 -0
- data/lib/twilreapi/active_call_router/unicef_io/call_router.rb +99 -0
- data/lib/twilreapi/active_call_router/unicef_io/torasup.rb +2 -0
- data/lib/twilreapi/active_call_router/unicef_io/torasup/configuration.rb +3 -0
- data/lib/twilreapi/active_call_router/unicef_io/torasup/data/unicef_io.yml +42 -0
- data/lib/twilreapi/active_call_router/unicef_io/version.rb +7 -0
- data/twilreapi-active_call_router-unicef_io.gemspec +27 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0e8460fa29bdedc5a35235bcb5176e323a40eb685a4c0ff0eff10cc9fa71b6f9
|
4
|
+
data.tar.gz: 3967c74c095e299598a20aeaacb00f27dbcee8e70a1b38f9f9a101ce111112db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3cdea464b771ef4914d77ca1bad59b256619856f2501a3616678171d5df0fdfcc8e8370f0dd68a38a79c9cca3647905140ab9b27bf46f4782abdaa9aed0e328e
|
7
|
+
data.tar.gz: 7569d82528bad5aea338e9eaf49d102da0228b412b1f67f35b2c1bac105a5bb8f0ac4c548b2ee8fdd520af12b963d8aaa9a6c585c10ac7b5b83e030fffd6f6f8
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) do |repo_name|
|
4
|
+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
5
|
+
"https://github.com/#{repo_name}.git"
|
6
|
+
end
|
7
|
+
|
8
|
+
# Specify your gem's dependencies in twilreapi-active_call_router-pin_cambodia.gemspec
|
9
|
+
|
10
|
+
gem "twilreapi-active_call_router", github: "dwilkie/twilreapi-active_call_router"
|
11
|
+
|
12
|
+
gemspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 David Wilkie
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Twilreapi::ActiveCallRouter::PinCambodia
|
2
|
+
|
3
|
+
[](https://travis-ci.org/somleng/twilreapi-active_call_router-unicef_io)
|
4
|
+
|
5
|
+
This gem contains call routing logic for [somleng.unicef.io](https://somleng.unicef.io) for [Twilreapi.](https://github.com/somleng/twilreapi)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'twilreapi-active_call_router-unicef_io', :github => "somleng/twilreapi-active_call_router-unicef_io"
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
## Configuration
|
20
|
+
|
21
|
+
To configure [Twilreapi](https://github.com/somleng/twilreapi) to use `Twilreapi::ActiveBiller::UnicefIO::CallRouter`, set the environment variable `ACTIVE_CALL_ROUTER_CLASS_NAME=Twilreapi::ActiveCallRouter::UnicefIO::CallRouter`
|
22
|
+
|
23
|
+
The following environment variables can be set to determine the call routing logic:
|
24
|
+
|
25
|
+
* `TWILREAPI_ACTIVE_CALL_ROUTER_UNICEF_IO_DEFAULT_CALLER_ID`
|
26
|
+
* Set this value to override the caller id
|
27
|
+
|
28
|
+
## Development
|
29
|
+
|
30
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
|
+
|
32
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/somleng/twilreapi-active_call_router-unicef_io.
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "twilreapi/active_call_router/unicef_io"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
require "twilreapi/active_call_router/base"
|
2
|
+
require_relative "torasup"
|
3
|
+
|
4
|
+
class Twilreapi::ActiveCallRouter::UnicefIO::CallRouter < Twilreapi::ActiveCallRouter::Base
|
5
|
+
attr_accessor :gateway, :caller_id
|
6
|
+
|
7
|
+
def routing_instructions
|
8
|
+
@routing_instructions ||= generate_routing_instructions
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def phone_call
|
14
|
+
options[:phone_call]
|
15
|
+
end
|
16
|
+
|
17
|
+
def source
|
18
|
+
phone_call.from
|
19
|
+
end
|
20
|
+
|
21
|
+
def destination
|
22
|
+
phone_call.to
|
23
|
+
end
|
24
|
+
|
25
|
+
def generate_routing_instructions
|
26
|
+
set_routing_variables
|
27
|
+
gateway_configuration = gateway || fallback_gateway || {}
|
28
|
+
gateway_name = gateway_configuration["name"]
|
29
|
+
gateway_host = gateway_configuration["host"]
|
30
|
+
address = normalized_destination
|
31
|
+
if gateway_configuration["prefix"] == false
|
32
|
+
address = Phony.format(
|
33
|
+
address,
|
34
|
+
format: :national,
|
35
|
+
spaces: ""
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
if gateway_name
|
40
|
+
dial_string_path = "gateway/#{gateway_name}/#{address}"
|
41
|
+
elsif gateway_host
|
42
|
+
dial_string_path = "external/#{address}@#{gateway_host}"
|
43
|
+
end
|
44
|
+
|
45
|
+
routing_instructions = {
|
46
|
+
"source" => caller_id,
|
47
|
+
"destination" => normalized_destination
|
48
|
+
}
|
49
|
+
|
50
|
+
if dial_string_path
|
51
|
+
routing_instructions["dial_string_path"] = dial_string_path
|
52
|
+
else
|
53
|
+
routing_instructions["disable_originate"] = "1"
|
54
|
+
end
|
55
|
+
|
56
|
+
routing_instructions
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_routing_variables
|
60
|
+
self.caller_id = default_caller_id || source
|
61
|
+
self.gateway = default_gateway
|
62
|
+
end
|
63
|
+
|
64
|
+
def fallback_gateway
|
65
|
+
gateways["fallback"] || other_gateways.first
|
66
|
+
end
|
67
|
+
|
68
|
+
def default_gateway
|
69
|
+
gateways["default"]
|
70
|
+
end
|
71
|
+
|
72
|
+
def other_gateways
|
73
|
+
gateways["others"] || []
|
74
|
+
end
|
75
|
+
|
76
|
+
def gateways
|
77
|
+
operator.gateways || {}
|
78
|
+
end
|
79
|
+
|
80
|
+
def operator
|
81
|
+
destination_torasup_number.operator
|
82
|
+
end
|
83
|
+
|
84
|
+
def destination_torasup_number
|
85
|
+
@destination_torasup_number ||= Torasup::PhoneNumber.new(normalized_destination)
|
86
|
+
end
|
87
|
+
|
88
|
+
def normalized_destination
|
89
|
+
@normalized_destination ||= Phony.normalize(destination)
|
90
|
+
end
|
91
|
+
|
92
|
+
def default_caller_id
|
93
|
+
self.class.configuration("default_caller_id")
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.configuration(key)
|
97
|
+
ENV["TWILREAPI_ACTIVE_CALL_ROUTER_UNICEF_IO_#{key.to_s.upcase}"]
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
so:
|
2
|
+
operators:
|
3
|
+
telesom:
|
4
|
+
metadata:
|
5
|
+
gateways:
|
6
|
+
default:
|
7
|
+
host: "196.201.207.191"
|
8
|
+
golis:
|
9
|
+
metadata:
|
10
|
+
gateways:
|
11
|
+
default:
|
12
|
+
host: "196.201.207.191"
|
13
|
+
nationlink:
|
14
|
+
metadata:
|
15
|
+
gateways:
|
16
|
+
default:
|
17
|
+
host: "196.201.207.191"
|
18
|
+
somtel:
|
19
|
+
metadata:
|
20
|
+
gateways:
|
21
|
+
default:
|
22
|
+
host: "196.201.207.191"
|
23
|
+
hormuud:
|
24
|
+
metadata:
|
25
|
+
gateways:
|
26
|
+
default:
|
27
|
+
host: "196.201.207.191"
|
28
|
+
sl:
|
29
|
+
operators:
|
30
|
+
africell:
|
31
|
+
metadata:
|
32
|
+
gateways:
|
33
|
+
default:
|
34
|
+
host: "freeswitch-private.internal.unicef.io"
|
35
|
+
br:
|
36
|
+
operators:
|
37
|
+
mundivox:
|
38
|
+
prefixes: "*"
|
39
|
+
metadata:
|
40
|
+
gateways:
|
41
|
+
default:
|
42
|
+
host: "187.102.153.186"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("lib", __dir__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "twilreapi/active_call_router/unicef_io/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "twilreapi-active_call_router-unicef_io"
|
8
|
+
spec.version = Twilreapi::ActiveCallRouter::UnicefIO::VERSION
|
9
|
+
spec.authors = ["David Wilkie"]
|
10
|
+
spec.email = ["dwilkie@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Call routing for somleng.unicef.io"
|
13
|
+
spec.homepage = "https://github.com/dwilkie/twilreapi-active_call_router-unicef_io"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "torasup", "~> 0.2.1"
|
22
|
+
spec.add_dependency "twilreapi-active_call_router"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twilreapi-active_call_router-unicef_io
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Wilkie
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: torasup
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: twilreapi-active_call_router
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
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.11'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.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.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- dwilkie@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".rubocop.yml"
|
93
|
+
- ".ruby-version"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- lib/twilreapi/active_call_router/unicef_io.rb
|
102
|
+
- lib/twilreapi/active_call_router/unicef_io/call_router.rb
|
103
|
+
- lib/twilreapi/active_call_router/unicef_io/torasup.rb
|
104
|
+
- lib/twilreapi/active_call_router/unicef_io/torasup/configuration.rb
|
105
|
+
- lib/twilreapi/active_call_router/unicef_io/torasup/data/unicef_io.yml
|
106
|
+
- lib/twilreapi/active_call_router/unicef_io/version.rb
|
107
|
+
- twilreapi-active_call_router-unicef_io.gemspec
|
108
|
+
homepage: https://github.com/dwilkie/twilreapi-active_call_router-unicef_io
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.7.3
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Call routing for somleng.unicef.io
|
132
|
+
test_files: []
|