myinfo 0.5.2 → 0.5.4

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: a2e8fbaf2bc21cdbcbdebcaa40e5b2057da71f654a09ea2ee245d59f1b3d2cd3
4
- data.tar.gz: 41a1e888d7ca13a631c6106f526feadf11ecbe8fbb5b2d48e3089dc35cb7f1db
3
+ metadata.gz: c7aeaabc21bdd0de155e96b9306ba1c86015f70eae7f0e1aeec8ef0c8ce0e553
4
+ data.tar.gz: 26abbbb4749b9ae61c4d38ec1e4e6ab7b28dec410602b7ec448024bc0ceb726d
5
5
  SHA512:
6
- metadata.gz: 48ee51d5be60f930cf18be5c8016eec5afc306471c0d60347633ec0ac9e77badff4604c68dcf4761f9562e9473a96d3c035f15730c3d60f234bb7ce21c80da40
7
- data.tar.gz: da22340e796b0a57a2547283748c09324dea4002d5784bcdedfd897bcc24846810bd6331eaf0bb83897e184200c06a177160b79b7fb49347e65b922a9042d307
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(config.base_url, 443)
90
+ Net::HTTP.new(url, 443)
84
91
  else
85
- Net::HTTP.new(config.base_url, 443, config.proxy[:address], config.proxy[:port])
92
+ Net::HTTP.new(url, 443, config.proxy[:address], config.proxy[:port])
86
93
  end
87
94
 
88
95
  @http.use_ssl = true
@@ -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 = "/#{slug}?#{params.to_query}"
19
+ endpoint_url = "/#{api_path}?#{params.to_query}"
20
20
 
21
21
  response = http.request_get(endpoint_url, headers)
22
22
  parse_response(response)
@@ -17,7 +17,7 @@ module MyInfo
17
17
  def call
18
18
  super do
19
19
  headers = header(params: params)
20
- endpoint_url = "/#{slug}?#{params.to_query}"
20
+ endpoint_url = "/#{api_path}?#{params.to_query}"
21
21
 
22
22
  response = http.request_get(endpoint_url, headers)
23
23
  parse_response(response)
@@ -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("/#{slug}", params.to_param, headers)
17
+ response = http.request_post("/#{api_path}", params.to_param, headers)
18
18
 
19
19
  parse_response(response)
20
20
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module MyInfo
4
4
  module Version
5
- WRAPPER_VERSION = '0.5.2'
5
+ WRAPPER_VERSION = '0.5.4'
6
6
  end
7
7
  end
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.2
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-07 00:00:00.000000000 Z
12
+ date: 2022-11-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jwe