Top Level Namespace

Defined Under Namespace

Modules: Binotel

Instance Method Summary collapse

Instance Method Details

#all_incoming_calls_since(param) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/binotel/stats_binotel.rb', line 4

def all_incoming_calls_since(param)
  time = (Time.now-(param.to_i*86400)).to_i
  param2 = { timestamp: time }.to_json
  params =  {"timestamp": time, "signature": signature_binotel(param2), "key": key_binotel }.to_json
  uri = URI.parse('https://api.binotel.com/api/2.0/stats/all-incoming-calls-since.json')
  post_binotel(uri, params)
end

#all_outgoing_calls_since(param) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/binotel/stats_binotel.rb', line 12

def all_outgoing_calls_since(param)
  time = (Time.now-(param.to_i*86400)).to_i
  param2 = { timestamp: time }.to_json
  params =  {"timestamp": time, "signature": signature_binotel(param2), "key": key_binotel }.to_json
  uri = URI.parse('https://api.binotel.com/api/2.0/stats/all-outgoing-calls-since.json')
  post_binotel(uri, params)
end

#calltracking_calls_for_period(start_p, stop_p) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/binotel/stats_binotel.rb', line 20

def calltracking_calls_for_period(start_p, stop_p)
  start = (Time.now-(start_p.to_i*86400)).to_i
  stop = (Time.now-(stop_p.to_i*86400)).to_i
  param2 = { startTime: start, stopTime: stop }.to_json
  params =  {startTime: start, stopTime: stop, "signature": signature_binotel(param2), "key": key_binotel }.to_json
  uri = URI.parse('https://api.binotel.com/api/2.0/stats/calltracking-calls-for-period.json')
  post_binotel(uri, params)
end

#key_binotelObject



4
5
6
# File 'lib/binotel/auth_binotel.rb', line 4

def key_binotel
  Rails.configuration.binotel_key
end

#password_binotelObject



8
9
10
# File 'lib/binotel/auth_binotel.rb', line 8

def password_binotel
  Rails.configuration.binotel_password
end

#post_binotel(uri, params) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/binotel/stats_binotel.rb', line 29

def post_binotel(uri, params)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.start {
    request = Net::HTTP::Post.new(
        uri.request_uri,
        'Content-Type' => 'application/json'
    )
    request.body = params

    response = http.request(request)
    body = JSON.parse(response.body)
  }
end

#signature_binotel(param) ⇒ Object



12
13
14
# File 'lib/binotel/auth_binotel.rb', line 12

def signature_binotel(param)
    signature = Digest::MD5.hexdigest(password_binotel+param)
end