Class: SwaggerPetstoreOpenApi30::PetstoreAuthCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb

Overview

Data class for PetstoreAuthCredentials.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(o_auth_client_id:, o_auth_redirect_uri:, o_auth_token: nil, o_auth_scopes: nil) ⇒ PetstoreAuthCredentials

Returns a new instance of PetstoreAuthCredentials.

Raises:

  • (ArgumentError)


74
75
76
77
78
79
80
81
82
83
# File 'lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb', line 74

def initialize(o_auth_client_id:, o_auth_redirect_uri:, o_auth_token: nil,
               o_auth_scopes: nil)
  raise ArgumentError, 'o_auth_client_id cannot be nil' if o_auth_client_id.nil?
  raise ArgumentError, 'o_auth_redirect_uri cannot be nil' if o_auth_redirect_uri.nil?

  @o_auth_client_id = o_auth_client_id
  @o_auth_redirect_uri = o_auth_redirect_uri
  @o_auth_token = o_auth_token
  @o_auth_scopes = o_auth_scopes
end

Instance Attribute Details

#o_auth_client_idObject (readonly)

Returns the value of attribute o_auth_client_id.



71
72
73
# File 'lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb', line 71

def o_auth_client_id
  @o_auth_client_id
end

#o_auth_redirect_uriObject (readonly)

Returns the value of attribute o_auth_redirect_uri.



71
72
73
# File 'lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb', line 71

def o_auth_redirect_uri
  @o_auth_redirect_uri
end

#o_auth_scopesObject (readonly)

Returns the value of attribute o_auth_scopes.



71
72
73
# File 'lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb', line 71

def o_auth_scopes
  @o_auth_scopes
end

#o_auth_tokenObject (readonly)

Returns the value of attribute o_auth_token.



71
72
73
# File 'lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb', line 71

def o_auth_token
  @o_auth_token
end

Class Method Details

.from_envObject



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb', line 85

def self.from_env
  o_auth_client_id = ENV['PETSTORE_AUTH_O_AUTH_CLIENT_ID']
  o_auth_redirect_uri = ENV['PETSTORE_AUTH_O_AUTH_REDIRECT_URI']
  o_auth_scopes = ENV['PETSTORE_AUTH_O_AUTH_SCOPES']
  all_nil = [
    o_auth_client_id,
    o_auth_redirect_uri
  ].all?(&:nil?)
  return nil if all_nil

  new(o_auth_client_id: o_auth_client_id,
      o_auth_redirect_uri: o_auth_redirect_uri,
      o_auth_scopes: o_auth_scopes)
end

Instance Method Details

#clone_with(o_auth_client_id: nil, o_auth_redirect_uri: nil, o_auth_token: nil, o_auth_scopes: nil) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb', line 100

def clone_with(o_auth_client_id: nil, o_auth_redirect_uri: nil,
               o_auth_token: nil, o_auth_scopes: nil)
  o_auth_client_id ||= self.o_auth_client_id
  o_auth_redirect_uri ||= self.o_auth_redirect_uri
  o_auth_token ||= self.o_auth_token
  o_auth_scopes ||= self.o_auth_scopes

  PetstoreAuthCredentials.new(o_auth_client_id: o_auth_client_id,
                              o_auth_redirect_uri: o_auth_redirect_uri,
                              o_auth_token: o_auth_token,
                              o_auth_scopes: o_auth_scopes)
end