lifecell_api 0.5.2 → 0.7.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e161334834d9819499fa1b81a404fe5b14c4ce8932d7b714eb010c9d8cb0e7f3
4
- data.tar.gz: eee3cbe67cf7464bade5da1ce92dd037548fa414304ae5e18cdc6120ee5c9f37
3
+ metadata.gz: 6052e820270074f159f3a1ae02c1aaaae772792a8df361790a28b8501b830754
4
+ data.tar.gz: 497ccf14008bd9437d8267003d44ab1336d76d946faed3714a6d8aee4a60a062
5
5
  SHA512:
6
- metadata.gz: caa06fd50e0a51f6cef47716e9e0912cb5a29e952d9d15753d1eac7baca51377daae4e04634e33877c2570743c334634655e7a6ee2e786b65cf387f7c171129f
7
- data.tar.gz: d21da4225c601fdd0ec6b9743bcba3d60123ed515e0771d34af8c4480a3621b4b89389bf7be60d5c5b779dda9d718ef806a3aae309e5e2a324393a91edfa5559
6
+ metadata.gz: 2a7a01ff2ff88688bae6c542babd8218f9875be5a9572b48a0a6e42a65513c5bc58803dfa4043c7746008ec4539f1df0ca59249874219f675574e221ba2da911
7
+ data.tar.gz: 027d832cfe58082ff84a7120daf4e4446e90ae6b14a6523c70f199751c58197e0af4193ad1bb7b094c9c93b21f55e5dd38c07916da061716004670517a00c3a8
@@ -0,0 +1,13 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+
9
+ # Maintain dependencies for GitHub Actions
10
+ - package-ecosystem: "github-actions"
11
+ directory: "/"
12
+ schedule:
13
+ interval: "weekly"
@@ -0,0 +1,30 @@
1
+ name: "Rubocop"
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+ pull_request:
7
+ branches: [ "master" ]
8
+ schedule:
9
+ - cron: '20 3 * * 6'
10
+
11
+ jobs:
12
+ rubocop:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+
17
+ steps:
18
+ - name: Checkout repository
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: 3.0
25
+
26
+ - name: Install dependencies
27
+ run: bundle install
28
+
29
+ - name: Rubocop run
30
+ run: bundle exec rubocop
@@ -0,0 +1,28 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+ pull_request:
7
+ branches: [ "master" ]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ test:
14
+
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ ruby-version: ['3.2']
19
+
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby-version }}
26
+ bundler-cache: true
27
+ - name: Run tests
28
+ run: bundle exec rspec
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  Gemfile.lock
2
2
  /examples/
3
+ /spec/examples.txt
4
+ /coverage
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,8 +1,3 @@
1
1
  AllCops:
2
+ TargetRubyVersion: 3.2
2
3
  NewCops: enable
3
-
4
- Metrics/AbcSize:
5
- Max: 17
6
-
7
- Metrics/MethodLength:
8
- Max: 11
data/Gemfile CHANGED
@@ -4,3 +4,18 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in life-api.gemspec
6
6
  gemspec
