Class: Sipwizard::Cdr

Inherits:
Hashie::Trash
  • Object
show all
Defined in:
lib/sipwizard/cdr.rb

Constant Summary collapse

API_PATH_MAP =
{
  count: 'cdr/count',
  find:  'cdr/get'
}

Class Method Summary collapse

Class Method Details

.countObject



40
41
42
43
44
# File 'lib/sipwizard/cdr.rb', line 40

def self.count
  response = Connection.new.get(API_PATH_MAP[:count])

  response['Success'] ? response['Result'] : -1
end

.find(id) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/sipwizard/cdr.rb', line 50

def self.find(id)
  relation = self.where({ ID: id }).count(1)
  result = Connection.new.get(API_PATH_MAP[:find], relation.relation)

  return nil unless result['Success']

  self.new(result['Result'][0])
end

.where(params) ⇒ Object



46
47
48
# File 'lib/sipwizard/cdr.rb', line 46

def self.where(params)
  Relation.new.where(params)
end