Class: Vapi::Oauth2AuthenticationSession

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/oauth_2_authentication_session.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token: OMIT, expires_at: OMIT, refresh_token: OMIT, additional_properties: nil) ⇒ Vapi::Oauth2AuthenticationSession

Parameters:

  • access_token (String) (defaults to: OMIT)

    This is the OAuth2 access token.

  • expires_at (DateTime) (defaults to: OMIT)

    This is the OAuth2 access token expiration.

  • refresh_token (String) (defaults to: OMIT)

    This is the OAuth2 refresh token.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vapi_server_sdk/types/oauth_2_authentication_session.rb', line 28

def initialize(access_token: OMIT, expires_at: OMIT, refresh_token: OMIT, additional_properties: nil)
  @access_token = access_token if access_token != OMIT
  @expires_at = expires_at if expires_at != OMIT
  @refresh_token = refresh_token if refresh_token != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "accessToken": access_token,
    "expiresAt": expires_at,
    "refreshToken": refresh_token
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#access_tokenString (readonly)

Returns This is the OAuth2 access token.

Returns:

  • (String)

    This is the OAuth2 access token.



10
11
12
# File 'lib/vapi_server_sdk/types/oauth_2_authentication_session.rb', line 10

def access_token
  @access_token
end

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



16
17
18
# File 'lib/vapi_server_sdk/types/oauth_2_authentication_session.rb', line 16

def additional_properties
  @additional_properties
end

#expires_atDateTime (readonly)

Returns This is the OAuth2 access token expiration.

Returns:

  • (DateTime)

    This is the OAuth2 access token expiration.



12
13
14
# File 'lib/vapi_server_sdk/types/oauth_2_authentication_session.rb', line 12

def expires_at
  @expires_at
end

#refresh_tokenString (readonly)

Returns This is the OAuth2 refresh token.

Returns:

  • (String)

    This is the OAuth2 refresh token.



14
15
16
# File 'lib/vapi_server_sdk/types/oauth_2_authentication_session.rb', line 14

def refresh_token
  @refresh_token
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::Oauth2AuthenticationSession

Deserialize a JSON object to an instance of Oauth2AuthenticationSession

Parameters:

  • json_object (String)

Returns:



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/vapi_server_sdk/types/oauth_2_authentication_session.rb', line 46

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  access_token = parsed_json["accessToken"]
  expires_at = (DateTime.parse(parsed_json["expiresAt"]) unless parsed_json["expiresAt"].nil?)
  refresh_token = parsed_json["refreshToken"]
  new(
    access_token: access_token,
    expires_at: expires_at,
    refresh_token: refresh_token,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


73
74
75
76
77
# File 'lib/vapi_server_sdk/types/oauth_2_authentication_session.rb', line 73

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.expires_at&.is_a?(DateTime) != false || raise("Passed value for field obj.expires_at 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.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Oauth2AuthenticationSession to a JSON object

Returns:

  • (String)


63
64
65
# File 'lib/vapi_server_sdk/types/oauth_2_authentication_session.rb', line 63

def to_json(*_args)
  @_field_set&.to_json
end