avaya 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7b1cdddee5b7c3f35a5a9a8f57389d5d94b25baa
4
+ data.tar.gz: 14a9fc26699de53c6e61a9e5fc2c135f8215776d
5
+ SHA512:
6
+ metadata.gz: cece55bf27eb70ac0db2ef7a02fe5b6d05ee94aa6f224097cae77dc2c7bd0c74aadc75f95d2ac544dc9d73b133e3af211b7c3e77c99a074fd6a63e13a4fd78e4
7
+ data.tar.gz: ac7b62b30af488eb2e60999291dceb3fef70c354e748a2b43d9f5b93d82a42d9590659cde45b1ee1721d5c4cce69ce7c805cee3a41eb7634cd14ee7282636e48
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ temp/
19
+ *.bundle
20
+ *.so
21
+ *.o
22
+ *.a
23
+ mkmf.log
24
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in Avaya.gemspec
4
+ gemspec
5
+
6
+ #gem 'net-tftp', '~> 0.1.0'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Freibuis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,65 @@
1
+ # Avaya Ip Office integration
2
+
3
+ This gem gives limted read only integration from your IPOFFICE (only tested on ip office 500v2)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'avaya' , :git => 'git://github.com/freibuis/Avaya-IP-Office.git' ,branch: master
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install avaya
18
+
19
+ For rails support just run the following command. This will create the initializer for you to edit
20
+
21
+ $ rails generate avaya:install
22
+
23
+ ## Usage
24
+
25
+ 1st create the connection
26
+ $ Avaya::Configuration.config {|config| config.host = "ip_office_server_ipaddress"}
27
+
28
+ Once you have set up the connection. you can use the helpers to get data out
29
+
30
+ ### Helper-ish
31
+
32
+ #### DirList: directory list
33
+
34
+ $ dir_list = Avaya::DirList.get
35
+
36
+ This returns an array of :name, :numbers
37
+
38
+ #### UserList: list of phone system users. if type is 3..7 then :ex_directory and :active is returned
39
+ ````ruby
40
+ user_list = Avaya::UserList.get
41
+ user_list = Avaya::UserList.get(2)
42
+ user_list = Avaya::UserList.get(3)
43
+ user_list = Avaya::UserList.get(4)
44
+ ````
45
+
46
+ #### HunList: list of phone system groups.
47
+ ````ruby
48
+ hunt_list = Avaya::HuntList.get
49
+ ````
50
+
51
+ an array of :name,:ext,:queue,:voice_mails,:hunt_id is returned
52
+
53
+
54
+ ## Todo:
55
+
56
+ Currently CallList not working as I need to reverse engineer the values from the phone platform
57
+
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it ( https://github.com/freibuis/Avaya-IP-Office/fork )
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'avaya/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "avaya"
8
+ spec.version = Avaya::VERSION
9
+ spec.authors = ["Freibuis"]
10
+ spec.email = ["freibuis@gmail.com"]
11
+ spec.summary = %q{A gem to talk to Avaya Ip Office Platform.}
12
+ spec.description = %q{If you are looking to talk to you Avaya Ip Office then this is the gem for you!}
13
+ spec.homepage = "https://github.com/freibuis/Avaya-IP-Office"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", "~> 0"
23
+ end
@@ -0,0 +1,21 @@
1
+ require 'net/tftp'
2
+
3
+ require "avaya/endpoint"
4
+
5
+ require "avaya/version"
6
+ require 'avaya/configuration'
7
+ require 'avaya/tftp'
8
+ require 'avaya/dir_list'
9
+ require 'avaya/hunt_list'
10
+ require 'avaya/hunt_info'
11
+ require 'avaya/user_list'
12
+ require 'avaya/member_of'
13
+ require 'avaya/user_info'
14
+ #require 'avaya/call_list'
15
+
16
+
17
+ module Avaya
18
+
19
+
20
+
21
+ end
@@ -0,0 +1,86 @@
1
+ module Avaya
2
+ class CallList
3
+ attr_reader :all_calls, :name, :ras, :pots, :sip, :q93
4
+
5
+ def initialize
6
+
7
+ @ras = []
8
+ @pots = []
9
+ @sip = []
10
+ @q93 = []
11
+ @all_calls = Avaya::TFTP.read(:call_list)
12
+
13
+ end
14
+
15
+ def self.get
16
+ call_list = self.new
17
+ call_list.get
18
+
19
+ end
20
+
21
+ def get
22
+
23
+ #items = @all_calls.collect { |row| row.gsub(/Line /, 'Line_').split(' ') }
24
+ @all_calls.each do |call|
25
+ case call
26
+ when call.starts_with? "NAME:"
27
+ @name = call.gsub!("NAME: ", '').gsub!('"', '')
28
+ when call.starts_with? "RAS:"
29
+ ras_line(call)
30
+ when call.starts_with? "SIPLine:"
31
+ sip_line(call)
32
+ when call.starts_with? "Q93Line:"
33
+ q93_line(call)
34
+
35
+ when call.starts_with? "CALL:"
36
+ call_line(call)
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+
43
+ def ras_line(line)
44
+ line = line.split(' ')
45
+ ras_det = {
46
+ id: line[0].gsub!(/NAME: /, ''),
47
+ count: line[0].gsub!(/Chans=/, '')
48
+ }
49
+ @ras.merge! ras_det
50
+
51
+ end
52
+
53
+ def sip_line(line)
54
+ line = line.split(' ')
55
+ pots_det = {
56
+ id: line[0].gsub!(/POTS: /, ''),
57
+ count: line[1].gsub!(/Chans=/, ''),
58
+ used: line[2].gsub!(/Used=/, ''),
59
+ }
60
+ @pots.merge! pots_det
61
+ end
62
+
63
+ def q93_line(line)
64
+
65
+ line = line.split.gsub(/Q931 PRI TE Version /, 'Q931_PRI_TE_Version_').split(' ')
66
+ q93_det = {
67
+ id: line[0].gsub!(/NAME: /, ''),
68
+ count: line[1].gsub!(/Chans=/, ''),
69
+ used: line[2].gsub!(/Used=/, ''),
70
+ version: line[4].gsub!(/Version=/, '').gsub!('_', ' ')
71
+ }
72
+ @q93.merge! q93_det
73
+ end
74
+
75
+ def call_line(line)
76
+ line = line.gsub(/Line /, 'Line_').split(' ')
77
+ call_det = {
78
+
79
+
80
+ }
81
+ end
82
+
83
+
84
+ end
85
+
86
+ end
@@ -0,0 +1,13 @@
1
+ module Avaya
2
+ module Configuration
3
+ attr_accessor :host, :port
4
+ extend self
5
+
6
+ def config(&value)
7
+ #@host = 'hostnameorip'
8
+ @port = 69
9
+ instance_eval &value
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,30 @@
1
+ module Avaya
2
+ class DirList
3
+ attr_reader :directory
4
+
5
+ def initialize
6
+ @directory = Avaya::TFTP.read(:dir_list)
7
+ end
8
+
9
+ def self.get
10
+ dir_list = self.new
11
+ dir_list.get
12
+
13
+ end
14
+
15
+ def get
16
+ list= []
17
+ directory.each do |row|
18
+ row = row.split(",")
19
+ list << {
20
+ name: row[0],
21
+ number: row[1]
22
+ }
23
+ end
24
+ list
25
+ end
26
+
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,24 @@
1
+ module Avaya
2
+ def self.endpoint(end_point, var2 = nil)
3
+ endpoints = {
4
+ who_is: "nasystem/who_is",
5
+ licence_list: "nasystem/licence_list",
6
+ user_list: "nasystem/user_list#{var2}",
7
+ hunt_list: "nasystem/hunt_list",
8
+ dir_list: "nasystem/dir_list",
9
+ extn_list: "nasystem/extn_list",
10
+ accountCode: "nasystem/AccountCode",
11
+ user_info: "nasystem/user_info/#{var2}",
12
+ user_info2: "nasystem/user_info2/#{var2}",
13
+ user_info3: "nasystem/user_info3/#{var2}",
14
+ member_of: "nasystem/MemberOf/#{var2}",
15
+ call_list: "nasystem/call_list/1/1",
16
+ call_info: "nasystem/call_info/#{var2}",
17
+ call_info2: "nasystem/call_info2/#{var2}",
18
+ hunt_info: "nasystem/hunt_info/#{var2}",
19
+
20
+ }
21
+ endpoints[end_point]
22
+
23
+ end
24
+ end
@@ -0,0 +1,30 @@
1
+ module Avaya
2
+ class HuntInfo
3
+ attr_reader :members
4
+
5
+ def initialize(group)
6
+ @members = Avaya::TFTP.read(:hunt_info, group)
7
+ end
8
+
9
+ def self.get group
10
+ hunt_list = self.new(group)
11
+ hunt_list.get
12
+
13
+ end
14
+
15
+ def get
16
+ list= []
17
+ members.each do |row|
18
+ list << {
19
+ ext: row.sub("*", ""),
20
+ active: ((row.include? "*") == false )
21
+ }
22
+ end
23
+
24
+ list
25
+ end
26
+
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,34 @@
1
+ module Avaya
2
+ class HuntList
3
+ attr_reader :directory
4
+
5
+ def initialize
6
+ @directory = Avaya::TFTP.read(:hunt_list)
7
+ end
8
+
9
+ def self.get
10
+ hunt_list = self.new
11
+ hunt_list.get
12
+
13
+ end
14
+
15
+ def get
16
+ list= []
17
+ directory.each do |row|
18
+ row = row.split(",")
19
+ list << {
20
+ name: row[0],
21
+ ext: row[1],
22
+ queue: row[2],
23
+ voice_mails: row[7],
24
+ hunt_id: row[9]
25
+ }
26
+ end
27
+
28
+ list
29
+ end
30
+
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,34 @@
1
+ module Avaya
2
+ class MemberOf
3
+ attr_reader :groups
4
+
5
+ def initialize(ext)
6
+ @groups = Avaya::TFTP.read(:member_of, ext)
7
+ end
8
+
9
+ def self.get ext
10
+ hunt_list = self.new(ext)
11
+ hunt_list.get
12
+
13
+ end
14
+
15
+ def get
16
+ list= []
17
+ groups.each do |group|
18
+ group = group.split(",")
19
+ list << {
20
+ group: group[0],
21
+ ext: group[1],
22
+ queue: group[2] ,
23
+ group_id: group.last
24
+
25
+ }
26
+ end
27
+
28
+ list
29
+ end
30
+
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,31 @@
1
+ require 'tempfile'
2
+ module Avaya
3
+ attr_accessor :file_data
4
+ attr_reader :random_file
5
+
6
+ class TFTP
7
+ def initialize (file)
8
+ tftp = Net::TFTP.new(Avaya::Configuration.host)
9
+ temp_file = Tempfile.new(random_file)
10
+ tftp.getbinaryfile(file, temp_file)
11
+ @file_data = temp_file.read
12
+ temp_file.close # close instead of unlink to prevent rails for breaking
13
+ end
14
+
15
+ def self.read(file, var2=nil)
16
+ tftp = self.new Avaya.endpoint(file, var2)
17
+ tftp.file_data
18
+ end
19
+
20
+ def file_data
21
+ @file_data.split("\r\n")
22
+ end
23
+
24
+ def random_file
25
+ (0...25).map { ('a'..'z').to_a[rand(26)] }.join
26
+ end
27
+
28
+ end
29
+
30
+
31
+ end
@@ -0,0 +1,41 @@
1
+ module Avaya
2
+ class UserInfo
3
+ attr_reader :user, :login_name, :full_name, :ext,
4
+ :forward_unconditional, :forward_unconditional_number, :forward_unconditional_all_calls,
5
+ :forward_me_to, :forward_busy, :dnd, :voicemail
6
+
7
+ def initialize(user)
8
+ @search = user
9
+ get
10
+
11
+ end
12
+
13
+ def self.get (user)
14
+ user_info = self.new(user)
15
+ user_info
16
+ end
17
+
18
+ def get
19
+ @user = Avaya::TFTP.read(:"user_info#{3}", @search)
20
+ @user = @user[0].split(',')
21
+
22
+ @login_name = @user[0]
23
+ @full_name = @user[1]
24
+ @ext = @user[2]
25
+ @forward_busy = @user[3] == "1" ? true : false
26
+ @forward_no_answer = @user[4] == "1" ? true : false
27
+ @forward_unconditional = @user[5] == "1" ? true : false
28
+ @forward_unconditional_number = @user[6]
29
+ @dnd = @user[7] == "1" ? true : false
30
+
31
+ @forward_unconditional_all_calls = @user[25] == "1" ? true : false
32
+ @forward_me_to = @user[8] == "1" ? true : false
33
+ @voicemail_to_email = @user[11] == "1" ? true : false
34
+ @voicemail_count = @user[11]
35
+ "updated"
36
+ end
37
+
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,39 @@
1
+ module Avaya
2
+ class UserList
3
+ attr_reader :user_list
4
+
5
+ def initialize(list_id ="")
6
+ @user_list = Avaya::TFTP.read(:user_list, list_id)
7
+ end
8
+
9
+ def self.get(list_id = "")
10
+ hunt_list = self.new(list_id)
11
+ hunt_list.get
12
+
13
+ end
14
+
15
+ def get
16
+ list= []
17
+ user_list.each do |row|
18
+ row = row.split(",")
19
+ new_row = {
20
+ name: row[0],
21
+ ext: row[1],
22
+ full_name: row[2],
23
+ user_id: row.last
24
+
25
+ }
26
+ unless @list_id == "" or @list_id == "2"
27
+ new_row.merge! ex_directory: (row[3] =="1")
28
+ new_row.merge! active: (row[4] == "1")
29
+ end
30
+ list << new_row
31
+ end
32
+
33
+ list
34
+ end
35
+
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,3 @@
1
+ module Avaya
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,2 @@
1
+ Usage:
2
+ rails generate avaya:install
@@ -0,0 +1,20 @@
1
+ module Avaya
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ desc "This generator creates an initializer file for Avaya Gem -> config/initializers/avaya.rb"
8
+
9
+ def copy_initializer
10
+ template 'initializer.rb', 'config/initializers/avaya.rb'
11
+ end
12
+
13
+ def self.banner
14
+ "rails generate avaya:install"
15
+ end
16
+
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ #Add you IP office ip address into config.host
2
+ Avaya::Configuration.config do |config|
3
+ #config.host = "127.0.0.1"
4
+ config.port = 69
5
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: avaya
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Freibuis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: If you are looking to talk to you Avaya Ip Office then this is the gem
42
+ for you!
43
+ email:
44
+ - freibuis@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - avaya.gemspec
55
+ - lib/avaya.rb
56
+ - lib/avaya/call_list.rb
57
+ - lib/avaya/configuration.rb
58
+ - lib/avaya/dir_list.rb
59
+ - lib/avaya/endpoint.rb
60
+ - lib/avaya/hunt_info.rb
61
+ - lib/avaya/hunt_list.rb
62
+ - lib/avaya/member_of.rb
63
+ - lib/avaya/tftp.rb
64
+ - lib/avaya/user_info.rb
65
+ - lib/avaya/user_list.rb
66
+ - lib/avaya/version.rb
67
+ - lib/generators/avaya/USAGE
68
+ - lib/generators/avaya/install_generator.rb
69
+ - lib/generators/avaya/templates/initializer.rb
70
+ homepage: https://github.com/freibuis/Avaya-IP-Office
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.2.2
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: A gem to talk to Avaya Ip Office Platform.
94
+ test_files: []