Module: Novofon::Methods

Included in:
Client, Client
Defined in:
lib/novofon/methods.rb

Instance Method Summary collapse

Instance Method Details

#balanceObject



5
6
7
# File 'lib/novofon/methods.rb', line 5

def balance
  request :get, "/info/balance/"
end

#callback(from, to, params = {}) ⇒ Object



13
14
15
# File 'lib/novofon/methods.rb', line 13

def callback(from, to, params = {})
  request :get, "/request/callback/", params.merge(from: from, to: to)
end

#checknumber(caller_id, to, code, params = {}) ⇒ Object



17
18
19
# File 'lib/novofon/methods.rb', line 17

def checknumber(caller_id, to, code, params = {})
  request :get, "/request/checknumber/", params.merge(caller_id: caller_id, to: to, code: code)
end

#direct_numbersObject



67
68
69
# File 'lib/novofon/methods.rb', line 67

def direct_numbers
  request :get, "/direct_numbers/"
end

#direct_numbers_available(direction_id) ⇒ Object



71
72
73
# File 'lib/novofon/methods.rb', line 71

def direct_numbers_available(direction_id)
  request :get, "/direct_numbers/available/#{direction_id}/"
end

#direct_numbers_countriesObject



75
76
77
# File 'lib/novofon/methods.rb', line 75

def direct_numbers_countries
  request :get, "/direct_numbers/countries"
end

#direct_numbers_country(country_code) ⇒ Object



79
80
81
# File 'lib/novofon/methods.rb', line 79

def direct_numbers_country(country_code)
  request :get, "/direct_numbers/country", country: country_code
end

#direct_numbers_order(number_id, period = nil, direction_id = nil, documents_group_id = nil, purpose = nil, receive_sms = nil, user_id = nil) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/novofon/methods.rb', line 83

def direct_numbers_order(number_id,
                         period = nil,
                         direction_id = nil,
                         documents_group_id = nil,
                         purpose = nil,
                         receive_sms = nil,
                         user_id = nil)
  params = { number_id: number_id,
             period: period,
             direction_id: direction_id,
             documents_group_id: documents_group_id,
             purpose: purpose,
             receive_sms: receive_sms }
  params[:user_id] = user_id unless user_id.nil?
  request :post, "/direct_numbers/order", params
end

#pbx_internalObject



41
42
43
# File 'lib/novofon/methods.rb', line 41

def pbx_internal
  request :get, "/pbx/internal/"
end

#pbx_record(id, status, params = {}) ⇒ Object



45
46
47
# File 'lib/novofon/methods.rb', line 45

def pbx_record(id, status, params = {})
  request :put, "/pbx/internal/recording/", params.merge(id: id, status: status)
end

#pbx_record_request(call_id: nil, pbx_call_id: nil, **params) ⇒ Object



37
38
39
# File 'lib/novofon/methods.rb', line 37

def pbx_record_request(call_id: nil, pbx_call_id: nil, **params)
  request :get, "/pbx/record/request/", params.merge(call_id: call_id, pbx_call_id: pbx_call_id)
end

#pbx_statistics(time_start, time_end) ⇒ Object



63
64
65
# File 'lib/novofon/methods.rb', line 63

def pbx_statistics(time_start, time_end)
  request :get, "/statistics/pbx/", start: time_s(time_start), end: time_s(time_end)
end

#price(number) ⇒ Object



9
10
11
# File 'lib/novofon/methods.rb', line 9

def price(number)
  request :get, "/info/price/", number: number
end

#redirection(params = {}) ⇒ Object



29
30
31
# File 'lib/novofon/methods.rb', line 29

def redirection(params = {})
  request :get, "/sip/redirection/", params
end

#send_sms(number, message, params = {}) ⇒ Object



49
50
51
# File 'lib/novofon/methods.rb', line 49

def send_sms(number, message, params = {})
  request :post, "/sms/send/", params.merge(number: number, message: message)
end

#set_redirect(id, params) ⇒ Object



33
34
35
# File 'lib/novofon/methods.rb', line 33

def set_redirect(id, params)
  request :put, "/sip/redirection/", params.merge(id: id)
end

#set_sip_caller(id, number) ⇒ Object



25
26
27
# File 'lib/novofon/methods.rb', line 25

def set_sip_caller(id, number)
  request :put, "/sip/callerid/", id: id, number: number
end

#sipObject



21
22
23
# File 'lib/novofon/methods.rb', line 21

def sip
  request :get, "/sip/"
end

#statistics(time_start, time_end, params = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/novofon/methods.rb', line 53

def statistics(time_start, time_end, params = {})
  result = request :get, "/statistics/", params.merge(start: time_s(time_start), end: time_s(time_end))

  result[:start] = Time.parse(result[:start])
  result[:end] = Time.parse(result[:end])
  result[:stats].each { |item| item[:callstart] = Time.parse(item[:callstart]) }

  result
end