Class: ScalarGalaxy::Resources::Authentication

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

Overview

Some endpoints are public, but some require authentication. We provide all the required endpoints to create an account and authorize yourself.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Authentication

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 Authentication.

Parameters:



75
76
77
# File 'lib/galaxy-ruby/resources/authentication.rb', line 75

def initialize(client:)
  @client = client
end

Instance Method Details

#create_token(email:, password:, request_options: {}) ⇒ ScalarGalaxy::Models::AuthenticationCreateTokenResponse

Yeah, this is the boring security stuff. Just get your super secret token and move on.

Parameters:

Returns:

See Also:



20
21
22
23
24
25
26
27
28
29
# File 'lib/galaxy-ruby/resources/authentication.rb', line 20

def create_token(params)
  parsed, options = ScalarGalaxy::AuthenticationCreateTokenParams.dump_request(params)
  @client.request(
    method: :post,
    path: "auth/token",
    body: parsed,
    model: ScalarGalaxy::Models::AuthenticationCreateTokenResponse,
    options: options
  )
end

#create_user(email:, password:, name: nil, request_options: {}) ⇒ ScalarGalaxy::Models::User

Time to create a user account, eh?

Parameters:

Returns:

See Also:



43
44
45
46
47
48
49
50
51
52
# File 'lib/galaxy-ruby/resources/authentication.rb', line 43

def create_user(params)
  parsed, options = ScalarGalaxy::AuthenticationCreateUserParams.dump_request(params)
  @client.request(
    method: :post,
    path: "user/signup",
    body: parsed,
    model: ScalarGalaxy::User,
    options: options
  )
end

#list_me(request_options: {}) ⇒ ScalarGalaxy::Models::User

Find yourself they say. That's what you can do here.

Parameters:

Returns:

See Also:



63
64
65
66
67
68
69
70
# File 'lib/galaxy-ruby/resources/authentication.rb', line 63

def list_me(params = {})
  @client.request(
    method: :get,
    path: "me",
    model: ScalarGalaxy::User,
    options: params[:request_options]
  )
end