Class: Vapi::Token
- Inherits:
-
Object
- Object
- Vapi::Token
- Defined in:
- lib/vapi_server_sdk/types/token.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#created_at ⇒ DateTime
readonly
This is the ISO 8601 date-time string of when the token was created.
-
#id ⇒ String
readonly
This is the unique identifier for the token.
-
#name ⇒ String
readonly
This is the name of the token.
-
#org_id ⇒ String
readonly
This is unique identifier for the org that this token belongs to.
-
#restrictions ⇒ Vapi::TokenRestrictions
readonly
This are the restrictions for the token.
-
#tag ⇒ Vapi::TokenTag
readonly
This is the tag for the token.
-
#updated_at ⇒ DateTime
readonly
This is the ISO 8601 date-time string of when the token was last updated.
-
#value ⇒ String
readonly
This is the token key.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::Token
Deserialize a JSON object to an instance of Token.
-
.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(id:, org_id:, created_at:, updated_at:, value:, tag: OMIT, name: OMIT, restrictions: OMIT, additional_properties: nil) ⇒ Vapi::Token constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Token to a JSON object.
Constructor Details
#initialize(id:, org_id:, created_at:, updated_at:, value:, tag: OMIT, name: OMIT, restrictions: OMIT, additional_properties: nil) ⇒ Vapi::Token
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/vapi_server_sdk/types/token.rb', line 45 def initialize(id:, org_id:, created_at:, updated_at:, value:, tag: OMIT, name: OMIT, restrictions: OMIT, additional_properties: nil) @tag = tag if tag != OMIT @id = id @org_id = org_id @created_at = created_at @updated_at = updated_at @value = value @name = name if name != OMIT @restrictions = restrictions if restrictions != OMIT @additional_properties = additional_properties @_field_set = { "tag": tag, "id": id, "orgId": org_id, "createdAt": created_at, "updatedAt": updated_at, "value": value, "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.
28 29 30 |
# File 'lib/vapi_server_sdk/types/token.rb', line 28 def additional_properties @additional_properties end |
#created_at ⇒ DateTime (readonly)
Returns This is the ISO 8601 date-time string of when the token was created.
18 19 20 |
# File 'lib/vapi_server_sdk/types/token.rb', line 18 def created_at @created_at end |
#id ⇒ String (readonly)
Returns This is the unique identifier for the token.
14 15 16 |
# File 'lib/vapi_server_sdk/types/token.rb', line 14 def id @id end |
#name ⇒ String (readonly)
Returns This is the name of the token. This is just for your own reference.
24 25 26 |
# File 'lib/vapi_server_sdk/types/token.rb', line 24 def name @name end |
#org_id ⇒ String (readonly)
Returns This is unique identifier for the org that this token belongs to.
16 17 18 |
# File 'lib/vapi_server_sdk/types/token.rb', line 16 def org_id @org_id end |
#restrictions ⇒ Vapi::TokenRestrictions (readonly)
Returns This are the restrictions for the token.
26 27 28 |
# File 'lib/vapi_server_sdk/types/token.rb', line 26 def restrictions @restrictions end |
#tag ⇒ Vapi::TokenTag (readonly)
Returns This is the tag for the token. It represents its scope.
12 13 14 |
# File 'lib/vapi_server_sdk/types/token.rb', line 12 def tag @tag end |
#updated_at ⇒ DateTime (readonly)
Returns This is the ISO 8601 date-time string of when the token was last updated.
20 21 22 |
# File 'lib/vapi_server_sdk/types/token.rb', line 20 def updated_at @updated_at end |
#value ⇒ String (readonly)
Returns This is the token key.
22 23 24 |
# File 'lib/vapi_server_sdk/types/token.rb', line 22 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::Token
Deserialize a JSON object to an instance of Token
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/vapi_server_sdk/types/token.rb', line 74 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) tag = parsed_json["tag"] id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) updated_at = (DateTime.parse(parsed_json["updatedAt"]) unless parsed_json["updatedAt"].nil?) value = parsed_json["value"] 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, id: id, org_id: org_id, created_at: created_at, updated_at: updated_at, value: value, 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.
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/vapi_server_sdk/types/token.rb', line 116 def self.validate_raw(obj:) obj.tag&.is_a?(Vapi::TokenTag) != false || raise("Passed value for field obj.tag is not the expected type, validation failed.") obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.org_id.is_a?(String) != false || raise("Passed value for field obj.org_id is not the expected type, validation failed.") obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") obj.value.is_a?(String) != false || raise("Passed value for field obj.value 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 Token to a JSON object
106 107 108 |
# File 'lib/vapi_server_sdk/types/token.rb', line 106 def to_json(*_args) @_field_set&.to_json end |