Class: CDEKApiClient::Entities::AuthResponse

Inherits:
Object
  • Object
show all
Includes:
Validatable
Defined in:
lib/cdek_api_client/entities/auth_response.rb

Overview

Represents an OAuth authentication response from the CDEK API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validatable

included, #validate!

Constructor Details

#initialize(access_token:, token_type:, expires_in:, scope:, jti:) ⇒ AuthResponse

Initializes a new AuthResponse object.

Raises:

  • (ArgumentError)

    if any attribute validation fails.



27
28
29
30
31
32
33
34
# File 'lib/cdek_api_client/entities/auth_response.rb', line 27

def initialize(access_token:, token_type:, expires_in:, scope:, jti:)
  @access_token = access_token
  @token_type = token_type
  @expires_in = expires_in
  @scope = scope
  @jti = jti
  validate!
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



11
12
13
# File 'lib/cdek_api_client/entities/auth_response.rb', line 11

def access_token
  @access_token
end

#expires_inObject

Returns the value of attribute expires_in.



11
12
13
# File 'lib/cdek_api_client/entities/auth_response.rb', line 11

def expires_in
  @expires_in
end

#jtiObject

Returns the value of attribute jti.



11
12
13
# File 'lib/cdek_api_client/entities/auth_response.rb', line 11

def jti
  @jti
end

#scopeObject

Returns the value of attribute scope.



11
12
13
# File 'lib/cdek_api_client/entities/auth_response.rb', line 11

def scope
  @scope
end

#token_typeObject

Returns the value of attribute token_type.



11
12
13
# File 'lib/cdek_api_client/entities/auth_response.rb', line 11

def token_type
  @token_type
end

Instance Method Details

#to_json(*_args) ⇒ String

Converts the AuthResponse object to a JSON representation.



39
40
41
42
43
44
45
46
47
# File 'lib/cdek_api_client/entities/auth_response.rb', line 39

def to_json(*_args)
  {
    access_token: @access_token,
    token_type: @token_type,
    expires_in: @expires_in,
    scope: @scope,
    jti: @jti
  }.to_json
end