Class: Vapi::HmacAuthenticationPlan

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secret_key:, algorithm:, signature_header: OMIT, timestamp_header: OMIT, signature_prefix: OMIT, include_timestamp: OMIT, payload_format: OMIT, message_id_header: OMIT, signature_encoding: OMIT, secret_is_base_64: OMIT, additional_properties: nil) ⇒ Vapi::HmacAuthenticationPlan

Parameters:

  • secret_key (String)

    This is the HMAC secret key used to sign requests.

  • algorithm (Vapi::HmacAuthenticationPlanAlgorithm)

    This is the HMAC algorithm to use for signing.

  • signature_header (String) (defaults to: OMIT)

    This is the header name where the signature will be sent. Defaults to ‘x-signature’.

  • timestamp_header (String) (defaults to: OMIT)

    This is the header name where the timestamp will be sent. Defaults to ‘x-timestamp’.

  • signature_prefix (String) (defaults to: OMIT)

    This is the prefix for the signature. For example, ‘sha256=’ for GitHub-style signatures.

  • include_timestamp (Boolean) (defaults to: OMIT)

    Whether to include a timestamp in the signature payload. Defaults to true.

  • payload_format (String) (defaults to: OMIT)

    Custom payload format. Use body for request body, timestamp for timestamp, method for HTTP method, url for URL, svix-id for unique message ID. Defaults to ‘timestamp.body’.

  • message_id_header (String) (defaults to: OMIT)

    This is the header name where the unique message ID will be sent. Used for Svix-style webhooks.

  • signature_encoding (Vapi::HmacAuthenticationPlanSignatureEncoding) (defaults to: OMIT)

    The encoding format for the signature. Defaults to ‘hex’.

  • secret_is_base_64 (Boolean) (defaults to: OMIT)

    Whether the secret key is base64-encoded and should be decoded before use. Defaults to false.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 64

def initialize(secret_key:, algorithm:, signature_header: OMIT, timestamp_header: OMIT, signature_prefix: OMIT,
               include_timestamp: OMIT, payload_format: OMIT, message_id_header: OMIT, signature_encoding: OMIT, secret_is_base_64: OMIT, additional_properties: nil)
  @secret_key = secret_key
  @algorithm = algorithm
  @signature_header = signature_header if signature_header != OMIT
  @timestamp_header = timestamp_header if timestamp_header != OMIT
  @signature_prefix = signature_prefix if signature_prefix != OMIT
  @include_timestamp = include_timestamp if include_timestamp != OMIT
  @payload_format = payload_format if payload_format != OMIT
  @message_id_header = message_id_header if message_id_header != OMIT
  @signature_encoding = signature_encoding if signature_encoding != OMIT
  @secret_is_base_64 = secret_is_base_64 if secret_is_base_64 != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "secretKey": secret_key,
    "algorithm": algorithm,
    "signatureHeader": signature_header,
    "timestampHeader": timestamp_header,
    "signaturePrefix": signature_prefix,
    "includeTimestamp": include_timestamp,
    "payloadFormat": payload_format,
    "messageIdHeader": message_id_header,
    "signatureEncoding": signature_encoding,
    "secretIsBase64": secret_is_base_64
  }.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



38
39
40
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 38

def additional_properties
  @additional_properties
end

#algorithmVapi::HmacAuthenticationPlanAlgorithm (readonly)

Returns This is the HMAC algorithm to use for signing.

Returns:



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

def algorithm
  @algorithm
end

#include_timestampBoolean (readonly)

Returns Whether to include a timestamp in the signature payload. Defaults to true.

Returns:

  • (Boolean)

    Whether to include a timestamp in the signature payload. Defaults to true.



24
25
26
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 24

def include_timestamp
  @include_timestamp
end

#message_id_headerString (readonly)

Returns This is the header name where the unique message ID will be sent. Used for Svix-style webhooks.

Returns:

  • (String)

    This is the header name where the unique message ID will be sent. Used for Svix-style webhooks.



31
32
33
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 31

def message_id_header
  @message_id_header
end

#payload_formatString (readonly)

Returns Custom payload format. Use body for request body, timestamp for timestamp, method for HTTP method, url for URL, svix-id for unique message ID. Defaults to ‘timestamp.body’.

Returns:

  • (String)

    Custom payload format. Use body for request body, timestamp for timestamp, method for HTTP method, url for URL, svix-id for unique message ID. Defaults to ‘timestamp.body’.



28
29
30
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 28

def payload_format
  @payload_format
