Class: CalltouchClient

Inherits:
Object
  • Object
show all
Defined in:
lib/calltouch_client.rb

Defined Under Namespace

Classes: ApiError

Constant Summary collapse

VERSION =
'0.0.1'

Instance Method Summary collapse

Constructor Details

#initialize(client_api_id) ⇒ CalltouchClient

Returns a new instance of CalltouchClient.



11
12
13
14
15
16
# File 'lib/calltouch_client.rb', line 11

def initialize(client_api_id)
  @client_api_id = client_api_id
  @session_id = nil
  @api_url = 'http://api.calltouch.ru/calls-service/RestAPI'
  @options = { clientApiId: client_api_id }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object

Pass post, get, delete, put and patch to the request method



123
124
125
126
127
128
129
# File 'lib/calltouch_client.rb', line 123

def method_missing(method_name, *arguments, &block)
  if method_name.to_s =~ /(post|get|put|patch|delete)/
    request($1.to_sym, *arguments, &block)
  else
    super
  end
end

Instance Method Details

#approved(id, options = {}) ⇒ Object

Approve order



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

def approved id, options = {}
  get "requests/orders/#{id}/approve", options.merge!(@options)
end

#calls(site_id, options = {}) ⇒ Object

clientApiId - required dateFrom - required dateTo - required clientId source.value source.filterMode medium.value medium.filterMode utmSource.value utmSource.filterMode utmMedium.value utmMedium.filterMode utmTerm.value utmTerm.filterMode utmContent.value utmContent.filterMode utmCampaign.value utmCampaign.filterMode keyword.value keyword.filterMode ani.value ani.filterMode phoneNumber.value phoneNumber.filterMode uniqueOnly callId withMapVisits



97
98
99
# File 'lib/calltouch_client.rb', line 97

def calls site_id, options = {}
	get "#{site_id}/calls-diary/calls", options.merge!(@options)
end

#calls_by_date(site_id, options = {}) ⇒ Object

Total calls count by date access_token - required dateFrom dateTo



115
116
117
# File 'lib/calltouch_client.rb', line 115

def calls_by_date site_id, options = {}
	get "statistics/#{site_id}/calls/count-by-date", options.merge!({ access_token: @client_api_id })
end

#calls_count(site_id, options = {}) ⇒ Object

Total calls count access_token - required dateFrom dateTo



106
107
108
# File 'lib/calltouch_client.rb', line 106

def calls_count site_id, options = {}
	get "statistics/#{site_id}/calls/total-count", options.merge!({ access_token: @client_api_id })
end

#canceled(id, options = {}) ⇒ Object

Cancel order



51
52
53
# File 'lib/calltouch_client.rb', line 51

def canceled id, options = {}
  get "requests/orders/#{id}/cancel", options.merge!(@options)
end

#completed(id, options = {}) ⇒ Object

Complete order



61
62
63
# File 'lib/calltouch_client.rb', line 61

def completed id, options = {}
  get "requests/orders/#{id}/complete", options.merge!(@options)
end

#get_order(id, options = {}) ⇒ Object

Get order



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

def get_order id, options = {}
  get "requests/orders/#{id}", options.merge!(@options)
end

#get_request(id, options = {}) ⇒ Object

Get request



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

def get_request id, options = {}
  get "requests/#{id}", options.merge!(@options)
end

#rejected(id, options = {}) ⇒ Object

Reject order



56
57
58
# File 'lib/calltouch_client.rb', line 56

def rejected id, options = {}
  get "requests/orders/#{id}/reject", options.merge!(@options)	
end

#search(options = {}) ⇒ Object

Search



31
32
33
# File 'lib/calltouch_client.rb', line 31

def search options = {}
  get 'requests', options.merge!(@options)
end

#set_order(options = {}) ⇒ Object

Order by calling



26
27
28
# File 'lib/calltouch_client.rb', line 26

def set_order options = {}
  get 'orders/register', options.merge!(@options)
end

#set_request(options = {}) ⇒ Object

Request



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

def set_request options = {}  	
  get 'requests/orders/register', options.merge!(@options)
end