celitech 2.0.7 → 2.0.10
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/LICENSE +21 -0
- data/README.md +31 -6
- data/lib/celitech/error.rb +9 -10
- data/lib/celitech/http/connection.rb +59 -6
- data/lib/celitech/http/oauth_token_manager.rb +17 -2
- data/lib/celitech/models/create_purchase_request.rb +1 -0
- data/lib/celitech/models/create_purchase_v2_request.rb +1 -0
- data/lib/celitech/models/{bad_request.rb → error_response.rb} +1 -1
- data/lib/celitech/models/{unauthorized.rb → suspend_esim_ok_response.rb} +1 -1
- data/lib/celitech/models/top_up_esim_request.rb +1 -0
- data/lib/celitech/serializers/params_serializer.rb +182 -0
- data/lib/celitech/services/destinations.rb +3 -6
- data/lib/celitech/services/e_sim.rb +35 -20
- data/lib/celitech/services/i_frame.rb +3 -6
- data/lib/celitech/services/packages.rb +3 -6
- data/lib/celitech/services/purchases.rb +48 -45
- data/lib/celitech/version.rb +1 -1
- data/lib/celitech.rb +3 -2
- metadata +66 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46c039c4f1a74210693493b6340e2fc6cb91fdeb88ebe455022f4556da1f8c9c
|
|
4
|
+
data.tar.gz: '081ea485c281a21f08c03ead1f878d19cdcf8ece3886a96ffe6e59cb87865b87'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb07394925d19f34ff4322110a6025c086c5b3143a7b5f15c0ed7b6f98f2c6d13822fb160df45a382aaa14a3a840e6b18c722cf7fcc0a0f5e8c45bb8be271339
|
|
7
|
+
data.tar.gz: 5863d3bc26987f89caf0e4feb3f3e00a5d2edfe4b99852d422628f3b6a4f9f0f766cfd2acca39188dcf5565a4fb575fec71a510f2764c87216d50a43d7821420
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
|
-
# Celitech Ruby SDK 2.0.
|
|
1
|
+
# Celitech Ruby SDK 2.0.10
|
|
2
2
|
|
|
3
3
|
Welcome to the Celitech SDK documentation. This guide will help you get started with integrating and using the Celitech SDK in your project.
|
|
4
4
|
|
|
5
5
|
## Versions
|
|
6
6
|
|
|
7
|
-
- API version: `2.0.
|
|
8
|
-
- SDK version: `2.0.
|
|
7
|
+
- API version: `2.0.10`
|
|
8
|
+
- SDK version: `2.0.10`
|
|
9
9
|
|
|
10
10
|
## About the API
|
|
11
11
|
|
|
12
12
|
Welcome to the CELITECH API documentation!
|
|
13
13
|
|
|
14
|
-
Useful links: [Homepage](https://www.celitech.com) | [Support email](mailto:
|
|
14
|
+
Useful links: [Homepage](https://www.celitech.com) | [Support email](mailto:devops@celitech.com) | [Blog](https://www.celitech.com/blog/)
|
|
15
|
+
|
|
16
|
+
# Introduction
|
|
17
|
+
|
|
18
|
+
This is the reference documentation and schemas for the CELITECH API and webhooks. For tutorials and other documentation please refer to the [CELITECH Documentation](https://docs.celitech.com).
|
|
19
|
+
|
|
20
|
+
"Partners" refers to online service providers that use our eSIM API. Access levels include Gold, Platinum, and Diamond.
|
|
21
|
+
|
|
22
|
+
## API
|
|
23
|
+
|
|
24
|
+
The CELITECH API is designed for use by partner platforms, including both web and mobile applications. It's assumed all endpoint calls are initiated from the backend of an integrated platform.
|
|
25
|
+
|
|
26
|
+
API URL: `https://api.celitech.net/v1`
|
|
27
|
+
|
|
28
|
+
## Authentication & Authorization
|
|
29
|
+
|
|
30
|
+
CELITECH API uses the OAuth 2.0 protocol for authentication and authorization.
|
|
31
|
+
The endpoints are protected using client credentials flow which is based on a token exchange. The token has a defined life span (typically 1 hour), after which a new token must be obtained.
|
|
32
|
+
|
|
33
|
+
To begin, obtain OAuth 2.0 client credentials ( **CLIENT_ID** & **CLIENT_SECRET** ) from the [CELITECH Dashboard](https://www.dashboard.celitech.com/). Then your client application requests an access token from the CELITECH Authorization Server, extracts a token from the response, and sends the token to the CELITECH API that you want to access.
|
|
34
|
+
|
|
35
|
+
Security Scheme Type: `OAuth2`
|
|
36
|
+
|
|
37
|
+
Flow type: `clientCredentials`
|
|
38
|
+
|
|
39
|
+
Token URL: `https://auth.celitech.net/oauth2/token`
|
|
15
40
|
|
|
16
41
|
## Table of Contents
|
|
17
42
|
|
|
@@ -209,12 +234,12 @@ The SDK includes several models that represent the data structures used in API r
|
|
|
209
234
|
| [GetEsimOkResponse](documentation/models/get_esim_ok_response.md) | |
|
|
210
235
|
| [GetEsimDeviceOkResponse](documentation/models/get_esim_device_ok_response.md) | |
|
|
211
236
|
| [GetEsimHistoryOkResponse](documentation/models/get_esim_history_ok_response.md) | |
|
|
237
|
+
| [SuspendEsimOkResponse](documentation/models/suspend_esim_ok_response.md) | |
|
|
212
238
|
| [TokenOkResponse](documentation/models/token_ok_response.md) | |
|
|
213
239
|
| [OAuthTokenResponse](documentation/models/o_auth_token_response.md) | |
|
|
214
240
|
| [OAuthTokenRequest](documentation/models/o_auth_token_request.md) | |
|
|
215
241
|
| [GrantType](documentation/models/grant_type.md) | |
|
|
216
|
-
| [
|
|
217
|
-
| [Unauthorized](documentation/models/unauthorized.md) | |
|
|
242
|
+
| [ErrorResponse](documentation/models/error_response.md) | |
|
|
218
243
|
|
|
219
244
|
</details>
|
|
220
245
|
|
data/lib/celitech/error.rb
CHANGED
|
@@ -20,6 +20,14 @@ module Celitech
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# The request never reached the server: connection refused, host unresolvable, socket closed by
|
|
24
|
+
# the peer, or a failed TLS handshake. The underlying transport exception is on `#cause`.
|
|
25
|
+
class ConnectionError < Error
|
|
26
|
+
def initialize(msg = 'Failed to connect')
|
|
27
|
+
super
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
23
31
|
class ValidationError < Error
|
|
24
32
|
attr_reader :field, :validation_message
|
|
25
33
|
|
|
@@ -30,16 +38,7 @@ module Celitech
|
|
|
30
38
|
end
|
|
31
39
|
end
|
|
32
40
|
|
|
33
|
-
class
|
|
34
|
-
attr_reader :data
|
|
35
|
-
|
|
36
|
-
def initialize(status, data, body, headers = {})
|
|
37
|
-
super(status, body, headers)
|
|
38
|
-
@data = data
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
class UnauthorizedError < APIError
|
|
41
|
+
class ErrorResponseError < APIError
|
|
43
42
|
attr_reader :data
|
|
44
43
|
|
|
45
44
|
def initialize(status, data, body, headers = {})
|
|
@@ -2,12 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
require 'json'
|
|
4
4
|
require 'net/http'
|
|
5
|
+
require 'openssl'
|
|
5
6
|
require 'time'
|
|
6
7
|
require 'uri'
|
|
7
8
|
|
|
8
9
|
module Celitech
|
|
9
10
|
module HTTP
|
|
10
11
|
class Connection
|
|
12
|
+
# Failures that mean the request never reached the server. `SocketError` covers DNS
|
|
13
|
+
# resolution; `EOFError` is the peer closing mid-exchange; `OpenSSL::SSL::SSLError` is a
|
|
14
|
+
# handshake or certificate failure. Wrapped as `ConnectionError` so a caller does not have to
|
|
15
|
+
# rescue Net::HTTP's and Socket's own exception classes to handle an unreachable server.
|
|
16
|
+
CONNECTION_ERRORS = [
|
|
17
|
+
SocketError,
|
|
18
|
+
EOFError,
|
|
19
|
+
Errno::ECONNREFUSED,
|
|
20
|
+
Errno::ECONNRESET,
|
|
21
|
+
Errno::ECONNABORTED,
|
|
22
|
+
Errno::EHOSTUNREACH,
|
|
23
|
+
Errno::ENETUNREACH,
|
|
24
|
+
Errno::EPIPE,
|
|
25
|
+
Errno::ETIMEDOUT,
|
|
26
|
+
OpenSSL::SSL::SSLError,
|
|
27
|
+
].freeze
|
|
28
|
+
|
|
29
|
+
# Net::HTTP's three timeout exceptions, all reachable because a configured timeout is applied
|
|
30
|
+
# as open_timeout, read_timeout AND write_timeout. Deliberately not widened to their shared
|
|
31
|
+
# parent `Timeout::Error`, which would also swallow an unrelated `Timeout.timeout` block in
|
|
32
|
+
# caller code. Wrapped as `TimeoutError` for the same reason as CONNECTION_ERRORS above.
|
|
33
|
+
# `IO::TimeoutError` is the fourth and is NOT a Net::HTTP class: since Ruby 3.2 an expired
|
|
34
|
+
# connect deadline surfaces from the IO layer, and it descends from IOError rather than
|
|
35
|
+
# Timeout::Error, so none of the three above catch it and CONNECTION_ERRORS excludes bare
|
|
36
|
+
# IOError. Without it a timed-out connect escaped unwrapped on ruby 3.3 -- the version the
|
|
37
|
+
# gemspec floors at and the e2e image runs -- while raising Net::OpenTimeout on 4.x, so it
|
|
38
|
+
# looked correct locally. No `defined?` guard: the gemspec requires >= 3.3.
|
|
39
|
+
TIMEOUT_ERRORS = [Net::OpenTimeout, Net::ReadTimeout, Net::WriteTimeout, IO::TimeoutError].freeze
|
|
40
|
+
|
|
11
41
|
attr_accessor :default_headers
|
|
12
42
|
attr_reader :base_url, :timeout, :retry_config
|
|
13
43
|
|
|
@@ -55,18 +85,21 @@ module Celitech
|
|
|
55
85
|
# transport (TLS, timeouts, proxy) — the caller owns those settings.
|
|
56
86
|
@custom_http = !http_client.nil?
|
|
57
87
|
@http = http_client || Net::HTTP.new(@uri.host, @uri.port)
|
|
58
|
-
@default_headers = { 'User-Agent' => 'postman-codegen/
|
|
88
|
+
@default_headers = { 'User-Agent' => 'postman-codegen/3.7.0 celitech/2.0.10 (ruby)' }.merge(default_headers)
|
|
59
89
|
@refresh_manager = refresh_manager
|
|
60
90
|
@mutex = Mutex.new
|
|
61
91
|
@hook = Hooks.new
|
|
62
92
|
unless @custom_http
|
|
63
93
|
@http.use_ssl = @uri.scheme == 'https'
|
|
94
|
+
# Guards ABSENCE, not zero: only nil and false are falsy in Ruby, so `timeout: 0` is
|
|
95
|
+
# truthy and IS applied, and Net::HTTP reads 0 as "fail immediately" (nil, not 0, is its
|
|
96
|
+
# no-timeout value). An absent timeout leaves Net::HTTP's own defaults in place.
|
|
64
97
|
if timeout
|
|
65
98
|
@http.open_timeout = timeout
|
|
66
99
|
@http.read_timeout = timeout
|
|
67
100
|
end
|
|
68
101
|
end
|
|
69
|
-
|
|
102
|
+
start_connection
|
|
70
103
|
end
|
|
71
104
|
|
|
72
105
|
def get(path, params = {}, headers = {})
|
|
@@ -135,15 +168,17 @@ module Celitech
|
|
|
135
168
|
@hook.after_response(req, response, params)
|
|
136
169
|
response
|
|
137
170
|
rescue APIError => e
|
|
138
|
-
if attempts < (@retry_config&.fetch(:attempts, nil) || 3) && %w[GET
|
|
171
|
+
if attempts < (@retry_config&.fetch(:attempts, nil) || 3) && %w[GET PUT DELETE HEAD OPTIONS].include?(req.method.upcase) && (e.status >= 500 || e.status == 408 || e.status == 429)
|
|
139
172
|
sleep(retry_after_delay(e) || retry_delay(attempts))
|
|
140
173
|
retry
|
|
141
174
|
end
|
|
142
175
|
@hook.on_error(e, req, params)
|
|
143
176
|
raise
|
|
144
177
|
end
|
|
145
|
-
rescue
|
|
178
|
+
rescue *TIMEOUT_ERRORS => e
|
|
146
179
|
raise TimeoutError, e.message
|
|
180
|
+
rescue *CONNECTION_ERRORS => e
|
|
181
|
+
raise ConnectionError, e.message
|
|
147
182
|
end
|
|
148
183
|
|
|
149
184
|
def stream_execute(req)
|
|
@@ -198,8 +233,10 @@ module Celitech
|
|
|
198
233
|
end
|
|
199
234
|
end
|
|
200
235
|
end
|
|
201
|
-
rescue
|
|
236
|
+
rescue *TIMEOUT_ERRORS => e
|
|
202
237
|
raise TimeoutError, e.message
|
|
238
|
+
rescue *CONNECTION_ERRORS => e
|
|
239
|
+
raise ConnectionError, e.message
|
|
203
240
|
end
|
|
204
241
|
end
|
|
205
242
|
end
|
|
@@ -278,7 +315,23 @@ module Celitech
|
|
|
278
315
|
rescue StandardError
|
|
279
316
|
nil
|
|
280
317
|
end
|
|
281
|
-
|
|
318
|
+
start_connection
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
# The connection is opened eagerly (in initialize) and re-opened on a dropped socket, so this
|
|
322
|
+
# is the other place a connection-level failure can surface — a refused connection used to
|
|
323
|
+
# escape the constructor as a bare Errno::ECONNREFUSED.
|
|
324
|
+
#
|
|
325
|
+
# Timeouts are wrapped here too, and are reachable from the constructor: Net::HTTP reads
|
|
326
|
+
# `timeout: 0` as "fail immediately", so opening the connection raises before any request is
|
|
327
|
+
# made. Without this the SDK's own `TimeoutError` was only raised from `execute`, and a
|
|
328
|
+
# `timeout: 0` client leaked a bare `Net::OpenTimeout` out of `Client.new`.
|
|
329
|
+
def start_connection
|
|
330
|
+
@http.start unless @http.started?
|
|
331
|
+
rescue *TIMEOUT_ERRORS => e
|
|
332
|
+
raise TimeoutError, e.message
|
|
333
|
+
rescue *CONNECTION_ERRORS => e
|
|
334
|
+
raise ConnectionError, e.message
|
|
282
335
|
end
|
|
283
336
|
|
|
284
337
|
def set_body(req, body, content_type)
|
|
@@ -16,10 +16,13 @@ module Celitech
|
|
|
16
16
|
class OAuthTokenManager
|
|
17
17
|
REFRESH_BUFFER_SECS = 5
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
# @param token_url [String] The token endpoint; a relative URL is joined to `base_url`.
|
|
20
|
+
# @param base_url [String, nil] The URL a relative `token_url` is resolved against.
|
|
21
|
+
def initialize(client_id:, client_secret:, token_url:, base_url: nil)
|
|
20
22
|
@client_id = client_id
|
|
21
23
|
@client_secret = client_secret
|
|
22
24
|
@token_url = token_url
|
|
25
|
+
@base_url = base_url
|
|
23
26
|
@access_token = nil
|
|
24
27
|
@expires_at = nil
|
|
25
28
|
@mutex = Mutex.new
|
|
@@ -27,6 +30,11 @@ module Celitech
|
|
|
27
30
|
|
|
28
31
|
attr_writer :client_id, :client_secret
|
|
29
32
|
|
|
33
|
+
# @return [Boolean] Whether both a client ID and a client secret are set.
|
|
34
|
+
def credentials?
|
|
35
|
+
[@client_id, @client_secret].none? { |value| value.nil? || value.to_s.empty? }
|
|
36
|
+
end
|
|
37
|
+
|
|
30
38
|
def headers
|
|
31
39
|
{ 'Authorization' => "Bearer #{token}" }
|
|
32
40
|
end
|
|
@@ -49,8 +57,15 @@ module Celitech
|
|
|
49
57
|
@access_token.nil? || (@expires_at && Time.now + REFRESH_BUFFER_SECS >= @expires_at)
|
|
50
58
|
end
|
|
51
59
|
|
|
60
|
+
def token_uri
|
|
61
|
+
url = @token_url.to_s
|
|
62
|
+
return URI.parse(url) if @base_url.nil? || url.match?(%r{\A[a-z][a-z0-9+.-]*://}i)
|
|
63
|
+
|
|
64
|
+
URI.parse("#{@base_url.to_s.chomp('/')}/#{url.delete_prefix('/')}")
|
|
65
|
+
end
|
|
66
|
+
|
|
52
67
|
def fetch_token
|
|
53
|
-
uri =
|
|
68
|
+
uri = token_uri
|
|
54
69
|
req = Net::HTTP::Post.new(uri.request_uri)
|
|
55
70
|
req.set_form_data(
|
|
56
71
|
grant_type: 'client_credentials',
|
|
@@ -144,6 +144,7 @@ module Celitech
|
|
|
144
144
|
end
|
|
145
145
|
|
|
146
146
|
def validate!
|
|
147
|
+
Validator.validate_string!(@reference_id, 'referenceId', max_length: 255, pattern: /^[a-zA-Z0-9\-_.@+]+$/) unless @reference_id.equal?(::Celitech::Models::UNSET)
|
|
147
148
|
@language&.validate! if !@language.equal?(::Celitech::Models::UNSET) && @language.respond_to?(:validate!)
|
|
148
149
|
end
|
|
149
150
|
|
|
@@ -145,6 +145,7 @@ module Celitech
|
|
|
145
145
|
|
|
146
146
|
def validate!
|
|
147
147
|
Validator.validate_number!(@quantity, 'quantity', min: 1, max: 5) unless @quantity.equal?(::Celitech::Models::UNSET)
|
|
148
|
+
Validator.validate_string!(@reference_id, 'referenceId', max_length: 255, pattern: /^[a-zA-Z0-9\-_.@+]+$/) unless @reference_id.equal?(::Celitech::Models::UNSET)
|
|
148
149
|
@language&.validate! if !@language.equal?(::Celitech::Models::UNSET) && @language.respond_to?(:validate!)
|
|
149
150
|
end
|
|
150
151
|
|
|
@@ -135,6 +135,7 @@ module Celitech
|
|
|
135
135
|
|
|
136
136
|
def validate!
|
|
137
137
|
Validator.validate_string!(@iccid, 'iccid', min_length: 18, max_length: 22) unless @iccid.equal?(::Celitech::Models::UNSET)
|
|
138
|
+
Validator.validate_string!(@reference_id, 'referenceId', max_length: 255, pattern: /^[a-zA-Z0-9\-_.@+]+$/) unless @reference_id.equal?(::Celitech::Models::UNSET)
|
|
138
139
|
end
|
|
139
140
|
|
|
140
141
|
def open_model_extras
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'uri'
|
|
5
|
+
|
|
6
|
+
module Celitech
|
|
7
|
+
module Serializers
|
|
8
|
+
# Serializes parameters using OpenAPI-defined styles for query and path parameters.
|
|
9
|
+
module Params
|
|
10
|
+
# Returns an array of "key=value" strings for the given query parameter.
|
|
11
|
+
# Returns an empty array if +value+ is nil.
|
|
12
|
+
def self.query_part(key, value, style = :form, explode: true)
|
|
13
|
+
value = normalize(value)
|
|
14
|
+
return [] if value.nil?
|
|
15
|
+
|
|
16
|
+
case style
|
|
17
|
+
when :space_delimited then space_delimited_parts(key, value, explode)
|
|
18
|
+
when :pipe_delimited then pipe_delimited_parts(key, value, explode)
|
|
19
|
+
when :deep_object then deep_object_parts(key, value)
|
|
20
|
+
else form_parts(key, value, explode)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Serializes a path parameter using the "simple" style (RFC 6570 §3.2.2), which is the
|
|
25
|
+
# OpenAPI default for a path parameter. A scalar is percent-encoded; an array is comma
|
|
26
|
+
# joined (+explode+ does not change simple-style arrays); an object is comma joined as
|
|
27
|
+
# "key,value" pairs, or as "key=value" pairs when exploded.
|
|
28
|
+
def self.simple(value, explode: false)
|
|
29
|
+
value = normalize(value)
|
|
30
|
+
return '' if value.nil?
|
|
31
|
+
|
|
32
|
+
if value.is_a?(Array)
|
|
33
|
+
value.compact.map { |v| encode(v) }.join(',')
|
|
34
|
+
elsif value.is_a?(Hash)
|
|
35
|
+
pairs = value.compact
|
|
36
|
+
if explode
|
|
37
|
+
pairs.map { |k, v| "#{encode(k)}=#{encode(v)}" }.join(',')
|
|
38
|
+
else
|
|
39
|
+
pairs.flat_map { |k, v| [encode(k), encode(v)] }.join(',')
|
|
40
|
+
end
|
|
41
|
+
else
|
|
42
|
+
encode(value)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Serializes a path parameter using the "label" style (RFC 6570 §3.2.5).
|
|
47
|
+
def self.label(value, explode: false)
|
|
48
|
+
value = normalize(value)
|
|
49
|
+
return '' if value.nil?
|
|
50
|
+
|
|
51
|
+
if value.is_a?(Array)
|
|
52
|
+
values = value.compact
|
|
53
|
+
return '' if values.empty?
|
|
54
|
+
|
|
55
|
+
explode ? values.map { |v| ".#{encode(v)}" }.join : ".#{values.map { |v| encode(v) }.join(',')}"
|
|
56
|
+
elsif value.is_a?(Hash)
|
|
57
|
+
return '' if value.empty?
|
|
58
|
+
|
|
59
|
+
if explode
|
|
60
|
+
parts = value.filter_map { |k, v| "#{encode(k)}=#{encode(v)}" unless v.nil? }
|
|
61
|
+
parts.empty? ? '' : ".#{parts.join('.')}"
|
|
62
|
+
else
|
|
63
|
+
parts = value.filter_map { |k, v| [encode(k), encode(v)] unless v.nil? }.flatten
|
|
64
|
+
parts.empty? ? '' : ".#{parts.join(',')}"
|
|
65
|
+
end
|
|
66
|
+
else
|
|
67
|
+
".#{encode(value)}"
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Serializes a path parameter using the "matrix" style (RFC 6570 §3.2.7).
|
|
72
|
+
def self.matrix(key, value, explode: false)
|
|
73
|
+
value = normalize(value)
|
|
74
|
+
return '' if value.nil?
|
|
75
|
+
|
|
76
|
+
if value.is_a?(Array)
|
|
77
|
+
values = value.compact
|
|
78
|
+
return '' if values.empty?
|
|
79
|
+
|
|
80
|
+
if explode
|
|
81
|
+
values.map { |v| ";#{key}=#{encode(v)}" }.join
|
|
82
|
+
else
|
|
83
|
+
";#{key}=#{values.map { |v| encode(v) }.join(',')}"
|
|
84
|
+
end
|
|
85
|
+
elsif value.is_a?(Hash)
|
|
86
|
+
return '' if value.empty?
|
|
87
|
+
|
|
88
|
+
if explode
|
|
89
|
+
parts = value.filter_map { |k, v| ";#{encode(k)}=#{encode(v)}" unless v.nil? }
|
|
90
|
+
parts.empty? ? '' : parts.join
|
|
91
|
+
else
|
|
92
|
+
parts = value.filter_map { |k, v| [encode(k), encode(v)] unless v.nil? }.flatten
|
|
93
|
+
parts.empty? ? '' : ";#{key}=#{parts.join(',')}"
|
|
94
|
+
end
|
|
95
|
+
else
|
|
96
|
+
";#{key}=#{encode(value)}"
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
private_class_method def self.form_parts(key, value, explode)
|
|
101
|
+
if value.is_a?(Array)
|
|
102
|
+
values = value.compact
|
|
103
|
+
return [] if values.empty?
|
|
104
|
+
|
|
105
|
+
if explode
|
|
106
|
+
values.map { |v| "#{encode(key)}=#{encode(v)}" }
|
|
107
|
+
else
|
|
108
|
+
["#{encode(key)}=#{values.map { |v| encode(v) }.join(',')}"]
|
|
109
|
+
end
|
|
110
|
+
elsif value.is_a?(Hash)
|
|
111
|
+
return [] if value.empty?
|
|
112
|
+
|
|
113
|
+
if explode
|
|
114
|
+
value.filter_map { |k, v| "#{encode(k)}=#{encode(v)}" unless v.nil? }
|
|
115
|
+
else
|
|
116
|
+
parts = value.filter_map { |k, v| [encode(k), encode(v)] unless v.nil? }.flatten
|
|
117
|
+
parts.empty? ? [] : ["#{encode(key)}=#{parts.join(',')}"]
|
|
118
|
+
end
|
|
119
|
+
else
|
|
120
|
+
["#{encode(key)}=#{encode(value)}"]
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
private_class_method def self.space_delimited_parts(key, value, explode)
|
|
125
|
+
return form_parts(key, value, true) if explode
|
|
126
|
+
return [] unless value.is_a?(Array)
|
|
127
|
+
|
|
128
|
+
values = value.compact
|
|
129
|
+
values.empty? ? [] : ["#{encode(key)}=#{values.map { |v| encode(v) }.join('%20')}"]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
private_class_method def self.pipe_delimited_parts(key, value, explode)
|
|
133
|
+
return form_parts(key, value, true) if explode
|
|
134
|
+
return [] unless value.is_a?(Array)
|
|
135
|
+
|
|
136
|
+
values = value.compact
|
|
137
|
+
# Pipe delimiter is intentionally not percent-encoded per the OpenAPI spec.
|
|
138
|
+
values.empty? ? [] : ["#{encode(key)}=#{values.map { |v| encode(v) }.join('|')}"]
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
private_class_method def self.deep_object_parts(key, value)
|
|
142
|
+
return [] unless value.is_a?(Hash)
|
|
143
|
+
|
|
144
|
+
value.filter_map { |k, v| "#{encode(key)}[#{encode(k)}]=#{encode(v)}" unless v.nil? }
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Reduces a declared parameter value to the plain Ruby shape the styles above are defined
|
|
148
|
+
# over: a union to its member, a model to its wire Hash. Without this a model reaches
|
|
149
|
+
# #encode as an object and is stringified by Ruby's #inspect, which puts a memory address
|
|
150
|
+
# on the wire instead of the caller's data.
|
|
151
|
+
private_class_method def self.normalize(value)
|
|
152
|
+
value = value.value if value.is_a?(Models::UnionType)
|
|
153
|
+
return to_hash(value) if value.is_a?(Models::Serializable)
|
|
154
|
+
|
|
155
|
+
value
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Percent-encodes a value using RFC 3986. Spaces are encoded as %20 (not +)
|
|
159
|
+
# so the result is safe for both query strings and path segments.
|
|
160
|
+
private_class_method def self.encode(value)
|
|
161
|
+
# Normalizing again here is for a nested MODEL leaf: the entry points above reduce only the
|
|
162
|
+
# top-level value, so a model held inside a Hash/Array reaches #encode unreduced. It cannot
|
|
163
|
+
# be deferred into the JSON branch below, because that branch's own test — "is this a
|
|
164
|
+
# ::Hash/::Array?" — is only true once the model has been reduced to one. The repeat pass
|
|
165
|
+
# on an already-plain value is two #is_a? checks; #to_hash runs only for a real model.
|
|
166
|
+
value = normalize(value)
|
|
167
|
+
# A style is defined over scalars, a flat array and a flat object only — OpenAPI says
|
|
168
|
+
# nothing about what a nested array/object leaf looks like. JSON is emitted for it so the
|
|
169
|
+
# caller's data survives, rather than Ruby's Array#to_s / Hash#to_s rendering.
|
|
170
|
+
value = ::JSON.generate(value) if value.is_a?(::Hash) || value.is_a?(::Array)
|
|
171
|
+
URI.encode_www_form_component(value.to_s).gsub('+', '%20')
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
private_class_method def self.to_hash(serializable)
|
|
175
|
+
serializable.class.wire_keys.each_with_object({}) do |(attr, key), h|
|
|
176
|
+
val = serializable.attributes[attr]
|
|
177
|
+
h[key] = val unless val.nil? || val.equal?(Models::UNSET)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
@@ -22,12 +22,9 @@ module Celitech
|
|
|
22
22
|
result
|
|
23
23
|
rescue APIError => e
|
|
24
24
|
case e.status
|
|
25
|
-
when 400
|
|
26
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
27
|
-
raise ::Celitech::
|
|
28
|
-
when 401
|
|
29
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::Unauthorized.from_hash(e.body) : nil
|
|
30
|
-
raise ::Celitech::UnauthorizedError.new(e.status, parsed, e.body, e.headers)
|
|
25
|
+
when 400, 401, 409, 422, 503
|
|
26
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
27
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
31
28
|
end
|
|
32
29
|
raise
|
|
33
30
|
end
|
|
@@ -27,12 +27,9 @@ module Celitech
|
|
|
27
27
|
result
|
|
28
28
|
rescue APIError => e
|
|
29
29
|
case e.status
|
|
30
|
-
when 400
|
|
31
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
32
|
-
raise ::Celitech::
|
|
33
|
-
when 401
|
|
34
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::Unauthorized.from_hash(e.body) : nil
|
|
35
|
-
raise ::Celitech::UnauthorizedError.new(e.status, parsed, e.body, e.headers)
|
|
30
|
+
when 400, 401, 409, 422, 503
|
|
31
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
32
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
36
33
|
end
|
|
37
34
|
raise
|
|
38
35
|
end
|
|
@@ -42,19 +39,16 @@ module Celitech
|
|
|
42
39
|
headers = config_headers(config).merge(resolve_config(config)&.additional_headers || {})
|
|
43
40
|
Validator.validate_string!(iccid, 'iccid', min_length: 18, max_length: 22)
|
|
44
41
|
conn = resolve_connection(config)
|
|
45
|
-
response = conn.get("/esim/#{iccid}/device", {}, headers)
|
|
42
|
+
response = conn.get("/esim/#{Serializers::Params.simple(iccid, explode: false)}/device", {}, headers)
|
|
46
43
|
return response if !config.equal?(NO_OVERRIDE) && config&.return_raw
|
|
47
44
|
result = ::Celitech::Models::GetEsimDeviceOkResponse.from_hash(response.body)
|
|
48
45
|
result&.validate! if resolve_config(config)&.enable_response_validation
|
|
49
46
|
result
|
|
50
47
|
rescue APIError => e
|
|
51
48
|
case e.status
|
|
52
|
-
when 400
|
|
53
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
54
|
-
raise ::Celitech::
|
|
55
|
-
when 401
|
|
56
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::Unauthorized.from_hash(e.body) : nil
|
|
57
|
-
raise ::Celitech::UnauthorizedError.new(e.status, parsed, e.body, e.headers)
|
|
49
|
+
when 400, 401, 409, 422, 503
|
|
50
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
51
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
58
52
|
end
|
|
59
53
|
raise
|
|
60
54
|
end
|
|
@@ -64,19 +58,40 @@ module Celitech
|
|
|
64
58
|
headers = config_headers(config).merge(resolve_config(config)&.additional_headers || {})
|
|
65
59
|
Validator.validate_string!(iccid, 'iccid', min_length: 18, max_length: 22)
|
|
66
60
|
conn = resolve_connection(config)
|
|
67
|
-
response = conn.get("/esim/#{iccid}/history", {}, headers)
|
|
61
|
+
response = conn.get("/esim/#{Serializers::Params.simple(iccid, explode: false)}/history", {}, headers)
|
|
68
62
|
return response if !config.equal?(NO_OVERRIDE) && config&.return_raw
|
|
69
63
|
result = ::Celitech::Models::GetEsimHistoryOkResponse.from_hash(response.body)
|
|
70
64
|
result&.validate! if resolve_config(config)&.enable_response_validation
|
|
71
65
|
result
|
|
72
66
|
rescue APIError => e
|
|
73
67
|
case e.status
|
|
74
|
-
when 400
|
|
75
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
76
|
-
raise ::Celitech::
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
when 400, 401, 409, 422, 503
|
|
69
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
70
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
71
|
+
end
|
|
72
|
+
raise
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Suspend eSIM
|
|
76
|
+
def suspend_esim(iccid:, idempotency_key: nil, config: NO_OVERRIDE)
|
|
77
|
+
headers = config_headers(config).merge(
|
|
78
|
+
{
|
|
79
|
+
'Idempotency-Key' => idempotency_key,
|
|
80
|
+
}.compact,
|
|
81
|
+
).merge(resolve_config(config)&.additional_headers || {})
|
|
82
|
+
Validator.validate_string!(iccid, 'iccid', min_length: 18, max_length: 22)
|
|
83
|
+
Validator.validate_string!(idempotency_key, 'Idempotency-Key', min_length: 1, max_length: 255)
|
|
84
|
+
conn = resolve_connection(config)
|
|
85
|
+
response = conn.post("/esim/#{Serializers::Params.simple(iccid, explode: false)}/suspend", nil, headers: headers)
|
|
86
|
+
return response if !config.equal?(NO_OVERRIDE) && config&.return_raw
|
|
87
|
+
result = ::Celitech::Models::SuspendEsimOkResponse.from_hash(response.body)
|
|
88
|
+
result&.validate! if resolve_config(config)&.enable_response_validation
|
|
89
|
+
result
|
|
90
|
+
rescue APIError => e
|
|
91
|
+
case e.status
|
|
92
|
+
when 400, 401, 409, 422, 503
|
|
93
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
94
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
80
95
|
end
|
|
81
96
|
raise
|
|
82
97
|
end
|
|
@@ -22,12 +22,9 @@ module Celitech
|
|
|
22
22
|
result
|
|
23
23
|
rescue APIError => e
|
|
24
24
|
case e.status
|
|
25
|
-
when 400
|
|
26
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
27
|
-
raise ::Celitech::
|
|
28
|
-
when 401
|
|
29
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::Unauthorized.from_hash(e.body) : nil
|
|
30
|
-
raise ::Celitech::UnauthorizedError.new(e.status, parsed, e.body, e.headers)
|
|
25
|
+
when 400, 401, 409, 422, 503
|
|
26
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
27
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
31
28
|
end
|
|
32
29
|
raise
|
|
33
30
|
end
|
|
@@ -45,12 +45,9 @@ module Celitech
|
|
|
45
45
|
result
|
|
46
46
|
rescue APIError => e
|
|
47
47
|
case e.status
|
|
48
|
-
when 400
|
|
49
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
50
|
-
raise ::Celitech::
|
|
51
|
-
when 401
|
|
52
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::Unauthorized.from_hash(e.body) : nil
|
|
53
|
-
raise ::Celitech::UnauthorizedError.new(e.status, parsed, e.body, e.headers)
|
|
48
|
+
when 400, 401, 409, 422, 503
|
|
49
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
50
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
54
51
|
end
|
|
55
52
|
raise
|
|
56
53
|
end
|
|
@@ -12,8 +12,13 @@ module Celitech
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
# Create Purchase V2
|
|
15
|
-
def create_purchase_v2(body:, config: NO_OVERRIDE)
|
|
16
|
-
headers = config_headers(config).merge(
|
|
15
|
+
def create_purchase_v2(body:, idempotency_key: nil, config: NO_OVERRIDE)
|
|
16
|
+
headers = config_headers(config).merge(
|
|
17
|
+
{
|
|
18
|
+
'Idempotency-Key' => idempotency_key,
|
|
19
|
+
}.compact,
|
|
20
|
+
).merge(resolve_config(config)&.additional_headers || {})
|
|
21
|
+
Validator.validate_string!(idempotency_key, 'Idempotency-Key', min_length: 1, max_length: 255)
|
|
17
22
|
body.validate! if body.respond_to?(:validate!)
|
|
18
23
|
conn = resolve_connection(config)
|
|
19
24
|
response = conn.post('/purchases/v2', body, headers: headers)
|
|
@@ -23,12 +28,9 @@ module Celitech
|
|
|
23
28
|
result
|
|
24
29
|
rescue APIError => e
|
|
25
30
|
case e.status
|
|
26
|
-
when 400
|
|
27
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
28
|
-
raise ::Celitech::
|
|
29
|
-
when 401
|
|
30
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::Unauthorized.from_hash(e.body) : nil
|
|
31
|
-
raise ::Celitech::UnauthorizedError.new(e.status, parsed, e.body, e.headers)
|
|
31
|
+
when 400, 401, 409, 422, 503
|
|
32
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
33
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
32
34
|
end
|
|
33
35
|
raise
|
|
34
36
|
end
|
|
@@ -70,20 +72,22 @@ module Celitech
|
|
|
70
72
|
result
|
|
71
73
|
rescue APIError => e
|
|
72
74
|
case e.status
|
|
73
|
-
when 400
|
|
74
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
75
|
-
raise ::Celitech::
|
|
76
|
-
when 401
|
|
77
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::Unauthorized.from_hash(e.body) : nil
|
|
78
|
-
raise ::Celitech::UnauthorizedError.new(e.status, parsed, e.body, e.headers)
|
|
75
|
+
when 400, 401, 409, 422, 503
|
|
76
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
77
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
79
78
|
end
|
|
80
79
|
raise
|
|
81
80
|
end
|
|
82
81
|
|
|
83
82
|
# Create Purchase
|
|
84
83
|
# @deprecated
|
|
85
|
-
def create_purchase(body:, config: NO_OVERRIDE)
|
|
86
|
-
headers = config_headers(config).merge(
|
|
84
|
+
def create_purchase(body:, idempotency_key: nil, config: NO_OVERRIDE)
|
|
85
|
+
headers = config_headers(config).merge(
|
|
86
|
+
{
|
|
87
|
+
'Idempotency-Key' => idempotency_key,
|
|
88
|
+
}.compact,
|
|
89
|
+
).merge(resolve_config(config)&.additional_headers || {})
|
|
90
|
+
Validator.validate_string!(idempotency_key, 'Idempotency-Key', min_length: 1, max_length: 255)
|
|
87
91
|
body.validate! if body.respond_to?(:validate!)
|
|
88
92
|
conn = resolve_connection(config)
|
|
89
93
|
response = conn.post('/purchases', body, headers: headers)
|
|
@@ -93,19 +97,21 @@ module Celitech
|
|
|
93
97
|
result
|
|
94
98
|
rescue APIError => e
|
|
95
99
|
case e.status
|
|
96
|
-
when 400
|
|
97
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
98
|
-
raise ::Celitech::
|
|
99
|
-
when 401
|
|
100
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::Unauthorized.from_hash(e.body) : nil
|
|
101
|
-
raise ::Celitech::UnauthorizedError.new(e.status, parsed, e.body, e.headers)
|
|
100
|
+
when 400, 401, 409, 422, 503
|
|
101
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
102
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
102
103
|
end
|
|
103
104
|
raise
|
|
104
105
|
end
|
|
105
106
|
|
|
106
107
|
# Top-up eSIM
|
|
107
|
-
def top_up_esim(body:, config: NO_OVERRIDE)
|
|
108
|
-
headers = config_headers(config).merge(
|
|
108
|
+
def top_up_esim(body:, idempotency_key: nil, config: NO_OVERRIDE)
|
|
109
|
+
headers = config_headers(config).merge(
|
|
110
|
+
{
|
|
111
|
+
'Idempotency-Key' => idempotency_key,
|
|
112
|
+
}.compact,
|
|
113
|
+
).merge(resolve_config(config)&.additional_headers || {})
|
|
114
|
+
Validator.validate_string!(idempotency_key, 'Idempotency-Key', min_length: 1, max_length: 255)
|
|
109
115
|
body.validate! if body.respond_to?(:validate!)
|
|
110
116
|
conn = resolve_connection(config)
|
|
111
117
|
response = conn.post('/purchases/topup', body, headers: headers)
|
|
@@ -115,19 +121,21 @@ module Celitech
|
|
|
115
121
|
result
|
|
116
122
|
rescue APIError => e
|
|
117
123
|
case e.status
|
|
118
|
-
when 400
|
|
119
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
120
|
-
raise ::Celitech::
|
|
121
|
-
when 401
|
|
122
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::Unauthorized.from_hash(e.body) : nil
|
|
123
|
-
raise ::Celitech::UnauthorizedError.new(e.status, parsed, e.body, e.headers)
|
|
124
|
+
when 400, 401, 409, 422, 503
|
|
125
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
126
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
124
127
|
end
|
|
125
128
|
raise
|
|
126
129
|
end
|
|
127
130
|
|
|
128
131
|
# Edit Purchase
|
|
129
|
-
def edit_purchase(body:, config: NO_OVERRIDE)
|
|
130
|
-
headers = config_headers(config).merge(
|
|
132
|
+
def edit_purchase(body:, idempotency_key: nil, config: NO_OVERRIDE)
|
|
133
|
+
headers = config_headers(config).merge(
|
|
134
|
+
{
|
|
135
|
+
'Idempotency-Key' => idempotency_key,
|
|
136
|
+
}.compact,
|
|
137
|
+
).merge(resolve_config(config)&.additional_headers || {})
|
|
138
|
+
Validator.validate_string!(idempotency_key, 'Idempotency-Key', min_length: 1, max_length: 255)
|
|
131
139
|
body.validate! if body.respond_to?(:validate!)
|
|
132
140
|
conn = resolve_connection(config)
|
|
133
141
|
response = conn.post('/purchases/edit', body, headers: headers)
|
|
@@ -137,12 +145,9 @@ module Celitech
|
|
|
137
145
|
result
|
|
138
146
|
rescue APIError => e
|
|
139
147
|
case e.status
|
|
140
|
-
when 400
|
|
141
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
142
|
-
raise ::Celitech::
|
|
143
|
-
when 401
|
|
144
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::Unauthorized.from_hash(e.body) : nil
|
|
145
|
-
raise ::Celitech::UnauthorizedError.new(e.status, parsed, e.body, e.headers)
|
|
148
|
+
when 400, 401, 409, 422, 503
|
|
149
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
150
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
146
151
|
end
|
|
147
152
|
raise
|
|
148
153
|
end
|
|
@@ -151,19 +156,17 @@ module Celitech
|
|
|
151
156
|
def get_purchase_consumption(purchase_id:, config: NO_OVERRIDE)
|
|
152
157
|
headers = config_headers(config).merge(resolve_config(config)&.additional_headers || {})
|
|
153
158
|
conn = resolve_connection(config)
|
|
154
|
-
|
|
159
|
+
url = "/purchases/#{Serializers::Params.simple(purchase_id, explode: false)}/consumption"
|
|
160
|
+
response = conn.get(url, {}, headers)
|
|
155
161
|
return response if !config.equal?(NO_OVERRIDE) && config&.return_raw
|
|
156
162
|
result = ::Celitech::Models::GetPurchaseConsumptionOkResponse.from_hash(response.body)
|
|
157
163
|
result&.validate! if resolve_config(config)&.enable_response_validation
|
|
158
164
|
result
|
|
159
165
|
rescue APIError => e
|
|
160
166
|
case e.status
|
|
161
|
-
when 400
|
|
162
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::
|
|
163
|
-
raise ::Celitech::
|
|
164
|
-
when 401
|
|
165
|
-
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::Unauthorized.from_hash(e.body) : nil
|
|
166
|
-
raise ::Celitech::UnauthorizedError.new(e.status, parsed, e.body, e.headers)
|
|
167
|
+
when 400, 401, 409, 422, 503
|
|
168
|
+
parsed = e.body.is_a?(Hash) ? ::Celitech::Models::ErrorResponse.from_hash(e.body) : nil
|
|
169
|
+
raise ::Celitech::ErrorResponseError.new(e.status, parsed, e.body, e.headers)
|
|
167
170
|
end
|
|
168
171
|
raise
|
|
169
172
|
end
|
data/lib/celitech/version.rb
CHANGED
data/lib/celitech.rb
CHANGED
|
@@ -7,6 +7,7 @@ require_relative 'celitech/models/union_type'
|
|
|
7
7
|
require_relative 'celitech/models/open_model'
|
|
8
8
|
require_relative 'celitech/serializers/json_serializer'
|
|
9
9
|
require_relative 'celitech/serializers/form_serializer'
|
|
10
|
+
require_relative 'celitech/serializers/params_serializer'
|
|
10
11
|
require_relative 'celitech/http/hooks'
|
|
11
12
|
require_relative 'celitech/http/connection'
|
|
12
13
|
require_relative 'celitech/http/response'
|
|
@@ -46,12 +47,12 @@ require_relative 'celitech/models/device'
|
|
|
46
47
|
require_relative 'celitech/models/get_esim_history_ok_response'
|
|
47
48
|
require_relative 'celitech/models/get_esim_history_ok_response_esim'
|
|
48
49
|
require_relative 'celitech/models/history'
|
|
50
|
+
require_relative 'celitech/models/suspend_esim_ok_response'
|
|
49
51
|
require_relative 'celitech/models/token_ok_response'
|
|
50
52
|
require_relative 'celitech/models/o_auth_token_response'
|
|
51
53
|
require_relative 'celitech/models/o_auth_token_request'
|
|
52
54
|
require_relative 'celitech/models/grant_type'
|
|
53
|
-
require_relative 'celitech/models/
|
|
54
|
-
require_relative 'celitech/models/unauthorized'
|
|
55
|
+
require_relative 'celitech/models/error_response'
|
|
55
56
|
require_relative 'celitech/services/destinations'
|
|
56
57
|
require_relative 'celitech/services/packages'
|
|
57
58
|
require_relative 'celitech/services/purchases'
|
metadata
CHANGED
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: celitech
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- CELITECH
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: minitest
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '5.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '5.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '13.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '13.0'
|
|
13
41
|
- !ruby/object:Gem::Dependency
|
|
14
42
|
name: rubocop
|
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -66,13 +94,28 @@ dependencies:
|
|
|
66
94
|
- - "~>"
|
|
67
95
|
- !ruby/object:Gem::Version
|
|
68
96
|
version: 1.26.1
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: webmock
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '3.19'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '3.19'
|
|
69
111
|
description:
|
|
70
112
|
email:
|
|
71
|
-
-
|
|
113
|
+
- devops@celitech.com
|
|
72
114
|
executables: []
|
|
73
115
|
extensions: []
|
|
74
116
|
extra_rdoc_files: []
|
|
75
117
|
files:
|
|
118
|
+
- LICENSE
|
|
76
119
|
- README.md
|
|
77
120
|
- lib/celitech.rb
|
|
78
121
|
- lib/celitech/client.rb
|
|
@@ -83,7 +126,6 @@ files:
|
|
|
83
126
|
- lib/celitech/http/hooks.rb
|
|
84
127
|
- lib/celitech/http/oauth_token_manager.rb
|
|
85
128
|
- lib/celitech/http/response.rb
|
|
86
|
-
- lib/celitech/models/bad_request.rb
|
|
87
129
|
- lib/celitech/models/create_purchase_ok_response.rb
|
|
88
130
|
- lib/celitech/models/create_purchase_ok_response_profile.rb
|
|
89
131
|
- lib/celitech/models/create_purchase_ok_response_purchase.rb
|
|
@@ -98,6 +140,7 @@ files:
|
|
|
98
140
|
- lib/celitech/models/device.rb
|
|
99
141
|
- lib/celitech/models/edit_purchase_ok_response.rb
|
|
100
142
|
- lib/celitech/models/edit_purchase_request.rb
|
|
143
|
+
- lib/celitech/models/error_response.rb
|
|
101
144
|
- lib/celitech/models/get_esim_device_ok_response.rb
|
|
102
145
|
- lib/celitech/models/get_esim_history_ok_response.rb
|
|
103
146
|
- lib/celitech/models/get_esim_history_ok_response_esim.rb
|
|
@@ -117,15 +160,16 @@ files:
|
|
|
117
160
|
- lib/celitech/models/purchases.rb
|
|
118
161
|
- lib/celitech/models/purchases_esim.rb
|
|
119
162
|
- lib/celitech/models/serializable.rb
|
|
163
|
+
- lib/celitech/models/suspend_esim_ok_response.rb
|
|
120
164
|
- lib/celitech/models/token_ok_response.rb
|
|
121
165
|
- lib/celitech/models/top_up_esim_ok_response.rb
|
|
122
166
|
- lib/celitech/models/top_up_esim_ok_response_profile.rb
|
|
123
167
|
- lib/celitech/models/top_up_esim_ok_response_purchase.rb
|
|
124
168
|
- lib/celitech/models/top_up_esim_request.rb
|
|
125
|
-
- lib/celitech/models/unauthorized.rb
|
|
126
169
|
- lib/celitech/models/union_type.rb
|
|
127
170
|
- lib/celitech/serializers/form_serializer.rb
|
|
128
171
|
- lib/celitech/serializers/json_serializer.rb
|
|
172
|
+
- lib/celitech/serializers/params_serializer.rb
|
|
129
173
|
- lib/celitech/services/destinations.rb
|
|
130
174
|
- lib/celitech/services/e_sim.rb
|
|
131
175
|
- lib/celitech/services/i_frame.rb
|
|
@@ -158,5 +202,21 @@ rubygems_version: 3.5.22
|
|
|
158
202
|
signing_key:
|
|
159
203
|
specification_version: 4
|
|
160
204
|
summary: 'Welcome to the CELITECH API documentation! Useful links: [Homepage](https://www.celitech.com)
|
|
161
|
-
| [Support email](mailto:
|
|
205
|
+
| [Support email](mailto:devops@celitech.com) | [Blog](https://www.celitech.com/blog/) #
|
|
206
|
+
Introduction This is the reference documentation and schemas for the CELITECH API
|
|
207
|
+
and webhooks. For tutorials and other documentation please refer to the [CELITECH
|
|
208
|
+
Documentation](https://docs.celitech.com). "Partners" refers to online service
|
|
209
|
+
providers that use our eSIM API. Access levels include Gold, Platinum, and Diamond. ##
|
|
210
|
+
API The CELITECH API is designed for use by partner platforms, including both web
|
|
211
|
+
and mobile applications. It''s assumed all endpoint calls are initiated from the
|
|
212
|
+
backend of an integrated platform. API URL: `https://api.celitech.net/v1` ## Authentication
|
|
213
|
+
& Authorization CELITECH API uses the OAuth 2.0 protocol for authentication and
|
|
214
|
+
authorization. The endpoints are protected using client credentials flow which is
|
|
215
|
+
based on a token exchange. The token has a defined life span (typically 1 hour),
|
|
216
|
+
after which a new token must be obtained. To begin, obtain OAuth 2.0 client credentials
|
|
217
|
+
( **CLIENT_ID** & **CLIENT_SECRET** ) from the [CELITECH Dashboard](https://www.dashboard.celitech.com/).
|
|
218
|
+
Then your client application requests an access token from the CELITECH Authorization
|
|
219
|
+
Server, extracts a token from the response, and sends the token to the CELITECH
|
|
220
|
+
API that you want to access. Security Scheme Type: `OAuth2` Flow type: `clientCredentials` Token
|
|
221
|
+
URL: `https://auth.celitech.net/oauth2/token`'
|
|
162
222
|
test_files: []
|