Class: Vapi::CreateTokenDto

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag: OMIT, name: OMIT, restrictions: OMIT, additional_properties: nil) ⇒ Vapi::CreateTokenDto

Parameters:

  • tag (Vapi::CreateTokenDtoTag) (defaults to: OMIT)

    This is the tag for the token. It represents its scope.

  • name (String) (defaults to: OMIT)

    This is the name of the token. This is just for your own reference.

  • restrictions (Vapi::TokenRestrictions) (defaults to: OMIT)

    This are the restrictions for the token.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



29
30
31
32
33
34
35
36
37
# File 'lib/vapi_server_sdk/types/create_token_dto.rb', line 29

def initialize(tag: OMIT, name: OMIT, restrictions: OMIT, additional_properties: nil)
  @tag = tag if tag != OMIT
  @name = name if name != OMIT
  @restrictions = restrictions if restrictions != OMIT
  @additional_properties = additional_properties
  @_field_set = { "tag": tag, "name": name, "restrictions": restrictions }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



17
18
19
# File 'lib/vapi_server_sdk/types/create_token_dto.rb', line 17

def additional_properties
  @additional_properties
end

#nameString (readonly)

Returns This is the name of the token. This is just for your own reference.

Returns:

  • (String)

    This is the name of the token. This is just for your own reference.



13
14
15
# File 'lib/vapi_server_sdk/types/create_token_dto.rb', line 13

def name
  @name
end

#restrictionsVapi::TokenRestrictions (readonly)

Returns This are the restrictions for the token.

Returns:



15
16
17
# File 'lib/vapi_server_sdk/types/create_token_dto.rb', line 15

def restrictions
  @restrictions
end

#tagVapi::CreateTokenDtoTag (readonly)

Returns This is the tag for the token. It represents its scope.

Returns:



11
12
13
# File 'lib/vapi_server_sdk/types/create_token_dto.rb', line 11

def tag
  @tag
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::CreateTokenDto

Deserialize a JSON object to an instance of CreateTokenDto

Parameters:

  • json_object (String)

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/vapi_server_sdk/types/create_token_dto.rb', line 43

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  tag = parsed_json["tag"]
  name = parsed_json["name"]
  if parsed_json["restrictions"].nil?
    restrictions = nil
  else
    restrictions = parsed_json["restrictions"].to_json
    restrictions = Vapi::TokenRestrictions.from_json(json_object: restrictions)
  end
  new(
    tag: tag,
    name: name,
    restrictions: restrictions,
    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)


75
76
77
78
79
# File 'lib/vapi_server_sdk/types/create_token_dto.rb', line 75

def self.validate_raw(obj:)
  obj.tag&.is_a?(Vapi::CreateTokenDtoTag) != false || raise("Passed value for field obj.tag is not the expected type, validation failed.")
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.restrictions.nil? || Vapi::TokenRestrictions.validate_raw(obj: obj.restrictions)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CreateTokenDto to a JSON object

Returns:

  • (String)


65
66
67
# File 'lib/vapi_server_sdk/types/create_token_dto.rb', line 65

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