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 +4 -4
- data/Gemfile.lock +1 -1
- data/ince-api.gemspec +1 -1
- data/lib/ince-api.rb +1 -0
- data/lib/ince_api/get_sims.rb +4 -0
- data/lib/ince_api/reset_connectivity.rb +36 -0
- data/spec/ince-api/get_sims_spec.rb +11 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9c29a91fac4424a3df093e22fb7fd3efdf35fbeec8afb98365e3e510649a0d7
|
4
|
+
data.tar.gz: 2d1290f5a1a64061cf26fa37f5513b012856023e525fba5fce5e298c4d55db9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c3267ad2830c8e1952f9d2d76b0116b6bebb7401244d27b9e01b867a878524713ab1877013de4b5840684e4e35691e945a115e716ca2f045732e9af5a7e43b8
|
7
|
+
data.tar.gz: a1715d6f54277a3ab61cf079f34c40a6b93b2f8664f88e385a8dbaf418a6719cdcd8a61459ba345b405b9de392c1c70768d97959626579c39a9007aabd529e69
|
data/Gemfile.lock
CHANGED
data/ince-api.gemspec
CHANGED
data/lib/ince-api.rb
CHANGED
data/lib/ince_api/get_sims.rb
CHANGED
@@ -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.
|
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:
|
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.
|
197
|
+
rubygems_version: 3.2.15
|
197
198
|
signing_key:
|
198
199
|
specification_version: 4
|
199
200
|
summary: 1nce API wrapper
|