Class: Intis::Sdk::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/intis/sdk/client.rb

Overview

The main class for SMS sending and getting API information

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Client

A new API client.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/intis/sdk/client.rb', line 9

def initialize(config = {})
  @config = {
    login: nil,
    api_key: nil,
    api_host: nil
  }.merge(config)

  raise "Login can't be empty" if @config[:login].nil?
  raise "Api key can't be empty" if @config[:api_key].nil?
  raise "Api host can't be empty" if @config[:api_host].nil?

  @gateway = Gateway.new @config
end

Instance Method Details

#add_template(name, text, override = 0) ⇒ Hash

Adding a template.



91
92
93
# File 'lib/intis/sdk/client.rb', line 91

def add_template name, text, override = 0
  @gateway.request("/get/add_template.php", name: name, text: text, override: override)
end

#add_to_stop(phone) ⇒ Hash

Adding a number to the stop list.



76
77
78
# File 'lib/intis/sdk/client.rb', line 76

def add_to_stop phone
  @gateway.request("/get/add2stop.php", phone: phone)
end

#del_template(name) ⇒ Hash

Deleting a template.



98
99
100
# File 'lib/intis/sdk/client.rb', line 98

def del_template name
  @gateway.request("/get/del_template.php", name: name)
end

#find_on_stop(phone) ⇒ Hash

Search in the black list.



69
70
71
# File 'lib/intis/sdk/client.rb', line 69

def find_on_stop phone
  @gateway.request("/get/find_on_stop.php", phone: phone)
end

#get_balanceHash

Balance request.



25
26
27
# File 'lib/intis/sdk/client.rb', line 25

def get_balance
  @gateway.request("/get/balance.php")
end

#get_baseHash

Lists request.



31
32
33
# File 'lib/intis/sdk/client.rb', line 31

def get_base
  @gateway.request("/get/base.php")
end

#get_hlr_stat(from, to) ⇒ Hash

Statistics of HLR requests.



120
121
122
# File 'lib/intis/sdk/client.rb', line 120

def get_hlr_stat from, to
  @gateway.request("/get/hlr_stat.php", from: from, to: to)
end

#get_incoming_by_date(date) ⇒ Hash

Request for incoming SMS by date.



134
135
136
# File 'lib/intis/sdk/client.rb', line 134

def get_incoming_by_date date
  @gateway.request("/get/incoming.php", date: date)
end

#get_incoming_by_period(from, to) ⇒ Hash

Request for incoming SMS by period.



142
143
144
# File 'lib/intis/sdk/client.rb', line 142

def get_incoming_by_period from, to
  @gateway.request("/get/incoming.php", from: from, to: to)
end

#get_operator(phone) ⇒ Hash

Mobile operator query.



127
128
129
# File 'lib/intis/sdk/client.rb', line 127

def get_operator phone
  @gateway.request("/get/operator.php", phone: phone)
end

#get_phone(base, page = 1) ⇒ Hash

Request for numbers from list.



45
46
47
# File 'lib/intis/sdk/client.rb', line 45

def get_phone base, page = 1
  @gateway.request("/get/phone.php", base: base, page: page)
end

#get_pricesHash

Prices request.



148
149
150
# File 'lib/intis/sdk/client.rb', line 148

def get_prices
  @gateway.request("/get/prices.php")
end

#get_sendersHash

Request for senders list.



37
38
39
# File 'lib/intis/sdk/client.rb', line 37

def get_senders
  @gateway.request("/get/senders.php")
end

#get_stat_by_month(month) ⇒ Hash

General statistics for a month by days.



105
106
107
# File 'lib/intis/sdk/client.rb', line 105

def get_stat_by_month month
  @gateway.request("/get/stat_by_month.php", month: month)
end

#get_status(state) ⇒ Hash

Status request.



52
53
54
# File 'lib/intis/sdk/client.rb', line 52

def get_status state
  @gateway.request("/get/state.php", state: state)
end

#get_templateHash

Request for templates list.



82
83
84
# File 'lib/intis/sdk/client.rb', line 82

def get_template
  @gateway.request("/get/template.php")
end

#hlr(phone) ⇒ Hash

HLR request.



112
113
114
# File 'lib/intis/sdk/client.rb', line 112

def hlr phone
  @gateway.request("/get/hlr.php", phone: phone)
end

#send(phone, text, sender, sending_time = nil) ⇒ Hash

SMS sending.



62
63
64
# File 'lib/intis/sdk/client.rb', line 62

def send phone, text, sender, sending_time = nil
  @gateway.request("/get/send.php", phone: phone, text: text, sender: sender, sendingTime: sending_time)
end