binotel 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e2992488001edcbd5cd867c92a98334930a56344
4
+ data.tar.gz: b7476d9f58bf0c403f1c94410973dc5f9a99627a
5
+ SHA512:
6
+ metadata.gz: 4fe876a016c321cd83e45d1c5d673cbfcf78af24faa291bb1603f5803670b1e7a6f422b1cbc447849f1c0fb8298496a248ecd8087c3427e57fe1913d100186c2
7
+ data.tar.gz: e36f4f6b704830759fab572539a2b04f0f89234ae24927252c624a218182a2d58dd7c1b1a0eb6388b3bd47575646c69ab3f74a22d8d8429a7f39a43e503a3695
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Eugene Peluhnya
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # Binotel
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'binotel'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install binotel
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,33 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Binotel'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+
33
+ task default: :test
@@ -0,0 +1,6 @@
1
+ require 'binotel/auth_binotel'
2
+ require 'binotel/stats_binotel'
3
+
4
+ module Binotel
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,15 @@
1
+ require 'digest/md5'
2
+
3
+
4
+ def key_binotel
5
+ Rails.configuration.binotel_key
6
+ end
7
+
8
+ def password_binotel
9
+ Rails.configuration.binotel_password
10
+ end
11
+
12
+ def signature_binotel(param)
13
+ signature = Digest::MD5.hexdigest(password_binotel+param)
14
+ end
15
+
@@ -0,0 +1,42 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+
4
+ def all_incoming_calls_since(param)
5
+ time = (Time.now-(param.to_i*86400)).to_i
6
+ param2 = { timestamp: time }.to_json
7
+ params = {"timestamp": time, "signature": signature_binotel(param2), "key": key_binotel }.to_json
8
+ uri = URI.parse('https://api.binotel.com/api/2.0/stats/all-incoming-calls-since.json')
9
+ post_binotel(uri, params)
10
+ end
11
+
12
+ def all_outgoing_calls_since(param)
13
+ time = (Time.now-(param.to_i*86400)).to_i
14
+ param2 = { timestamp: time }.to_json
15
+ params = {"timestamp": time, "signature": signature_binotel(param2), "key": key_binotel }.to_json
16
+ uri = URI.parse('https://api.binotel.com/api/2.0/stats/all-outgoing-calls-since.json')
17
+ post_binotel(uri, params)
18
+ end
19
+
20
+ def calltracking_calls_for_period(start_p, stop_p)
21
+ start = (Time.now-(start_p.to_i*86400)).to_i
22
+ stop = (Time.now-(stop_p.to_i*86400)).to_i
23
+ param2 = { startTime: start, stopTime: stop }.to_json
24
+ params = {startTime: start, stopTime: stop, "signature": signature_binotel(param2), "key": key_binotel }.to_json
25
+ uri = URI.parse('https://api.binotel.com/api/2.0/stats/calltracking-calls-for-period.json')
26
+ post_binotel(uri, params)
27
+ end
28
+
29
+ def post_binotel(uri, params)
30
+ http = Net::HTTP.new(uri.host, uri.port)
31
+ http.use_ssl = true
32
+ http.start {
33
+ request = Net::HTTP::Post.new(
34
+ uri.request_uri,
35
+ 'Content-Type' => 'application/json'
36
+ )
37
+ request.body = params
38
+
39
+ response = http.request(request)
40
+ body = JSON.parse(response.body)
41
+ }
42
+ end
@@ -0,0 +1,3 @@
1
+ module Binotel
2
+ VERSION = '0.1.1'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :binotel do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: binotel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Eugene Peluhnya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
27
+ description: Binotel API access.
28
+ email:
29
+ - peluhnya@outlook.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - lib/binotel.rb
38
+ - lib/binotel/auth_binotel.rb
39
+ - lib/binotel/stats_binotel.rb
40
+ - lib/binotel/version.rb
41
+ - lib/tasks/binotel_tasks.rake
42
+ homepage: http://iteasycode.com
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.6.8
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Binotel API.
66
+ test_files: []