Module: Zadarma::Methods

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

Instance Method Summary collapse

Instance Method Details

#balanceObject



3
4
5
# File 'lib/zadarma/methods.rb', line 3

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

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



11
12
13
# File 'lib/zadarma/methods.rb', line 11

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

#direct_numbersObject



59
60
61
# File 'lib/zadarma/methods.rb', line 59

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

#direct_numbers_available(direction_id) ⇒ Object



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

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

#direct_numbers_countriesObject



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

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

#direct_numbers_country(country_code) ⇒ Object



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

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



79
80
81
82
83
# File 'lib/zadarma/methods.rb', line 79

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 if !user_id.nil?
  request :post, "/direct_numbers/order", params
end

#documents_groups_listObject



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

def documents_groups_list
  request :get, "/documents/groups/list/"
end

#pbx_internalObject



32
33
34
# File 'lib/zadarma/methods.rb', line 32

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

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



36
37
38
# File 'lib/zadarma/methods.rb', line 36

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

#pbx_statistics(time_start, time_end) ⇒ Object



55
56
57
# File 'lib/zadarma/methods.rb', line 55

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



7
8
9
# File 'lib/zadarma/methods.rb', line 7

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

#redirection(params = {}) ⇒ Object



23
24
25
# File 'lib/zadarma/methods.rb', line 23

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

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



40
41
42
# File 'lib/zadarma/methods.rb', line 40

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

#set_redirect(id, params) ⇒ Object



27
28
29
# File 'lib/zadarma/methods.rb', line 27

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

#set_sip_caller(id, number) ⇒ Object



19
20
21
# File 'lib/zadarma/methods.rb', line 19

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

#sipObject



15
16
17
# File 'lib/zadarma/methods.rb', line 15

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

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



45
46
47
48
49
50
51
52
53
# File 'lib/zadarma/methods.rb', line 45

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