end

#secret_is_base_64Boolean (readonly)

Returns Whether the secret key is base64-encoded and should be decoded before use. Defaults to false.

Returns:

  • (Boolean)

    Whether the secret key is base64-encoded and should be decoded before use. Defaults to false.



36
37
38
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 36

def secret_is_base_64
  @secret_is_base_64
end

#secret_keyString (readonly)

Returns This is the HMAC secret key used to sign requests.

Returns:

  • (String)

    This is the HMAC secret key used to sign requests.



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

def secret_key
  @secret_key
end

#signature_encodingVapi::HmacAuthenticationPlanSignatureEncoding (readonly)

Returns The encoding format for the signature. Defaults to ‘hex’.

Returns:



33
34
35
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 33

def signature_encoding
  @signature_encoding
end

#signature_headerString (readonly)

Returns This is the header name where the signature will be sent. Defaults to ‘x-signature’.

Returns:

  • (String)

    This is the header name where the signature will be sent. Defaults to ‘x-signature’.



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

def signature_header
  @signature_header
end

#signature_prefixString (readonly)

Returns This is the prefix for the signature. For example, ‘sha256=’ for GitHub-style signatures.

Returns:

  • (String)

    This is the prefix for the signature. For example, ‘sha256=’ for GitHub-style signatures.



22
23
24
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 22

def signature_prefix
  @signature_prefix
end

#timestamp_headerString (readonly)

Returns This is the header name where the timestamp will be sent. Defaults to ‘x-timestamp’.

Returns:

  • (String)

    This is the header name where the timestamp will be sent. Defaults to ‘x-timestamp’.



19
20
21
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 19

def timestamp_header
  @timestamp_header
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::HmacAuthenticationPlan

Deserialize a JSON object to an instance of HmacAuthenticationPlan

Parameters:

  • json_object (String)

Returns:



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 97

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  secret_key = parsed_json["secretKey"]
  algorithm = parsed_json["algorithm"]
  signature_header = parsed_json["signatureHeader"]
  timestamp_header = parsed_json["timestampHeader"]
  signature_prefix = parsed_json["signaturePrefix"]
  include_timestamp = parsed_json["includeTimestamp"]
  payload_format = parsed_json["payloadFormat"]
  message_id_header = parsed_json["messageIdHeader"]
  signature_encoding = parsed_json["signatureEncoding"]
  secret_is_base_64 = parsed_json["secretIsBase64"]
  new(
    secret_key: secret_key,
    algorithm: algorithm,
    signature_header: signature_header,
    timestamp_header: timestamp_header,
    signature_prefix: signature_prefix,
    include_timestamp: include_timestamp,
    payload_format: payload_format,
    message_id_header: message_id_header,
    signature_encoding: signature_encoding,
    secret_is_base_64: secret_is_base_64,
    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)


138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 138

def self.validate_raw(obj:)
  obj.secret_key.is_a?(String) != false || raise("Passed value for field obj.secret_key is not the expected type, validation failed.")
  obj.algorithm.is_a?(Vapi::HmacAuthenticationPlanAlgorithm) != false || raise("Passed value for field obj.algorithm is not the expected type, validation failed.")
  obj.signature_header&.is_a?(String) != false || raise("Passed value for field obj.signature_header is not the expected type, validation failed.")
  obj.timestamp_header&.is_a?(String) != false || raise("Passed value for field obj.timestamp_header is not the expected type, validation failed.")
  obj.signature_prefix&.is_a?(String) != false || raise("Passed value for field obj.signature_prefix is not the expected type, validation failed.")
  obj.include_timestamp&.is_a?(Boolean) != false || raise("Passed value for field obj.include_timestamp is not the expected type, validation failed.")
  obj.payload_format&.is_a?(String) != false || raise("Passed value for field obj.payload_format is not the expected type, validation failed.")
  obj.message_id_header&.is_a?(String) != false || raise("Passed value for field obj.message_id_header is not the expected type, validation failed.")
  obj.signature_encoding&.is_a?(Vapi::HmacAuthenticationPlanSignatureEncoding) != false || raise("Passed value for field obj.signature_encoding is not the expected type, validation failed.")
  obj.secret_is_base_64&.is_a?(Boolean) != false || raise("Passed value for field obj.secret_is_base_64 is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of HmacAuthenticationPlan to a JSON object

Returns:

  • (String)


128
129
130
# File 'lib/vapi_server_sdk/types/hmac_authentication_plan.rb', line 128

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