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
|
@@ -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#upload_image
|
|
6
|
+
class PlanetUploadImageParams < ScalarGalaxy::Internal::Type::BaseModel
|
|
7
7
|
extend ScalarGalaxy::Internal::Type::RequestParameters::Converter
|
|
8
8
|
include ScalarGalaxy::Internal::Type::RequestParameters
|
|
9
9
|
|
data/lib/galaxy-ruby/models/{planet_delte_image_response.rb → planet_upload_image_response.rb}
RENAMED
|
@@ -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#upload_image
|
|
6
|
+
class PlanetUploadImageResponse < ScalarGalaxy::Internal::Type::BaseModel
|
|
7
7
|
# @!attribute file_size
|
|
8
8
|
# Size of the uploaded image in bytes
|
|
9
9
|
#
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ScalarGalaxy
|
|
4
|
+
module Models
|
|
5
|
+
class UserParam < ScalarGalaxy::Internal::Type::BaseModel
|
|
6
|
+
# @!attribute name
|
|
7
|
+
#
|
|
8
|
+
# @return [String, nil]
|
|
9
|
+
optional :name, String
|
|
10
|
+
|
|
11
|
+
drop_on_dump :id
|
|
12
|
+
|
|
13
|
+
# @!method initialize(name: nil)
|
|
14
|
+
# A user
|
|
15
|
+
#
|
|
16
|
+
# @param name [String]
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/galaxy-ruby/models.rb
CHANGED
|
@@ -5,42 +5,39 @@ module ScalarGalaxy
|
|
|
5
5
|
cls.define_sorbet_constant!(:OrHash) { T.type_alias { T.any(cls, ScalarGalaxy::Internal::AnyHash) } }
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
ScalarGalaxy::Internal::Util
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
mod.define_sorbet_constant!(:OrSymbol) { T.type_alias { T.any(Symbol, String) } }
|
|
27
|
-
else
|
|
28
|
-
end
|
|
8
|
+
ScalarGalaxy::Internal::Util.walk_namespaces(ScalarGalaxy::Models).each do |mod|
|
|
9
|
+
case mod
|
|
10
|
+
in ScalarGalaxy::Internal::Type::Enum | ScalarGalaxy::Internal::Type::Union
|
|
11
|
+
mod.constants.each do |name|
|
|
12
|
+
case mod.const_get(name)
|
|
13
|
+
in true | false
|
|
14
|
+
mod.define_sorbet_constant!(:TaggedBoolean) { T.type_alias { T::Boolean } }
|
|
15
|
+
mod.define_sorbet_constant!(:OrBoolean) { T.type_alias { T::Boolean } }
|
|
16
|
+
in Integer
|
|
17
|
+
mod.define_sorbet_constant!(:TaggedInteger) { T.type_alias { Integer } }
|
|
18
|
+
mod.define_sorbet_constant!(:OrInteger) { T.type_alias { Integer } }
|
|
19
|
+
in Float
|
|
20
|
+
mod.define_sorbet_constant!(:TaggedFloat) { T.type_alias { Float } }
|
|
21
|
+
mod.define_sorbet_constant!(:OrFloat) { T.type_alias { Float } }
|
|
22
|
+
in Symbol
|
|
23
|
+
mod.define_sorbet_constant!(:TaggedSymbol) { T.type_alias { Symbol } }
|
|
24
|
+
mod.define_sorbet_constant!(:OrSymbol) { T.type_alias { T.any(Symbol, String) } }
|
|
25
|
+
else
|
|
29
26
|
end
|
|
30
|
-
else
|
|
31
27
|
end
|
|
28
|
+
else
|
|
32
29
|
end
|
|
30
|
+
end
|
|
33
31
|
|
|
34
|
-
ScalarGalaxy::Internal::Util
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
next if mod.sorbet_constant_defined?(const)
|
|
32
|
+
ScalarGalaxy::Internal::Util.walk_namespaces(ScalarGalaxy::Models)
|
|
33
|
+
.lazy
|
|
34
|
+
.grep(ScalarGalaxy::Internal::Type::Union)
|
|
35
|
+
.each do |mod|
|
|
36
|
+
const = :Variants
|
|
37
|
+
next if mod.sorbet_constant_defined?(const)
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
mod.define_sorbet_constant!(const) { T.type_alias { mod.to_sorbet_type } }
|
|
40
|
+
end
|
|
44
41
|
|
|
45
42
|
AuthenticationCreateTokenParams = ScalarGalaxy::Models::AuthenticationCreateTokenParams
|
|
46
43
|
|
|
@@ -52,6 +49,8 @@ module ScalarGalaxy
|
|
|
52
49
|
|
|
53
50
|
CelestialBodyCreateParams = ScalarGalaxy::Models::CelestialBodyCreateParams
|
|
54
51
|
|
|
52
|
+
CelestialBodyParam = ScalarGalaxy::Models::CelestialBodyParam
|
|
53
|
+
|
|
55
54
|
Credentials = ScalarGalaxy::Models::Credentials
|
|
56
55
|
|
|
57
56
|
NewPlanetWebhookEvent = ScalarGalaxy::Models::NewPlanetWebhookEvent
|
|
@@ -62,17 +61,23 @@ module ScalarGalaxy
|
|
|
62
61
|
|
|
63
62
|
PlanetDeleteParams = ScalarGalaxy::Models::PlanetDeleteParams
|
|
64
63
|
|
|
65
|
-
|
|
64
|
+
PlanetListParams = ScalarGalaxy::Models::PlanetListParams
|
|
66
65
|
|
|
67
|
-
|
|
66
|
+
PlanetParam = ScalarGalaxy::Models::PlanetParam
|
|
68
67
|
|
|
69
68
|
PlanetRetrieveParams = ScalarGalaxy::Models::PlanetRetrieveParams
|
|
70
69
|
|
|
71
70
|
PlanetUpdateParams = ScalarGalaxy::Models::PlanetUpdateParams
|
|
72
71
|
|
|
72
|
+
PlanetUploadImageParams = ScalarGalaxy::Models::PlanetUploadImageParams
|
|
73
|
+
|
|
73
74
|
UnwrapWebhookEvent = ScalarGalaxy::Models::UnwrapWebhookEvent
|
|
74
75
|
|
|
75
76
|
User = ScalarGalaxy::Models::User
|
|
76
77
|
|
|
78
|
+
UserParam = ScalarGalaxy::Models::UserParam
|
|
79
|
+
|
|
80
|
+
WebhookParsedParams = ScalarGalaxy::Models::WebhookParsedParams
|
|
81
|
+
|
|
77
82
|
WebhookUnwrapParams = ScalarGalaxy::Models::WebhookUnwrapParams
|
|
78
83
|
end
|
|
@@ -26,8 +26,8 @@ module ScalarGalaxy
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# @!attribute idempotency_key
|
|
29
|
-
# Idempotency key to send with request and
|
|
30
|
-
#
|
|
29
|
+
# Idempotency key to send with this request and its retries when the client
|
|
30
|
+
# has an idempotency header configured.
|
|
31
31
|
#
|
|
32
32
|
# @return [String, nil]
|
|
33
33
|
optional :idempotency_key, String
|
|
@@ -37,7 +37,10 @@ module ScalarGalaxy
|
|
|
37
37
|
# `query` given at the client level.
|
|
38
38
|
#
|
|
39
39
|
# @return [Hash{String=>Array<String>, String, nil}, nil]
|
|
40
|
-
optional :extra_query,
|
|
40
|
+
optional :extra_query,
|
|
41
|
+
ScalarGalaxy::Internal::Type::HashOf[
|
|
42
|
+
ScalarGalaxy::Internal::Type::ArrayOf[String]
|
|
43
|
+
]
|
|
41
44
|
|
|
42
45
|
# @!attribute extra_headers
|
|
43
46
|
# Extra headers to send with the request. These are `.merged`’d into any
|
|
@@ -51,7 +54,10 @@ module ScalarGalaxy
|
|
|
51
54
|
# generated as part of the normal request.
|
|
52
55
|
#
|
|
53
56
|
# @return [Object, nil]
|
|
54
|
-
optional :extra_body,
|
|
57
|
+
optional :extra_body,
|
|
58
|
+
ScalarGalaxy::Internal::Type::HashOf[
|
|
59
|
+
ScalarGalaxy::Internal::Type::Unknown
|
|
60
|
+
]
|
|
55
61
|
|
|
56
62
|
# @!attribute max_retries
|
|
57
63
|
# Maximum number of retries to attempt after a failed initial request.
|
|
@@ -71,7 +77,9 @@ module ScalarGalaxy
|
|
|
71
77
|
# @param values [Hash{Symbol=>Object}]
|
|
72
78
|
|
|
73
79
|
define_sorbet_constant!(:OrHash) do
|
|
74
|
-
T.type_alias
|
|
80
|
+
T.type_alias do
|
|
81
|
+
T.any(ScalarGalaxy::RequestOptions, ScalarGalaxy::Internal::AnyHash)
|
|
82
|
+
end
|
|
75
83
|
end
|
|
76
84
|
end
|
|
77
85
|
end
|
|
@@ -9,7 +9,7 @@ module ScalarGalaxy
|
|
|
9
9
|
#
|
|
10
10
|
# @overload create(celestial_body:, request_options: {})
|
|
11
11
|
#
|
|
12
|
-
# @param celestial_body [ScalarGalaxy::Models::
|
|
12
|
+
# @param celestial_body [ScalarGalaxy::Models::PlanetParam, ScalarGalaxy::Models::CelestialBodyParam::Satellite]
|
|
13
13
|
# @param request_options [ScalarGalaxy::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
14
14
|
#
|
|
15
15
|
# @return [ScalarGalaxy::Models::Planet, ScalarGalaxy::Models::CelestialBody::Satellite]
|
|
@@ -7,15 +7,13 @@ module ScalarGalaxy
|
|
|
7
7
|
# Time to play god and create a new planet. What do you think? Ah, don't think too
|
|
8
8
|
# much. What could go wrong anyway?
|
|
9
9
|
#
|
|
10
|
-
# @overload create(
|
|
11
|
-
#
|
|
12
|
-
# @param id [Integer]
|
|
10
|
+
# @overload create(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, request_options: {})
|
|
13
11
|
#
|
|
14
12
|
# @param name [String]
|
|
15
13
|
#
|
|
16
14
|
# @param atmosphere [Array<ScalarGalaxy::Models::Planet::Atmosphere>] Atmospheric composition
|
|
17
15
|
#
|
|
18
|
-
# @param creator [ScalarGalaxy::Models::
|
|
16
|
+
# @param creator [ScalarGalaxy::Models::UserParam] A user
|
|
19
17
|
#
|
|
20
18
|
# @param description [String, nil]
|
|
21
19
|
#
|
|
@@ -27,8 +25,6 @@ module ScalarGalaxy
|
|
|
27
25
|
#
|
|
28
26
|
# @param image [String, nil]
|
|
29
27
|
#
|
|
30
|
-
# @param last_updated [Time]
|
|
31
|
-
#
|
|
32
28
|
# @param physical_properties [ScalarGalaxy::Models::Planet::PhysicalProperties]
|
|
33
29
|
#
|
|
34
30
|
# @param satellites [Array<Object>]
|
|
@@ -79,17 +75,15 @@ module ScalarGalaxy
|
|
|
79
75
|
# Sometimes you make mistakes, that's fine. No worries, you can update all
|
|
80
76
|
# planets.
|
|
81
77
|
#
|
|
82
|
-
# @overload update(planet_id,
|
|
78
|
+
# @overload update(planet_id, 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, request_options: {})
|
|
83
79
|
#
|
|
84
80
|
# @param planet_id [Integer] The ID of the planet to get
|
|
85
81
|
#
|
|
86
|
-
# @param id [Integer]
|
|
87
|
-
#
|
|
88
82
|
# @param name [String]
|
|
89
83
|
#
|
|
90
84
|
# @param atmosphere [Array<ScalarGalaxy::Models::Planet::Atmosphere>] Atmospheric composition
|
|
91
85
|
#
|
|
92
|
-
# @param creator [ScalarGalaxy::Models::
|
|
86
|
+
# @param creator [ScalarGalaxy::Models::UserParam] A user
|
|
93
87
|
#
|
|
94
88
|
# @param description [String, nil]
|
|
95
89
|
#
|
|
@@ -101,8 +95,6 @@ module ScalarGalaxy
|
|
|
101
95
|
#
|
|
102
96
|
# @param image [String, nil]
|
|
103
97
|
#
|
|
104
|
-
# @param last_updated [Time]
|
|
105
|
-
#
|
|
106
98
|
# @param physical_properties [ScalarGalaxy::Models::Planet::PhysicalProperties]
|
|
107
99
|
#
|
|
108
100
|
# @param satellites [Array<Object>]
|
|
@@ -129,6 +121,32 @@ module ScalarGalaxy
|
|
|
129
121
|
)
|
|
130
122
|
end
|
|
131
123
|
|
|
124
|
+
# It's easy to say you know them all, but do you really? Retrieve all the planets
|
|
125
|
+
# and check whether you missed one.
|
|
126
|
+
#
|
|
127
|
+
# @overload list(limit: nil, offset: nil, request_options: {})
|
|
128
|
+
#
|
|
129
|
+
# @param limit [Integer] The number of items to return
|
|
130
|
+
#
|
|
131
|
+
# @param offset [Integer] The number of items to skip before starting to collect the result set
|
|
132
|
+
#
|
|
133
|
+
# @param request_options [ScalarGalaxy::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
134
|
+
#
|
|
135
|
+
# @return [ScalarGalaxy::Models::PlanetListResponse]
|
|
136
|
+
#
|
|
137
|
+
# @see ScalarGalaxy::Models::PlanetListParams
|
|
138
|
+
def list(params = {})
|
|
139
|
+
parsed, options = ScalarGalaxy::PlanetListParams.dump_request(params)
|
|
140
|
+
query = ScalarGalaxy::Internal::Util.encode_query_params(parsed)
|
|
141
|
+
@client.request(
|
|
142
|
+
method: :get,
|
|
143
|
+
path: "planets",
|
|
144
|
+
query: query,
|
|
145
|
+
model: ScalarGalaxy::Models::PlanetListResponse,
|
|
146
|
+
options: options
|
|
147
|
+
)
|
|
148
|
+
end
|
|
149
|
+
|
|
132
150
|
# This endpoint was used to delete planets. Unfortunately, that caused a lot of
|
|
133
151
|
# trouble for planets with life. So, this endpoint is now deprecated and should
|
|
134
152
|
# not be used anymore.
|
|
@@ -153,7 +171,7 @@ module ScalarGalaxy
|
|
|
153
171
|
|
|
154
172
|
# Got a crazy good photo of a planet? Share it with the world!
|
|
155
173
|
#
|
|
156
|
-
# @overload
|
|
174
|
+
# @overload upload_image(planet_id, image: nil, request_options: {})
|
|
157
175
|
#
|
|
158
176
|
# @param planet_id [Integer] The ID of the planet to get
|
|
159
177
|
#
|
|
@@ -161,45 +179,17 @@ module ScalarGalaxy
|
|
|
161
179
|
#
|
|
162
180
|
# @param request_options [ScalarGalaxy::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
163
181
|
#
|
|
164
|
-
# @return [ScalarGalaxy::Models::
|
|
182
|
+
# @return [ScalarGalaxy::Models::PlanetUploadImageResponse]
|
|
165
183
|
#
|
|
166
|
-
# @see ScalarGalaxy::Models::
|
|
167
|
-
def
|
|
168
|
-
parsed, options = ScalarGalaxy::
|
|
184
|
+
# @see ScalarGalaxy::Models::PlanetUploadImageParams
|
|
185
|
+
def upload_image(planet_id, params = {})
|
|
186
|
+
parsed, options = ScalarGalaxy::PlanetUploadImageParams.dump_request(params)
|
|
169
187
|
@client.request(
|
|
170
188
|
method: :post,
|
|
171
189
|
path: ["planets/%1$s/image", planet_id],
|
|
172
|
-
headers: {
|
|
173
|
-
"content-type" => "multipart/form-data"
|
|
174
|
-
},
|
|
190
|
+
headers: {"content-type" => "multipart/form-data"},
|
|
175
191
|
body: parsed,
|
|
176
|
-
model: ScalarGalaxy::Models::
|
|
177
|
-
options: options
|
|
178
|
-
)
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
# It's easy to say you know them all, but do you really? Retrieve all the planets
|
|
182
|
-
# and check whether you missed one.
|
|
183
|
-
#
|
|
184
|
-
# @overload list_all_data(limit: nil, offset: nil, request_options: {})
|
|
185
|
-
#
|
|
186
|
-
# @param limit [Integer] The number of items to return
|
|
187
|
-
#
|
|
188
|
-
# @param offset [Integer] The number of items to skip before starting to collect the result set
|
|
189
|
-
#
|
|
190
|
-
# @param request_options [ScalarGalaxy::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
191
|
-
#
|
|
192
|
-
# @return [ScalarGalaxy::Models::PlanetListAllDataResponse]
|
|
193
|
-
#
|
|
194
|
-
# @see ScalarGalaxy::Models::PlanetListAllDataParams
|
|
195
|
-
def list_all_data(params = {})
|
|
196
|
-
parsed, options = ScalarGalaxy::PlanetListAllDataParams.dump_request(params)
|
|
197
|
-
query = ScalarGalaxy::Internal::Util.encode_query_params(parsed)
|
|
198
|
-
@client.request(
|
|
199
|
-
method: :get,
|
|
200
|
-
path: "planets",
|
|
201
|
-
query: query,
|
|
202
|
-
model: ScalarGalaxy::Models::PlanetListAllDataResponse,
|
|
192
|
+
model: ScalarGalaxy::Models::PlanetUploadImageResponse,
|
|
203
193
|
options: options
|
|
204
194
|
)
|
|
205
195
|
end
|
|
@@ -5,24 +5,81 @@ module ScalarGalaxy
|
|
|
5
5
|
class Webhooks
|
|
6
6
|
# @param payload [String] The raw webhook payload as a string
|
|
7
7
|
#
|
|
8
|
-
# @param headers [Hash{String=>String}] The raw HTTP headers that came with the payload
|
|
8
|
+
# @param headers [Hash{String, Symbol=>String, Array<String>}] The raw HTTP headers that came with the payload
|
|
9
9
|
#
|
|
10
|
-
# @param key [String, nil] The webhook signing key
|
|
10
|
+
# @param key [String, nil] The webhook signing key. When `nil`, the client's `webhook_secret` is used if it was passed to the client, else `ENV["SCALAR_WEBHOOK_SECRET"]` read at call time, else the client's `webhook_secret` as read when the client was built.
|
|
11
11
|
#
|
|
12
12
|
# @return [ScalarGalaxy::Models::NewPlanetWebhookEvent]
|
|
13
|
-
def unwrap(payload, headers:, key:
|
|
14
|
-
|
|
13
|
+
def unwrap(payload, headers:, key: nil)
|
|
14
|
+
key ||= @client.explicit_webhook_secret
|
|
15
|
+
key_from_env = ENV["SCALAR_WEBHOOK_SECRET"]
|
|
16
|
+
key ||= key_from_env unless key_from_env.to_s.strip.empty?
|
|
17
|
+
key ||= @client.webhook_secret
|
|
18
|
+
if key.nil? || key.delete_prefix("whsec_").unpack1("m").empty?
|
|
15
19
|
raise ArgumentError.new(
|
|
16
|
-
"Cannot verify a webhook without a key on either the client's webhook_secret or passed in as an argument"
|
|
20
|
+
"Cannot verify a webhook without a key on either the client's webhook_secret or passed in as an argument (or set in the SCALAR_WEBHOOK_SECRET environment variable)"
|
|
17
21
|
)
|
|
18
22
|
end
|
|
19
23
|
|
|
20
|
-
::
|
|
24
|
+
ScalarGalaxy::Internal::WebhookVerifier.verify!(payload, headers, key)
|
|
21
25
|
|
|
22
26
|
parsed = JSON.parse(payload, symbolize_names: true)
|
|
23
27
|
ScalarGalaxy::Internal::Type::Converter.coerce(ScalarGalaxy::Models::UnwrapWebhookEvent, parsed)
|
|
24
28
|
end
|
|
25
29
|
|
|
30
|
+
# Back-compat alias for `unwrap`, which it calls with the same arguments. SDKs
|
|
31
|
+
# that named this helper `parsed` shipped it under this name.
|
|
32
|
+
#
|
|
33
|
+
# @deprecated Use {#unwrap} instead.
|
|
34
|
+
#
|
|
35
|
+
# @param payload [String] The raw webhook payload as a string
|
|
36
|
+
#
|
|
37
|
+
# @param headers [Hash{String, Symbol=>String, Array<String>}] The raw HTTP headers that came with the payload
|
|
38
|
+
#
|
|
39
|
+
# @param key [String, nil] The webhook signing key. When `nil`, the client's `webhook_secret` is used if it was passed to the client, else `ENV["SCALAR_WEBHOOK_SECRET"]` read at call time, else the client's `webhook_secret` as read when the client was built.
|
|
40
|
+
#
|
|
41
|
+
# @return [ScalarGalaxy::Models::NewPlanetWebhookEvent]
|
|
42
|
+
def parsed(payload, headers:, key: nil)
|
|
43
|
+
unwrap(payload, headers: headers, key: key)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Verifies that the payload was signed with the webhook key, raising when it was
|
|
47
|
+
# not.
|
|
48
|
+
#
|
|
49
|
+
# @param payload [String] The raw webhook payload as a string
|
|
50
|
+
#
|
|
51
|
+
# @param headers [Hash{String, Symbol=>String, Array<String>}] The raw HTTP headers that came with the payload
|
|
52
|
+
#
|
|
53
|
+
# @param key [String, nil] The webhook signing key. When `nil`, the client's `webhook_secret` is used if it was passed to the client, else `ENV["SCALAR_WEBHOOK_SECRET"]` read at call time, else the client's `webhook_secret` as read when the client was built.
|
|
54
|
+
#
|
|
55
|
+
# @return [Hash{Symbol=>Object}] The verified payload, parsed with symbolized keys
|
|
56
|
+
def verify_signature(payload:, headers:, key: nil)
|
|
57
|
+
key ||= @client.explicit_webhook_secret
|
|
58
|
+
key_from_env = ENV["SCALAR_WEBHOOK_SECRET"]
|
|
59
|
+
key ||= key_from_env unless key_from_env.to_s.strip.empty?
|
|
60
|
+
key ||= @client.webhook_secret
|
|
61
|
+
if key.nil? || key.delete_prefix("whsec_").unpack1("m").empty?
|
|
62
|
+
raise ArgumentError.new(
|
|
63
|
+
"The webhook secret must either be set using the env var, SCALAR_WEBHOOK_SECRET, on the client class, or passed to this method"
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
ScalarGalaxy::Internal::WebhookVerifier.verify!(payload, headers, key)
|
|
68
|
+
JSON.parse(payload, symbolize_names: true)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Parses the payload into a typed event without verifying its signature.
|
|
72
|
+
#
|
|
73
|
+
# Only use this for a payload whose signature was already verified, or in tests.
|
|
74
|
+
#
|
|
75
|
+
# @param payload [String] The raw webhook payload as a string
|
|
76
|
+
#
|
|
77
|
+
# @return [ScalarGalaxy::Models::NewPlanetWebhookEvent]
|
|
78
|
+
def parse_unsafe(payload)
|
|
79
|
+
parsed = JSON.parse(payload, symbolize_names: true)
|
|
80
|
+
ScalarGalaxy::Internal::Type::Converter.coerce(ScalarGalaxy::Models::UnwrapWebhookEvent, parsed)
|
|
81
|
+
end
|
|
82
|
+
|
|
26
83
|
# @api private
|
|
27
84
|
#
|
|
28
85
|
# @param client [ScalarGalaxy::Client]
|
data/lib/galaxy-ruby/version.rb
CHANGED
data/lib/galaxy-ruby.rb
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
# Standard libraries.
|
|
4
4
|
# rubocop:disable Lint/RedundantRequireStatement
|
|
5
5
|
require "English"
|
|
6
|
-
require "cgi"
|
|
7
6
|
require "date"
|
|
8
7
|
require "erb"
|
|
9
8
|
require "etc"
|
|
@@ -16,20 +15,18 @@ require "securerandom"
|
|
|
16
15
|
require "set"
|
|
17
16
|
require "stringio"
|
|
18
17
|
require "time"
|
|
18
|
+
require "timeout"
|
|
19
19
|
require "uri"
|
|
20
20
|
# rubocop:enable Lint/RedundantRequireStatement
|
|
21
21
|
|
|
22
22
|
# We already ship the preferred sorbet manifests in the package itself.
|
|
23
23
|
# `tapioca` currently does not offer us a way to opt out of unnecessary compilation.
|
|
24
|
-
if Object.const_defined?(:Tapioca) &&
|
|
24
|
+
if Object.const_defined?(:Tapioca) &&
|
|
25
|
+
caller.chain([$PROGRAM_NAME]).chain(ARGV).any?(/tapioca/) &&
|
|
25
26
|
ARGV.none?(/dsl/)
|
|
26
27
|
return
|
|
27
28
|
end
|
|
28
29
|
|
|
29
|
-
# Gems.
|
|
30
|
-
require "connection_pool"
|
|
31
|
-
require "standardwebhooks"
|
|
32
|
-
|
|
33
30
|
# Package files.
|
|
34
31
|
require_relative "galaxy-ruby/version"
|
|
35
32
|
require_relative "galaxy-ruby/internal/util"
|
|
@@ -48,7 +45,9 @@ require_relative "galaxy-ruby/internal"
|
|
|
48
45
|
require_relative "galaxy-ruby/request_options"
|
|
49
46
|
require_relative "galaxy-ruby/file_part"
|
|
50
47
|
require_relative "galaxy-ruby/errors"
|
|
48
|
+
require_relative "galaxy-ruby/internal/webhook_verifier"
|
|
51
49
|
require_relative "galaxy-ruby/internal/transport/base_client"
|
|
50
|
+
require_relative "galaxy-ruby/internal/transport/connection_pool"
|
|
52
51
|
require_relative "galaxy-ruby/internal/transport/pooled_net_requester"
|
|
53
52
|
require_relative "galaxy-ruby/client"
|
|
54
53
|
require_relative "galaxy-ruby/models/credentials"
|
|
@@ -59,17 +58,20 @@ require_relative "galaxy-ruby/models/authentication_create_user_params"
|
|
|
59
58
|
require_relative "galaxy-ruby/models/authentication_list_me_params"
|
|
60
59
|
require_relative "galaxy-ruby/models/celestial_body"
|
|
61
60
|
require_relative "galaxy-ruby/models/celestial_body_create_params"
|
|
61
|
+
require_relative "galaxy-ruby/models/celestial_body_param"
|
|
62
62
|
require_relative "galaxy-ruby/models/new_planet_webhook_event"
|
|
63
63
|
require_relative "galaxy-ruby/models/planet_create_params"
|
|
64
64
|
require_relative "galaxy-ruby/models/planet_delete_params"
|
|
65
|
-
require_relative "galaxy-ruby/models/
|
|
66
|
-
require_relative "galaxy-ruby/models/
|
|
67
|
-
require_relative "galaxy-ruby/models/
|
|
68
|
-
require_relative "galaxy-ruby/models/planet_list_all_data_response"
|
|
65
|
+
require_relative "galaxy-ruby/models/planet_list_params"
|
|
66
|
+
require_relative "galaxy-ruby/models/planet_list_response"
|
|
67
|
+
require_relative "galaxy-ruby/models/planet_param"
|
|
69
68
|
require_relative "galaxy-ruby/models/planet_retrieve_params"
|
|
70
69
|
require_relative "galaxy-ruby/models/planet_update_params"
|
|
70
|
+
require_relative "galaxy-ruby/models/planet_upload_image_params"
|
|
71
|
+
require_relative "galaxy-ruby/models/planet_upload_image_response"
|
|
71
72
|
require_relative "galaxy-ruby/models/unwrap_webhook_event"
|
|
72
73
|
require_relative "galaxy-ruby/models/user"
|
|
74
|
+
require_relative "galaxy-ruby/models/user_param"
|
|
73
75
|
require_relative "galaxy-ruby/models/webhook_unwrap_params"
|
|
74
76
|
require_relative "galaxy-ruby/models"
|
|
75
77
|
require_relative "galaxy-ruby/resources/planets"
|
data/rbi/galaxy-ruby/client.rbi
CHANGED
|
@@ -46,6 +46,14 @@ module ScalarGalaxy
|
|
|
46
46
|
sig { returns(T.nilable(String)) }
|
|
47
47
|
attr_reader :webhook_secret
|
|
48
48
|
|
|
49
|
+
# @api private
|
|
50
|
+
#
|
|
51
|
+
# The `webhook_secret` passed to the constructor, or `nil` when it was left to
|
|
52
|
+
# default to `ENV["SCALAR_WEBHOOK_SECRET"]`. The webhook helpers read that
|
|
53
|
+
# variable again on every call, so only a value passed here outranks it.
|
|
54
|
+
sig { returns(T.nilable(String)) }
|
|
55
|
+
attr_reader :explicit_webhook_secret
|
|
56
|
+
|
|
49
57
|
# Everything about planets
|
|
50
58
|
sig { returns(ScalarGalaxy::Resources::Planets) }
|
|
51
59
|
attr_reader :planets
|
|
@@ -67,6 +75,21 @@ module ScalarGalaxy
|
|
|
67
75
|
private def auth_headers
|
|
68
76
|
end
|
|
69
77
|
|
|
78
|
+
# @api private
|
|
79
|
+
sig { override.returns(T::Array[String]) }
|
|
80
|
+
private def auth_header_keys
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# @api private
|
|
84
|
+
sig { override.returns(T::Hash[String, String]) }
|
|
85
|
+
private def auth_query
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# @api private
|
|
89
|
+
sig { override.returns(T::Array[String]) }
|
|
90
|
+
private def auth_query_keys
|
|
91
|
+
end
|
|
92
|
+
|
|
70
93
|
# Creates and returns a new client for interacting with the API.
|
|
71
94
|
sig do
|
|
72
95
|
params(
|
data/rbi/galaxy-ruby/errors.rbi
CHANGED
|
@@ -39,6 +39,18 @@ module ScalarGalaxy
|
|
|
39
39
|
sig { returns(T.nilable(T.anything)) }
|
|
40
40
|
attr_accessor :body
|
|
41
41
|
|
|
42
|
+
sig { returns(T.nilable(String)) }
|
|
43
|
+
def request_id
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
sig { returns(T.nilable(T::Hash[T.any(String, Symbol), T.anything])) }
|
|
47
|
+
def problem_details
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
sig { params(name: String).returns(T.nilable(String)) }
|
|
51
|
+
private def response_header(name)
|
|
52
|
+
end
|
|
53
|
+
|
|
42
54
|
# @api private
|
|
43
55
|
sig do
|
|
44
56
|
params(
|
|
@@ -51,15 +63,7 @@ module ScalarGalaxy
|
|
|
51
63
|
message: T.nilable(String)
|
|
52
64
|
).returns(T.attached_class)
|
|
53
65
|
end
|
|
54
|
-
def self.new(
|
|
55
|
-
url:,
|
|
56
|
-
status: nil,
|
|
57
|
-
headers: nil,
|
|
58
|
-
body: nil,
|
|
59
|
-
request: nil,
|
|
60
|
-
response: nil,
|
|
61
|
-
message: nil
|
|
62
|
-
)
|
|
66
|
+
def self.new(url:, status: nil, headers: nil, body: nil, request: nil, response: nil, message: nil)
|
|
63
67
|
end
|
|
64
68
|
end
|
|
65
69
|
|
|
@@ -132,15 +136,7 @@ module ScalarGalaxy
|
|
|
132
136
|
message: T.nilable(String)
|
|
133
137
|
).returns(T.attached_class)
|
|
134
138
|
end
|
|
135
|
-
def self.for(
|
|
136
|
-
url:,
|
|
137
|
-
status:,
|
|
138
|
-
headers:,
|
|
139
|
-
body:,
|
|
140
|
-
request:,
|
|
141
|
-
response:,
|
|
142
|
-
message: nil
|
|
143
|
-
)
|
|
139
|
+
def self.for(url:, status:, headers:, body:, request:, response:, message: nil)
|
|
144
140
|
end
|
|
145
141
|
|
|
146
142
|
sig { returns(Integer) }
|
|
@@ -158,15 +154,7 @@ module ScalarGalaxy
|
|
|
158
154
|
message: T.nilable(String)
|
|
159
155
|
).returns(T.attached_class)
|
|
160
156
|
end
|
|
161
|
-
def self.new(
|
|
162
|
-
url:,
|
|
163
|
-
status:,
|
|
164
|
-
headers:,
|
|
165
|
-
body:,
|
|
166
|
-
request:,
|
|
167
|
-
response:,
|
|
168
|
-
message: nil
|
|
169
|
-
)
|
|
157
|
+
def self.new(url:, status:, headers:, body:, request:, response:, message: nil)
|
|
170
158
|
end
|
|
171
159
|
end
|
|
172
160
|
|
|
@@ -201,5 +189,15 @@ module ScalarGalaxy
|
|
|
201
189
|
class InternalServerError < ScalarGalaxy::Errors::APIStatusError
|
|
202
190
|
HTTP_STATUS = T.let((500..), T::Range[Integer])
|
|
203
191
|
end
|
|
192
|
+
|
|
193
|
+
# Raised by SDKs that verify webhook signatures through the `standardwebhooks` gem when that gem
|
|
194
|
+
# is not installed. This SDK verifies them with the standard library and never raises it; the
|
|
195
|
+
# class is declared so code that rescues or names it keeps working.
|
|
196
|
+
class MissingDependencyError < ScalarGalaxy::Errors::Error
|
|
197
|
+
# @api private
|
|
198
|
+
sig { params(gem_name: String, feature: String).returns(T.attached_class) }
|
|
199
|
+
def self.new(gem_name:, feature:)
|
|
200
|
+
end
|
|
201
|
+
end
|
|
204
202
|
end
|
|
205
203
|
end
|