Class: Samsara::Auth::Tokens::Types::CreateTokensResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/auth/tokens/types/create_tokens_response.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token:, token_type:, expires_in:, refresh_token:, scope:, additional_properties: nil) ⇒ Samsara::Auth::Tokens::Types::CreateTokensResponse

Parameters:

  • access_token (String)
  • token_type (String)
  • expires_in (Integer)
  • refresh_token (String)
  • scope (String)
  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



35
36
37
38
39
40
41
42
43
# File 'lib/samsara_api/auth/tokens/types/create_tokens_response.rb', line 35

def initialize(access_token:, token_type:, expires_in:, refresh_token:, scope:, additional_properties: nil)
  @access_token = access_token
  @token_type = token_type
  @expires_in = expires_in
  @refresh_token = refresh_token
  @scope = scope
  @additional_properties = additional_properties
  @_field_set = { "access_token": access_token, "token_type": token_type, "expires_in": expires_in, "refresh_token": refresh_token, "scope": scope }
end

Instance Attribute Details

#access_token ⇒ String (readonly)

Returns:

  • (String)


11
12
13
# File 'lib/samsara_api/auth/tokens/types/create_tokens_response.rb', line 11

def access_token
  @access_token
end

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



21
22
23
# File 'lib/samsara_api/auth/tokens/types/create_tokens_response.rb', line 21

def additional_properties
  @additional_properties
end

#expires_in ⇒ Integer (readonly)

Returns:

  • (Integer)


15
16
17
# File 'lib/samsara_api/auth/tokens/types/create_tokens_response.rb', line 15

def expires_in
  @expires_in
end

#refresh_token ⇒ String (readonly)

Returns:

  • (String)


17
18
19
# File 'lib/samsara_api/auth/tokens/types/create_tokens_response.rb', line 17

def refresh_token
  @refresh_token
end

#scope ⇒ String (readonly)

Returns:

  • (String)


19
20
21
# File 'lib/samsara_api/auth/tokens/types/create_tokens_response.rb', line 19

def scope
  @scope
end

#token_type ⇒ String (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/samsara_api/auth/tokens/types/create_tokens_response.rb', line 13

def token_type
  @token_type
end

Class Method Details

.from_json(json_object:) ⇒ Samsara::Auth::Tokens::Types::CreateTokensResponse

Parameters:

  • json_object (String)

Returns:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/samsara_api/auth/tokens/types/create_tokens_response.rb', line 48

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  access_token = parsed_json["access_token"]
  token_type = parsed_json["token_type"]
  expires_in = parsed_json["expires_in"]
  refresh_token = parsed_json["refresh_token"]
  scope = parsed_json["scope"]
  new(
    access_token: access_token,
    token_type: token_type,
    expires_in: expires_in,
    refresh_token: refresh_token,
    scope: scope,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


77
78
79
80
81
82
83
# File 'lib/samsara_api/auth/tokens/types/create_tokens_response.rb', line 77

def self.validate_raw(obj:)
  obj.access_token.is_a?(String) != false || raise("Passed value for field obj.access_token is not the expected type, validation failed.")
  obj.token_type.is_a?(String) != false || raise("Passed value for field obj.token_type is not the expected type, validation failed.")
  obj.expires_in.is_a?(Integer) != false || raise("Passed value for field obj.expires_in is not the expected type, validation failed.")
  obj.refresh_token.is_a?(String) != false || raise("Passed value for field obj.refresh_token is not the expected type, validation failed.")
  obj.scope.is_a?(String) != false || raise("Passed value for field obj.scope is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


68
69
70
# File 'lib/samsara_api/auth/tokens/types/create_tokens_response.rb', line 68

def to_json
  @_field_set&.to_json
end