galaxy-ruby 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 +27 -0
- data/README.md +26 -5
- data/SKILL.md +6 -4
- data/api.md +8 -8
- data/lib/galaxy-ruby/client.rb +43 -12
- data/lib/galaxy-ruby/errors.rb +40 -0
- data/lib/galaxy-ruby/file_part.rb +13 -1
- data/lib/galaxy-ruby/internal/transport/base_client.rb +278 -42
- data/lib/galaxy-ruby/internal/transport/connection_pool.rb +160 -0
- data/lib/galaxy-ruby/internal/transport/pooled_net_requester.rb +77 -10
- data/lib/galaxy-ruby/internal/type/base_model.rb +62 -17
- data/lib/galaxy-ruby/internal/type/boolean.rb +3 -1
- data/lib/galaxy-ruby/internal/type/converter.rb +13 -3
- data/lib/galaxy-ruby/internal/type/enum.rb +9 -4
- data/lib/galaxy-ruby/internal/type/file_input.rb +8 -2
- data/lib/galaxy-ruby/internal/type/hash_of.rb +3 -1
- data/lib/galaxy-ruby/internal/type/union.rb +17 -6
- data/lib/galaxy-ruby/internal/type/unknown.rb +3 -1
- data/lib/galaxy-ruby/internal/util.rb +273 -15
- data/lib/galaxy-ruby/internal/webhook_verifier.rb +240 -0
- data/lib/galaxy-ruby/internal.rb +4 -1
- data/lib/galaxy-ruby/models/authentication_create_token_params.rb +7 -1
- data/lib/galaxy-ruby/models/authentication_create_user_params.rb +2 -0
- data/lib/galaxy-ruby/models/celestial_body_create_params.rb +3 -3
- data/lib/galaxy-ruby/models/celestial_body_param.rb +72 -0
- data/lib/galaxy-ruby/models/credentials.rb +1 -9
- data/lib/galaxy-ruby/models/planet_create_params.rb +11 -1
- data/lib/galaxy-ruby/models/{planet_list_all_data_params.rb → planet_list_params.rb} +2 -2
- data/lib/galaxy-ruby/models/{planet_list_all_data_response.rb → planet_list_response.rb} +9 -9
- data/lib/galaxy-ruby/models/planet_param.rb +204 -0
- data/lib/galaxy-ruby/models/planet_update_params.rb +12 -1
- data/lib/galaxy-ruby/models/{planet_delte_image_params.rb → planet_upload_image_params.rb} +2 -2
- data/lib/galaxy-ruby/models/{planet_delte_image_response.rb → planet_upload_image_response.rb} +2 -2
- data/lib/galaxy-ruby/models/user_param.rb +19 -0
- data/lib/galaxy-ruby/models/webhook_unwrap_params.rb +2 -0
- data/lib/galaxy-ruby/models.rb +38 -33
- data/lib/galaxy-ruby/request_options.rb +13 -5
- data/lib/galaxy-ruby/resources/celestial_bodies.rb +1 -1
- data/lib/galaxy-ruby/resources/planets.rb +37 -47
- data/lib/galaxy-ruby/resources/webhooks.rb +63 -6
- data/lib/galaxy-ruby/version.rb +1 -1
- data/lib/galaxy-ruby.rb +12 -10
- data/rbi/galaxy-ruby/client.rbi +23 -0
- data/rbi/galaxy-ruby/errors.rbi +25 -27
- data/rbi/galaxy-ruby/internal/transport/base_client.rbi +88 -68
- data/rbi/galaxy-ruby/internal/transport/connection_pool.rbi +44 -0
- data/rbi/galaxy-ruby/internal/transport/pooled_net_requester.rbi +18 -19
- data/rbi/galaxy-ruby/internal/type/base_model.rbi +27 -49
- data/rbi/galaxy-ruby/internal/type/base_page.rbi +1 -2
- data/rbi/galaxy-ruby/internal/type/converter.rbi +12 -51
- data/rbi/galaxy-ruby/internal/type/enum.rbi +1 -5
- data/rbi/galaxy-ruby/internal/type/request_parameters.rbi +2 -6
- data/rbi/galaxy-ruby/internal/type/union.rbi +2 -11
- data/rbi/galaxy-ruby/internal/util.rbi +101 -115
- data/rbi/galaxy-ruby/internal/webhook_verifier.rbi +86 -0
- data/rbi/galaxy-ruby/internal.rbi +1 -4
- data/rbi/galaxy-ruby/models/authentication_create_token_params.rbi +11 -5
- data/rbi/galaxy-ruby/models/celestial_body_create_params.rbi +8 -5
- data/rbi/galaxy-ruby/models/celestial_body_param.rbi +138 -0
- data/rbi/galaxy-ruby/models/credentials.rbi +2 -5
- data/rbi/galaxy-ruby/models/planet_create_params.rbi +22 -5
- data/rbi/galaxy-ruby/models/{planet_list_all_data_params.rbi → planet_list_params.rbi} +2 -5
- data/rbi/galaxy-ruby/models/{planet_list_all_data_response.rbi → planet_list_response.rbi} +11 -15
- data/rbi/galaxy-ruby/models/planet_param.rbi +346 -0
- data/rbi/galaxy-ruby/models/planet_update_params.rbi +19 -2
- data/rbi/galaxy-ruby/models/{planet_delte_image_params.rbi → planet_upload_image_params.rbi} +2 -2
- data/rbi/galaxy-ruby/models/{planet_delte_image_response.rbi → planet_upload_image_response.rbi} +2 -2
- data/rbi/galaxy-ruby/models/unwrap_webhook_event.rbi +1 -1
- data/rbi/galaxy-ruby/models/user_param.rbi +27 -0
- data/rbi/galaxy-ruby/models/webhook_unwrap_params.rbi +2 -0
- data/rbi/galaxy-ruby/models.rbi +10 -2
- data/rbi/galaxy-ruby/request_options.rbi +4 -10
- data/rbi/galaxy-ruby/resources/celestial_bodies.rbi +2 -2
- data/rbi/galaxy-ruby/resources/planets.rbi +22 -30
- data/rbi/galaxy-ruby/resources/webhooks.rbi +64 -3
- data/sig/galaxy-ruby/client.rbs +8 -0
- data/sig/galaxy-ruby/errors.rbs +13 -0
- data/sig/galaxy-ruby/internal/transport/base_client.rbs +38 -2
- data/sig/galaxy-ruby/internal/transport/connection_pool.rbs +19 -0
- data/sig/galaxy-ruby/internal/transport/pooled_net_requester.rbs +13 -2
- data/sig/galaxy-ruby/internal/type/base_model.rbs +4 -0
- data/sig/galaxy-ruby/internal/util.rbs +29 -1
- data/sig/galaxy-ruby/internal/webhook_verifier.rbs +53 -0
- data/sig/galaxy-ruby/models/authentication_create_token_params.rbs +13 -3
- data/sig/galaxy-ruby/models/celestial_body_create_params.rbs +4 -4
- data/sig/galaxy-ruby/models/celestial_body_param.rbs +69 -0
- data/sig/galaxy-ruby/models/credentials.rbs +1 -3
- data/sig/galaxy-ruby/models/planet_create_params.rbs +14 -3
- data/sig/galaxy-ruby/models/{planet_list_all_data_params.rbs → planet_list_params.rbs} +2 -2
- data/sig/galaxy-ruby/models/{planet_list_all_data_response.rbs → planet_list_response.rbs} +15 -13
- data/sig/galaxy-ruby/models/planet_param.rbs +199 -0
- data/sig/galaxy-ruby/models/planet_update_params.rbs +8 -1
- data/sig/galaxy-ruby/models/{planet_delte_image_params.rbs → planet_upload_image_params.rbs} +2 -2
- data/sig/galaxy-ruby/models/{planet_delte_image_response.rbs → planet_upload_image_response.rbs} +2 -2
- data/sig/galaxy-ruby/models/user_param.rbs +15 -0
- data/sig/galaxy-ruby/models/webhook_unwrap_params.rbs +4 -0
- data/sig/galaxy-ruby/models.rbs +10 -2
- data/sig/galaxy-ruby/resources/celestial_bodies.rbs +1 -1
- data/sig/galaxy-ruby/resources/planets.rbs +10 -14
- data/sig/galaxy-ruby/resources/webhooks.rbs +17 -1
- metadata +32 -71
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The two error classes the `standardwebhooks` gem raised verification failures as, declared with the
|
|
4
|
+
# gem's own hierarchy so that whichever of the gem and this file loads second reopens them instead of
|
|
5
|
+
# conflicting. They come first because this SDK's verification error subclasses the second one, so code
|
|
6
|
+
# written against the gem (`rescue StandardWebhooks::WebhookVerificationError`, `is_a?`, `rescue_from`)
|
|
7
|
+
# keeps catching it whether or not the gem is installed.
|
|
8
|
+
module StandardWebhooks
|
|
9
|
+
class StandardWebhooksError < StandardError
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class WebhookVerificationError < StandardWebhooksError
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
module ScalarGalaxy
|
|
17
|
+
module Errors
|
|
18
|
+
# Raised when a webhook delivery fails signature verification: a required header is missing, the
|
|
19
|
+
# timestamp is unreadable or outside the tolerance, no signature matches, or the helper is signed
|
|
20
|
+
# with an algorithm this SDK cannot verify, which refuses every delivery.
|
|
21
|
+
#
|
|
22
|
+
# A `StandardWebhooks::WebhookVerificationError`, as the `standardwebhooks` gem's own failures
|
|
23
|
+
# were, and deliberately not an `Errors::Error`: a handler rescuing this SDK's API errors is not
|
|
24
|
+
# meant to swallow a forged or stale delivery.
|
|
25
|
+
class WebhookVerificationError < ::StandardWebhooks::WebhookVerificationError
|
|
26
|
+
# @param message [String, nil]
|
|
27
|
+
def initialize(message = nil)
|
|
28
|
+
super
|
|
29
|
+
# The gem's `StandardWebhooksError#initialize` keeps the message in `@message` without calling
|
|
30
|
+
# `Exception#initialize`, so with the gem loaded `to_s`, `inspect` and string interpolation
|
|
31
|
+
# would report the class name instead. Setting it here keeps the message either way.
|
|
32
|
+
::Exception.instance_method(:initialize).bind_call(self, message)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
module Internal
|
|
38
|
+
# @api private
|
|
39
|
+
#
|
|
40
|
+
# Verifies Standard Webhooks signatures with the standard library alone: an HMAC (SHA-256 unless
|
|
41
|
+
# the helper's scheme names SHA-1 or SHA-512) over `"<id>.<timestamp>.<payload>"`, keyed with the
|
|
42
|
+
# base64-decoded secret, which the `webhook-signature` header carries as one or more
|
|
43
|
+
# space-separated `v1,<base64>` entries. The header names and the replay window come from the
|
|
44
|
+
# helper's scheme too; each generated helper passes the ones it differs from the defaults in.
|
|
45
|
+
#
|
|
46
|
+
# @see https://github.com/standard-webhooks/standard-webhooks/blob/main/spec/standard-webhooks.md
|
|
47
|
+
module WebhookVerifier
|
|
48
|
+
# Prefix the Standard Webhooks dashboards put on a signing secret; it is not part of the key.
|
|
49
|
+
SECRET_PREFIX = "whsec_"
|
|
50
|
+
|
|
51
|
+
# How far, in seconds, the `webhook-timestamp` may sit from now in either direction. The
|
|
52
|
+
# signature covers the timestamp, so this bounds how long a captured delivery can be replayed;
|
|
53
|
+
# the future side allows for a sender whose clock runs ahead.
|
|
54
|
+
TOLERANCE_SECONDS = 5 * 60
|
|
55
|
+
|
|
56
|
+
# The scheme a helper verifies with when it names none: Standard Webhooks' HMAC-SHA256.
|
|
57
|
+
DEFAULT_ALGORITHM = "hmac-sha256"
|
|
58
|
+
|
|
59
|
+
# The `OpenSSL::Digest` each HMAC scheme a config can name is computed with. A scheme missing
|
|
60
|
+
# here (`ed25519`, `rsa-sha256`) is one this runtime cannot check, and `verify!` refuses every
|
|
61
|
+
# delivery for it rather than accepting one unchecked.
|
|
62
|
+
HMAC_DIGESTS = {"hmac-sha1" => "SHA1", "hmac-sha256" => "SHA256", "hmac-sha512" => "SHA512"}.freeze
|
|
63
|
+
|
|
64
|
+
class << self
|
|
65
|
+
# @api private
|
|
66
|
+
#
|
|
67
|
+
# @param payload [String] the raw request body, exactly as received
|
|
68
|
+
# @param headers [Hash{String, Symbol=>String, Array<String>}] names match in any case; see
|
|
69
|
+
# {header_value}
|
|
70
|
+
# @param secret [String] the signing secret, with or without the `whsec_` prefix
|
|
71
|
+
# @param algorithm [String] the helper's configured scheme, as config spells it (`hmac-sha512`)
|
|
72
|
+
# @param id_header [String] the lowercase name of the header carrying the message id
|
|
73
|
+
# @param timestamp_header [String] the lowercase name of the header carrying the timestamp
|
|
74
|
+
# @param signature_header [String] the lowercase name of the header carrying the signatures
|
|
75
|
+
# @param tolerance [Integer] how far, in seconds, the timestamp may sit from now either way
|
|
76
|
+
# @param decoder [String, nil] the helper's decode-only method, named in the error an
|
|
77
|
+
# unsupported algorithm raises; `nil` when the helper generates none
|
|
78
|
+
#
|
|
79
|
+
# @raise [ArgumentError] when the secret decodes to no key bytes at all
|
|
80
|
+
# @raise [ScalarGalaxy::Errors::WebhookVerificationError] also for an algorithm this runtime
|
|
81
|
+
# cannot check, whatever the delivery carries
|
|
82
|
+
# @return [void]
|
|
83
|
+
def verify!(
|
|
84
|
+
payload,
|
|
85
|
+
headers,
|
|
86
|
+
secret,
|
|
87
|
+
algorithm: DEFAULT_ALGORITHM,
|
|
88
|
+
id_header: "webhook-id",
|
|
89
|
+
timestamp_header: "webhook-timestamp",
|
|
90
|
+
signature_header: "webhook-signature",
|
|
91
|
+
tolerance: TOLERANCE_SECONDS,
|
|
92
|
+
decoder: nil
|
|
93
|
+
)
|
|
94
|
+
# Checked before anything else, the secret included: no delivery can verify under a scheme
|
|
95
|
+
# this runtime does not implement, so none is ever accepted, and the message says what to do.
|
|
96
|
+
digest = HMAC_DIGESTS[algorithm]
|
|
97
|
+
unless digest
|
|
98
|
+
# The decode-only method is configurable (and can be turned off), so the helper names it.
|
|
99
|
+
decode = decoder ? "decode the payload with #{decoder}" : "decode the payload yourself"
|
|
100
|
+
raise ScalarGalaxy::Errors::WebhookVerificationError,
|
|
101
|
+
"Unsupported webhook signature algorithm #{algorithm}: this SDK cannot verify it; " \
|
|
102
|
+
"check the signature yourself, then #{decode}"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
key = decode_secret(secret)
|
|
106
|
+
|
|
107
|
+
msg_id = header_value(headers, id_header)
|
|
108
|
+
msg_timestamp = header_value(headers, timestamp_header)
|
|
109
|
+
msg_signature = header_value(headers, signature_header)
|
|
110
|
+
if !msg_id || !msg_timestamp || !msg_signature
|
|
111
|
+
raise ScalarGalaxy::Errors::WebhookVerificationError, "Missing required headers"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
verify_timestamp!(msg_timestamp, tolerance)
|
|
115
|
+
|
|
116
|
+
# Every part is joined as binary (`.b`), byte for byte as received. The id and the body come
|
|
117
|
+
# from the sender, so their encodings need not agree: interpolating a UTF-8 id with non-ASCII
|
|
118
|
+
# characters beside a binary body (or the reverse) raises `Encoding::CompatibilityError`,
|
|
119
|
+
# where the delivery has to be refused as unsigned instead.
|
|
120
|
+
signed = [msg_id, msg_timestamp, payload].map { |part| part.to_s.b }.join(".")
|
|
121
|
+
expected = [OpenSSL::HMAC.digest(OpenSSL::Digest.new(digest), key, signed)].pack("m0")
|
|
122
|
+
# `split(" ")` splits on any run of whitespace, so a header folded with tabs or newlines
|
|
123
|
+
# still yields its entries. The explicit pattern matters: a bare `split` uses `$;` when the
|
|
124
|
+
# host process has set it. Entries for other versions are skipped rather than rejected,
|
|
125
|
+
# which is what lets a sender add a new scheme beside `v1`. The header is split as binary:
|
|
126
|
+
# a UTF-8 string holding an invalid byte sequence raises `ArgumentError` from `split`, so a
|
|
127
|
+
# garbled entry would otherwise escape as that error and hide a valid entry beside it, where
|
|
128
|
+
# it has to be one more signature that does not match.
|
|
129
|
+
entries = msg_signature.to_s.b.split(" ")
|
|
130
|
+
matched =
|
|
131
|
+
entries.any? do |entry|
|
|
132
|
+
version, signature = entry.split(",", 2)
|
|
133
|
+
version == "v1" && secure_compare(expected, signature)
|
|
134
|
+
end
|
|
135
|
+
return if matched
|
|
136
|
+
|
|
137
|
+
raise ScalarGalaxy::Errors::WebhookVerificationError, "No matching signature found"
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# @api private
|
|
141
|
+
#
|
|
142
|
+
# HTTP header names are case-insensitive, and callers spell them differently: a hash built by
|
|
143
|
+
# hand or copied from a log is often title-cased (`Webhook-Id`), upper-cased, or keyed by
|
|
144
|
+
# Symbol. The exact lowercase String key wins when present; otherwise the first String or Symbol
|
|
145
|
+
# key matching in any case is used. A multi-valued header (an Array, as
|
|
146
|
+
# `Net::HTTPHeader#to_hash` returns them) yields its first value. A Rack `env` hash is not a
|
|
147
|
+
# header hash: its `HTTP_WEBHOOK_ID` keys do not match, so pass the request's headers instead.
|
|
148
|
+
#
|
|
149
|
+
# @param headers [Hash{String, Symbol=>String, Array<String>}]
|
|
150
|
+
# @param name [String] the lowercase header name
|
|
151
|
+
#
|
|
152
|
+
# @return [String, nil]
|
|
153
|
+
private def header_value(headers, name)
|
|
154
|
+
value = headers[name]
|
|
155
|
+
# An object that only answers `[]` (some framework header wrappers fold case there) has
|
|
156
|
+
# nothing to scan, so a miss stays a miss.
|
|
157
|
+
if value.nil? && headers.respond_to?(:each)
|
|
158
|
+
headers.each do |key, candidate|
|
|
159
|
+
next unless !candidate.nil? && (key.is_a?(String) || key.is_a?(Symbol))
|
|
160
|
+
# Folded as binary, so only ASCII letters change case: HTTP header names are ASCII, and
|
|
161
|
+
# `downcase` on a UTF-8 name holding an invalid byte sequence raises `ArgumentError`.
|
|
162
|
+
next unless key.to_s.b.downcase == name
|
|
163
|
+
|
|
164
|
+
value = candidate
|
|
165
|
+
break
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
value.is_a?(Array) ? value.first : value
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# @api private
|
|
172
|
+
#
|
|
173
|
+
# The secret is base64 after its optional `whsec_` prefix. It is decoded leniently, the way
|
|
174
|
+
# `Base64.decode64` does it, skipping characters outside the alphabet and tolerating missing
|
|
175
|
+
# padding, so every secret that verified before still does; strict decoding would turn a
|
|
176
|
+
# pasted secret with a stray newline into a crash.
|
|
177
|
+
#
|
|
178
|
+
# A secret that decodes to nothing (`""`, a bare `whsec_`, an unset variable read as an empty
|
|
179
|
+
# string) is refused rather than used: an HMAC keyed with no bytes is one anyone can compute,
|
|
180
|
+
# so every forged delivery would verify. A misconfiguration, so it is an `ArgumentError`, like
|
|
181
|
+
# the missing-key check in the helper that calls this, not a verification failure.
|
|
182
|
+
#
|
|
183
|
+
# @param secret [String]
|
|
184
|
+
#
|
|
185
|
+
# @raise [ArgumentError]
|
|
186
|
+
# @return [String]
|
|
187
|
+
private def decode_secret(secret)
|
|
188
|
+
key = secret.delete_prefix(SECRET_PREFIX).unpack1("m")
|
|
189
|
+
raise ArgumentError, "Webhook secret decodes to an empty key" if key.empty?
|
|
190
|
+
|
|
191
|
+
key
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# @api private
|
|
195
|
+
#
|
|
196
|
+
# `Integer()` accepts an optional sign, surrounding whitespace, `_` separators and a `0x`-style
|
|
197
|
+
# prefix, and rejects anything else, so the comparison below only ever sees a whole number of
|
|
198
|
+
# seconds. The signature is still computed over the header exactly as it was sent.
|
|
199
|
+
#
|
|
200
|
+
# @param msg_timestamp [String]
|
|
201
|
+
# @param tolerance [Integer] the replay window, in seconds, on each side of now
|
|
202
|
+
#
|
|
203
|
+
# @raise [ScalarGalaxy::Errors::WebhookVerificationError]
|
|
204
|
+
private def verify_timestamp!(msg_timestamp, tolerance = TOLERANCE_SECONDS)
|
|
205
|
+
timestamp =
|
|
206
|
+
begin
|
|
207
|
+
Integer(msg_timestamp)
|
|
208
|
+
rescue StandardError
|
|
209
|
+
raise ScalarGalaxy::Errors::WebhookVerificationError, "Invalid Signature Headers"
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
now = Time.now.to_i
|
|
213
|
+
if timestamp < now - tolerance
|
|
214
|
+
raise ScalarGalaxy::Errors::WebhookVerificationError, "Message timestamp too old"
|
|
215
|
+
end
|
|
216
|
+
return unless timestamp > now + tolerance
|
|
217
|
+
|
|
218
|
+
raise ScalarGalaxy::Errors::WebhookVerificationError, "Message timestamp too new"
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# @api private
|
|
222
|
+
#
|
|
223
|
+
# Compares in constant time, so how long a mismatch takes says nothing about how many leading
|
|
224
|
+
# bytes of a forged signature were right. `OpenSSL.fixed_length_secure_compare` raises on
|
|
225
|
+
# inputs of different lengths, so the lengths are checked first; that only reveals the length,
|
|
226
|
+
# which every valid signature shares.
|
|
227
|
+
#
|
|
228
|
+
# @param expected [String]
|
|
229
|
+
# @param signature [String, nil]
|
|
230
|
+
#
|
|
231
|
+
# @return [Boolean]
|
|
232
|
+
private def secure_compare(expected, signature)
|
|
233
|
+
return false unless signature.is_a?(String) && expected.bytesize == signature.bytesize
|
|
234
|
+
|
|
235
|
+
OpenSSL.fixed_length_secure_compare(expected, signature)
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
data/lib/galaxy-ruby/internal.rb
CHANGED
|
@@ -5,7 +5,10 @@ module ScalarGalaxy
|
|
|
5
5
|
extend ScalarGalaxy::Internal::Util::SorbetRuntimeSupport
|
|
6
6
|
|
|
7
7
|
OMIT =
|
|
8
|
-
Object
|
|
8
|
+
Object
|
|
9
|
+
.new
|
|
10
|
+
.tap { _1.define_singleton_method(:inspect) { "#<#{ScalarGalaxy::Internal}::OMIT>" } }
|
|
11
|
+
.freeze
|
|
9
12
|
|
|
10
13
|
define_sorbet_constant!(:AnyHash) { T.type_alias { T::Hash[Symbol, T.anything] } }
|
|
11
14
|
define_sorbet_constant!(:FileInput) do
|
|
@@ -7,7 +7,13 @@ module ScalarGalaxy
|
|
|
7
7
|
extend ScalarGalaxy::Internal::Type::RequestParameters::Converter
|
|
8
8
|
include ScalarGalaxy::Internal::Type::RequestParameters
|
|
9
9
|
|
|
10
|
-
# @!
|
|
10
|
+
# @!attribute password
|
|
11
|
+
#
|
|
12
|
+
# @return [String]
|
|
13
|
+
required :password, String
|
|
14
|
+
|
|
15
|
+
# @!method initialize(password:, request_options: {})
|
|
16
|
+
# @param password [String]
|
|
11
17
|
# @param request_options [ScalarGalaxy::RequestOptions, Hash{Symbol=>Object}]
|
|
12
18
|
end
|
|
13
19
|
end
|
|
@@ -9,11 +9,11 @@ module ScalarGalaxy
|
|
|
9
9
|
|
|
10
10
|
# @!attribute celestial_body
|
|
11
11
|
#
|
|
12
|
-
# @return [ScalarGalaxy::Models::
|
|
13
|
-
required :celestial_body, union: -> { ScalarGalaxy::
|
|
12
|
+
# @return [ScalarGalaxy::Models::PlanetParam, ScalarGalaxy::Models::CelestialBodyParam::Satellite]
|
|
13
|
+
required :celestial_body, union: -> { ScalarGalaxy::CelestialBodyParam }
|
|
14
14
|
|
|
15
15
|
# @!method initialize(celestial_body:, request_options: {})
|
|
16
|
-
# @param celestial_body [ScalarGalaxy::Models::
|
|
16
|
+
# @param celestial_body [ScalarGalaxy::Models::PlanetParam, ScalarGalaxy::Models::CelestialBodyParam::Satellite]
|
|
17
17
|
# @param request_options [ScalarGalaxy::RequestOptions, Hash{Symbol=>Object}]
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ScalarGalaxy
|
|
4
|
+
module Models
|
|
5
|
+
# A celestial body which can be either a planet or a satellite
|
|
6
|
+
module CelestialBodyParam
|
|
7
|
+
extend ScalarGalaxy::Internal::Type::Union
|
|
8
|
+
|
|
9
|
+
discriminator :type
|
|
10
|
+
|
|
11
|
+
variant -> { ScalarGalaxy::PlanetParam }
|
|
12
|
+
|
|
13
|
+
variant -> { ScalarGalaxy::CelestialBodyParam::Satellite }
|
|
14
|
+
|
|
15
|
+
class Satellite < ScalarGalaxy::Internal::Type::BaseModel
|
|
16
|
+
# @!attribute name
|
|
17
|
+
#
|
|
18
|
+
# @return [String]
|
|
19
|
+
required :name, String
|
|
20
|
+
|
|
21
|
+
# @!attribute description
|
|
22
|
+
#
|
|
23
|
+
# @return [String, nil]
|
|
24
|
+
optional :description, String, nil?: true
|
|
25
|
+
|
|
26
|
+
# @!attribute diameter
|
|
27
|
+
# Diameter in kilometers
|
|
28
|
+
#
|
|
29
|
+
# @return [Float, nil]
|
|
30
|
+
optional :diameter, Float
|
|
31
|
+
|
|
32
|
+
# @!attribute orbit
|
|
33
|
+
#
|
|
34
|
+
# @return [Object, nil]
|
|
35
|
+
optional :orbit, ScalarGalaxy::Internal::Type::Unknown
|
|
36
|
+
|
|
37
|
+
# @!attribute type
|
|
38
|
+
#
|
|
39
|
+
# @return [Symbol, ScalarGalaxy::Models::CelestialBodyParam::Satellite::Type, nil]
|
|
40
|
+
optional :type, enum: -> { ScalarGalaxy::CelestialBodyParam::Satellite::Type }
|
|
41
|
+
|
|
42
|
+
drop_on_dump :id
|
|
43
|
+
|
|
44
|
+
# @!method initialize(name:, description: nil, diameter: nil, orbit: nil, type: nil)
|
|
45
|
+
# @param name [String]
|
|
46
|
+
#
|
|
47
|
+
# @param description [String, nil]
|
|
48
|
+
#
|
|
49
|
+
# @param diameter [Float] Diameter in kilometers
|
|
50
|
+
#
|
|
51
|
+
# @param orbit [Object]
|
|
52
|
+
#
|
|
53
|
+
# @param type [Symbol, ScalarGalaxy::Models::CelestialBodyParam::Satellite::Type]
|
|
54
|
+
|
|
55
|
+
# @see ScalarGalaxy::Models::CelestialBodyParam::Satellite#type
|
|
56
|
+
module Type
|
|
57
|
+
extend ScalarGalaxy::Internal::Type::Enum
|
|
58
|
+
|
|
59
|
+
MOON = :moon
|
|
60
|
+
ASTEROID = :asteroid
|
|
61
|
+
COMET = :comet
|
|
62
|
+
|
|
63
|
+
# @!method self.values
|
|
64
|
+
# @return [Array<Symbol>]
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# @!method self.variants
|
|
69
|
+
# @return [Array(ScalarGalaxy::Models::PlanetParam, ScalarGalaxy::Models::CelestialBodyParam::Satellite)]
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -8,18 +8,10 @@ module ScalarGalaxy
|
|
|
8
8
|
# @return [String]
|
|
9
9
|
required :email, String
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
# @!attribute password
|
|
13
|
-
#
|
|
14
|
-
# @return [String]
|
|
15
|
-
required :password, String
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# @!method initialize(email:, password:)
|
|
11
|
+
# @!method initialize(email:)
|
|
19
12
|
# Credentials to authenticate a user
|
|
20
13
|
#
|
|
21
14
|
# @param email [String]
|
|
22
|
-
# @param password [String]
|
|
23
15
|
end
|
|
24
16
|
end
|
|
25
17
|
end
|
|
@@ -7,7 +7,17 @@ module ScalarGalaxy
|
|
|
7
7
|
extend ScalarGalaxy::Internal::Type::RequestParameters::Converter
|
|
8
8
|
include ScalarGalaxy::Internal::Type::RequestParameters
|
|
9
9
|
|
|
10
|
-
# @!
|
|
10
|
+
# @!attribute creator
|
|
11
|
+
# A user
|
|
12
|
+
#
|
|
13
|
+
# @return [ScalarGalaxy::Models::UserParam, nil]
|
|
14
|
+
optional :creator, -> { ScalarGalaxy::UserParam }
|
|
15
|
+
|
|
16
|
+
drop_on_dump :lastUpdated
|
|
17
|
+
|
|
18
|
+
# @!method initialize(creator: nil, request_options: {})
|
|
19
|
+
# @param creator [ScalarGalaxy::Models::UserParam] A user
|
|
20
|
+
#
|
|
11
21
|
# @param request_options [ScalarGalaxy::RequestOptions, Hash{Symbol=>Object}]
|
|
12
22
|
end
|
|
13
23
|
end
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module ScalarGalaxy
|
|
4
4
|
module Models
|
|
5
|
-
# @see ScalarGalaxy::Resources::Planets#
|
|
6
|
-
class
|
|
5
|
+
# @see ScalarGalaxy::Resources::Planets#list
|
|
6
|
+
class PlanetListParams < ScalarGalaxy::Internal::Type::BaseModel
|
|
7
7
|
extend ScalarGalaxy::Internal::Type::RequestParameters::Converter
|
|
8
8
|
include ScalarGalaxy::Internal::Type::RequestParameters
|
|
9
9
|
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
module ScalarGalaxy
|
|
4
4
|
module Models
|
|
5
|
-
# @see ScalarGalaxy::Resources::Planets#
|
|
6
|
-
class
|
|
5
|
+
# @see ScalarGalaxy::Resources::Planets#list
|
|
6
|
+
class PlanetListResponse < ScalarGalaxy::Internal::Type::BaseModel
|
|
7
7
|
# @!attribute data
|
|
8
8
|
#
|
|
9
|
-
# @return [Array<
|
|
10
|
-
optional :data, ScalarGalaxy::Internal::Type::ArrayOf[ScalarGalaxy::
|
|
9
|
+
# @return [Array<ScalarGalaxy::Models::Planet>, nil]
|
|
10
|
+
optional :data, -> { ScalarGalaxy::Internal::Type::ArrayOf[ScalarGalaxy::Planet] }
|
|
11
11
|
|
|
12
12
|
# @!attribute meta
|
|
13
13
|
#
|
|
14
|
-
# @return [ScalarGalaxy::Models::
|
|
15
|
-
optional :meta, -> { ScalarGalaxy::Models::
|
|
14
|
+
# @return [ScalarGalaxy::Models::PlanetListResponse::Meta, nil]
|
|
15
|
+
optional :meta, -> { ScalarGalaxy::Models::PlanetListResponse::Meta }
|
|
16
16
|
|
|
17
17
|
# @!method initialize(data: nil, meta: nil)
|
|
18
|
-
# @param data [Array<
|
|
19
|
-
# @param meta [ScalarGalaxy::Models::
|
|
18
|
+
# @param data [Array<ScalarGalaxy::Models::Planet>]
|
|
19
|
+
# @param meta [ScalarGalaxy::Models::PlanetListResponse::Meta]
|
|
20
20
|
|
|
21
|
-
# @see ScalarGalaxy::Models::
|
|
21
|
+
# @see ScalarGalaxy::Models::PlanetListResponse#meta
|
|
22
22
|
class Meta < ScalarGalaxy::Internal::Type::BaseModel
|
|
23
23
|
# @!attribute limit
|
|
24
24
|
#
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ScalarGalaxy
|
|
4
|
+
module Models
|
|
5
|
+
class PlanetParam < ScalarGalaxy::Internal::Type::BaseModel
|
|
6
|
+
# @!attribute name
|
|
7
|
+
#
|
|
8
|
+
# @return [String]
|
|
9
|
+
required :name, String
|
|
10
|
+
|
|
11
|
+
# @!attribute atmosphere
|
|
12
|
+
# Atmospheric composition
|
|
13
|
+
#
|
|
14
|
+
# @return [Array<ScalarGalaxy::Models::PlanetParam::Atmosphere>, nil]
|
|
15
|
+
optional :atmosphere,
|
|
16
|
+
-> { ScalarGalaxy::Internal::Type::ArrayOf[ScalarGalaxy::PlanetParam::Atmosphere] }
|
|
17
|
+
|
|
18
|
+
# @!attribute creator
|
|
19
|
+
# A user
|
|
20
|
+
#
|
|
21
|
+
# @return [ScalarGalaxy::Models::UserParam, nil]
|
|
22
|
+
optional :creator, -> { ScalarGalaxy::UserParam }
|
|
23
|
+
|
|
24
|
+
# @!attribute description
|
|
25
|
+
#
|
|
26
|
+
# @return [String, nil]
|
|
27
|
+
optional :description, String, nil?: true
|
|
28
|
+
|
|
29
|
+
# @!attribute discovered_at
|
|
30
|
+
#
|
|
31
|
+
# @return [Time, nil]
|
|
32
|
+
optional :discovered_at, Time, api_name: :discoveredAt
|
|
33
|
+
|
|
34
|
+
# @!attribute failure_callback_url
|
|
35
|
+
# URL which gets invoked upon a failed operation
|
|
36
|
+
#
|
|
37
|
+
# @return [String, nil]
|
|
38
|
+
optional :failure_callback_url, String, api_name: :failureCallbackUrl
|
|
39
|
+
|
|
40
|
+
# @!attribute habitability_index
|
|
41
|
+
# A score from 0 to 1 indicating potential habitability
|
|
42
|
+
#
|
|
43
|
+
# @return [Float, nil]
|
|
44
|
+
optional :habitability_index, Float, api_name: :habitabilityIndex
|
|
45
|
+
|
|
46
|
+
# @!attribute image
|
|
47
|
+
#
|
|
48
|
+
# @return [String, nil]
|
|
49
|
+
optional :image, String, nil?: true
|
|
50
|
+
|
|
51
|
+
# @!attribute physical_properties
|
|
52
|
+
#
|
|
53
|
+
# @return [ScalarGalaxy::Models::PlanetParam::PhysicalProperties, nil]
|
|
54
|
+
optional :physical_properties,
|
|
55
|
+
-> { ScalarGalaxy::PlanetParam::PhysicalProperties },
|
|
56
|
+
api_name: :physicalProperties
|
|
57
|
+
|
|
58
|
+
# @!attribute satellites
|
|
59
|
+
#
|
|
60
|
+
# @return [Array<Object>, nil]
|
|
61
|
+
optional :satellites, ScalarGalaxy::Internal::Type::ArrayOf[ScalarGalaxy::Internal::Type::Unknown]
|
|
62
|
+
|
|
63
|
+
# @!attribute success_callback_url
|
|
64
|
+
# URL which gets invoked upon a successful operation
|
|
65
|
+
#
|
|
66
|
+
# @return [String, nil]
|
|
67
|
+
optional :success_callback_url, String, api_name: :successCallbackUrl
|
|
68
|
+
|
|
69
|
+
# @!attribute tags
|
|
70
|
+
#
|
|
71
|
+
# @return [Array<String>, nil]
|
|
72
|
+
optional :tags, ScalarGalaxy::Internal::Type::ArrayOf[String]
|
|
73
|
+
|
|
74
|
+
# @!attribute type
|
|
75
|
+
#
|
|
76
|
+
# @return [Symbol, ScalarGalaxy::Models::PlanetParam::Type, nil]
|
|
77
|
+
optional :type, enum: -> { ScalarGalaxy::PlanetParam::Type }
|
|
78
|
+
|
|
79
|
+
drop_on_dump :id, :last_updated, :lastUpdated
|
|
80
|
+
|
|
81
|
+
# @!method initialize(name:, atmosphere: nil, creator: nil, description: nil, discovered_at: nil, failure_callback_url: nil, habitability_index: nil, image: nil, physical_properties: nil, satellites: nil, success_callback_url: nil, tags: nil, type: nil)
|
|
82
|
+
# A planet in the Scalar Galaxy
|
|
83
|
+
#
|
|
84
|
+
# @param name [String]
|
|
85
|
+
#
|
|
86
|
+
# @param atmosphere [Array<ScalarGalaxy::Models::PlanetParam::Atmosphere>] Atmospheric composition
|
|
87
|
+
#
|
|
88
|
+
# @param creator [ScalarGalaxy::Models::UserParam] A user
|
|
89
|
+
#
|
|
90
|
+
# @param description [String, nil]
|
|
91
|
+
#
|
|
92
|
+
# @param discovered_at [Time]
|
|
93
|
+
#
|
|
94
|
+
# @param failure_callback_url [String] URL which gets invoked upon a failed operation
|
|
95
|
+
#
|
|
96
|
+
# @param habitability_index [Float] A score from 0 to 1 indicating potential habitability
|
|
97
|
+
#
|
|
98
|
+
# @param image [String, nil]
|
|
99
|
+
#
|
|
100
|
+
# @param physical_properties [ScalarGalaxy::Models::PlanetParam::PhysicalProperties]
|
|
101
|
+
#
|
|
102
|
+
# @param satellites [Array<Object>]
|
|
103
|
+
#
|
|
104
|
+
# @param success_callback_url [String] URL which gets invoked upon a successful operation
|
|
105
|
+
#
|
|
106
|
+
# @param tags [Array<String>]
|
|
107
|
+
#
|
|
108
|
+
# @param type [Symbol, ScalarGalaxy::Models::PlanetParam::Type]
|
|
109
|
+
|
|
110
|
+
class Atmosphere < ScalarGalaxy::Internal::Type::BaseModel
|
|
111
|
+
# @!attribute compound
|
|
112
|
+
#
|
|
113
|
+
# @return [String, nil]
|
|
114
|
+
optional :compound, String
|
|
115
|
+
|
|
116
|
+
# @!attribute percentage
|
|
117
|
+
#
|
|
118
|
+
# @return [Float, nil]
|
|
119
|
+
optional :percentage, Float
|
|
120
|
+
|
|
121
|
+
# @!method initialize(compound: nil, percentage: nil)
|
|
122
|
+
# @param compound [String]
|
|
123
|
+
# @param percentage [Float]
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# @see ScalarGalaxy::Models::PlanetParam#physical_properties
|
|
127
|
+
class PhysicalProperties < ScalarGalaxy::Internal::Type::BaseModel
|
|
128
|
+
# @!attribute gravity
|
|
129
|
+
# Surface gravity in Earth g
|
|
130
|
+
#
|
|
131
|
+
# @return [Float, nil]
|
|
132
|
+
optional :gravity, Float
|
|
133
|
+
|
|
134
|
+
# @!attribute mass
|
|
135
|
+
# Mass in Earth masses (must be greater than 0)
|
|
136
|
+
#
|
|
137
|
+
# @return [Float, nil]
|
|
138
|
+
optional :mass, Float
|
|
139
|
+
|
|
140
|
+
# @!attribute radius
|
|
141
|
+
# Radius in Earth radii (must be greater than 0)
|
|
142
|
+
#
|
|
143
|
+
# @return [Float, nil]
|
|
144
|
+
optional :radius, Float
|
|
145
|
+
|
|
146
|
+
# @!attribute temperature
|
|
147
|
+
#
|
|
148
|
+
# @return [ScalarGalaxy::Models::PlanetParam::PhysicalProperties::Temperature, nil]
|
|
149
|
+
optional :temperature, -> { ScalarGalaxy::PlanetParam::PhysicalProperties::Temperature }
|
|
150
|
+
|
|
151
|
+
# @!method initialize(gravity: nil, mass: nil, radius: nil, temperature: nil)
|
|
152
|
+
# @param gravity [Float] Surface gravity in Earth g
|
|
153
|
+
#
|
|
154
|
+
# @param mass [Float] Mass in Earth masses (must be greater than 0)
|
|
155
|
+
#
|
|
156
|
+
# @param radius [Float] Radius in Earth radii (must be greater than 0)
|
|
157
|
+
#
|
|
158
|
+
# @param temperature [ScalarGalaxy::Models::PlanetParam::PhysicalProperties::Temperature]
|
|
159
|
+
|
|
160
|
+
# @see ScalarGalaxy::Models::PlanetParam::PhysicalProperties#temperature
|
|
161
|
+
class Temperature < ScalarGalaxy::Internal::Type::BaseModel
|
|
162
|
+
# @!attribute average
|
|
163
|
+
# Average temperature in Kelvin
|
|
164
|
+
#
|
|
165
|
+
# @return [Float, nil]
|
|
166
|
+
optional :average, Float
|
|
167
|
+
|
|
168
|
+
# @!attribute max
|
|
169
|
+
# Maximum temperature in Kelvin
|
|
170
|
+
#
|
|
171
|
+
# @return [Float, nil]
|
|
172
|
+
optional :max, Float
|
|
173
|
+
|
|
174
|
+
# @!attribute min
|
|
175
|
+
# Minimum temperature in Kelvin
|
|
176
|
+
#
|
|
177
|
+
# @return [Float, nil]
|
|
178
|
+
optional :min, Float
|
|
179
|
+
|
|
180
|
+
# @!method initialize(average: nil, max: nil, min: nil)
|
|
181
|
+
# @param average [Float] Average temperature in Kelvin
|
|
182
|
+
#
|
|
183
|
+
# @param max [Float] Maximum temperature in Kelvin
|
|
184
|
+
#
|
|
185
|
+
# @param min [Float] Minimum temperature in Kelvin
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# @see ScalarGalaxy::Models::PlanetParam#type
|
|
190
|
+
module Type
|
|
191
|
+
extend ScalarGalaxy::Internal::Type::Enum
|
|
192
|
+
|
|
193
|
+
TERRESTRIAL = :terrestrial
|
|
194
|
+
GAS_GIANT = :gas_giant
|
|
195
|
+
ICE_GIANT = :ice_giant
|
|
196
|
+
DWARF = :dwarf
|
|
197
|
+
SUPER_EARTH = :super_earth
|
|
198
|
+
|
|
199
|
+
# @!method self.values
|
|
200
|
+
# @return [Array<Symbol>]
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
end
|
|
@@ -12,8 +12,19 @@ module ScalarGalaxy
|
|
|
12
12
|
# @return [Integer]
|
|
13
13
|
required :planet_id, Integer
|
|
14
14
|
|
|
15
|
-
# @!
|
|
15
|
+
# @!attribute creator
|
|
16
|
+
# A user
|
|
17
|
+
#
|
|
18
|
+
# @return [ScalarGalaxy::Models::UserParam, nil]
|
|
19
|
+
optional :creator, -> { ScalarGalaxy::UserParam }
|
|
20
|
+
|
|
21
|
+
drop_on_dump :lastUpdated
|
|
22
|
+
|
|
23
|
+
# @!method initialize(planet_id:, creator: nil, request_options: {})
|
|
16
24
|
# @param planet_id [Integer]
|
|
25
|
+
#
|
|
26
|
+
# @param creator [ScalarGalaxy::Models::UserParam] A user
|
|
27
|
+
#
|
|
17
28
|
# @param request_options [ScalarGalaxy::RequestOptions, Hash{Symbol=>Object}]
|
|
18
29
|
end
|
|
19
30
|
end
|