7
+
8
+ group :development do
9
+ gem 'pry'
10
+ gem 'rubocop', require: false
11
+ end
12
+
13
+ group :development, :test do
14
+ gem 'rspec'
15
+ end
16
+
17
+ group :test do
18
+ gem 'simplecov'
19
+ gem 'vcr'
20
+ gem 'webmock'
21
+ end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2020 Anton Maminov
1
+ Copyright (c) 2013-2023 Anton Maminov
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # lifecell::API
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/lifecell_api.svg)](https://badge.fury.io/rb/lifecell_api)
4
+ [![Ruby](https://github.com/mamantoha/lifecell_api/actions/workflows/ruby.yml/badge.svg)](https://github.com/mamantoha/lifecell_api/actions/workflows/ruby.yml)
5
+ [![Rubocop](https://github.com/mamantoha/lifecell_api/actions/workflows/rubocop.yml/badge.svg)](https://github.com/mamantoha/lifecell_api/actions/workflows/rubocop.yml)
6
+
3
7
  A Ruby library for interfacing with lifecell's undocumented/unannounced API.
4
8
 
5
9
  Formerly known as `life-api`.
@@ -36,9 +40,9 @@ require 'lifecell_api'
36
40
 
37
41
  ### Authentication
38
42
 
39
- You can authenticate with life:) in two ways: with password or with token.
43
+ You can authenticate with lifecell in two ways: with password or with token.
40
44
 
41
- Authentication with password to the life:) API is accomplished using a phone number(`msisdn`) starting with the country code("380"), and SuperPassword(`password`).
45
+ Authentication with password to the lifecell API is accomplished using a phone number(`msisdn`) starting with the country code("380"), and SuperPassword(`password`).
42
46
 
43
47
  ```ruby
44
48
  msisdn = '38063xxxxxxx'
@@ -64,16 +68,17 @@ Now you can make requests to the API.
64
68
 
65
69
  ### API Examples
66
70
 
67
- Below you can see some the methods for working with life:) data.
71
+ Below you can see some the methods for working with lifecell data.
68
72
 
69
73
  #### Returns advanced information on the current subscriber
70
- ```
74
+
75
+ ```ruby
71
76
  life.summary_data
72
77
  ```
73
78
 
74
79
  Sample response
75
80
 
76
- ```
81
+ ```ruby
77
82
  {"method"=>"getSummaryData",
78
83
  "responseCode"=>"0",
79
84
  "subscriber"=>
@@ -101,13 +106,13 @@ Sample response
101
106
 
102
107
  #### Returns the balance of the current subscriber
103
108
 
104
- ```
109
+ ```ruby
105
110
  life.balances
106
111
  ```
107
112
 
108
113
  Sample response
109
114
 
110
- ```
115
+ ```ruby
111
116
  {"method"=>"getBalances",
112
117
  "responseCode"=>"0",
113
118
  "balance"=>
@@ -168,13 +173,13 @@ Sample response
168
173
 
169
174
  #### Returns payments history for calendar month in format 'YYYY-mm'
170
175
 
171
- ```
176
+ ```ruby
172
177
  life.payments_history('2013-03')
173
178
  ```
174
179
 
175
180
  Sample response
176
181
 
177
- ```
182
+ ```ruby
178
183
  {"method"=>"getPaymentsHistory",
179
184
  "responseCode"=>"0",
180
185
  "payments"=>
@@ -190,12 +195,6 @@ Sample response
190
195
  "sum"=>"40.00"}]}}
191
196
  ```
192
197
 
193
- ## Supported Rubies
194
-
195
- Tested with the following Ruby versions:
196
-
197
- * MRI 2.5.0
198
-
199
198
  ## Contributing
200
199
 
201
200
  1. Fork it
@@ -206,6 +205,6 @@ Tested with the following Ruby versions:
206
205
 
207
206
  ## License and Author
208
207
 
209
- Copyright (c) 2013-2020 by Anton Maminov
208
+ Copyright (c) 2013-2023 by Anton Maminov
210
209
 
211
210
  This library is distributed under the MIT license. Please see the LICENSE file.
@@ -4,6 +4,7 @@ require 'bundler'
4
4
  Bundler.setup :default
5
5
 
6
6
  require 'logger'
7
+ require 'time'
7
8
  require 'lifecell_api'
8
9
 
9
10
  puts Lifecell::API::VERSION
@@ -11,7 +12,7 @@ puts Lifecell::API::VERSION
11
12
  msisdn = '38xxxxxxxxx'
12
13
  password = 'xxxxxx'
13
14
 
14
- life = Lifecell::API.new(msisdn: msisdn, password: password, lang: 'en')
15
+ life = Lifecell::API.new(msisdn:, password:, lang: 'en')
15
16
  life.log = Logger.new($stderr)
16
17
  life.sign_in
17
18
 
@@ -23,7 +24,7 @@ puts "Tariff: #{tariff}"
23
24
  line_suspend_date = summary_data['subscriber']['attribute']
24
25
  .select { |f| f['name'] == 'LINE_SUSPEND_DATE' }
25
26
  .first['content']
26
- line_suspend_date = Time.mktime(line_suspend_date).strftime('%d.%m.%Y')
27
+ line_suspend_date = Time.parse(line_suspend_date).to_time.strftime('%d.%m.%Y')
27
28
  puts "Suspend date: #{line_suspend_date}"
28
29
 
29
30
  puts
@@ -37,7 +38,7 @@ puts "Bonus: #{bonus} ₴"
37
38
  puts "Dept: #{debt} ₴"
38
39
 
39
40
  puts "\nBalances:"
40
- balances = life.balances
41
+ balances = life.balances
41
42
  balances['balance'].keep_if { |i| i['amount'].to_i != 0 }.each do |i|
42
43
  puts " * #{i['name']}: #{i['amount']} #{i['measure']}"
43
44
  end
@@ -67,9 +67,9 @@ module Lifecell
67
67
  def ui_properties(language_id, last_date_update)
68
68
  request(
69
69
  'getUIProperties',
70
- accessKeyCode: @access_key_code,
70
+ accessKeyCode: ACCESS_KEY_CODE,
71
71
  languageId: language_id,
72
- osType: @os_type,
72
+ osType: OS_TYPE,
73
73
  lastDateUpdate: last_date_update
74
74
  )
75
75
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lifecell
4
4
  class API
5
- VERSION = '0.5.2'
5
+ VERSION = '0.7.0'
6
6
  end
7
7
  end
data/lib/lifecell_api.rb CHANGED
@@ -11,7 +11,7 @@ require 'xmlsimple'
11
11
  require 'lifecell_api/methods'
12
12
  require 'lifecell_api/version'
13
13
 
14
- # The Lifecell::API library is used for interactions with a https://api.life.com.ua.
14
+ # The Lifecell::API library is used for interactions with a https://api.lifecell.com.ua.
15
15
  # lifecell - GSM operator in Ukraine
16
16
  #
17
17
  # == Example
@@ -27,6 +27,7 @@ require 'lifecell_api/version'
27
27
  #
28
28
  module Lifecell
29
29
  class MethodError < ArgumentError; end
30
+
30
31
  class StatusError < ArgumentError; end
31
32
 
32
33
  RESPONSE_CODES = {
@@ -59,6 +60,11 @@ module Lifecell
59
60
  class API
60
61
  attr_accessor :token, :sub_id
61
62
 
63
+ BASE_URL = 'https://api.lifecell.com.ua/mobile/'
64
+ ACCESS_KEY_CODE = '7'
65
+ APPLICATION_KEY = 'E6j_$4UnR_)0b'
66
+ OS_TYPE = 'ANDROID'
67
+
62
68
  class << self
63
69
  # Default logger for all Lifecell::API instances
64
70
  #
@@ -75,18 +81,12 @@ module Lifecell
75
81
  # * +:password+ - super password
76
82
  # * +:lang+ - 'uk', 'ru' or 'en'
77
83
  #
78
- def initialize(params = {})
79
- @msisdn = params.delete(:msisdn)
80
- @password = params.delete(:password)
81
- @lang = params.delete(:lang) || 'uk'
84
+ def initialize(msisdn:, password:, lang: 'uk')
85
+ @msisdn = msisdn
86
+ @password = password
87
+ @lang = lang
82
88
 
83
89
  @log = nil
84
-
85
- @os_type = 'ANDROID'
86
-
87
- @api_url = 'https://api.life.com.ua/mobile/'
88
- @access_key_code = '7'
89
- @application_key = 'E6j_$4UnR_)0b'
90
90
  end
91
91
 
92
92
  # The current logger. If no logger has been set Lifecell::API.log is used.
@@ -100,7 +100,7 @@ module Lifecell
100
100
  attr_writer :log
101
101
 
102
102
  def request(method, params = {})
103
- params = { accessKeyCode: @access_key_code }.merge(params)
103
+ params = { accessKeyCode: ACCESS_KEY_CODE }.merge(params)
104
104
  url = create_signed_url(method, params)
105
105
 
106
106
  log&.debug("[#{method}] request: #{url}")
@@ -138,16 +138,16 @@ module Lifecell
138
138
 
139
139
  def create_signed_url(method, params)
140
140
  query = create_param(params)
141
- str = method + '?' + query + '&signature='
141
+ str = "#{method}?#{query}&signature="
142
142
 
143
143
  digest = OpenSSL::Digest.new('sha1')
144
- hash = OpenSSL::HMAC.digest(digest, @application_key, str)
144
+ hash = OpenSSL::HMAC.digest(digest, APPLICATION_KEY, str)
145
145
 
146
146
  hash = Base64.encode64(hash).chomp
147
147
 
148
148
  str += urlencode(hash)
149
149
 
150
- @api_url + str
150
+ BASE_URL + str
151
151
  end
152
152
 
153
153
  # Returns a string representation of the receiver suitable for use
@@ -168,7 +168,7 @@ module Lifecell
168
168
  end
169
169
 
170
170
  def base_api_parameters
171
- { msisdn: @msisdn, languageId: @lang, osType: @os_type, token: @token }
171
+ { msisdn: @msisdn, languageId: @lang, osType: OS_TYPE, token: @token }
172
172
  end
173
173
  end
174
174
  end
data/lifecell_api.gemspec CHANGED
@@ -12,17 +12,16 @@ Gem::Specification.new do |gem|
12
12
  gem.description = 'A Ruby interface to the lifecell API'
13
13
  gem.summary = <<-SUMMARY
14
14
  The Lifecell::API library is used for interactions
15
- with api.life.com.ua
15
+ with api.lifecell.com.ua
16
16
  SUMMARY
17
17
  gem.homepage = 'https://github.com/mamantoha/lifecell_api'
18
18
  gem.license = 'MIT'
19
19
 
20
20
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
21
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
22
  gem.require_paths = ['lib']
24
23
 
24
+ gem.required_ruby_version = '>= 3.2'
25
25
  gem.add_runtime_dependency('xml-simple', '~> 1.1.2')
26
- gem.add_development_dependency('pry')
27
- gem.add_development_dependency('rubocop')
26
+ gem.metadata['rubygems_mfa_required'] = 'true'
28
27
  end
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.lifecell.com.ua/mobile/signIn?accessKeyCode=7&msisdn=380630000000&signature=pZqbYXP/F5cxZhNX2lXA/rlzynI=&superPassword=passw0rd
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Sat, 20 May 2023 13:09:07 GMT
25
+ Content-Type:
26
+ - application/xml;charset=UTF-8
27
+ Content-Length:
28
+ - '242'
29
+ Connection:
30
+ - keep-alive
31
+ X-Frame-Options:
32
+ - SAMEORIGIN
33
+ body:
34
+ encoding: UTF-8
35
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><response method="signIn"><responseCode>0</responseCode><resultText>Successful
36
+ logic performing or data returning</resultText><token>T0KEN</token><subId>SUB_ID</subId></response>
37
+ recorded_at: Sat, 20 May 2023 13:09:07 GMT
38
+ recorded_with: VCR 6.1.0
@@ -0,0 +1,97 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.lifecell.com.ua/mobile/signIn?accessKeyCode=7&msisdn=380630000000&signature=pZqbYXP/F5cxZhNX2lXA/rlzynI=&superPassword=passw0rd
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Sat, 20 May 2023 13:48:38 GMT
25
+ Content-Type:
26
+ - application/xml;charset=UTF-8
27
+ Content-Length:
28
+ - '242'
29
+ Connection:
30
+ - keep-alive
31
+ X-Frame-Options:
32
+ - SAMEORIGIN
33
+ body:
34
+ encoding: UTF-8
35
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><response method="signIn"><responseCode>0</responseCode><resultText>Successful
36
+ logic performing or data returning</resultText><token>T0KEN</token><subId>SUB_ID</subId></response>
37
+ recorded_at: Sat, 20 May 2023 13:48:38 GMT
38
+ - request:
39
+ method: get
40
+ uri: https://api.lifecell.com.ua/mobile/getSummaryData?accessKeyCode=7&languageId=uk&msisdn=380630000000&osType=ANDROID&signature=zeFGal/zqqJzY9%2BST2/RVzdhiwQ=&token=T0KEN
41
+ body:
42
+ encoding: US-ASCII
43
+ string: ''
44
+ headers:
45
+ Accept-Encoding:
46
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
47
+ Accept:
48
+ - "*/*"
49
+ User-Agent:
50
+ - Ruby
51
+ response:
52
+ status:
53
+ code: 200
54
+ message: OK
55
+ headers:
56
+ Server:
57
+ - nginx
58
+ Date:
59
+ - Sat, 20 May 2023 13:48:40 GMT
60
+ Content-Type:
61
+ - application/xml;charset=UTF-8
62
+ Content-Length:
63
+ - '2872'
64
+ Connection:
65
+ - keep-alive
66
+ X-Frame-Options:
67
+ - SAMEORIGIN
68
+ body:
69
+ encoding: UTF-8
70
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><response method="getSummaryData"><responseCode>0</responseCode><resultText>Successful
71
+ logic performing or data returning</resultText><subscriber msisdn="380630000000"><attribute
72
+ name="ICCID">89380062300016907xxx</attribute><attribute name="PUK">25159xxx</attribute><attribute
73
+ name="PUK2">00036xxx</attribute><attribute name="PIN2">9300</attribute><attribute
74
+ name="IMSI">25506109310xxxx</attribute><attribute name="PIN">70xx</attribute><attribute
75
+ name="SIM_TYPE">ESIM</attribute><attribute name="LINE_STATE">ACT/STD</attribute><attribute
76
+ name="USE_COMMON_MAIN">false</attribute><attribute name="IS_FISHKA">N</attribute><attribute
77
+ name="NEXT_FEE_CHARGING_DATE">28.05.23</attribute><attribute name="LANGUAGE_ID">ug</attribute><attribute
78
+ name="LINE_ACTIVATION_DATE">2010-03-02T11:28:07.000+02:00</attribute><attribute
79
+ name="LINE_SUSPEND_DATE">2024-04-29T00:00:00.000+03:00</attribute><attribute
80
+ name="DEVICE_LTE_SUPPORT">YES</attribute><balance code="Line_Main" amount="206.95"/><balance
81
+ code="Line_Bonus" amount="0.00"/><balance code="Line_Debt" amount="0.00"/><tariff><code>IND_PRE_INET_HEAT</code><name>Internet
82
+ Heat</name><description>&lt;ul&gt;&lt;li&gt;20GB of Internet&lt;/li&gt;&lt;li&gt;500
83
+ min to all numbers within Ukraine (landline and mobile, including lifecell)&lt;/li&gt;&lt;li&gt;Unlim
84
+ to Facebook, Instagram, Twitter&lt;/li&gt;&lt;li&gt;50GB in lifebox storage&lt;/li&gt;&lt;li&gt;+1GB
85
+ for every 30 min of outgoing calls from BiP Out&lt;/li&gt;&lt;/ul&gt;&lt;br&gt;&lt;b&gt;Service
86
+ package cost for 4 weeks - 200 UAH&lt;/b&gt;&lt;b&gt;&lt;br&gt;&lt;/b&gt;&lt;b&gt;&lt;br&gt;&lt;/b&gt;Tariffs
87
+ are quoted with all taxes.&lt;br&gt;</description><picture_url>https://m.lifecell.ua/uploads/medialibrary/2021/01/4SITE_internetHeat_EN.png</picture_url><webview_url>https://m.lifecell.ua/en/mobile/tariffs/internet-heat/</webview_url><short_description>&lt;html&gt;&lt;body&gt;&lt;p&gt;Hot
88
+ tariff for the internet&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</short_description><tariff_price_discount>200</tariff_price_discount><tariff_price_full>200</tariff_price_full><tariff_order_period>4
89
+ weeks</tariff_order_period></tariff><use_common_main>false</use_common_main></subscriber><applicationAttributes><attribute
90
+ name="REORDER_A">Yes</attribute><attribute name="REORDER_B">Yes</attribute><attribute
91
+ name="GIFT_B">Yes</attribute><attribute name="IS_HANDMADE_AVAILABLE">Yes</attribute><attribute
92
+ name="IS_SHAKE_AND_WIN_AVAILABLE">Yes</attribute><attribute name="SIMAGOTCHI">Yes</attribute><attribute
93
+ name="IS_GIFTS_POOL_AVAILABLE">Yes</attribute><attribute name="POSSIBILITY_DIYA_IDENTIFICATION">No</attribute><attribute
94
+ name="POSSIBILITY_DIYA_REGISTRATION">No</attribute><attribute name="IS_SMILE_BONUS_AVAILABLE">No</attribute><attribute
95
+ name="IS_BAYRAKTAR_AVAILABLE">No</attribute></applicationAttributes></response>
96
+ recorded_at: Sat, 20 May 2023 13:48:40 GMT
97
+ recorded_with: VCR 6.1.0
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'lifecell_api'
5
+
6
+ RSpec.describe Lifecell::API do
7
+ let(:msisdn) { '380630000000' }
8
+ let(:password) { 'passw0rd' }
9
+ let(:token) { 'T0KEN' }
10
+
11
+ it 'initialize' do
12
+ lifecell_api = Lifecell::API.new(msisdn: '380xxxxxxxxx', password: 'xxxxxx', lang: 'uk')
13
+ expect(lifecell_api).to be_a(Lifecell::API)
14
+ expect(lifecell_api.token).to be_nil
15
+ end
16
+
17
+ it 'sign_in', :vcr do
18
+ lifecell_api = Lifecell::API.new(msisdn:, password:, lang: 'uk')
19
+ lifecell_api.sign_in
20
+
21
+ expect(lifecell_api.token).to eq(token)
22
+ end
23
+
24
+ it 'summary_data', :vcr do
25
+ lifecell_api = Lifecell::API.new(msisdn:, password:, lang: 'uk')
26
+ lifecell_api.sign_in
27
+
28
+ expect(lifecell_api.token).to eq(token)
29
+
30
+ summary_data = lifecell_api.summary_data
31
+
32
+ expect(summary_data['subscriber']['tariff']['name']).to eq('Internet Heat')
33
+ end
34
+ end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'vcr'
4
+
5
+ require 'simplecov'
6
+ SimpleCov.start
7
+
8
+ RSpec.configure do |config|
9
+ config.expect_with :rspec do |expectations|
10
+ # This option will default to `true` in RSpec 4. It makes the `description`
11
+ # and `failure_message` of custom matchers include text for helper methods
12
+ # defined using `chain`, e.g.:
13
+ # be_bigger_than(2).and_smaller_than(4).description
14
+ # # => "be bigger than 2 and smaller than 4"
15
+ # ...rather than:
16
+ # # => "be bigger than 2"
17
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
18
+ end
19
+
20
+ # rspec-mocks config goes here. You can use an alternate test double
21
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
22
+ config.mock_with :rspec do |mocks|
23
+ # Prevents you from mocking or stubbing a method that does not exist on
24
+ # a real object. This is generally recommended, and will default to
25
+ # `true` in RSpec 4.
26
+ mocks.verify_partial_doubles = true
27
+ end
28
+
29
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
30
+ # have no way to turn it off -- the option exists only for backwards
31
+ # compatibility in RSpec 3). It causes shared context metadata to be
32
+ # inherited by the metadata hash of host groups and examples, rather than
33
+ # triggering implicit auto-inclusion in groups with matching metadata.
34
+ config.shared_context_metadata_behavior = :apply_to_host_groups
35
+
36
+ # The settings below are suggested to provide a good initial experience
37
+ # with RSpec, but feel free to customize to your heart's content.
38
+
39
+ # This allows you to limit a spec run to individual examples or groups
40
+ # you care about by tagging them with `:focus` metadata. When nothing
41
+ # is tagged with `:focus`, all examples get run. RSpec also provides
42
+ # aliases for `it`, `describe`, and `context` that include `:focus`
43
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
44
+ config.filter_run_when_matching :focus
45
+
46
+ # Allows RSpec to persist some state between runs in order to support
47
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
48
+ # you configure your source control system to ignore this file.
49
+ config.example_status_persistence_file_path = 'spec/examples.txt'
50
+
51
+ # Limits the available syntax to the non-monkey patched syntax that is
52
+ # recommended. For more details, see:
53
+ # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
54
+ config.disable_monkey_patching!
55
+
56
+ # This setting enables warnings. It's recommended, but in some cases may
57
+ # be too noisy due to issues in dependencies.
58
+ config.warnings = true
59
+
60
+ # Many RSpec users commonly either run the entire suite or an individual
61
+ # file, and it's useful to allow more verbose output when running an
62
+ # individual spec file.
63
+ if config.files_to_run.one?
64
+ # Use the documentation formatter for detailed output,
65
+ # unless a formatter has already been configured
66
+ # (e.g. via a command-line flag).
67
+ config.default_formatter = 'doc'
68
+ end
69
+
70
+ # Print the 10 slowest examples and example groups at the
71
+ # end of the spec run, to help surface which specs are running
72
+ # particularly slow.
73
+ config.profile_examples = 10
74
+
75
+ # Run specs in random order to surface order dependencies. If you find an
76
+ # order dependency and want to debug it, you can fix the order by providing
77
+ # the seed, which is printed after each run.
78
+ # --seed 1234
79
+ config.order = :random
80
+
81
+ # Seed global randomization in this process using the `--seed` CLI option.
82
+ # Setting this allows you to use `--seed` to deterministically reproduce
83
+ # test failures related to randomization by passing the same `--seed` value
84
+ # as the one that triggered the failure.
85
+ Kernel.srand config.seed
86
+ end
87
+
88
+ VCR.configure do |config|
89
+ config.cassette_library_dir = 'spec/cassettes'
90
+ config.hook_into :webmock
91
+ config.configure_rspec_metadata!
92
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lifecell_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Maminov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-26 00:00:00.000000000 Z
11
+ date: 2023-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xml-simple
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
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
27
  description: A Ruby interface to the lifecell API
56
28
  email:
57
29
  - anton.maminov@gmail.com
@@ -59,7 +31,11 @@ executables: []
59
31
  extensions: []
60
32
  extra_rdoc_files: []
61
33
  files:
34
+ - ".github/dependabot.yml"
35
+ - ".github/workflows/rubocop.yml"
36
+ - ".github/workflows/ruby.yml"
62
37
  - ".gitignore"
38
+ - ".rspec"
63
39
  - ".rubocop.yml"
64
40
  - Gemfile
65
41
  - LICENSE
@@ -70,11 +46,16 @@ files:
70
46
  - lib/lifecell_api/methods.rb
71
47
  - lib/lifecell_api/version.rb
72
48
  - lifecell_api.gemspec
49
+ - spec/cassettes/Lifecell_API/sign_in.yml
50
+ - spec/cassettes/Lifecell_API/summary_data.yml
51
+ - spec/lifecell_api/lifecell_api_spec.rb
52
+ - spec/spec_helper.rb
73
53
  homepage: https://github.com/mamantoha/lifecell_api
74
54
  licenses:
75
55
  - MIT
76
- metadata: {}
77
- post_install_message:
56
+ metadata:
57
+ rubygems_mfa_required: 'true'
58
+ post_install_message:
78
59
  rdoc_options: []
79
60
  require_paths:
80
61
  - lib
@@ -82,15 +63,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
63
  requirements:
83
64
  - - ">="
84
65
  - !ruby/object:Gem::Version
85
- version: '0'
66
+ version: '3.2'
86
67
  required_rubygems_version: !ruby/object:Gem::Requirement
87
68
  requirements:
88
69
  - - ">="
89
70
  - !ruby/object:Gem::Version
90
71
  version: '0'
91
72
  requirements: []
92
- rubygems_version: 3.1.2
93
- signing_key:
73
+ rubygems_version: 3.4.14
74
+ signing_key:
94
75
  specification_version: 4
95
- summary: The Lifecell::API library is used for interactions with api.life.com.ua
76
+ summary: The Lifecell::API library is used for interactions with api.lifecell.com.ua
96
77
  test_files: []