Class: Vapi::CreateTokenDto
- Inherits:
-
Object
- Object
- Vapi::CreateTokenDto
- Defined in:
- lib/vapi_server_sdk/types/create_token_dto.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#name ⇒ String
readonly
This is the name of the token.
-
#restrictions ⇒ Vapi::TokenRestrictions
readonly
This are the restrictions for the token.
-
#tag ⇒ Vapi::CreateTokenDtoTag
readonly
This is the tag for the token.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::CreateTokenDto
Deserialize a JSON object to an instance of CreateTokenDto.
-
.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.
Instance Method Summary collapse
- #initialize(tag: OMIT, name: OMIT, restrictions: OMIT, additional_properties: nil) ⇒ Vapi::CreateTokenDto constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CreateTokenDto to a JSON object.
Constructor Details
#initialize(tag: OMIT, name: OMIT, restrictions: OMIT, additional_properties: nil) ⇒ Vapi::CreateTokenDto
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_properties ⇒ OpenStruct (readonly)
Returns 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 |
#name ⇒ String (readonly)
Returns 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 |
#restrictions ⇒ Vapi::TokenRestrictions (readonly)
Returns This are the restrictions for the token.
15 16 17 |
# File 'lib/vapi_server_sdk/types/create_token_dto.rb', line 15 def restrictions @restrictions end |
#tag ⇒ Vapi::CreateTokenDtoTag (readonly)
Returns This is the tag for the token. It represents its scope.
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
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.
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
65 66 67 |
# File 'lib/vapi_server_sdk/types/create_token_dto.rb', line 65 def to_json(*_args) @_field_set&.to_json end |