ince-api 0.0.5 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6cf316b89d977fd71b7ce34016293b8ddedaf6f7e603b68dfe97fa36caa7da9
4
- data.tar.gz: 27e68644caa19d84c3cc81f08b55e8c938c50a832c9e3d95dfefb59b9f433aee
3
+ metadata.gz: d9c29a91fac4424a3df093e22fb7fd3efdf35fbeec8afb98365e3e510649a0d7
4
+ data.tar.gz: 2d1290f5a1a64061cf26fa37f5513b012856023e525fba5fce5e298c4d55db9c
5
5
  SHA512:
6
- metadata.gz: 022716e249754766b011e08191061520187b35c86f9af510c42823396bafad73b9e29337534c639c8de5394d126d452994ce8eeafa31d23957d523f7e1e92cf5
7
- data.tar.gz: 73320c7161f9a43a4c9e50a84df43f0faa0605c74c9e3f6886136a7648c25aab2de9779d2ff47b282b562ddc588222964f1bd99407a117b9dec57d3adf7d347a
6
+ metadata.gz: 1c3267ad2830c8e1952f9d2d76b0116b6bebb7401244d27b9e01b867a878524713ab1877013de4b5840684e4e35691e945a115e716ca2f045732e9af5a7e43b8
7
+ data.tar.gz: a1715d6f54277a3ab61cf079f34c40a6b93b2f8664f88e385a8dbaf418a6719cdcd8a61459ba345b405b9de392c1c70768d97959626579c39a9007aabd529e69
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ince-api (0.0.4)
4
+ ince-api (0.0.6)
5
5
  base64 (~> 0.1)
6
6
  net-http (~> 0.2)
7
7
  openssl (~> 2.2)
data/ince-api.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ince-api'
3
- s.version = '0.0.5'
3
+ s.version = '0.1.2'
4
4
  s.summary = "1nce API wrapper"
5
5
  s.description = "A simple wrapper for 1nce API"
6
6
  s.authors = ["Stanislaw Zawadzki"]
data/lib/ince-api.rb CHANGED
@@ -13,3 +13,4 @@ require_relative 'ince_api/get_sim_usage'
13
13
  require_relative 'ince_api/single_sim_configuration'
14
14
  require_relative 'ince_api/multiple_sims_configuration'
15
15
  require_relative 'ince_api/create_sms'
16
+ require_relative 'ince_api/reset_connectivity'
@@ -1,5 +1,7 @@
1
1
  module InceApi
2
2
  class GetSims
3
+ attr_reader :headers
4
+
3
5
  def initialize(access_token:, params: {})
4
6
  @access_token = access_token
5
7
  @params = params
@@ -7,6 +9,8 @@ module InceApi
7
9
 
8
10
  def sims
9
11
  response = connection.request(request)
12
+ @headers = response.each_header.to_h
13
+
10
14
  JSON.parse(response.body)
11
15
  end
12
16
 
@@ -0,0 +1,36 @@
1
+ module InceApi
2
+ class ResetConnectivity
3
+ def initialize(access_token:, iccid:)
4
+ @access_token = access_token
5
+ @iccid = iccid
6
+ end
7
+
8
+ def reset
9
+ response = connection.request(request)
10
+ if response.body != ''
11
+ JSON.parse(response.body)
12
+ else
13
+ {'status_code' => 404, 'error_message' => 'SIM with ICCID not found'}
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def url
20
+ @url ||= URI("https://api.1nce.com/management-api/v1/sims/#{@iccid}/reset")
21
+ end
22
+
23
+ def connection
24
+ @connection ||= Net::HTTP.new(url.host, url.port).tap do |http|
25
+ http.use_ssl = true
26
+ end
27
+ end
28
+
29
+ def request
30
+ Net::HTTP::Post.new(url).tap do |request|
31
+ request["Accept"] = 'application/json'
32
+ request['Authorization'] = "Bearer #{@access_token}"
33
+ end
34
+ end
35
+ end
36
+ end
@@ -30,6 +30,17 @@ RSpec.describe InceApi::GetSims do
30
30
  expect(@response_p1.first['iccid']).not_to eq(@response_p2.first['iccid'])
31
31
  end
32
32
 
33
+ it 'returns headers too' do
34
+ VCR.use_cassette('get_sims_with_params') do
35
+ service = described_class.new(access_token: 'VALID TOKEN', params: {page: 2, pageSize: 5})
36
+ response = service.sims
37
+ headers = service.headers
38
+ expect(response.size).to eq 5
39
+
40
+ expect(headers['x-current-page']).to eq '2'
41
+ end
42
+ end
43
+
33
44
  it 'invalid token' do
34
45
  VCR.use_cassette('get_sims_wrong_token') do
35
46
  response = described_class.new(access_token: 'INVALID TOKEN').sims
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ince-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislaw Zawadzki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-15 00:00:00.000000000 Z
11
+ date: 2022-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uri
@@ -142,6 +142,7 @@ files:
142
142
  - lib/ince_api/get_sim_usage.rb
143
143
  - lib/ince_api/get_sims.rb
144
144
  - lib/ince_api/multiple_sims_configuration.rb
145
+ - lib/ince_api/reset_connectivity.rb
145
146
  - lib/ince_api/single_sim_configuration.rb
146
147
  - spec/fixtures/vcr_cassettes/create_sms.yml
147
148
  - spec/fixtures/vcr_cassettes/get_sim.yml
@@ -193,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
194
  - !ruby/object:Gem::Version
194
195
  version: '0'
195
196
  requirements: []
196
- rubygems_version: 3.1.4
197
+ rubygems_version: 3.2.15
197
198
  signing_key:
198
199
  specification_version: 4
199
200
  summary: 1nce API wrapper