myinfo 0.5.2 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/myinfo/v3/api.rb +9 -2
- data/lib/myinfo/v3/person.rb +1 -1
- data/lib/myinfo/v3/person_basic.rb +1 -1
- data/lib/myinfo/v3/token.rb +1 -1
- data/lib/myinfo/version.rb +1 -1
- data/lib/myinfo.rb +9 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7aeaabc21bdd0de155e96b9306ba1c86015f70eae7f0e1aeec8ef0c8ce0e553
|
4
|
+
data.tar.gz: 26abbbb4749b9ae61c4d38ec1e4e6ab7b28dec410602b7ec448024bc0ceb726d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25015c46d6e06e6d9ec2405448926e9d0482c1ee9fe5d0aadea0467afe1a830518abc376beb46757c89234322df9077ea983025330744ed071e1f28dbbab7c48
|
7
|
+
data.tar.gz: 9edf346e8b4da8d49cc95e6db9efc477b690b0b9bbbd6d680cf8a537c5ca38081c1b7dd2eac169b8dfd2050fc0bdf0a5028b8159c1e9850364f0dfcdd8017bfd
|
data/README.md
CHANGED
@@ -22,6 +22,8 @@
|
|
22
22
|
config.public_cert = File.read(Rails.root.join('public_cert_location'))
|
23
23
|
config.sandbox = false # optional, false by default
|
24
24
|
config.proxy = { address: 'proxy_address', port: 'proxy_port' } # optional, nil by default
|
25
|
+
config.gateway_url = 'https://test_gateway_url' #optional, nil by default
|
26
|
+
config.gateway_key = '44d953c796cccebcec9bdc826852857ab412fbe2' #optional, nil by default
|
25
27
|
end
|
26
28
|
```
|
27
29
|
|
@@ -62,6 +64,8 @@ result = MyInfo::V3::Person.call(access_token: response.data) if response.succes
|
|
62
64
|
config.public_cert = File.read(Rails.root.join('public_cert_location'))
|
63
65
|
config.sandbox = false # optional, false by default
|
64
66
|
config.proxy = { address: 'proxy_address', port: 'proxy_port' } # optional, nil by default
|
67
|
+
config.gateway_url = 'https://test_gateway_url' #optional, nil by default
|
68
|
+
config.gateway_key = '44d953c796cccebcec9bdc826852857ab412fbe2' #optional, nil by default
|
65
69
|
end
|
66
70
|
```
|
67
71
|
|
data/lib/myinfo/v3/api.rb
CHANGED
@@ -41,6 +41,7 @@ module MyInfo
|
|
41
41
|
'Accept' => 'application/json',
|
42
42
|
'Cache-Control' => 'no-cache'
|
43
43
|
}.tap do |values|
|
44
|
+
values['x-api-key'] = config.gateway_key if config.gateway_key.present?
|
44
45
|
values['Authorization'] = auth_header(params: params, access_token: access_token) unless config.sandbox?
|
45
46
|
|
46
47
|
if support_gzip?
|
@@ -50,6 +51,11 @@ module MyInfo
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
54
|
+
def api_path
|
55
|
+
path = config.gateway_path.present? ? "#{config.gateway_path}/" : ''
|
56
|
+
"#{path}#{slug}"
|
57
|
+
end
|
58
|
+
|
53
59
|
def parse_response(response)
|
54
60
|
if response.code == '200'
|
55
61
|
yield
|
@@ -79,10 +85,11 @@ module MyInfo
|
|
79
85
|
end
|
80
86
|
|
81
87
|
def http
|
88
|
+
url = config.gateway_host || config.base_url
|
82
89
|
@http ||= if config.proxy.blank?
|
83
|
-
Net::HTTP.new(
|
90
|
+
Net::HTTP.new(url, 443)
|
84
91
|
else
|
85
|
-
Net::HTTP.new(
|
92
|
+
Net::HTTP.new(url, 443, config.proxy[:address], config.proxy[:port])
|
86
93
|
end
|
87
94
|
|
88
95
|
@http.use_ssl = true
|
data/lib/myinfo/v3/person.rb
CHANGED
@@ -16,7 +16,7 @@ module MyInfo
|
|
16
16
|
def call
|
17
17
|
super do
|
18
18
|
headers = header(params: params, access_token: access_token)
|
19
|
-
endpoint_url = "/#{
|
19
|
+
endpoint_url = "/#{api_path}?#{params.to_query}"
|
20
20
|
|
21
21
|
response = http.request_get(endpoint_url, headers)
|
22
22
|
parse_response(response)
|
data/lib/myinfo/v3/token.rb
CHANGED
@@ -14,7 +14,7 @@ module MyInfo
|
|
14
14
|
def call
|
15
15
|
super do
|
16
16
|
headers = header(params: params).merge({ 'Content-Type' => 'application/x-www-form-urlencoded' })
|
17
|
-
response = http.request_post("/#{
|
17
|
+
response = http.request_post("/#{api_path}", params.to_param, headers)
|
18
18
|
|
19
19
|
parse_response(response)
|
20
20
|
end
|
data/lib/myinfo/version.rb
CHANGED
data/lib/myinfo.rb
CHANGED
@@ -30,7 +30,7 @@ module MyInfo
|
|
30
30
|
# Configuration to set various properties needed to use MyInfo
|
31
31
|
class Configuration
|
32
32
|
attr_accessor :singpass_eservice_id, :app_id, :client_id, :proxy, :private_key, :public_cert, :client_secret,
|
33
|
-
:redirect_uri
|
33
|
+
:redirect_uri, :gateway_url, :gateway_key
|
34
34
|
|
35
35
|
attr_reader :base_url
|
36
36
|
attr_writer :public_facing, :sandbox
|
@@ -49,6 +49,14 @@ module MyInfo
|
|
49
49
|
"https://#{base_url}"
|
50
50
|
end
|
51
51
|
|
52
|
+
def gateway_host
|
53
|
+
gateway_url&.sub('https://', '')&.split('/')&.first
|
54
|
+
end
|
55
|
+
|
56
|
+
def gateway_path
|
57
|
+
gateway_url.present? ? gateway_url.sub('https://', '').split('/')[1..].join('/') : ''
|
58
|
+
end
|
59
|
+
|
52
60
|
def public?
|
53
61
|
@public_facing
|
54
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myinfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lim Yao Jie
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-11-
|
12
|
+
date: 2022-11-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jwe
|