intis-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a7dfa336daee9b1935b0b769af0c6be15d91b17d
4
+ data.tar.gz: 8197a5786788f39ab60c5ef610d7ea80b8a32672
5
+ SHA512:
6
+ metadata.gz: 73c5bd45364eda20751cee48960992089bf1ec4bfc160a90d56d105e72e85f38dcd19abf455807f49b2d051aba382c2ad073283c23c04d8b6bf94b0d07b35bc0
7
+ data.tar.gz: 6fa619ccdb741ffec692ec5c11a1bd45d5818d2345d2057e61017ec2847d24a53259f45eb12a7b26a5129025bc940cc7ff787ae5709d7577d13e999a785de3ff
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'rspec', '>= 2.14'
5
+ end
6
+
7
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Konstantin Shlyk
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,280 @@
1
+ # Intis::Sdk
2
+
3
+ The Intis telecom gateway lets you send SMS messages worldwide via its API. This program sends HTTP(s) requests and receives information as a response in JSON and/or XML. The main functions of our API include:
4
+
5
+ * sending SMS messages (including scheduling options);
6
+ * receiving status reports about messages that have been sent previously;
7
+ * requesting lists of authorised sender names;
8
+ * requesting lists of incoming SMS messages;
9
+ * requesting current balance status;
10
+ * requesting lists of databases;
11
+ * requesting lists of numbers within particular contact list;
12
+ * searching for a particular number in a stop list;
13
+ * requesting lists of templates;
14
+ * adding new templates;
15
+ * requesting monthly statistics;
16
+ * making HLR request;
17
+ * receiving HLR request statistics;
18
+ * requesting an operator’s name by phone number;
19
+
20
+ To begin using our API please [apply](https://go.intistele.com/external/client/register/) for your account at our website where you can get your login and API key.
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem 'intis-sdk'
28
+ ```
29
+
30
+ And then execute:
31
+
32
+ $ bundle
33
+
34
+ Or install it yourself as:
35
+
36
+ $ gem install intis-sdk
37
+
38
+ ## Usage
39
+
40
+ Class Intis::Sdk::Client - The main class for SMS sending and getting API information
41
+
42
+ There are three mandatory parameters that you have to provide the constructor in order to initialize. They are:
43
+
44
+ * login - user login
45
+ * api_key - user API key
46
+ * api_host - API address
47
+
48
+ ```ruby
49
+ client = Intis::Sdk::Client.new(login: 'your_api_login', api_key: 'your_api_key', api_host: 'your_api_host')
50
+ ```
51
+
52
+ This class includes the following methods:
53
+
54
+ Use the get_balance method to request your balance status
55
+
56
+ ```ruby
57
+ balance = client.get_balance
58
+
59
+ amount = balance[:money] # Getting amount of money
60
+ currency = balance[:currency] # Getting name of currency
61
+ ```
62
+
63
+ To get a list of all the contact databases you have use the function get_base
64
+
65
+ ```ruby
66
+ bases = client.get_base
67
+
68
+ bases.each do |id, base|
69
+ id # Getting list ID
70
+ base[:name] # Getting list name
71
+ base[:count] # Getting number of contacts in list
72
+ base[:pages] # Getting number of pages in list
73
+
74
+ base[:on_birth] # Getting key that is responsible for sending greetings, 0 - do not send, 1 - send
75
+ base[:day_before] # Getting the number of days to send greetings before
76
+ base[:birth_sender] # Getting name of sender for greeting SMS
77
+ base[:birth_text] # Getting text template that will be used in the messages
78
+ base[:time_birth] # Getting time for sending greetings. All SMS will be sent at this time.
79
+ base[:local_time] # Getting variable that indicates using of local time while SMS sending.
80
+ end
81
+ ```
82
+
83
+ Our gateway supports the option of having unlimited sender’s names. To see a list of all senders’ names use the method get_senders
84
+
85
+ ```ruby
86
+ senders = client.get_senders
87
+
88
+ senders.each do |sender, status|
89
+ sender # Getting sender name
90
+ status # Getting sender status
91
+ end
92
+ ```
93
+
94
+ To get a list of phone numbers from a certain contact list you need the get_phone(base_id, page) method. For your convenience, the entire list is split into separate pages. The parameters are: base_id - the ID of a particular database (mandator), and page - a page number in a particular database (optional).
95
+
96
+ ```ruby
97
+ phones = client.get_phone(base_id)
98
+
99
+ phones.each do |phone, info|
100
+ phone # Getting subscriber number
101
+ info[:name] # Getting subscriber first name
102
+ info[:middle_name] # Getting subscriber middle name
103
+ info[:last_name] # Getting subscriber last name
104
+ info[:date_birth] # Getting subscriber birthday
105
+ info[:male] # Getting gender of subscriber
106
+ info[:operator] # Getting operator of subscriber
107
+ info[:region] # Getting region of subscriber
108
+ info[:note1] # Getting subscriber note 1
109
+ info[:note2] # Getting subscriber note 2
110
+ end
111
+ ```
112
+
113
+ To receive status info for an SMS you have already sent, use the function get_status(message_id) where message_id - is an array of sent message IDs.
114
+
115
+ ```ruby
116
+ statuses = client.get_status(message_id)
117
+
118
+ statuses.each do |id, status|
119
+ id # Getting message ID
120
+ status # Getting a message status
121
+ end
122
+ ```
123
+
124
+ To send a message (to one or several recipients), use the function send(phone, text, sender, sending_time), where phone - is a set of numbers you send your messages to, sender is a sender’s name and text stands for the content of the message and sending_time - Example: 2014-05-30 14:06 (an optional parameter, it is used when it is necessary to schedule SMS messages).
125
+
126
+ ```ruby
127
+ statuses = client.send(phone, text, sender, sending_time)
128
+
129
+ statuses.each do |phone, status|
130
+ phone # Getting phone number
131
+ status[:id_sms] # Getting message ID
132
+ status[:cost] # Getting price for message
133
+ status[:count_sms] # Getting number of message parts
134
+ status[:error] # Getting code error in SMS sending
135
+ end
136
+ ```
137
+
138
+ To add a number to a stoplist run add_to_stop(phone) where phone is an individual phone number
139
+
140
+ ```ruby
141
+ result = client.add_to_stop(phone)
142
+ result[:id] # return ID in stop list
143
+ ```
144
+
145
+ To check if a particular phone number is listed within a stop list use the function find_on_stop(phone), where phone is an individual phone number.
146
+
147
+ ```ruby
148
+ check = client.find_on_stop(phone)
149
+
150
+ check[:description] # Getting reason of adding to stop list
151
+ check[:time_in] # Getting time of adding to stop list
152
+ ```
153
+
154
+ Our gateway supports the option of creating multiple templates of SMS messages. To get a list of templates use the function get_template. As a response you will get a list of all the messages that a certain login has set up.
155
+
156
+ ```ruby
157
+ templates = client.get_template
158
+ templates.each do |id, info|
159
+ id # Getting template ID
160
+ info[:name] # Getting template name
161
+ info[:template] # Getting text of template
162
+ info[:up_time] # Getting the date and time when a particular template was created
163
+ end
164
+ ```
165
+
166
+ To add a new template to a system run the function add_template(title, template, override) where title is a name of a template, and template is the text content of a template
167
+
168
+ ```ruby
169
+ result = client.add_template(title, text)
170
+ result[:id] # return ID user template
171
+ ```
172
+
173
+ To get stats about messages you have sent during a particular month use the function get_stat_by_month(month) where month - is the particular date you need statistics for in the format YYYY-MM.
174
+
175
+ ```ruby
176
+ stats = client.get_stat_by_month(month)
177
+
178
+ stats.each do |date, info|
179
+ date # Getting day of month
180
+
181
+ info.each do |state, stat|
182
+ state # Getting status of message
183
+ stat[:cost] # Getting prices of message
184
+ stat[:parts] # Getting number of message parts
185
+ end
186
+ end
187
+ ```
188
+
189
+ HLR (Home Location Register) - is the centralised databas that provides detailed information regarding the GSM mobile network of every mobile user. HLR requests let you check the availability of a single phone number or a list of numbers for further clean up of unavailable numbers from a contact list. To perform an HLR request, our system supports the function hlr(phone) where phone is the array of phone numbers.
190
+
191
+ ```ruby
192
+ result = client.hlr(phones)
193
+
194
+ result.each do |hlr_data|
195
+ hlr_data[:id] # Getting ID
196
+ hlr_data[:destination] # Getting recipient
197
+ hlr_data[:IMSI] # Getting IMSI
198
+ hlr_data[:mccmnc] # Getting MCC and MNC of subscriber
199
+ hlr_data[:stat] # Getting status of subscriber
200
+ hlr_data[:orn] # Getting the original name of the subscriber's operator
201
+ hlr_data[:onp] # Getting the original prefix of the subscriber's operator
202
+ hlr_data[:ocn] # Getting the original name of the subscriber's country
203
+ hlr_data[:ocp] # Getting the original code of the subscriber's country
204
+ hlr_data[:pcn] # Getting name of country if subscriber's phone number is ported
205
+ hlr_data[:pcp] # Getting prefix of country if subscriber's phone number is ported
206
+ hlr_data[:pon] # Getting name of operator if subscriber's phone number is ported
207
+ hlr_data[:pnp] # Getting prefix of operator if subscriber's phone number is ported
208
+ hlr_data[:rcn] # Getting name of country if the subscriber is in roaming
209
+ hlr_data[:rcp] # Getting prefix of country if the subscriber is in roaming
210
+ hlr_data[:ron] # Getting name of operator if the subscriber is in roaming
211
+ hlr_data[:rnp] # Getting prefix of operator if the subscriber is in roaming
212
+ hlr_data[:is_roaming] # Determining if the subscriber is in roaming
213
+ hlr_data[:is_ported] # Identification of ported number
214
+ end
215
+ ```
216
+
217
+ Besides, you can can get HLR requests statistics regarding a certain time range. To do that, use the function get_hlr_stat(from, to) where from and to are the beginning and end of a time period.
218
+
219
+ ```ruby
220
+ stats = client.get_hlr_stat(from, to)
221
+
222
+ stats.each do |number, hlr_data|
223
+ number # Getting phone number
224
+ hlr_data[:id] # Getting ID
225
+ hlr_data[:destination] # Getting recipient
226
+ hlr_data[:IMSI] # Getting IMSI
227
+ hlr_data[:mccmnc] # Getting MCC and MNC of subscriber
228
+ hlr_data[:stat] # Getting status of subscriber
229
+ hlr_data[:orn] # Getting the original name of the subscriber's operator
230
+ hlr_data[:onp] # Getting the original prefix of the subscriber's operator
231
+ hlr_data[:ocn] # Getting the original name of the subscriber's country
232
+ hlr_data[:ocp] # Getting the original code of the subscriber's country
233
+ hlr_data[:pcn] # Getting name of country if subscriber's phone number is ported
234
+ hlr_data[:pcp] # Getting prefix of country if subscriber's phone number is ported
235
+ hlr_data[:pon] # Getting name of operator if subscriber's phone number is ported
236
+ hlr_data[:pnp] # Getting prefix of operator if subscriber's phone number is ported
237
+ hlr_data[:rcn] # Getting name of country if the subscriber is in roaming
238
+ hlr_data[:rcp] # Getting prefix of country if the subscriber is in roaming
239
+ hlr_data[:ron] # Getting name of operator if the subscriber is in roaming
240
+ hlr_data[:rnp] # Getting prefix of operator if the subscriber is in roaming
241
+ hlr_data[:is_roaming] # Determining if the subscriber is in roaming
242
+ hlr_data[:is_ported] # Identification of ported number
243
+ hlr_data[:message_id] # Getting message ID
244
+ htl_data[:total_price] # Getting final price of request
245
+ hlr_data[:request_id] # Getting request ID
246
+ hlr_data[:request_time] # Getting time of request
247
+ end
248
+ ```
249
+
250
+ To get information regarding which mobile network a certain phone number belongs to, use the function get_operator(phone), where phone is a phone number.
251
+
252
+ ```ruby
253
+ operator = client.get_operator(phone)
254
+
255
+ operator[:operator] # Getting operator of subscriber
256
+ ```
257
+
258
+ Please bear in mind that this method has less accuracy than HLR requests as it uses our internal database to check which mobile operator a phone numbers belongs to.
259
+
260
+ To get a list of incoming messages please use the function get_incoming_by_date(date), where date stands for a particular day in YYYY-mm-dd format. Or use the function get_incoming_by_period(from, to), where from - date of start in the format YYYY-MM-DD HH:II:SS (Example: 2014-05-01 14:06:00) and to - date of end in the format YYYY-MM-DD HH:II:SS (Example: 2014-05-30 23:59:59)
261
+
262
+ ```ruby
263
+ messages = client.get_incoming_by_date(date)
264
+
265
+ messages.each do |id, message|
266
+ id # Getting message ID
267
+ message[:sender] # Getting sender name of the incoming message
268
+ message[:prefix] # Getting prefix of the incoming message
269
+ message[:date] # Getting date of the incoming message
270
+ message[:text] # Getting text of the incoming message
271
+ end
272
+ ```
273
+
274
+ ## Contributing
275
+
276
+ 1. Fork it ( https:#github.com/[my-github-username]/intis-sdk/fork )
277
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
278
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
279
+ 4. Push to the branch (`git push origin my-new-feature`)
280
+ 5. Create a new Pull Request
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'intis/sdk/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "intis-sdk"
8
+ spec.version = Intis::Sdk::VERSION
9
+ spec.authors = ["Konstantin Shlyk"]
10
+ spec.email = ["konstantin@shlyk.org"]
11
+ spec.summary = %q{Intis Telecom API Ruby SDK}
12
+ spec.description = %q{Ruby SDK for operating with Intis telecom API and sending SMS}
13
+ spec.homepage = "https://www.intistele.com/"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,2 @@
1
+ require "intis/sdk/version"
2
+ require "intis/sdk/client"
@@ -0,0 +1,152 @@
1
+ require "intis/sdk/gateway"
2
+
3
+ module Intis::Sdk
4
+ # The main class for SMS sending and getting API information
5
+ class Client
6
+
7
+ # A new API client.
8
+ # @param config [Hash] hash with keys: login, api_key, api_host.
9
+ def initialize(config = {})
10
+ @config = {
11
+ login: nil,
12
+ api_key: nil,
13
+ api_host: nil
14
+ }.merge(config)
15
+
16
+ raise "Login can't be empty" if @config[:login].nil?
17
+ raise "Api key can't be empty" if @config[:api_key].nil?
18
+ raise "Api host can't be empty" if @config[:api_host].nil?
19
+
20
+ @gateway = Gateway.new @config
21
+ end
22
+
23
+ # Balance request.
24
+ # @return [Hash] response.
25
+ def get_balance
26
+ @gateway.request("/get/balance.php")
27
+ end
28
+
29
+ # Lists request.
30
+ # @return [Hash] response.
31
+ def get_base
32
+ @gateway.request("/get/base.php")
33
+ end
34
+
35
+ # Request for senders list.
36
+ # @return [Hash] response.
37
+ def get_senders
38
+ @gateway.request("/get/senders.php")
39
+ end
40
+
41
+ # Request for numbers from list.
42
+ # @param base [String] List ID.
43
+ # @param page [Integer] Page number.
44
+ # @return [Hash] response.
45
+ def get_phone base, page = 1
46
+ @gateway.request("/get/phone.php", base: base, page: page)
47
+ end
48
+
49
+ # Status request.
50
+ # @param state [String] status ID. If you need statuses of several SMS, you should specify ID separated by commas.
51
+ # @return [Hash] response.
52
+ def get_status state
53
+ @gateway.request("/get/state.php", state: state)
54
+ end
55
+
56
+ # SMS sending.
57
+ # @param phone [String] One or several numbers separated by commas (no more than 100 numbers in the request).
58
+ # @param text [String] Text of SMS message.
59
+ # @param sender [String] Sender name (one of the approved in your account).
60
+ # @param sending_time [String] Example: 2014-05-30 14:06 (an optional parameter, it is used when it is necessary to schedule SMS messages).
61
+ # @return [Hash] response.
62
+ def send phone, text, sender, sending_time = nil
63
+ @gateway.request("/get/send.php", phone: phone, text: text, sender: sender, sendingTime: sending_time)
64
+ end
65
+
66
+ # Search in the black list.
67
+ # @param phone [String] Required number.
68
+ # @return [Hash] response.
69
+ def find_on_stop phone
70
+ @gateway.request("/get/find_on_stop.php", phone: phone)
71
+ end
72
+
73
+ # Adding a number to the stop list.
74
+ # @param phone [String] Required number.
75
+ # @return [Hash] response.
76
+ def add_to_stop phone
77
+ @gateway.request("/get/add2stop.php", phone: phone)
78
+ end
79
+
80
+ # Request for templates list.
81
+ # @return [Hash] response.
82
+ def get_template
83
+ @gateway.request("/get/template.php")
84
+ end
85
+
86
+ # Adding a template.
87
+ # @param name [String] Template name.
88
+ # @param text [String] Template text.
89
+ # @param override [Integer] - Example: 0 or 1 (an optional parameter; it is used for template editting, if the template you want to edit is found and the override parameter is 1, the template will be edited).
90
+ # @return [Hash] response.
91
+ def add_template name, text, override = 0
92
+ @gateway.request("/get/add_template.php", name: name, text: text, override: override)
93
+ end
94
+
95
+ # Deleting a template.
96
+ # @param name [String] Template name.
97
+ # @return [Hash] response.
98
+ def del_template name
99
+ @gateway.request("/get/del_template.php", name: name)
100
+ end
101
+
102
+ # General statistics for a month by days.
103
+ # @param month [String] Year and month in the format YYYY-MM.
104
+ # @return [Hash] response.
105
+ def get_stat_by_month month
106
+ @gateway.request("/get/stat_by_month.php", month: month)
107
+ end
108
+
109
+ # HLR request.
110
+ # @param phone [String] one or several numbers separated by commas, but no more than 100 numbers in the request.
111
+ # @return [Hash] response.
112
+ def hlr phone
113
+ @gateway.request("/get/hlr.php", phone: phone)
114
+ end
115
+
116
+ # Statistics of HLR requests.
117
+ # @param from [String] date of start in the format YYYY-MM-DD.
118
+ # @param to [String] date of end in the format YYYY-MM-DD.
119
+ # @return [Hash] response.
120
+ def get_hlr_stat from, to
121
+ @gateway.request("/get/hlr_stat.php", from: from, to: to)
122
+ end
123
+
124
+ # Mobile operator query.
125
+ # @param phone [String] Phone number.
126
+ # @return [Hash] response.
127
+ def get_operator phone
128
+ @gateway.request("/get/operator.php", phone: phone)
129
+ end
130
+
131
+ # Request for incoming SMS by date.
132
+ # @param date [String] date in the format YYYY-MM-DD.
133
+ # @return [Hash] response.
134
+ def get_incoming_by_date date
135
+ @gateway.request("/get/incoming.php", date: date)
136
+ end
137
+
138
+ # Request for incoming SMS by period.
139
+ # @param from [String] date of start in the format YYYY-MM-DD HH:II:SS (Example: 2014-05-01 14:06:00).
140
+ # @param to [String] date of end in the format YYYY-MM-DD HH:II:SS (Example: 2014-05-30 23:59:59).
141
+ # @return [Hash] response.
142
+ def get_incoming_by_period from, to
143
+ @gateway.request("/get/incoming.php", from: from, to: to)
144
+ end
145
+
146
+ # Prices request.
147
+ # @return [Hash] response.
148
+ def get_prices
149
+ @gateway.request("/get/prices.php")
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,45 @@
1
+ require "intis/sdk/url_helper"
2
+ require "net/http"
3
+ require "openssl"
4
+ require "json"
5
+ require 'digest'
6
+
7
+ module Intis::Sdk
8
+ class Gateway
9
+ def initialize(config)
10
+ @config = config
11
+ end
12
+
13
+ def request(path, params = {})
14
+ url = URI.parse("https://#{@config[:api_host]}/external#{path}")
15
+
16
+ http = Net::HTTP.new(url.host, url.port)
17
+
18
+ http.read_timeout = 15
19
+ http.open_timeout = 15
20
+ http.use_ssl = true
21
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
22
+
23
+ headers = {}
24
+
25
+ params[:login] = @config[:login]
26
+ params[:timestamp] = Time.now.to_i
27
+
28
+ signature = Digest::MD5.hexdigest(params.sort.map{|k,v| v}.join + @config[:api_key])
29
+ params[:signature] = signature
30
+
31
+ url_params = ""
32
+ url_params += URI.encode_www_form(params) if params.any?
33
+
34
+ req = Net::HTTP::Get.new(url.path + "?" + url_params, headers)
35
+
36
+ response = http.start() {|http| http.request(req) }
37
+
38
+ if response.kind_of?(Net::HTTPSuccess)
39
+ return UrlHelper.parse_data(response)
40
+ else
41
+ raise response.inspect
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,19 @@
1
+ require "json"
2
+
3
+ module Intis::Sdk
4
+ class UrlHelper
5
+ def self.parse_data(response)
6
+ response_body = JSON.parse(response.body, symbolize_names: true)
7
+ validate_response! response_body
8
+
9
+ response_body
10
+ end
11
+
12
+ def self.validate_response!(response_body)
13
+ if !response_body.kind_of?(Array) and response_body.has_key? :error
14
+ response_error = response_body[:error]
15
+ raise("Error. Error code: #{response_error}")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module Intis
2
+ module Sdk
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+ require 'intis/sdk'
3
+ require 'net/http'
4
+ require 'logger'
5
+ require 'date'
6
+
7
+ describe Intis::Sdk::Client do
8
+ let(:log) {
9
+ Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
10
+ }
11
+
12
+ before(:context) do
13
+ @client = Intis::Sdk::Client.new({
14
+ login: 'your api login',
15
+ api_key: 'your api key',
16
+ api_host: 'go.intistele.com'
17
+ })
18
+ end
19
+
20
+ it 'should return balance' do
21
+ response = @client.get_balance
22
+ expect(response[:money]).to be
23
+ expect(response[:bonusAmount]).to be
24
+ expect(response[:currency]).to be
25
+ end
26
+
27
+ it 'should return phone bases' do
28
+ response = @client.get_base
29
+ expect(response).to be
30
+ end
31
+
32
+ it 'should return phones' do
33
+ response = @client.get_phone(247)
34
+ expect(response).to be
35
+ end
36
+
37
+ it 'should return senders' do
38
+ response = @client.get_senders
39
+ expect(response).to be
40
+ end
41
+
42
+ it 'should return templates' do
43
+ response = @client.get_template
44
+ expect(response).to be
45
+ end
46
+
47
+ it 'should return stat for current month' do
48
+ response = @client.get_stat_by_month(Date.today.strftime("%Y-%m"))
49
+ expect(response).to be
50
+ end
51
+
52
+ it 'should make hlr request' do
53
+ response = @client.hlr('79051111111')
54
+ expect(response).to be
55
+ end
56
+
57
+ it 'should return hlr stat for current month' do
58
+ response = @client.get_hlr_stat(Date.today.strftime("%Y-%m-%d"), Date.today.strftime("%Y-%m-%d"))
59
+ expect(response).to be
60
+ end
61
+
62
+ it 'should return operator by phone' do
63
+ response = @client.get_operator("79051111111")
64
+ expect(response[:price]).to be
65
+ expect(response[:country]).to be
66
+ expect(response[:operator]).to be
67
+ expect(response[:currency]).to be
68
+ expect(response[:phone]).to be
69
+ expect(response[:regionCode]).to be
70
+ end
71
+
72
+ it 'should return prices' do
73
+ response = @client.get_prices
74
+ expect(response).to be
75
+ end
76
+
77
+ it 'should return incoming' do
78
+ response = @client.get_incoming_by_date(Date.today.strftime("%Y-%m-%d"))
79
+ expect(response).to be
80
+ end
81
+ end
@@ -0,0 +1 @@
1
+ require 'intis/sdk'
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: intis-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Konstantin Shlyk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Ruby SDK for operating with Intis telecom API and sending SMS
42
+ email:
43
+ - konstantin@shlyk.org
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - intis-sdk.gemspec
55
+ - lib/intis/sdk.rb
56
+ - lib/intis/sdk/client.rb
57
+ - lib/intis/sdk/gateway.rb
58
+ - lib/intis/sdk/url_helper.rb
59
+ - lib/intis/sdk/version.rb
60
+ - spec/intis/sdk/client_spec.rb
61
+ - spec/spec_helper.rb
62
+ homepage: https://www.intistele.com/
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.5
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Intis Telecom API Ruby SDK
86
+ test_files:
87
+ - spec/intis/sdk/client_spec.rb
88
+ - spec/spec_helper.rb