Class: ScalarGalaxy::Resources::Planets

Inherits:
Object
  • Object
show all
Defined in:
lib/galaxy-ruby/resources/planets.rb,
sig/galaxy-ruby/resources/planets.rbs

Overview

Everything about planets

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Planets

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Planets.

Parameters:



210
211
212
# File 'lib/galaxy-ruby/resources/planets.rb', line 210

def initialize(client:)
  @client = client
end

Instance Method Details

#create(id:, name:, atmosphere: nil, creator: nil, description: nil, discovered_at: nil, failure_callback_url: nil, habitability_index: nil, image: nil, last_updated: nil, physical_properties: nil, satellites: nil, success_callback_url: nil, tags: nil, type: nil, request_options: {}) ⇒ ScalarGalaxy::Models::Planet

Time to play god and create a new planet. What do you think? Ah, don't think too much. What could go wrong anyway?

Parameters:

Returns:

See Also:



47
48
49
50
51
52
53
54
55
56
# File 'lib/galaxy-ruby/resources/planets.rb', line 47

def create(params)
  parsed, options = ScalarGalaxy::PlanetCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "planets",
    body: parsed,
    model: ScalarGalaxy::Planet,
    options: options
  )
end

#delete(planet_id, request_options: {}) ⇒ nil

This endpoint was used to delete planets. Unfortunately, that caused a lot of trouble for planets with life. So, this endpoint is now deprecated and should not be used anymore.

Parameters:

Returns:

  • (nil)

See Also:



145
146
147
148
149
150
151
152
# File 'lib/galaxy-ruby/resources/planets.rb', line 145

def delete(planet_id, params = {})
  @client.request(
    method: :delete,
    path: ["planets/%1$s", planet_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#delte_image(planet_id, image: nil, request_options: {}) ⇒ ScalarGalaxy::Models::PlanetDelteImageResponse

Got a crazy good photo of a planet? Share it with the world!

Parameters:

Returns:

See Also:



167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/galaxy-ruby/resources/planets.rb', line 167

def delte_image(planet_id, params = {})
  parsed, options = ScalarGalaxy::PlanetDelteImageParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["planets/%1$s/image", planet_id],
    headers: {
      "content-type" => "multipart/form-data"
    },
    body: parsed,
    model: ScalarGalaxy::Models::PlanetDelteImageResponse,
    options: options
  )
end

#list_all_data(limit: nil, offset: nil, request_options: {}) ⇒ ScalarGalaxy::Models::PlanetListAllDataResponse

It's easy to say you know them all, but do you really? Retrieve all the planets and check whether you missed one.

Parameters:

  • limit (Integer)

    The number of items to return

  • offset (Integer)

    The number of items to skip before starting to collect the result set

  • request_options (ScalarGalaxy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



195
196
197
198
199
200
201
202
203
204
205
# File 'lib/galaxy-ruby/resources/planets.rb', line 195

def list_all_data(params = {})
  parsed, options = ScalarGalaxy::PlanetListAllDataParams.dump_request(params)
  query = ScalarGalaxy::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "planets",
    query: query,
    model: ScalarGalaxy::Models::PlanetListAllDataResponse,
    options: options
  )
end

#retrieve(planet_id, request_options: {}) ⇒ ScalarGalaxy::Models::Planet

You'll better learn a little bit more about the planets. It might come in handy once space travel is available for everyone.

Parameters:

Returns:

See Also:



70
71
72
73
74
75
76
77
# File 'lib/galaxy-ruby/resources/planets.rb', line 70

def retrieve(planet_id, params = {})
  @client.request(
    method: :get,
    path: ["planets/%1$s", planet_id],
    model: ScalarGalaxy::Planet,
    options: params[:request_options]
  )
end

#update(planet_id, id:, name:, atmosphere: nil, creator: nil, description: nil, discovered_at: nil, failure_callback_url: nil, habitability_index: nil, image: nil, last_updated: nil, physical_properties: nil, satellites: nil, success_callback_url: nil, tags: nil, type: nil, request_options: {}) ⇒ ScalarGalaxy::Models::Planet

Sometimes you make mistakes, that's fine. No worries, you can update all planets.

Parameters:

Returns:

See Also:



121
122
123
124
125
126
127
128
129
130
# File 'lib/galaxy-ruby/resources/planets.rb', line 121

def update(planet_id, params)
  parsed, options = ScalarGalaxy::PlanetUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["planets/%1$s", planet_id],
    body: parsed,
    model: ScalarGalaxy::Planet,
    options: options
  )
end