lifecell_api 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +6 -0
- data/LICENSE +22 -0
- data/README.md +209 -0
- data/Rakefile +3 -0
- data/examples/get_balance.rb +45 -0
- data/lib/lifecell_api.rb +170 -0
- data/lib/lifecell_api/methods.rb +159 -0
- data/lib/lifecell_api/version.rb +7 -0
- data/lifecell_api.gemspec +28 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bc9d7e6af4706e51d9547c821cb7167c15f2ac837bc44b7b85939608622e66b8
|
4
|
+
data.tar.gz: 859f0f786da1feb7255b04b6c301b41dc0390293e9b397059f1c2503fe43fde3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '0649856738cc83c20f024ca748bfcf0c8e6fda2f6d2fad044c3b76b60d42921679d8775f7825c7a5b5db5ba4a24f365656e481ab2d1d4d508a93e3bd9ccaa341'
|
7
|
+
data.tar.gz: e6c9afdac89deffa06cb70d67f550830857c6df157427589a76c187039b343f9132814b42069d1b2c1c45b44b58b4f4d609ed681ac6d11fa3cf4ab9d32727c13
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.0
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013-2018 Anton Maminov
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
# lifecell::API
|
2
|
+
|
3
|
+
A Ruby library for interfacing with lifecell's undocumented/unannounced API.
|
4
|
+
|
5
|
+
[lifecell](http://lifecell.com.ua) — GSM operator in Ukraine.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem 'lifecell_api'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```
|
18
|
+
$ bundle
|
19
|
+
```
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
```
|
24
|
+
$ gem install lifecell_api
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
First of all require the `lifecell_api` library.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'lifecell_api'
|
33
|
+
```
|
34
|
+
|
35
|
+
### Authentication
|
36
|
+
|
37
|
+
You can authenticate with life:) in two ways: with password or with token.
|
38
|
+
|
39
|
+
Authentication with password to the life:) API is accomplished using a phone number(`msisdn`) starting with the country code("380"), and SuperPassword(`password`).
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
msisdn = '38063xxxxxxx'
|
43
|
+
password = 'xxxxxx'
|
44
|
+
|
45
|
+
life = Lifecell::API.new(msisdn: msisdn, password: password)
|
46
|
+
life.sign_in
|
47
|
+
token = life.token
|
48
|
+
sub_id = life.sub_id
|
49
|
+
```
|
50
|
+
|
51
|
+
> To obtain the SuperPassword send an SMS with key word PAROL to number 123.
|
52
|
+
|
53
|
+
or
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
life = Lifecell::API.new
|
57
|
+
life.token = token
|
58
|
+
life.sub_id = sub_id
|
59
|
+
```
|
60
|
+
|
61
|
+
Now you can make requests to the API.
|
62
|
+
|
63
|
+
### API Examples
|
64
|
+
|
65
|
+
Below you can see some the methods for working with life:) data.
|
66
|
+
|
67
|
+
#### Returns advanced information on the current subscriber
|
68
|
+
```
|
69
|
+
life.summary_data
|
70
|
+
```
|
71
|
+
|
72
|
+
Sample response
|
73
|
+
|
74
|
+
```
|
75
|
+
{"method"=>"getSummaryData",
|
76
|
+
"responseCode"=>"0",
|
77
|
+
"subscriber"=>
|
78
|
+
{"attribute"=>
|
79
|
+
[{"name"=>"ICCID", "content"=>"89380062300016907xxx"},
|
80
|
+
{"name"=>"PUK", "content"=>"25159xxx"},
|
81
|
+
{"name"=>"PUK2", "content"=>"00036xxx"},
|
82
|
+
{"name"=>"PIN2", "content"=>"55xx"},
|
83
|
+
{"name"=>"IMSI", "content"=>"25506109310xxxx"},
|
84
|
+
{"name"=>"PIN", "content"=>"70xx"},
|
85
|
+
{"name"=>"LINE_STATE", "content"=>"ACT/STD"},
|
86
|
+
{"name"=>"USE_COMMON_MAIN", "content"=>"false"},
|
87
|
+
{"name"=>"LINE_ACTIVATION_DATE",
|
88
|
+
"content"=>"2010-03-02T11:28:07.392+02:00"},
|
89
|
+
{"name"=>"LANGUAGE_ID", "content"=>"uk_tr"},
|
90
|
+
{"name"=>"DEVICE_NAME", "content"=>"HTC Sensation (PG58130)"},
|
91
|
+
{"name"=>"LINE_SUSPEND_DATE", "content"=>"2014-03-21T00:00:00+02:00"}],
|
92
|
+
"balance"=>
|
93
|
+
[{"code"=>"Line_Main", "amount"=>"12.83"},
|
94
|
+
{"code"=>"Line_Bonus", "amount"=>"0.00"},
|
95
|
+
{"code"=>"Line_Debt", "amount"=>"0.00"}],
|
96
|
+
"bundleFreeMigration"=>{"amount"=>"0"},
|
97
|
+
"tariff"=>{"code"=>"IND_PRE_YOUTH", "name"=>"Crazy day"}}}
|
98
|
+
```
|
99
|
+
|
100
|
+
#### Returns the balance of the current subscriber
|
101
|
+
|
102
|
+
```
|
103
|
+
life.balances
|
104
|
+
```
|
105
|
+
|
106
|
+
Sample response
|
107
|
+
|
108
|
+
```
|
109
|
+
{"method"=>"getBalances",
|
110
|
+
"responseCode"=>"0",
|
111
|
+
"balance"=>
|
112
|
+
[{"code"=>"Bundle_Gprs_Internet",
|
113
|
+
"amount"=>"0.00",
|
114
|
+
"measure"=>"Bytes",
|
115
|
+
"name"=>"Free Internet"},
|
116
|
+
{"code"=>"Bundle_Gprs_Wap",
|
117
|
+
"amount"=>"0.00",
|
118
|
+
"measure"=>"Bytes",
|
119
|
+
"name"=>"Free Internet [WAP]"},
|
120
|
+
{"code"=>"Bundle_Gprs_Internet_Youth",
|
121
|
+
"amount"=>"32624640.00",
|
122
|
+
"measure"=>"Bytes",
|
123
|
+
"name"=>"Internet [Crazy Day]"},
|
124
|
+
{"code"=>"Bundle_Usage_Internet_Weekly",
|
125
|
+
"amount"=>"0.00",
|
126
|
+
"measure"=>"Bytes",
|
127
|
+
"name"=>"Used Internet [Week]"},
|
128
|
+
{"code"=>"Bundle_Mms_Ukraine",
|
129
|
+
"amount"=>"0.00",
|
130
|
+
"measure"=>"MMS",
|
131
|
+
"name"=>"Free MMS [in Ukraine]"},
|
132
|
+
{"code"=>"Bundle_Sms_Ukraine",
|
133
|
+
"amount"=>"40.00",
|
134
|
+
"measure"=>"SMS",
|
135
|
+
"name"=>"Free SMS [in Ukraine]"},
|
136
|
+
{"code"=>"Bundle_Youth_Voice_Omo_Pstn",
|
137
|
+
"amount"=>"2160.00",
|
138
|
+
"measure"=>"Seconds",
|
139
|
+
"name"=>"100 min «life:) Сrazy day maximum» [other mob operators]"},
|
140
|
+
{"code"=>"Bundle_UsageN_FF_FREE",
|
141
|
+
"amount"=>"0.00",
|
142
|
+
"measure"=>"Seconds",
|
143
|
+
"name"=>"Free minutes [Family Numbers]"},
|
144
|
+
{"code"=>"Bundle_UsageN_Onnet_Region",
|
145
|
+
"amount"=>"0.00",
|
146
|
+
"measure"=>"Seconds",
|
147
|
+
"name"=>"Free minutes [Free life:) Donbas]"},
|
148
|
+
{"code"=>"Bundle_Voice_Onnet",
|
149
|
+
"amount"=>"24000.00",
|
150
|
+
"measure"=>"Seconds",
|
151
|
+
"name"=>"Free minutes [life:) network]"},
|
152
|
+
{"code"=>"Bundle_Voice_Offnet",
|
153
|
+
"amount"=>"0.00",
|
154
|
+
"measure"=>"Seconds",
|
155
|
+
"name"=>
|
156
|
+
"Free minutes [other mobile operators and fixed numbers of Ukraine]"},
|
157
|
+
{"code"=>"Line_Bonus",
|
158
|
+
"amount"=>"0.00",
|
159
|
+
"measure"=>"UAH",
|
160
|
+
"name"=>"Line Bonus"},
|
161
|
+
{"code"=>"Line_Main",
|
162
|
+
"amount"=>"12.83",
|
163
|
+
"measure"=>"UAH",
|
164
|
+
"name"=>"Line Main"}]}
|
165
|
+
```
|
166
|
+
|
167
|
+
#### Returns payments history for calendar month in format 'YYYY-mm'
|
168
|
+
|
169
|
+
```
|
170
|
+
life.payments_history('2013-03')
|
171
|
+
```
|
172
|
+
|
173
|
+
Sample response
|
174
|
+
|
175
|
+
```
|
176
|
+
{"method"=>"getPaymentsHistory",
|
177
|
+
"responseCode"=>"0",
|
178
|
+
"payments"=>
|
179
|
+
{"sum"=>"50.00",
|
180
|
+
"payment"=>
|
181
|
+
[{"date"=>"2013-03-21",
|
182
|
+
"time"=>"10:40:12",
|
183
|
+
"type"=>"Payment via WEB",
|
184
|
+
"sum"=>"10.00"},
|
185
|
+
{"date"=>"2013-03-21",
|
186
|
+
"time"=>"13:25:28",
|
187
|
+
"type"=>"Payment via WEB",
|
188
|
+
"sum"=>"40.00"}]}}
|
189
|
+
```
|
190
|
+
|
191
|
+
## Supported Rubies
|
192
|
+
|
193
|
+
Tested with the following Ruby versions:
|
194
|
+
|
195
|
+
* MRI 2.5.0
|
196
|
+
|
197
|
+
## Contributing
|
198
|
+
|
199
|
+
1. Fork it
|
200
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
201
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
202
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
203
|
+
5. Create new Pull Request
|
204
|
+
|
205
|
+
## License and Author
|
206
|
+
|
207
|
+
Copyright (c) 2013-2018 by Anton Maminov
|
208
|
+
|
209
|
+
This library is distributed under the MIT license. Please see the LICENSE file.
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
Bundler.setup :default
|
5
|
+
|
6
|
+
require 'logger'
|
7
|
+
require 'lifecell_api'
|
8
|
+
|
9
|
+
puts Lifecell::API::VERSION
|
10
|
+
|
11
|
+
msisdn = '38xxxxxxxxx'
|
12
|
+
password = 'xxxxxx'
|
13
|
+
|
14
|
+
life = Lifecell::API.new(msisdn: msisdn, password: password, lang: 'en')
|
15
|
+
life.log = Logger.new($stderr)
|
16
|
+
life.sign_in
|
17
|
+
|
18
|
+
summary_data = life.summary_data
|
19
|
+
|
20
|
+
tariff = summary_data['subscriber']['tariff']['name']
|
21
|
+
puts "Tariff: #{tariff}"
|
22
|
+
|
23
|
+
line_suspend_date = summary_data['subscriber']['attribute']
|
24
|
+
.select { |f| f['name'] == 'LINE_SUSPEND_DATE' }
|
25
|
+
.first['content']
|
26
|
+
line_suspend_date = Time.mktime(line_suspend_date).strftime('%d.%m.%Y')
|
27
|
+
puts "Suspend date: #{line_suspend_date}"
|
28
|
+
|
29
|
+
puts
|
30
|
+
|
31
|
+
balance = summary_data['subscriber']['balance']
|
32
|
+
main = balance.select { |f| f['code'] == 'Line_Main' }.first['amount']
|
33
|
+
bonus = balance.select { |f| f['code'] == 'Line_Bonus' }.first['amount']
|
34
|
+
debt = balance.select { |f| f['code'] == 'Line_Debt' }.first['amount']
|
35
|
+
puts "Main: #{main} ₴"
|
36
|
+
puts "Bonus: #{bonus} ₴"
|
37
|
+
puts "Dept: #{debt} ₴"
|
38
|
+
|
39
|
+
puts "\nBalances:"
|
40
|
+
balances = life.balances
|
41
|
+
balances['balance'].keep_if { |i| i['amount'].to_i != 0 }.each do |i|
|
42
|
+
puts " * #{i['name']}: #{i['amount']} #{i['measure']}"
|
43
|
+
end
|
44
|
+
|
45
|
+
life.sign_out
|
data/lib/lifecell_api.rb
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'cgi'
|
5
|
+
require 'net/https'
|
6
|
+
require 'openssl'
|
7
|
+
require 'base64'
|
8
|
+
|
9
|
+
require 'xmlsimple'
|
10
|
+
|
11
|
+
require 'lifecell_api/methods'
|
12
|
+
require 'lifecell_api/version'
|
13
|
+
|
14
|
+
# The Lifecell::API library is used for interactions with a https://api.life.com.ua.
|
15
|
+
# lifecell - GSM operator in Ukraine
|
16
|
+
#
|
17
|
+
# == Example
|
18
|
+
#
|
19
|
+
# require 'lifecell_api'
|
20
|
+
# require 'logger'
|
21
|
+
#
|
22
|
+
# life = Lifecell::API.new(msisdn: msisdn, password: password, lang: 'uk')
|
23
|
+
# life.log = Logger.new($stderr)
|
24
|
+
# life.sign_in
|
25
|
+
# life.get_summary_data
|
26
|
+
# life.sign_out
|
27
|
+
#
|
28
|
+
module Lifecell
|
29
|
+
class MethodError < ArgumentError; end
|
30
|
+
|
31
|
+
RESPONSE_CODES = {
|
32
|
+
'0' => 'SUCCESSFULY_PERFORMED',
|
33
|
+
'-1' => 'METHOD_INVOCATION_TIMEOUT',
|
34
|
+
'-2' => 'INTERNAL_ERROR',
|
35
|
+
'-3' => 'INVALID_PARAMETERS_LIST',
|
36
|
+
'-4' => 'VENDOR_AUTHORIZATION_FAILED',
|
37
|
+
'-5' => 'VENDOR_ACCESS_KEY_EXPIRED',
|
38
|
+
'-6' => 'VENDOR_AUTHENTICATION_FAILED',
|
39
|
+
'-7' => 'SUPERPASS_CHECKING_FAILED',
|
40
|
+
'-8' => 'INCORRECT_SUBSCRIBER_ID',
|
41
|
+
'-9' => 'INCORRECT_SUBSRIBER_STATE',
|
42
|
+
'-10' => 'SUPERPASS_BLOCKED',
|
43
|
+
'-11' => 'SUBSCRIBER_ID_NOT_FOUND',
|
44
|
+
'-12' => 'TOKEN_EXPIRED',
|
45
|
+
'-13' => 'CHANGE_TARIFF_FAILED',
|
46
|
+
'-14' => 'SERVICE_ACTIVATION_FAILED',
|
47
|
+
'-15' => 'OFFER_ACTIVATION_FAILED',
|
48
|
+
'-16' => 'GET_TARIFFS_FAILED',
|
49
|
+
'-17' => 'GET_SERVICES_FAILED',
|
50
|
+
'-18' => 'REMOVE_SERVICE_FROM_PREPROCESSING_FAILED',
|
51
|
+
'-19' => 'LOGIC_IS_BLOCKING',
|
52
|
+
'-20' => 'TOO_MANY_REQUESTS',
|
53
|
+
'-40' => 'PAYMENTS_OR_EXPENSES_MISSED',
|
54
|
+
'-21474833648' => 'INTERNAL_APPLICATION_ERROR'
|
55
|
+
}.freeze
|
56
|
+
|
57
|
+
# :nodoc:
|
58
|
+
class API
|
59
|
+
attr_accessor :token, :sub_id
|
60
|
+
|
61
|
+
class << self
|
62
|
+
# Default logger for all Lifecell::API instances
|
63
|
+
#
|
64
|
+
# Lifecell::API.log = Logger.new($stderr)
|
65
|
+
#
|
66
|
+
attr_accessor :log
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create a new API object using the given parameters.
|
70
|
+
#
|
71
|
+
# == Required parameters
|
72
|
+
#
|
73
|
+
# * +:msisdn+ - telephone number in format '38063*******'
|
74
|
+
# * +:password+ - super password
|
75
|
+
# * +:lang+ - 'uk', 'ru' or 'en'
|
76
|
+
#
|
77
|
+
def initialize(params = {})
|
78
|
+
@msisdn = params.delete(:msisdn)
|
79
|
+
@password = params.delete(:password)
|
80
|
+
@lang = params.delete(:lang) || 'uk'
|
81
|
+
|
82
|
+
@log = nil
|
83
|
+
|
84
|
+
@os_type = 'ANDROID'
|
85
|
+
|
86
|
+
@api_url = 'https://api.life.com.ua/mobile/'
|
87
|
+
@access_key_code = '7'
|
88
|
+
@application_key = 'E6j_$4UnR_)0b'
|
89
|
+
end
|
90
|
+
|
91
|
+
# The current logger. If no logger has been set Lifecell::API.log is used.
|
92
|
+
#
|
93
|
+
def log
|
94
|
+
@log || Lifecell::API.log
|
95
|
+
end
|
96
|
+
|
97
|
+
# Sets the +logger+ used by this instance of Lifecell::API
|
98
|
+
#
|
99
|
+
attr_writer :log
|
100
|
+
|
101
|
+
def request(method, params = {})
|
102
|
+
params = { accessKeyCode: @access_key_code }.merge(params)
|
103
|
+
url = create_signed_url(method, params)
|
104
|
+
|
105
|
+
log&.debug("[#{method}] request: #{url}")
|
106
|
+
|
107
|
+
response = response(url)
|
108
|
+
|
109
|
+
log&.debug("[#{method}] response: #{response.body}")
|
110
|
+
|
111
|
+
xml = parse_xml(response.body)
|
112
|
+
return xml if xml['responseCode'] == '0'
|
113
|
+
raise_error!(xml)
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def raise_error!(xml)
|
119
|
+
raise MethodError, "Unknown error: #{xml}" unless xml['responseCode']
|
120
|
+
|
121
|
+
error_message = Lifecell::RESPONSE_CODES[xml['responseCode']]
|
122
|
+
error_message ||= "Unknown error code #{xml['responseCode']}"
|
123
|
+
raise MethodError, error_message
|
124
|
+
end
|
125
|
+
|
126
|
+
def response(url)
|
127
|
+
uri = URI(url)
|
128
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
129
|
+
|
130
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
131
|
+
http.request(request)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def create_signed_url(method, params)
|
136
|
+
query = create_param(params)
|
137
|
+
str = method + '?' + query + '&signature='
|
138
|
+
|
139
|
+
digest = OpenSSL::Digest.new('sha1')
|
140
|
+
hash = OpenSSL::HMAC.digest(digest, @application_key, str)
|
141
|
+
|
142
|
+
hash = Base64.encode64(hash).chomp
|
143
|
+
|
144
|
+
str += urlencode(hash)
|
145
|
+
|
146
|
+
@api_url + str
|
147
|
+
end
|
148
|
+
|
149
|
+
# Returns a string representation of the receiver suitable for use
|
150
|
+
# as a URL query string
|
151
|
+
def create_param(params)
|
152
|
+
params.map do |key, value|
|
153
|
+
"#{urlencode(key)}=#{urlencode(value)}"
|
154
|
+
end.sort * '&'
|
155
|
+
end
|
156
|
+
|
157
|
+
# URL-encode a string
|
158
|
+
def urlencode(str)
|
159
|
+
CGI.escape(str.to_s)
|
160
|
+
end
|
161
|
+
|
162
|
+
def parse_xml(str)
|
163
|
+
XmlSimple.xml_in(str, 'ForceArray' => false)
|
164
|
+
end
|
165
|
+
|
166
|
+
def base_api_parameters
|
167
|
+
{ msisdn: @msisdn, languageId: @lang, osType: @os_type, token: @token }
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The list of available API method names:
|
4
|
+
# (16/22)
|
5
|
+
#
|
6
|
+
# [-] activateDeactivateService
|
7
|
+
# [+] callMeBack
|
8
|
+
# [+] changeLanguage
|
9
|
+
# [+] changeSuperPassword
|
10
|
+
# [-] changeTariff
|
11
|
+
# [+] getAvailableTariffs
|
12
|
+
# [+] getBalances
|
13
|
+
# [+] getExpensesSummary
|
14
|
+
# [+] getLanguages
|
15
|
+
# [+] getPaymentsHistory
|
16
|
+
# [-] getSeparateBalances
|
17
|
+
# [+] getServices
|
18
|
+
# [+] getSummaryData
|
19
|
+
# [+] getToken
|
20
|
+
# [+] getUIProperties
|
21
|
+
# [-] offerAction
|
22
|
+
# [+] refillBalanceByScratchCard
|
23
|
+
# [-] removeFromPreProcessing
|
24
|
+
# [+] requestBalanceTransfer
|
25
|
+
# [+] signIn
|
26
|
+
# [+] signOut
|
27
|
+
# [-] transferBalance
|
28
|
+
|
29
|
+
# :nodoc:
|
30
|
+
module Lifecell
|
31
|
+
# :nodoc:
|
32
|
+
class API
|
33
|
+
def sign_in
|
34
|
+
xml = request('signIn', msisdn: @msisdn, superPassword: @password)
|
35
|
+
@token = xml['token']
|
36
|
+
@sub_id = xml['subId']
|
37
|
+
xml
|
38
|
+
end
|
39
|
+
|
40
|
+
def sign_out
|
41
|
+
request(
|
42
|
+
'signOut',
|
43
|
+
msisdn: @msisdn,
|
44
|
+
subId: @sub_id
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def change_super_password(old_password, new_password)
|
49
|
+
request(
|
50
|
+
'changeSuperPassword',
|
51
|
+
base_api_parameters.merge(
|
52
|
+
oldPassword: old_password,
|
53
|
+
newPassword: new_password
|
54
|
+
)
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
def token
|
59
|
+
request(
|
60
|
+
'getToken',
|
61
|
+
msisdn: @msisdn, subId: @sub_id
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
# +last_date_update+ is DateTime object
|
66
|
+
#
|
67
|
+
def ui_properties(language_id, last_date_update)
|
68
|
+
request(
|
69
|
+
'getUIProperties',
|
70
|
+
accessKeyCode: @access_key_code,
|
71
|
+
languageId: language_id,
|
72
|
+
osType: @os_type,
|
73
|
+
lastDateUpdate: last_date_update
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
def summary_data
|
78
|
+
request(
|
79
|
+
'getSummaryData',
|
80
|
+
base_api_parameters
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
84
|
+
def services
|
85
|
+
request('getServices', base_api_parameters)
|
86
|
+
end
|
87
|
+
|
88
|
+
def available_tariffs
|
89
|
+
request(
|
90
|
+
'getAvailableTariffs',
|
91
|
+
base_api_parameters
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
def balances
|
96
|
+
request(
|
97
|
+
'getBalances',
|
98
|
+
base_api_parameters
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
def languages
|
103
|
+
request(
|
104
|
+
'getLanguages',
|
105
|
+
base_api_parameters
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
109
|
+
def change_language(new_language_id)
|
110
|
+
request(
|
111
|
+
'changeLanguage',
|
112
|
+
base_api_parameters.merge(newLanguageId: new_language_id)
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
116
|
+
def call_me_back(msisdn_b)
|
117
|
+
request(
|
118
|
+
'callMeBack',
|
119
|
+
base_api_parameters.merge(msisdnB: msisdn_b)
|
120
|
+
)
|
121
|
+
end
|
122
|
+
|
123
|
+
def request_balance_transfer(msisdn_b)
|
124
|
+
request(
|
125
|
+
'requestBalanceTransfer',
|
126
|
+
base_api_parameters.merge(msisdnB: msisdn_b)
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Payments history for calendar month +month_period+
|
131
|
+
#
|
132
|
+
# +month_period+ - A string like 'yyyy-MM' that represent month of year
|
133
|
+
#
|
134
|
+
def payments_history(month_period)
|
135
|
+
request(
|
136
|
+
'getPaymentsHistory',
|
137
|
+
base_api_parameters.merge(monthPeriod: month_period)
|
138
|
+
)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Summary expenses report for calendar month +month_period+
|
142
|
+
#
|
143
|
+
# +month_period+ - A string like 'yyyy-MM' that represent month of year
|
144
|
+
#
|
145
|
+
def expenses_summary(month_period)
|
146
|
+
request(
|
147
|
+
'getExpensesSummary',
|
148
|
+
base_api_parameters.merge(monthPeriod: month_period)
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
152
|
+
def refill_balance_by_scratch_card(secret_code)
|
153
|
+
request(
|
154
|
+
'refillBalanceByScratchCard',
|
155
|
+
base_api_parameters.merge(secretCode: secret_code)
|
156
|
+
)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'lifecell_api/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |gem|
|
8
|
+
gem.name = 'lifecell_api'
|
9
|
+
gem.version = Lifecell::API::VERSION
|
10
|
+
gem.authors = ['Anton Maminov']
|
11
|
+
gem.email = ['anton.maminov@gmail.com']
|
12
|
+
gem.description = 'A Ruby interface to the lifecell API'
|
13
|
+
gem.summary = <<-SUMMARY
|
14
|
+
The Life::API library is used for interactions
|
15
|
+
with api.life.com.ua
|
16
|
+
SUMMARY
|
17
|
+
gem.homepage = 'https://github.com/mamantoha/lifecell_api'
|
18
|
+
gem.license = 'MIT'
|
19
|
+
|
20
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
21
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
22
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
23
|
+
gem.require_paths = ['lib']
|
24
|
+
|
25
|
+
gem.add_runtime_dependency('xml-simple', '~> 1.1.2')
|
26
|
+
gem.add_development_dependency('pry')
|
27
|
+
gem.add_development_dependency('rubocop')
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lifecell_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anton Maminov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: xml-simple
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A Ruby interface to the lifecell API
|
56
|
+
email:
|
57
|
+
- anton.maminov@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".ruby-version"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- examples/get_balance.rb
|
69
|
+
- lib/lifecell_api.rb
|
70
|
+
- lib/lifecell_api/methods.rb
|
71
|
+
- lib/lifecell_api/version.rb
|
72
|
+
- lifecell_api.gemspec
|
73
|
+
homepage: https://github.com/mamantoha/lifecell_api
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.7.3
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: The Life::API library is used for interactions with api.life.com.ua
|
97
|
+
test_files: []
|