rerout 0.5.0 → 0.6.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/rerout/client.rb +39 -9
- data/lib/rerout/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 016c1f73ad3a38b6256f068ecf5d2ca3ab7d5f40e342c52f4e434835e337241f
|
|
4
|
+
data.tar.gz: 8ef0ff707b6f64bb9feb72f0c59df1f9a95b8a757898dba201d8ae90081d9f80
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83f97655cb2138c867d4937715bf4ec4e3c2f8cfcc56513e1062f6c87979454588bae276b90880d02e7573cecb1f4fae3f31a9c89be5d6918f8367143fd255af
|
|
7
|
+
data.tar.gz: a0be08c8c9fb89ea350c26bf1312bc93989e860b4eceb1b63a630d0cf4f0c7c80f6cf307aaf926e2271123b98c3ba6697d92b0ce25352f2df488033458cc5012
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ All notable changes to the `rerout` gem are documented in this file. The
|
|
|
4
4
|
format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.6.0] - 2026-07-13
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Explicit isolated sandbox selection, automatic routing to
|
|
12
|
+
\`https://sandbox-api.rerout.co\`, and fail-closed validation that prevents
|
|
13
|
+
genuine \`rrk_test_\` credentials from being mixed with live keys.
|
|
14
|
+
|
|
7
15
|
## [0.5.0] - 2026-06-20
|
|
8
16
|
|
|
9
17
|
### Added
|
data/lib/rerout/client.rb
CHANGED
|
@@ -24,6 +24,7 @@ require_relative 'tags_resource'
|
|
|
24
24
|
module Rerout
|
|
25
25
|
# Default production API base URL.
|
|
26
26
|
DEFAULT_BASE_URL = 'https://api.rerout.co'
|
|
27
|
+
SANDBOX_BASE_URL = 'https://sandbox-api.rerout.co'
|
|
27
28
|
|
|
28
29
|
# Main entry point — construct one of these per project API key and re-use
|
|
29
30
|
# it across requests. Thread-safe so long as the injected Faraday connection
|
|
@@ -52,21 +53,19 @@ module Rerout
|
|
|
52
53
|
|
|
53
54
|
# @param api_key [String] project API key (`rrk_…`). Required.
|
|
54
55
|
# @param base_url [String, nil] override base URL. Defaults to `https://api.rerout.co`.
|
|
56
|
+
# @param environment [Symbol] production or sandbox data plane.
|
|
57
|
+
# @param sandbox [Boolean] convenience alias for the sandbox environment.
|
|
55
58
|
# @param connection [Faraday::Connection, nil] inject a Faraday connection
|
|
56
59
|
# (useful for the test adapter or for sharing connection pools).
|
|
57
60
|
# @param timeout [Integer] per-request timeout in seconds. Default 30.
|
|
58
61
|
# @param user_agent [String, nil] override the default `User-Agent` header.
|
|
59
|
-
def initialize(api_key:, base_url: nil,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
message: 'A project API key is required to construct Rerout::Client.',
|
|
64
|
-
status: 0
|
|
65
|
-
)
|
|
66
|
-
end
|
|
62
|
+
def initialize(api_key:, base_url: nil, environment: :production, sandbox: false,
|
|
63
|
+
connection: nil, timeout: 30, user_agent: nil)
|
|
64
|
+
validate_api_key!(api_key)
|
|
65
|
+
is_sandbox = resolve_sandbox!(api_key, environment, sandbox)
|
|
67
66
|
|
|
68
67
|
@api_key = api_key
|
|
69
|
-
@base_url = (base_url || DEFAULT_BASE_URL).to_s.sub(%r{/+\z}, '')
|
|
68
|
+
@base_url = (base_url || (is_sandbox ? SANDBOX_BASE_URL : DEFAULT_BASE_URL)).to_s.sub(%r{/+\z}, '')
|
|
70
69
|
@timeout = timeout
|
|
71
70
|
@user_agent = user_agent || "rerout-ruby/#{Rerout::VERSION}"
|
|
72
71
|
@connection = connection || default_connection
|
|
@@ -105,6 +104,37 @@ module Rerout
|
|
|
105
104
|
|
|
106
105
|
private
|
|
107
106
|
|
|
107
|
+
def validate_api_key!(api_key)
|
|
108
|
+
return if api_key.is_a?(String) && !api_key.strip.empty?
|
|
109
|
+
|
|
110
|
+
raise Error.new(
|
|
111
|
+
code: 'missing_api_key',
|
|
112
|
+
message: 'A project API key is required to construct Rerout::Client.',
|
|
113
|
+
status: 0
|
|
114
|
+
)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def resolve_sandbox!(api_key, environment, sandbox)
|
|
118
|
+
resolved_environment = sandbox ? :sandbox : environment.to_sym
|
|
119
|
+
unless %i[production sandbox].include?(resolved_environment)
|
|
120
|
+
raise Error.new(
|
|
121
|
+
code: 'invalid_environment',
|
|
122
|
+
message: 'environment must be production or sandbox.',
|
|
123
|
+
status: 0
|
|
124
|
+
)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
is_sandbox = resolved_environment == :sandbox
|
|
128
|
+
is_sandbox_key = api_key.match?(/\Arrk_test_[A-Za-z0-9]{32}\z/)
|
|
129
|
+
return is_sandbox if is_sandbox_key == is_sandbox
|
|
130
|
+
|
|
131
|
+
raise Error.new(
|
|
132
|
+
code: 'wrong_environment',
|
|
133
|
+
message: 'The API key does not match the selected Rerout environment.',
|
|
134
|
+
status: 0
|
|
135
|
+
)
|
|
136
|
+
end
|
|
137
|
+
|
|
108
138
|
def perform_request(method:, path:, query:, headers:, payload:)
|
|
109
139
|
full_url = "#{@base_url}#{path}"
|
|
110
140
|
@connection.public_send(method) do |req|
|
data/lib/rerout/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rerout
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Codecraft Solutions
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-07-13 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: faraday
|
|
@@ -135,6 +136,7 @@ metadata:
|
|
|
135
136
|
bug_tracker_uri: https://github.com/ModestNerds-Co/rerout-sdks/issues
|
|
136
137
|
documentation_uri: https://rerout.co/docs
|
|
137
138
|
rubygems_mfa_required: 'true'
|
|
139
|
+
post_install_message:
|
|
138
140
|
rdoc_options: []
|
|
139
141
|
require_paths:
|
|
140
142
|
- lib
|
|
@@ -149,7 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
149
151
|
- !ruby/object:Gem::Version
|
|
150
152
|
version: '0'
|
|
151
153
|
requirements: []
|
|
152
|
-
rubygems_version: 3.
|
|
154
|
+
rubygems_version: 3.0.3.1
|
|
155
|
+
signing_key:
|
|
153
156
|
specification_version: 4
|
|
154
157
|
summary: Official Ruby SDK for the Rerout branded-link API.
|
|
155
158
|
test_files: []
|