repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/communication_preferences/api/status_api.rb | lib/hubspot/codegen/communication_preferences/api/status_api.rb | =begin
#Communication Preferences Subscriptions
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module Hubspot
module CommunicationPreferences
class StatusApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Get subscription statuses for a contact
# Returns a list of subscriptions and their status for a given contact.
# @param email_address [String]
# @param [Hash] opts the optional parameters
# @return [PublicSubscriptionStatusesResponse]
def get_email_status(email_address, opts = {})
data, _status_code, _headers = get_email_status_with_http_info(email_address, opts)
data
end
# Get subscription statuses for a contact
# Returns a list of subscriptions and their status for a given contact.
# @param email_address [String]
# @param [Hash] opts the optional parameters
# @return [Array<(PublicSubscriptionStatusesResponse, Integer, Hash)>] PublicSubscriptionStatusesResponse data, response status code and response headers
def get_email_status_with_http_info(email_address, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: StatusApi.get_email_status ...'
end
# verify the required parameter 'email_address' is set
if @api_client.config.client_side_validation && email_address.nil?
fail ArgumentError, "Missing the required parameter 'email_address' when calling StatusApi.get_email_status"
end
# resource path
local_var_path = '/communication-preferences/v3/status/email/{emailAddress}'.sub('{' + 'emailAddress' + '}', CGI.escape(email_address.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'PublicSubscriptionStatusesResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"StatusApi.get_email_status",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StatusApi#get_email_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Subscribe a contact
# Subscribes a contact to the given subscription type. This API is not valid to use for subscribing a contact at a brand or portal level and will return an error.
# @param public_update_subscription_status_request [PublicUpdateSubscriptionStatusRequest]
# @param [Hash] opts the optional parameters
# @return [PublicSubscriptionStatus]
def subscribe(public_update_subscription_status_request, opts = {})
data, _status_code, _headers = subscribe_with_http_info(public_update_subscription_status_request, opts)
data
end
# Subscribe a contact
# Subscribes a contact to the given subscription type. This API is not valid to use for subscribing a contact at a brand or portal level and will return an error.
# @param public_update_subscription_status_request [PublicUpdateSubscriptionStatusRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(PublicSubscriptionStatus, Integer, Hash)>] PublicSubscriptionStatus data, response status code and response headers
def subscribe_with_http_info(public_update_subscription_status_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: StatusApi.subscribe ...'
end
# verify the required parameter 'public_update_subscription_status_request' is set
if @api_client.config.client_side_validation && public_update_subscription_status_request.nil?
fail ArgumentError, "Missing the required parameter 'public_update_subscription_status_request' when calling StatusApi.subscribe"
end
# resource path
local_var_path = '/communication-preferences/v3/subscribe'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(public_update_subscription_status_request)
# return_type
return_type = opts[:debug_return_type] || 'PublicSubscriptionStatus'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"StatusApi.subscribe",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StatusApi#subscribe\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Unsubscribe a contact
# Unsubscribes a contact from the given subscription type. This API is not valid to use for unsubscribing a contact at a brand or portal level and will return an error.
# @param public_update_subscription_status_request [PublicUpdateSubscriptionStatusRequest]
# @param [Hash] opts the optional parameters
# @return [PublicSubscriptionStatus]
def unsubscribe(public_update_subscription_status_request, opts = {})
data, _status_code, _headers = unsubscribe_with_http_info(public_update_subscription_status_request, opts)
data
end
# Unsubscribe a contact
# Unsubscribes a contact from the given subscription type. This API is not valid to use for unsubscribing a contact at a brand or portal level and will return an error.
# @param public_update_subscription_status_request [PublicUpdateSubscriptionStatusRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(PublicSubscriptionStatus, Integer, Hash)>] PublicSubscriptionStatus data, response status code and response headers
def unsubscribe_with_http_info(public_update_subscription_status_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: StatusApi.unsubscribe ...'
end
# verify the required parameter 'public_update_subscription_status_request' is set
if @api_client.config.client_side_validation && public_update_subscription_status_request.nil?
fail ArgumentError, "Missing the required parameter 'public_update_subscription_status_request' when calling StatusApi.unsubscribe"
end
# resource path
local_var_path = '/communication-preferences/v3/unsubscribe'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(public_update_subscription_status_request)
# return_type
return_type = opts[:debug_return_type] || 'PublicSubscriptionStatus'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"StatusApi.unsubscribe",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StatusApi#unsubscribe\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/api_error.rb | lib/hubspot/codegen/marketing/emails/api_error.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Marketing
module Emails
class ApiError < ::StandardError
attr_reader :code, :response_headers, :response_body
# Usage examples:
# ApiError.new
# ApiError.new("message")
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
# ApiError.new(:code => 404, :message => "Not Found")
def initialize(arg = nil)
if arg.is_a? Hash
if arg.key?(:message) || arg.key?('message')
super(arg[:message] || arg['message'])
else
super arg
end
arg.each do |k, v|
instance_variable_set "@#{k}", v
end
else
super arg
end
end
# Override to_s to display a friendly error message
def to_s
message
end
def message
if @message.nil?
msg = "Error message: the server returns an error"
else
msg = @message
end
msg += "\nHTTP status code: #{code}" if code
msg += "\nResponse headers: #{response_headers}" if response_headers
msg += "\nResponse body: #{response_body}" if response_body
msg
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/configuration.rb | lib/hubspot/codegen/marketing/emails/configuration.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Marketing
module Emails
class Configuration
# Defines url scheme
attr_accessor :scheme
# Defines url host
attr_accessor :host
# Defines url base path
attr_accessor :base_path
# Define server configuration index
attr_accessor :server_index
# Define server operation configuration index
attr_accessor :server_operation_index
# Default server variables
attr_accessor :server_variables
# Default server operation variables
attr_accessor :server_operation_variables
# Defines API keys used with API Key authentications.
#
# @return [Hash] key: parameter name, value: parameter value (API key)
#
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
# config.api_key['api_key'] = 'xxx'
attr_accessor :api_key
# Defines API key prefixes used with API Key authentications.
#
# @return [Hash] key: parameter name, value: API key prefix
#
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
# config.api_key_prefix['api_key'] = 'Token'
attr_accessor :api_key_prefix
# Defines the username used with HTTP basic authentication.
#
# @return [String]
attr_accessor :username
# Defines the password used with HTTP basic authentication.
#
# @return [String]
attr_accessor :password
# Defines the access token (Bearer) used with OAuth2.
attr_accessor :access_token
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
# details will be logged with `logger.debug` (see the `logger` attribute).
# Default to false.
#
# @return [true, false]
attr_accessor :debugging
# Defines the logger used for debugging.
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
#
# @return [#debug]
attr_accessor :logger
# Defines the temporary folder to store downloaded files
# (for API endpoints that have file response).
# Default to use `Tempfile`.
#
# @return [String]
attr_accessor :temp_folder_path
# The time limit for HTTP request in seconds.
# Default to 0 (never times out).
attr_accessor :timeout
# Set this to false to skip client side validation in the operation.
# Default to true.
# @return [true, false]
attr_accessor :client_side_validation
### TLS/SSL setting
# Set this to false to skip verifying SSL certificate when calling API from https server.
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl
### TLS/SSL setting
# Set this to false to skip verifying SSL host name
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl_host
### TLS/SSL setting
# Set this to customize the certificate file to verify the peer.
#
# @return [String] the path to the certificate file
#
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
attr_accessor :ssl_ca_cert
### TLS/SSL setting
# Client certificate file (for client certificate)
attr_accessor :cert_file
### TLS/SSL setting
# Client private key file (for client certificate)
attr_accessor :key_file
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
# Default to nil.
#
# @see The params_encoding option of Ethon. Related source code:
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
attr_accessor :params_encoding
attr_accessor :inject_format
attr_accessor :force_ending_format
attr_accessor :error_handler
def initialize
@scheme = 'https'
@host = 'api.hubapi.com'
@base_path = ''
@server_index = 0
@server_operation_index = {}
@server_variables = {}
@server_operation_variables = {}
@api_key = {}
@api_key_prefix = {}
@client_side_validation = true
@verify_ssl = true
@verify_ssl_host = true
@cert_file = nil
@key_file = nil
@timeout = 0
@params_encoding = nil
@debugging = false
@inject_format = false
@force_ending_format = false
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
# error_handler params: { 'status_code': { max_retries: ..., seconds_delay: ... }, ... }
@error_handler = {}
yield(self) if block_given?
end
# The default Configuration object.
def self.default
@@default ||= Configuration.new
end
def configure
yield(self) if block_given?
end
def scheme=(scheme)
# remove :// from scheme
@scheme = scheme.sub(/:\/\//, '')
end
def host=(host)
# remove http(s):// and anything after a slash
@host = host.sub(/https?:\/\//, '').split('/').first
end
def base_path=(base_path)
# Add leading and trailing slashes to base_path
@base_path = "/#{base_path}".gsub(/\/+/, '/')
@base_path = '' if @base_path == '/'
end
# Returns base URL for specified operation based on server settings
def base_url(operation = nil)
index = server_operation_index.fetch(operation, server_index)
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
end
# Gets API key (with prefix if set).
# @param [String] param_name the parameter name of API key auth
def api_key_with_prefix(param_name, param_alias = nil)
key = @api_key[param_name]
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
if @api_key_prefix[param_name]
"#{@api_key_prefix[param_name]} #{key}"
else
key
end
end
# Gets Basic Auth token string
def basic_auth_token
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
end
# Returns Auth Settings hash for api client.
def auth_settings
{
'oauth2' =>
{
type: 'oauth2',
in: 'header',
key: 'Authorization',
value: "Bearer #{access_token}"
},
}
end
# Returns an array of Server setting
def server_settings
[
{
url: "https://api.hubapi.com",
description: "No description provided",
}
]
end
def operation_server_settings
{
}
end
# Returns URL based on server settings
#
# @param index array index of the server settings
# @param variables hash of variable and the corresponding value
def server_url(index, variables = {}, servers = nil)
servers = server_settings if servers == nil
# check array index out of bound
if (index < 0 || index >= servers.size)
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
end
server = servers[index]
url = server[:url]
return url unless server.key? :variables
# go through variable and assign a value
server[:variables].each do |name, variable|
if variables.key?(name)
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
url.gsub! "{" + name.to_s + "}", variables[name]
else
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
end
else
# use default value
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
end
end
url
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/api_client.rb | lib/hubspot/codegen/marketing/emails/api_client.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'json'
require 'logger'
require 'tempfile'
require 'time'
require 'typhoeus'
module Hubspot
module Marketing
module Emails
class ApiClient
# The Configuration object holding settings to be used in the API client.
attr_accessor :config
# Defines the headers to be used in HTTP requests of all API calls by default.
#
# @return [Hash]
attr_accessor :default_headers
# Initializes the ApiClient
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
def initialize(config = Configuration.default)
@config = config
@user_agent = "hubspot-api-client-ruby; #{VERSION}"
@default_headers = {
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
}
end
def self.default
@@default ||= ApiClient.new
end
# Call an API with given options.
#
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
# the data deserialized from response body (could be nil), response status code and response headers.
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
if !response.success? && config.error_handler.any?
config.error_handler.each do |statuses, opts|
statuses = statuses.is_a?(Integer) ? [statuses] : statuses
retries = opts[:max_retries] || 5
while retries > 0 && statuses.include?(response.code)
sleep opts[:seconds_delay] if opts[:seconds_delay]
response = request.run
opts[:retry_block].call if opts[:retry_block]
retries -= 1
end
end
end
unless response.success?
if response.timed_out?
fail ApiError.new('Connection timed out')
elsif response.code == 0
# Errors from libcurl will be made visible here
fail ApiError.new(:code => 0,
:message => response.return_message)
else
fail ApiError.new(:code => response.code,
:response_headers => response.headers,
:response_body => response.body),
response.status_message
end
end
if opts[:return_type]
data = deserialize(response, opts[:return_type])
else
data = nil
end
return data, response.code, response.headers
end
# Builds the HTTP request
#
# @param [String] http_method HTTP method/verb (e.g. POST)
# @param [String] path URL path (e.g. /account/new)
# @option opts [Hash] :header_params Header parameters
# @option opts [Hash] :query_params Query parameters
# @option opts [Hash] :form_params Query parameters
# @option opts [Object] :body HTTP body (JSON/XML)
# @return [Typhoeus::Request] A Typhoeus Request
def build_request(http_method, path, opts = {})
url = build_request_url(path, opts)
http_method = http_method.to_sym.downcase
header_params = @default_headers.merge(opts[:header_params] || {})
query_params = opts[:query_params] || {}
form_params = opts[:form_params] || {}
follow_location = opts[:follow_location] || true
update_params_for_auth! header_params, query_params, opts[:auth_names]
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
req_opts = {
:method => http_method,
:headers => header_params,
:params => query_params,
:params_encoding => @config.params_encoding,
:timeout => @config.timeout,
:ssl_verifypeer => @config.verify_ssl,
:ssl_verifyhost => _verify_ssl_host,
:sslcert => @config.cert_file,
:sslkey => @config.key_file,
:verbose => @config.debugging,
:followlocation => follow_location
}
# set custom cert, if provided
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
if [:post, :patch, :put, :delete].include?(http_method)
req_body = build_request_body(header_params, form_params, opts[:body])
req_opts.update :body => req_body
if @config.debugging
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
end
end
request = Typhoeus::Request.new(url, req_opts)
download_file(request) if opts[:return_type] == 'File'
request
end
# Builds the HTTP request body
#
# @param [Hash] header_params Header parameters
# @param [Hash] form_params Query parameters
# @param [Object] body HTTP body (JSON/XML)
# @return [String] HTTP body data in the form of string
def build_request_body(header_params, form_params, body)
# http form
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
header_params['Content-Type'] == 'multipart/form-data'
data = {}
form_params.each do |key, value|
case value
when ::File, ::Array, nil
# let typhoeus handle File, Array and nil parameters
data[key] = value
else
data[key] = value.to_s
end
end
elsif body
data = body.is_a?(String) ? body : body.to_json
else
data = nil
end
data
end
# Save response body into a file in (the defined) temporary folder, using the filename
# from the "Content-Disposition" header if provided, otherwise a random filename.
# The response body is written to the file in chunks in order to handle files which
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
# process can use.
#
# @see Configuration#temp_folder_path
def download_file(request)
tempfile = nil
encoding = nil
request.on_headers do |response|
content_disposition = response.headers['Content-Disposition']
if content_disposition && content_disposition =~ /filename=/i
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
prefix = sanitize_filename(filename)
else
prefix = 'download-'
end
prefix = prefix + '-' unless prefix.end_with?('-')
encoding = response.body.encoding
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
@tempfile = tempfile
end
request.on_body do |chunk|
chunk.force_encoding(encoding)
tempfile.write(chunk)
end
request.on_complete do |response|
if tempfile
tempfile.close
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
"explicitly with `tempfile.delete`"
end
end
end
# Check if the given MIME is a JSON MIME.
# JSON MIME examples:
# application/json
# application/json; charset=UTF8
# APPLICATION/JSON
# */*
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end
# Deserialize the response to the given return type.
#
# @param [Response] response HTTP response
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
def deserialize(response, return_type)
body = response.body
# handle file downloading - return the File instance processed in request callbacks
# note that response body is empty when the file is written in chunks in request on_body callback
return @tempfile if return_type == 'File'
return nil if body.nil? || body.empty?
# return response body directly for String return type
return body if return_type == 'String'
# ensuring a default content type
content_type = response.headers['Content-Type'] || 'application/json'
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
begin
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
rescue JSON::ParserError => e
if %w(String Date Time).include?(return_type)
data = body
else
raise e
end
end
convert_to_type data, return_type
end
# Convert data to the given return type.
# @param [Object] data Data to be converted
# @param [String] return_type Return type
# @return [Mixed] Data in a particular type
def convert_to_type(data, return_type)
return nil if data.nil?
case return_type
when 'String'
data.to_s
when 'Integer'
data.to_i
when 'Float'
data.to_f
when 'Boolean'
data == true
when 'Time'
# parse date time (expecting ISO 8601 format)
Time.parse data
when 'Date'
# parse date time (expecting ISO 8601 format)
Date.parse data
when 'Object'
# generic object (usually a Hash), return directly
data
when /\AArray<(.+)>\z/
# e.g. Array<Pet>
sub_type = $1
data.map { |item| convert_to_type(item, sub_type) }
when /\AHash\<String, (.+)\>\z/
# e.g. Hash<String, Integer>
sub_type = $1
{}.tap do |hash|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
end
else
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(return_type)
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
end
end
# Sanitize filename by removing path.
# e.g. ../../sun.gif becomes sun.gif
#
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
end
def build_request_url(path, opts = {})
# Add leading and trailing slashes to path
path = "/#{path}".gsub(/\/+/, '/')
@config.base_url(opts[:operation]) + path
end
# Update header and query params based on authentication settings.
#
# @param [Hash] header_params Header parameters
# @param [Hash] query_params Query parameters
# @param [String] auth_names Authentication scheme name
def update_params_for_auth!(header_params, query_params, auth_names)
Array(auth_names).each do |auth_name|
auth_setting = @config.auth_settings[auth_name]
next unless auth_setting
case auth_setting[:in]
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
end
end
end
# Sets user agent in HTTP header
#
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
def user_agent=(user_agent)
@user_agent = user_agent
@default_headers['User-Agent'] = @user_agent
end
# Return Accept header based on an array of accepts provided.
# @param [Array] accepts array for Accept
# @return [String] the Accept header (e.g. application/json)
def select_header_accept(accepts)
return nil if accepts.nil? || accepts.empty?
# use JSON when present, otherwise use all of the provided
json_accept = accepts.find { |s| json_mime?(s) }
json_accept || accepts.join(',')
end
# Return Content-Type header based on an array of content types provided.
# @param [Array] content_types array for Content-Type
# @return [String] the Content-Type header (e.g. application/json)
def select_header_content_type(content_types)
# return nil by default
return if content_types.nil? || content_types.empty?
# use JSON when present, otherwise use the first one
json_content_type = content_types.find { |s| json_mime?(s) }
json_content_type || content_types.first
end
# Convert object (array, hash, object, etc) to JSON string.
# @param [Object] model object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_http_body(model)
return model if model.nil? || model.is_a?(String)
local_body = nil
if model.is_a?(Array)
local_body = model.map { |m| object_to_hash(m) }
else
local_body = object_to_hash(model)
end
local_body.to_json
end
# Convert object(non-array) to hash.
# @param [Object] obj object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_hash(obj)
if obj.respond_to?(:to_hash)
obj.to_hash
else
obj
end
end
# Build parameter value according to the given collection format.
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
def build_collection_param(param, collection_format)
case collection_format
when :csv
param.join(',')
when :ssv
param.join(' ')
when :tsv
param.join("\t")
when :pipes
param.join('|')
when :multi
# return the array directly as typhoeus will handle it as expected
param
else
fail "unknown collection format: #{collection_format.inspect}"
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_rss_email_details.rb | lib/hubspot/codegen/marketing/emails/models/public_rss_email_details.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# RSS related data if it is a blog or rss email.
class PublicRssEmailDetails
#
attr_accessor :blog_image_max_width
#
attr_accessor :blog_email_type
#
attr_accessor :hubspot_blog_id
#
attr_accessor :rss_entry_template
#
attr_accessor :timing
#
attr_accessor :max_entries
#
attr_accessor :use_headline_as_subject
#
attr_accessor :blog_layout
#
attr_accessor :url
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'blog_image_max_width' => :'blogImageMaxWidth',
:'blog_email_type' => :'blogEmailType',
:'hubspot_blog_id' => :'hubspotBlogId',
:'rss_entry_template' => :'rssEntryTemplate',
:'timing' => :'timing',
:'max_entries' => :'maxEntries',
:'use_headline_as_subject' => :'useHeadlineAsSubject',
:'blog_layout' => :'blogLayout',
:'url' => :'url'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'blog_image_max_width' => :'Integer',
:'blog_email_type' => :'String',
:'hubspot_blog_id' => :'String',
:'rss_entry_template' => :'String',
:'timing' => :'Hash<String, Object>',
:'max_entries' => :'Integer',
:'use_headline_as_subject' => :'Boolean',
:'blog_layout' => :'String',
:'url' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicRssEmailDetails` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicRssEmailDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'blog_image_max_width')
self.blog_image_max_width = attributes[:'blog_image_max_width']
end
if attributes.key?(:'blog_email_type')
self.blog_email_type = attributes[:'blog_email_type']
end
if attributes.key?(:'hubspot_blog_id')
self.hubspot_blog_id = attributes[:'hubspot_blog_id']
end
if attributes.key?(:'rss_entry_template')
self.rss_entry_template = attributes[:'rss_entry_template']
end
if attributes.key?(:'timing')
if (value = attributes[:'timing']).is_a?(Hash)
self.timing = value
end
end
if attributes.key?(:'max_entries')
self.max_entries = attributes[:'max_entries']
end
if attributes.key?(:'use_headline_as_subject')
self.use_headline_as_subject = attributes[:'use_headline_as_subject']
end
if attributes.key?(:'blog_layout')
self.blog_layout = attributes[:'blog_layout']
end
if attributes.key?(:'url')
self.url = attributes[:'url']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
blog_image_max_width == o.blog_image_max_width &&
blog_email_type == o.blog_email_type &&
hubspot_blog_id == o.hubspot_blog_id &&
rss_entry_template == o.rss_entry_template &&
timing == o.timing &&
max_entries == o.max_entries &&
use_headline_as_subject == o.use_headline_as_subject &&
blog_layout == o.blog_layout &&
url == o.url
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[blog_image_max_width, blog_email_type, hubspot_blog_id, rss_entry_template, timing, max_entries, use_headline_as_subject, blog_layout, url].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_email_content.rb | lib/hubspot/codegen/marketing/emails/models/public_email_content.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Data structure representing the content of the email.
class PublicEmailContent
#
attr_accessor :smart_fields
#
attr_accessor :theme_settings_values
#
attr_accessor :flex_areas
#
attr_accessor :widgets
#
attr_accessor :plain_text_version
#
attr_accessor :template_path
#
attr_accessor :widget_containers
attr_accessor :style_settings
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'smart_fields' => :'smartFields',
:'theme_settings_values' => :'themeSettingsValues',
:'flex_areas' => :'flexAreas',
:'widgets' => :'widgets',
:'plain_text_version' => :'plainTextVersion',
:'template_path' => :'templatePath',
:'widget_containers' => :'widgetContainers',
:'style_settings' => :'styleSettings'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'smart_fields' => :'Hash<String, Object>',
:'theme_settings_values' => :'Hash<String, Object>',
:'flex_areas' => :'Hash<String, Object>',
:'widgets' => :'Hash<String, Object>',
:'plain_text_version' => :'String',
:'template_path' => :'String',
:'widget_containers' => :'Hash<String, Object>',
:'style_settings' => :'PublicEmailStyleSettings'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicEmailContent` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicEmailContent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'smart_fields')
if (value = attributes[:'smart_fields']).is_a?(Hash)
self.smart_fields = value
end
end
if attributes.key?(:'theme_settings_values')
if (value = attributes[:'theme_settings_values']).is_a?(Hash)
self.theme_settings_values = value
end
end
if attributes.key?(:'flex_areas')
if (value = attributes[:'flex_areas']).is_a?(Hash)
self.flex_areas = value
end
end
if attributes.key?(:'widgets')
if (value = attributes[:'widgets']).is_a?(Hash)
self.widgets = value
end
end
if attributes.key?(:'plain_text_version')
self.plain_text_version = attributes[:'plain_text_version']
end
if attributes.key?(:'template_path')
self.template_path = attributes[:'template_path']
end
if attributes.key?(:'widget_containers')
if (value = attributes[:'widget_containers']).is_a?(Hash)
self.widget_containers = value
end
end
if attributes.key?(:'style_settings')
self.style_settings = attributes[:'style_settings']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
smart_fields == o.smart_fields &&
theme_settings_values == o.theme_settings_values &&
flex_areas == o.flex_areas &&
widgets == o.widgets &&
plain_text_version == o.plain_text_version &&
template_path == o.template_path &&
widget_containers == o.widget_containers &&
style_settings == o.style_settings
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[smart_fields, theme_settings_values, flex_areas, widgets, plain_text_version, template_path, widget_containers, style_settings].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/version_user.rb | lib/hubspot/codegen/marketing/emails/models/version_user.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Model definition for a version user. Contains addition information about the user who created a version.
class VersionUser
# The user's full name.
attr_accessor :full_name
# The user ID.
attr_accessor :id
# The user email.
attr_accessor :email
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'full_name' => :'fullName',
:'id' => :'id',
:'email' => :'email'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'full_name' => :'String',
:'id' => :'String',
:'email' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::VersionUser` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::VersionUser`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'full_name')
self.full_name = attributes[:'full_name']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'email')
self.email = attributes[:'email']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @full_name.nil?
invalid_properties.push('invalid value for "full_name", full_name cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @email.nil?
invalid_properties.push('invalid value for "email", email cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @full_name.nil?
return false if @id.nil?
return false if @email.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
full_name == o.full_name &&
id == o.id &&
email == o.email
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[full_name, id, email].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/aggregate_email_statistics.rb | lib/hubspot/codegen/marketing/emails/models/aggregate_email_statistics.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Aggregated statistics for the given interval, plus the IDs of emails that were sent during that interval.
class AggregateEmailStatistics
# List of email IDs that were sent during the time span.
attr_accessor :emails
# The aggregated statistics per campaign.
attr_accessor :campaign_aggregations
attr_accessor :aggregate
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'emails' => :'emails',
:'campaign_aggregations' => :'campaignAggregations',
:'aggregate' => :'aggregate'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'emails' => :'Array<Integer>',
:'campaign_aggregations' => :'Hash<String, EmailStatisticsData>',
:'aggregate' => :'EmailStatisticsData'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::AggregateEmailStatistics` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::AggregateEmailStatistics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'emails')
if (value = attributes[:'emails']).is_a?(Array)
self.emails = value
end
end
if attributes.key?(:'campaign_aggregations')
if (value = attributes[:'campaign_aggregations']).is_a?(Hash)
self.campaign_aggregations = value
end
end
if attributes.key?(:'aggregate')
self.aggregate = attributes[:'aggregate']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
emails == o.emails &&
campaign_aggregations == o.campaign_aggregations &&
aggregate == o.aggregate
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[emails, campaign_aggregations, aggregate].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/previous_page.rb | lib/hubspot/codegen/marketing/emails/models/previous_page.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Contains information about the previous page.
class PreviousPage
# The cursor token value to get the previous set of results. Use this value as query parameter (&before=...) to obtain the previous page.
attr_accessor :before
# The link to the previous page.
attr_accessor :link
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'before' => :'before',
:'link' => :'link'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'before' => :'String',
:'link' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PreviousPage` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PreviousPage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'before')
self.before = attributes[:'before']
end
if attributes.key?(:'link')
self.link = attributes[:'link']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @before.nil?
invalid_properties.push('invalid value for "before", before cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @before.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
before == o.before &&
link == o.link
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[before, link].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/next_page.rb | lib/hubspot/codegen/marketing/emails/models/next_page.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Contains information about the next page.
class NextPage
# The link to the next page.
attr_accessor :link
# The cursor token value to get the next set of results. Use this value as query parameter (&after=...) to obtain the next page.
attr_accessor :after
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'link' => :'link',
:'after' => :'after'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'link' => :'String',
:'after' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::NextPage` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::NextPage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'link')
self.link = attributes[:'link']
end
if attributes.key?(:'after')
self.after = attributes[:'after']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @after.nil?
invalid_properties.push('invalid value for "after", after cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @after.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
link == o.link &&
after == o.after
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[link, after].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_email_style_settings.rb | lib/hubspot/codegen/marketing/emails/models/public_email_style_settings.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
class PublicEmailStyleSettings
attr_accessor :email_body_padding
attr_accessor :color_picker_favorite5
attr_accessor :body_color
attr_accessor :color_picker_favorite6
attr_accessor :background_image
attr_accessor :email_body_width
attr_accessor :secondary_font
attr_accessor :primary_accent_color
attr_accessor :color_picker_favorite3
attr_accessor :primary_font_line_height
attr_accessor :color_picker_favorite4
attr_accessor :secondary_font_color
attr_accessor :color_picker_favorite1
attr_accessor :color_picker_favorite2
attr_accessor :body_border_color
attr_accessor :body_border_width
attr_accessor :links_font
attr_accessor :background_color
attr_accessor :background_image_type
attr_accessor :divider_style_settings
attr_accessor :secondary_accent_color
attr_accessor :secondary_font_line_height
attr_accessor :primary_font_size
attr_accessor :secondary_font_size
attr_accessor :primary_font_color
attr_accessor :heading_one_font
attr_accessor :primary_font
attr_accessor :heading_two_font
attr_accessor :button_style_settings
attr_accessor :body_border_color_choice
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'email_body_padding' => :'emailBodyPadding',
:'color_picker_favorite5' => :'colorPickerFavorite5',
:'body_color' => :'bodyColor',
:'color_picker_favorite6' => :'colorPickerFavorite6',
:'background_image' => :'backgroundImage',
:'email_body_width' => :'emailBodyWidth',
:'secondary_font' => :'secondaryFont',
:'primary_accent_color' => :'primaryAccentColor',
:'color_picker_favorite3' => :'colorPickerFavorite3',
:'primary_font_line_height' => :'primaryFontLineHeight',
:'color_picker_favorite4' => :'colorPickerFavorite4',
:'secondary_font_color' => :'secondaryFontColor',
:'color_picker_favorite1' => :'colorPickerFavorite1',
:'color_picker_favorite2' => :'colorPickerFavorite2',
:'body_border_color' => :'bodyBorderColor',
:'body_border_width' => :'bodyBorderWidth',
:'links_font' => :'linksFont',
:'background_color' => :'backgroundColor',
:'background_image_type' => :'backgroundImageType',
:'divider_style_settings' => :'dividerStyleSettings',
:'secondary_accent_color' => :'secondaryAccentColor',
:'secondary_font_line_height' => :'secondaryFontLineHeight',
:'primary_font_size' => :'primaryFontSize',
:'secondary_font_size' => :'secondaryFontSize',
:'primary_font_color' => :'primaryFontColor',
:'heading_one_font' => :'headingOneFont',
:'primary_font' => :'primaryFont',
:'heading_two_font' => :'headingTwoFont',
:'button_style_settings' => :'buttonStyleSettings',
:'body_border_color_choice' => :'bodyBorderColorChoice'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'email_body_padding' => :'String',
:'color_picker_favorite5' => :'String',
:'body_color' => :'String',
:'color_picker_favorite6' => :'String',
:'background_image' => :'String',
:'email_body_width' => :'String',
:'secondary_font' => :'String',
:'primary_accent_color' => :'String',
:'color_picker_favorite3' => :'String',
:'primary_font_line_height' => :'String',
:'color_picker_favorite4' => :'String',
:'secondary_font_color' => :'String',
:'color_picker_favorite1' => :'String',
:'color_picker_favorite2' => :'String',
:'body_border_color' => :'String',
:'body_border_width' => :'Integer',
:'links_font' => :'PublicFontStyle',
:'background_color' => :'String',
:'background_image_type' => :'String',
:'divider_style_settings' => :'PublicDividerStyleSettings',
:'secondary_accent_color' => :'String',
:'secondary_font_line_height' => :'String',
:'primary_font_size' => :'Integer',
:'secondary_font_size' => :'Integer',
:'primary_font_color' => :'String',
:'heading_one_font' => :'PublicFontStyle',
:'primary_font' => :'String',
:'heading_two_font' => :'PublicFontStyle',
:'button_style_settings' => :'PublicButtonStyleSettings',
:'body_border_color_choice' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicEmailStyleSettings` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicEmailStyleSettings`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'email_body_padding')
self.email_body_padding = attributes[:'email_body_padding']
end
if attributes.key?(:'color_picker_favorite5')
self.color_picker_favorite5 = attributes[:'color_picker_favorite5']
end
if attributes.key?(:'body_color')
self.body_color = attributes[:'body_color']
end
if attributes.key?(:'color_picker_favorite6')
self.color_picker_favorite6 = attributes[:'color_picker_favorite6']
end
if attributes.key?(:'background_image')
self.background_image = attributes[:'background_image']
end
if attributes.key?(:'email_body_width')
self.email_body_width = attributes[:'email_body_width']
end
if attributes.key?(:'secondary_font')
self.secondary_font = attributes[:'secondary_font']
end
if attributes.key?(:'primary_accent_color')
self.primary_accent_color = attributes[:'primary_accent_color']
end
if attributes.key?(:'color_picker_favorite3')
self.color_picker_favorite3 = attributes[:'color_picker_favorite3']
end
if attributes.key?(:'primary_font_line_height')
self.primary_font_line_height = attributes[:'primary_font_line_height']
end
if attributes.key?(:'color_picker_favorite4')
self.color_picker_favorite4 = attributes[:'color_picker_favorite4']
end
if attributes.key?(:'secondary_font_color')
self.secondary_font_color = attributes[:'secondary_font_color']
end
if attributes.key?(:'color_picker_favorite1')
self.color_picker_favorite1 = attributes[:'color_picker_favorite1']
end
if attributes.key?(:'color_picker_favorite2')
self.color_picker_favorite2 = attributes[:'color_picker_favorite2']
end
if attributes.key?(:'body_border_color')
self.body_border_color = attributes[:'body_border_color']
end
if attributes.key?(:'body_border_width')
self.body_border_width = attributes[:'body_border_width']
end
if attributes.key?(:'links_font')
self.links_font = attributes[:'links_font']
end
if attributes.key?(:'background_color')
self.background_color = attributes[:'background_color']
end
if attributes.key?(:'background_image_type')
self.background_image_type = attributes[:'background_image_type']
end
if attributes.key?(:'divider_style_settings')
self.divider_style_settings = attributes[:'divider_style_settings']
end
if attributes.key?(:'secondary_accent_color')
self.secondary_accent_color = attributes[:'secondary_accent_color']
end
if attributes.key?(:'secondary_font_line_height')
self.secondary_font_line_height = attributes[:'secondary_font_line_height']
end
if attributes.key?(:'primary_font_size')
self.primary_font_size = attributes[:'primary_font_size']
end
if attributes.key?(:'secondary_font_size')
self.secondary_font_size = attributes[:'secondary_font_size']
end
if attributes.key?(:'primary_font_color')
self.primary_font_color = attributes[:'primary_font_color']
end
if attributes.key?(:'heading_one_font')
self.heading_one_font = attributes[:'heading_one_font']
end
if attributes.key?(:'primary_font')
self.primary_font = attributes[:'primary_font']
end
if attributes.key?(:'heading_two_font')
self.heading_two_font = attributes[:'heading_two_font']
end
if attributes.key?(:'button_style_settings')
self.button_style_settings = attributes[:'button_style_settings']
end
if attributes.key?(:'body_border_color_choice')
self.body_border_color_choice = attributes[:'body_border_color_choice']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
email_body_padding == o.email_body_padding &&
color_picker_favorite5 == o.color_picker_favorite5 &&
body_color == o.body_color &&
color_picker_favorite6 == o.color_picker_favorite6 &&
background_image == o.background_image &&
email_body_width == o.email_body_width &&
secondary_font == o.secondary_font &&
primary_accent_color == o.primary_accent_color &&
color_picker_favorite3 == o.color_picker_favorite3 &&
primary_font_line_height == o.primary_font_line_height &&
color_picker_favorite4 == o.color_picker_favorite4 &&
secondary_font_color == o.secondary_font_color &&
color_picker_favorite1 == o.color_picker_favorite1 &&
color_picker_favorite2 == o.color_picker_favorite2 &&
body_border_color == o.body_border_color &&
body_border_width == o.body_border_width &&
links_font == o.links_font &&
background_color == o.background_color &&
background_image_type == o.background_image_type &&
divider_style_settings == o.divider_style_settings &&
secondary_accent_color == o.secondary_accent_color &&
secondary_font_line_height == o.secondary_font_line_height &&
primary_font_size == o.primary_font_size &&
secondary_font_size == o.secondary_font_size &&
primary_font_color == o.primary_font_color &&
heading_one_font == o.heading_one_font &&
primary_font == o.primary_font &&
heading_two_font == o.heading_two_font &&
button_style_settings == o.button_style_settings &&
body_border_color_choice == o.body_border_color_choice
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[email_body_padding, color_picker_favorite5, body_color, color_picker_favorite6, background_image, email_body_width, secondary_font, primary_accent_color, color_picker_favorite3, primary_font_line_height, color_picker_favorite4, secondary_font_color, color_picker_favorite1, color_picker_favorite2, body_border_color, body_border_width, links_font, background_color, background_image_type, divider_style_settings, secondary_accent_color, secondary_font_line_height, primary_font_size, secondary_font_size, primary_font_color, heading_one_font, primary_font, heading_two_font, button_style_settings, body_border_color_choice].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/paging.rb | lib/hubspot/codegen/marketing/emails/models/paging.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Contains information pagination of results.
class Paging
attr_accessor :_next
attr_accessor :prev
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'_next' => :'next',
:'prev' => :'prev'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'_next' => :'NextPage',
:'prev' => :'PreviousPage'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::Paging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::Paging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'_next')
self._next = attributes[:'_next']
end
if attributes.key?(:'prev')
self.prev = attributes[:'prev']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @_next.nil?
invalid_properties.push('invalid value for "_next", _next cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @_next.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
_next == o._next &&
prev == o.prev
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[_next, prev].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/collection_response_with_total_email_statistic_interval_no_paging.rb | lib/hubspot/codegen/marketing/emails/models/collection_response_with_total_email_statistic_interval_no_paging.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Response object for collections of EmailStatisticIntervals.
class CollectionResponseWithTotalEmailStatisticIntervalNoPaging
# Total number of objects.
attr_accessor :total
# Collection of objects.
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'total' => :'total',
:'results' => :'results'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'total' => :'Integer',
:'results' => :'Array<EmailStatisticInterval>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::CollectionResponseWithTotalEmailStatisticIntervalNoPaging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::CollectionResponseWithTotalEmailStatisticIntervalNoPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'total')
self.total = attributes[:'total']
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @total.nil?
invalid_properties.push('invalid value for "total", total cannot be nil.')
end
if @results.nil?
invalid_properties.push('invalid value for "results", results cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @total.nil?
return false if @results.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
total == o.total &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[total, results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/collection_response_with_total_version_public_email.rb | lib/hubspot/codegen/marketing/emails/models/collection_response_with_total_version_public_email.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Response object for collections of marketing emails with pagination information.
class CollectionResponseWithTotalVersionPublicEmail
# Total number of content emails.
attr_accessor :total
attr_accessor :paging
# Collection of emails.
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'total' => :'total',
:'paging' => :'paging',
:'results' => :'results'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'total' => :'Integer',
:'paging' => :'Paging',
:'results' => :'Array<VersionPublicEmail>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::CollectionResponseWithTotalVersionPublicEmail` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::CollectionResponseWithTotalVersionPublicEmail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'total')
self.total = attributes[:'total']
end
if attributes.key?(:'paging')
self.paging = attributes[:'paging']
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @total.nil?
invalid_properties.push('invalid value for "total", total cannot be nil.')
end
if @results.nil?
invalid_properties.push('invalid value for "results", results cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @total.nil?
return false if @results.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
total == o.total &&
paging == o.paging &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[total, paging, results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_email.rb | lib/hubspot/codegen/marketing/emails/models/public_email.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# A marketing email
class PublicEmail
# The ID of the feedback survey linked to the email.
attr_accessor :feedback_survey_id
# The subject of the email.
attr_accessor :subject
# The date and time the email is scheduled for, in ISO8601 representation. This is only used in local time or scheduled emails.
attr_accessor :publish_date
# Returns whether the email is a transactional email or not. This is read only.
attr_accessor :is_transactional
attr_accessor :language
# The email type, this is derived from other properties on the email such as subcategory.
attr_accessor :type
attr_accessor :content
attr_accessor :business_unit_id
attr_accessor :webversion
attr_accessor :workflow_names
# Determines if the email is archived or not.
attr_accessor :archived
# The date and time of the email's creation, in ISO8601 representation.
attr_accessor :created_at
attr_accessor :stats
attr_accessor :jitter_send_time
attr_accessor :from
# The email ID.
attr_accessor :id
# The email state.
attr_accessor :state
# The id of the user who created the email.
attr_accessor :created_by_id
# The date and time of the last update to the email, in ISO8601 representation.
attr_accessor :updated_at
attr_accessor :rss_data
# The date and time the email was published at, in ISO8601 representation.
attr_accessor :published_at
attr_accessor :published_by_id
# Returns the published status of the email. This is read only.
attr_accessor :is_published
attr_accessor :testing
# The id of the user who last updated the email.
attr_accessor :updated_by_id
attr_accessor :folder_id
attr_accessor :subscription_details
attr_accessor :deleted_at
# The name of the email, as displayed on the email dashboard.
attr_accessor :name
# The active domain of the email.
attr_accessor :active_domain
# The campaign id on the email.
attr_accessor :campaign
attr_accessor :to
# The email subcategory.
attr_accessor :subcategory
attr_accessor :campaign_name
# Determines whether the email will be sent immediately on publish.
attr_accessor :send_on_publish
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'feedback_survey_id' => :'feedbackSurveyId',
:'subject' => :'subject',
:'publish_date' => :'publishDate',
:'is_transactional' => :'isTransactional',
:'language' => :'language',
:'type' => :'type',
:'content' => :'content',
:'business_unit_id' => :'businessUnitId',
:'webversion' => :'webversion',
:'workflow_names' => :'workflowNames',
:'archived' => :'archived',
:'created_at' => :'createdAt',
:'stats' => :'stats',
:'jitter_send_time' => :'jitterSendTime',
:'from' => :'from',
:'id' => :'id',
:'state' => :'state',
:'created_by_id' => :'createdById',
:'updated_at' => :'updatedAt',
:'rss_data' => :'rssData',
:'published_at' => :'publishedAt',
:'published_by_id' => :'publishedById',
:'is_published' => :'isPublished',
:'testing' => :'testing',
:'updated_by_id' => :'updatedById',
:'folder_id' => :'folderId',
:'subscription_details' => :'subscriptionDetails',
:'deleted_at' => :'deletedAt',
:'name' => :'name',
:'active_domain' => :'activeDomain',
:'campaign' => :'campaign',
:'to' => :'to',
:'subcategory' => :'subcategory',
:'campaign_name' => :'campaignName',
:'send_on_publish' => :'sendOnPublish'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'feedback_survey_id' => :'String',
:'subject' => :'String',
:'publish_date' => :'Time',
:'is_transactional' => :'Boolean',
:'language' => :'String',
:'type' => :'String',
:'content' => :'PublicEmailContent',
:'business_unit_id' => :'String',
:'webversion' => :'PublicWebversionDetails',
:'workflow_names' => :'Array<String>',
:'archived' => :'Boolean',
:'created_at' => :'Time',
:'stats' => :'EmailStatisticsData',
:'jitter_send_time' => :'Boolean',
:'from' => :'PublicEmailFromDetails',
:'id' => :'String',
:'state' => :'String',
:'created_by_id' => :'String',
:'updated_at' => :'Time',
:'rss_data' => :'PublicRssEmailDetails',
:'published_at' => :'Time',
:'published_by_id' => :'String',
:'is_published' => :'Boolean',
:'testing' => :'PublicEmailTestingDetails',
:'updated_by_id' => :'String',
:'folder_id' => :'Integer',
:'subscription_details' => :'PublicEmailSubscriptionDetails',
:'deleted_at' => :'Time',
:'name' => :'String',
:'active_domain' => :'String',
:'campaign' => :'String',
:'to' => :'PublicEmailToDetails',
:'subcategory' => :'String',
:'campaign_name' => :'String',
:'send_on_publish' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicEmail` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicEmail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'feedback_survey_id')
self.feedback_survey_id = attributes[:'feedback_survey_id']
end
if attributes.key?(:'subject')
self.subject = attributes[:'subject']
end
if attributes.key?(:'publish_date')
self.publish_date = attributes[:'publish_date']
end
if attributes.key?(:'is_transactional')
self.is_transactional = attributes[:'is_transactional']
end
if attributes.key?(:'language')
self.language = attributes[:'language']
end
if attributes.key?(:'type')
self.type = attributes[:'type']
end
if attributes.key?(:'content')
self.content = attributes[:'content']
end
if attributes.key?(:'business_unit_id')
self.business_unit_id = attributes[:'business_unit_id']
end
if attributes.key?(:'webversion')
self.webversion = attributes[:'webversion']
end
if attributes.key?(:'workflow_names')
if (value = attributes[:'workflow_names']).is_a?(Array)
self.workflow_names = value
end
end
if attributes.key?(:'archived')
self.archived = attributes[:'archived']
end
if attributes.key?(:'created_at')
self.created_at = attributes[:'created_at']
end
if attributes.key?(:'stats')
self.stats = attributes[:'stats']
end
if attributes.key?(:'jitter_send_time')
self.jitter_send_time = attributes[:'jitter_send_time']
end
if attributes.key?(:'from')
self.from = attributes[:'from']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'state')
self.state = attributes[:'state']
end
if attributes.key?(:'created_by_id')
self.created_by_id = attributes[:'created_by_id']
end
if attributes.key?(:'updated_at')
self.updated_at = attributes[:'updated_at']
end
if attributes.key?(:'rss_data')
self.rss_data = attributes[:'rss_data']
end
if attributes.key?(:'published_at')
self.published_at = attributes[:'published_at']
end
if attributes.key?(:'published_by_id')
self.published_by_id = attributes[:'published_by_id']
end
if attributes.key?(:'is_published')
self.is_published = attributes[:'is_published']
end
if attributes.key?(:'testing')
self.testing = attributes[:'testing']
end
if attributes.key?(:'updated_by_id')
self.updated_by_id = attributes[:'updated_by_id']
end
if attributes.key?(:'folder_id')
self.folder_id = attributes[:'folder_id']
end
if attributes.key?(:'subscription_details')
self.subscription_details = attributes[:'subscription_details']
end
if attributes.key?(:'deleted_at')
self.deleted_at = attributes[:'deleted_at']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'active_domain')
self.active_domain = attributes[:'active_domain']
end
if attributes.key?(:'campaign')
self.campaign = attributes[:'campaign']
end
if attributes.key?(:'to')
self.to = attributes[:'to']
end
if attributes.key?(:'subcategory')
self.subcategory = attributes[:'subcategory']
end
if attributes.key?(:'campaign_name')
self.campaign_name = attributes[:'campaign_name']
end
if attributes.key?(:'send_on_publish')
self.send_on_publish = attributes[:'send_on_publish']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @subject.nil?
invalid_properties.push('invalid value for "subject", subject cannot be nil.')
end
if @content.nil?
invalid_properties.push('invalid value for "content", content cannot be nil.')
end
if @from.nil?
invalid_properties.push('invalid value for "from", from cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @state.nil?
invalid_properties.push('invalid value for "state", state cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @to.nil?
invalid_properties.push('invalid value for "to", to cannot be nil.')
end
if @subcategory.nil?
invalid_properties.push('invalid value for "subcategory", subcategory cannot be nil.')
end
if @send_on_publish.nil?
invalid_properties.push('invalid value for "send_on_publish", send_on_publish cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @subject.nil?
language_validator = EnumAttributeValidator.new('String', ["af", "af-na", "af-za", "agq", "agq-cm", "ak", "ak-gh", "am", "am-et", "ann", "ann-ng", "ar", "ar-001", "ar-ae", "ar-bh", "ar-dj", "ar-dz", "ar-eg", "ar-eh", "ar-er", "ar-il", "ar-iq", "ar-jo", "ar-km", "ar-kw", "ar-lb", "ar-ly", "ar-ma", "ar-mr", "ar-om", "ar-ps", "ar-qa", "ar-sa", "ar-sd", "ar-so", "ar-ss", "ar-sy", "ar-td", "ar-tn", "ar-ye", "as", "asa", "asa-tz", "ast", "ast-es", "as-in", "az", "az-az", "bas", "bas-cm", "be", "bem", "bem-zm", "bez", "bez-tz", "be-by", "bg", "bgc", "bgc-in", "bg-bg", "bho", "bho-in", "bm", "bm-ml", "bn", "bn-bd", "bn-in", "bo", "bo-cn", "bo-in", "br", "brx", "brx-in", "br-fr", "bs", "bs-ba", "ca", "ca-ad", "ca-es", "ca-fr", "ca-it", "ccp", "ccp-bd", "ccp-in", "ce", "ceb", "ceb-ph", "ce-ru", "cgg", "cgg-ug", "chr", "chr-us", "ckb", "ckb-iq", "ckb-ir", "cs", "cs-cz", "cu", "cu-ru", "cv", "cv-ru", "cy", "cy-gb", "da", "dav", "dav-ke", "da-dk", "da-gl", "de", "de-at", "de-be", "de-ch", "de-de", "de-gr", "de-it", "de-li", "de-lu", "dje", "dje-ne", "doi", "doi-in", "dsb", "dsb-de", "dua", "dua-cm", "dyo", "dyo-sn", "dz", "dz-bt", "ebu", "ebu-ke", "ee", "ee-gh", "ee-tg", "el", "el-cy", "el-gr", "en", "en-001", "en-150", "en-ae", "en-ag", "en-ai", "en-as", "en-at", "en-au", "en-bb", "en-be", "en-bi", "en-bm", "en-bs", "en-bw", "en-bz", "en-ca", "en-cc", "en-ch", "en-ck", "en-cm", "en-cn", "en-cx", "en-cy", "en-de", "en-dg", "en-dk", "en-dm", "en-ee", "en-er", "en-fi", "en-fj", "en-fk", "en-fm", "en-fr", "en-gb", "en-gd", "en-gg", "en-gh", "en-gi", "en-gm", "en-gu", "en-gy", "en-hk", "en-ie", "en-il", "en-im", "en-in", "en-io", "en-je", "en-jm", "en-ke", "en-ki", "en-kn", "en-ky", "en-lc", "en-lr", "en-ls", "en-lu", "en-mg", "en-mh", "en-mo", "en-mp", "en-ms", "en-mt", "en-mu", "en-mv", "en-mw", "en-mx", "en-my", "en-na", "en-nf", "en-ng", "en-nl", "en-nr", "en-nu", "en-nz", "en-pg", "en-ph", "en-pk", "en-pn", "en-pr", "en-pw", "en-rw", "en-sb", "en-sc", "en-sd", "en-se", "en-sg", "en-sh", "en-si", "en-sl", "en-ss", "en-sx", "en-sz", "en-tc", "en-tk", "en-to", "en-tt", "en-tv", "en-tz", "en-ug", "en-um", "en-us", "en-vc", "en-vg", "en-vi", "en-vu", "en-ws", "en-za", "en-zm", "en-zw", "eo", "eo-001", "es", "es-419", "es-ar", "es-bo", "es-br", "es-bz", "es-cl", "es-co", "es-cr", "es-cu", "es-do", "es-ea", "es-ec", "es-es", "es-gq", "es-gt", "es-hn", "es-ic", "es-mx", "es-ni", "es-pa", "es-pe", "es-ph", "es-pr", "es-py", "es-sv", "es-us", "es-uy", "es-ve", "et", "et-ee", "eu", "eu-es", "ewo", "ewo-cm", "fa", "fa-af", "fa-ir", "ff", "ff-bf", "ff-cm", "ff-gh", "ff-gm", "ff-gn", "ff-gw", "ff-lr", "ff-mr", "ff-ne", "ff-ng", "ff-sl", "ff-sn", "fi", "fil", "fil-ph", "fi-fi", "fo", "fo-dk", "fo-fo", "fr", "frr", "frr-de", "fr-be", "fr-bf", "fr-bi", "fr-bj", "fr-bl", "fr-ca", "fr-cd", "fr-cf", "fr-cg", "fr-ch", "fr-ci", "fr-cm", "fr-dj", "fr-dz", "fr-fr", "fr-ga", "fr-gf", "fr-gn", "fr-gp", "fr-gq", "fr-ht", "fr-km", "fr-lu", "fr-ma", "fr-mc", "fr-mf", "fr-mg", "fr-ml", "fr-mq", "fr-mr", "fr-mu", "fr-nc", "fr-ne", "fr-pf", "fr-pm", "fr-re", "fr-rw", "fr-sc", "fr-sn", "fr-sy", "fr-td", "fr-tg", "fr-tn", "fr-vu", "fr-wf", "fr-yt", "fur", "fur-it", "fy", "fy-nl", "ga", "ga-gb", "ga-ie", "gd", "gd-gb", "gl", "gl-es", "gsw", "gsw-ch", "gsw-fr", "gsw-li", "gu", "guz", "guz-ke", "gu-in", "gv", "gv-im", "ha", "haw", "haw-us", "ha-gh", "ha-ne", "ha-ng", "he", "hi", "hi-in", "hr", "hr-ba", "hr-hr", "hsb", "hsb-de", "hu", "hu-hu", "hy", "hy-am", "ia", "ia-001", "id", "ig", "ig-ng", "ii", "ii-cn", "id-id", "is", "is-is", "it", "it-ch", "it-it", "it-sm", "it-va", "he-il", "ja", "ja-jp", "jgo", "jgo-cm", "yi", "yi-001", "jmc", "jmc-tz", "jv", "jv-id", "ka", "kab", "kab-dz", "kam", "kam-ke", "ka-ge", "kde", "kde-tz", "kea", "kea-cv", "kgp", "kgp-br", "khq", "khq-ml", "ki", "ki-ke", "kk", "kkj", "kkj-cm", "kk-kz", "kl", "kln", "kln-ke", "kl-gl", "km", "km-kh", "kn", "kn-in", "ko", "kok", "kok-in", "ko-kp", "ko-kr", "ks", "ksb", "ksb-tz", "ksf", "ksf-cm", "ksh", "ksh-de", "ks-in", "ku", "ku-tr", "kw", "kw-gb", "ky", "ky-kg", "lag", "lag-tz", "lb", "lb-lu", "lg", "lg-ug", "lkt", "lkt-us", "ln", "ln-ao", "ln-cd", "ln-cf", "ln-cg", "lo", "lo-la", "lrc", "lrc-iq", "lrc-ir", "lt", "lt-lt", "lu", "luo", "luo-ke", "luy", "luy-ke", "lu-cd", "lv", "lv-lv", "mai", "mai-in", "mas", "mas-ke", "mas-tz", "mdf", "mdf-ru", "mer", "mer-ke", "mfe", "mfe-mu", "mg", "mgh", "mgh-mz", "mgo", "mgo-cm", "mg-mg", "mi", "mi-nz", "mk", "mk-mk", "ml", "ml-in", "mn", "mni", "mni-in", "mn-mn", "mr", "mr-in", "ms", "ms-bn", "ms-id", "ms-my", "ms-sg", "mt", "mt-mt", "mua", "mua-cm", "my", "my-mm", "mzn", "mzn-ir", "naq", "naq-na", "nb", "nb-no", "nb-sj", "nd", "nds", "nds-de", "nds-nl", "nd-zw", "ne", "ne-in", "ne-np", "nl", "nl-aw", "nl-be", "nl-bq", "nl-ch", "nl-cw", "nl-lu", "nl-nl", "nl-sr", "nl-sx", "nmg", "nmg-cm", "nn", "nnh", "nnh-cm", "nn-no", "no", "no-no", "nus", "nus-ss", "nyn", "nyn-ug", "oc", "oc-es", "oc-fr", "om", "om-et", "om-ke", "or", "or-in", "os", "os-ge", "os-ru", "pa", "pa-in", "pa-pk", "pcm", "pcm-ng", "pis", "pis-sb", "pl", "pl-pl", "prg", "prg-001", "ps", "ps-af", "ps-pk", "pt", "pt-ao", "pt-br", "pt-ch", "pt-cv", "pt-gq", "pt-gw", "pt-lu", "pt-mo", "pt-mz", "pt-pt", "pt-st", "pt-tl", "qu", "qu-bo", "qu-ec", "qu-pe", "raj", "raj-in", "rm", "rm-ch", "rn", "rn-bi", "ro", "rof", "rof-tz", "ro-md", "ro-ro", "ru", "ru-by", "ru-kg", "ru-kz", "ru-md", "ru-ru", "ru-ua", "rw", "rwk", "rwk-tz", "rw-rw", "sa", "sah", "sah-ru", "saq", "saq-ke", "sat", "sat-in", "sa-in", "sbp", "sbp-tz", "sc", "sc-it", "sd", "sd-in", "sd-pk", "se", "seh", "seh-mz", "ses", "ses-ml", "se-fi", "se-no", "se-se", "sg", "sg-cf", "shi", "shi-ma", "si", "si-lk", "sk", "sk-sk", "sl", "sl-si", "smn", "smn-fi", "sms", "sms-fi", "sn", "sn-zw", "so", "so-dj", "so-et", "so-ke", "so-so", "sq", "sq-al", "sq-mk", "sq-xk", "sr", "sr-ba", "sr-cs", "sr-me", "sr-rs", "sr-xk", "su", "su-id", "sv", "sv-ax", "sv-fi", "sv-se", "sw", "sw-cd", "sw-ke", "sw-tz", "sw-ug", "sy", "ta", "ta-in", "ta-lk", "ta-my", "ta-sg", "te", "teo", "teo-ke", "teo-ug", "te-in", "tg", "tg-tj", "th", "th-th", "ti", "ti-er", "ti-et", "tk", "tk-tm", "tl", "to", "tok", "tok-001", "to-to", "tr", "tr-cy", "tr-tr", "tt", "tt-ru", "twq", "twq-ne", "tzm", "tzm-ma", "ug", "ug-cn", "uk", "uk-ua", "ur", "ur-in", "ur-pk", "uz", "uz-af", "uz-uz", "vai", "vai-lr", "vi", "vi-vn", "vo", "vo-001", "vun", "vun-tz", "wae", "wae-ch", "wo", "wo-sn", "xh", "xh-za", "xog", "xog-ug", "yav", "yav-cm", "yo", "yo-bj", "yo-ng", "yrl", "yrl-br", "yrl-co", "yrl-ve", "yue", "yue-cn", "yue-hk", "zgh", "zgh-ma", "zh", "zh-cn", "zh-hans", "zh-hant", "zh-hk", "zh-mo", "zh-sg", "zh-tw", "zu", "zu-za"])
return false unless language_validator.valid?(@language)
type_validator = EnumAttributeValidator.new('String', ["AB_EMAIL", "BATCH_EMAIL", "LOCALTIME_EMAIL", "AUTOMATED_AB_EMAIL", "BLOG_EMAIL", "BLOG_EMAIL_CHILD", "RSS_EMAIL", "RSS_EMAIL_CHILD", "RESUBSCRIBE_EMAIL", "OPTIN_EMAIL", "OPTIN_FOLLOWUP_EMAIL", "AUTOMATED_EMAIL", "FEEDBACK_CES_EMAIL", "FEEDBACK_CUSTOM_EMAIL", "FEEDBACK_CUSTOM_SURVEY_EMAIL", "FEEDBACK_NPS_EMAIL", "FOLLOWUP_EMAIL", "LEADFLOW_EMAIL", "SINGLE_SEND_API", "MARKETING_SINGLE_SEND_API", "SMTP_TOKEN", "TICKET_EMAIL", "MEMBERSHIP_REGISTRATION_EMAIL", "MEMBERSHIP_PASSWORD_SAVED_EMAIL", "MEMBERSHIP_PASSWORD_RESET_EMAIL", "MEMBERSHIP_EMAIL_VERIFICATION_EMAIL", "MEMBERSHIP_PASSWORDLESS_AUTH_EMAIL", "MEMBERSHIP_REGISTRATION_FOLLOW_UP_EMAIL", "MEMBERSHIP_OTP_LOGIN_EMAIL", "MEMBERSHIP_FOLLOW_UP_EMAIL", "MEMBERSHIP_VERIFICATION_EMAIL"])
return false unless type_validator.valid?(@type)
return false if @content.nil?
return false if @from.nil?
return false if @id.nil?
return false if @state.nil?
state_validator = EnumAttributeValidator.new('String', ["AUTOMATED", "AUTOMATED_DRAFT", "AUTOMATED_SENDING", "AUTOMATED_FOR_FORM", "AUTOMATED_FOR_FORM_BUFFER", "AUTOMATED_FOR_FORM_DRAFT", "AUTOMATED_FOR_FORM_LEGACY", "BLOG_EMAIL_DRAFT", "BLOG_EMAIL_PUBLISHED", "DRAFT", "DRAFT_AB", "DRAFT_AB_VARIANT", "ERROR", "LOSER_AB_VARIANT", "PAGE_STUB", "PRE_PROCESSING", "PROCESSING", "PUBLISHED", "PUBLISHED_AB", "PUBLISHED_AB_VARIANT", "PUBLISHED_OR_SCHEDULED", "RSS_TO_EMAIL_DRAFT", "RSS_TO_EMAIL_PUBLISHED", "SCHEDULED", "SCHEDULED_AB", "SCHEDULED_OR_PUBLISHED", "AUTOMATED_AB", "AUTOMATED_AB_VARIANT", "AUTOMATED_DRAFT_AB", "AUTOMATED_DRAFT_ABVARIANT", "AUTOMATED_LOSER_ABVARIANT"])
return false unless state_validator.valid?(@state)
return false if @name.nil?
return false if @to.nil?
return false if @subcategory.nil?
return false if @send_on_publish.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] language Object to be assigned
def language=(language)
validator = EnumAttributeValidator.new('String', ["af", "af-na", "af-za", "agq", "agq-cm", "ak", "ak-gh", "am", "am-et", "ann", "ann-ng", "ar", "ar-001", "ar-ae", "ar-bh", "ar-dj", "ar-dz", "ar-eg", "ar-eh", "ar-er", "ar-il", "ar-iq", "ar-jo", "ar-km", "ar-kw", "ar-lb", "ar-ly", "ar-ma", "ar-mr", "ar-om", "ar-ps", "ar-qa", "ar-sa", "ar-sd", "ar-so", "ar-ss", "ar-sy", "ar-td", "ar-tn", "ar-ye", "as", "asa", "asa-tz", "ast", "ast-es", "as-in", "az", "az-az", "bas", "bas-cm", "be", "bem", "bem-zm", "bez", "bez-tz", "be-by", "bg", "bgc", "bgc-in", "bg-bg", "bho", "bho-in", "bm", "bm-ml", "bn", "bn-bd", "bn-in", "bo", "bo-cn", "bo-in", "br", "brx", "brx-in", "br-fr", "bs", "bs-ba", "ca", "ca-ad", "ca-es", "ca-fr", "ca-it", "ccp", "ccp-bd", "ccp-in", "ce", "ceb", "ceb-ph", "ce-ru", "cgg", "cgg-ug", "chr", "chr-us", "ckb", "ckb-iq", "ckb-ir", "cs", "cs-cz", "cu", "cu-ru", "cv", "cv-ru", "cy", "cy-gb", "da", "dav", "dav-ke", "da-dk", "da-gl", "de", "de-at", "de-be", "de-ch", "de-de", "de-gr", "de-it", "de-li", "de-lu", "dje", "dje-ne", "doi", "doi-in", "dsb", "dsb-de", "dua", "dua-cm", "dyo", "dyo-sn", "dz", "dz-bt", "ebu", "ebu-ke", "ee", "ee-gh", "ee-tg", "el", "el-cy", "el-gr", "en", "en-001", "en-150", "en-ae", "en-ag", "en-ai", "en-as", "en-at", "en-au", "en-bb", "en-be", "en-bi", "en-bm", "en-bs", "en-bw", "en-bz", "en-ca", "en-cc", "en-ch", "en-ck", "en-cm", "en-cn", "en-cx", "en-cy", "en-de", "en-dg", "en-dk", "en-dm", "en-ee", "en-er", "en-fi", "en-fj", "en-fk", "en-fm", "en-fr", "en-gb", "en-gd", "en-gg", "en-gh", "en-gi", "en-gm", "en-gu", "en-gy", "en-hk", "en-ie", "en-il", "en-im", "en-in", "en-io", "en-je", "en-jm", "en-ke", "en-ki", "en-kn", "en-ky", "en-lc", "en-lr", "en-ls", "en-lu", "en-mg", "en-mh", "en-mo", "en-mp", "en-ms", "en-mt", "en-mu", "en-mv", "en-mw", "en-mx", "en-my", "en-na", "en-nf", "en-ng", "en-nl", "en-nr", "en-nu", "en-nz", "en-pg", "en-ph", "en-pk", "en-pn", "en-pr", "en-pw", "en-rw", "en-sb", "en-sc", "en-sd", "en-se", "en-sg", "en-sh", "en-si", "en-sl", "en-ss", "en-sx", "en-sz", "en-tc", "en-tk", "en-to", "en-tt", "en-tv", "en-tz", "en-ug", "en-um", "en-us", "en-vc", "en-vg", "en-vi", "en-vu", "en-ws", "en-za", "en-zm", "en-zw", "eo", "eo-001", "es", "es-419", "es-ar", "es-bo", "es-br", "es-bz", "es-cl", "es-co", "es-cr", "es-cu", "es-do", "es-ea", "es-ec", "es-es", "es-gq", "es-gt", "es-hn", "es-ic", "es-mx", "es-ni", "es-pa", "es-pe", "es-ph", "es-pr", "es-py", "es-sv", "es-us", "es-uy", "es-ve", "et", "et-ee", "eu", "eu-es", "ewo", "ewo-cm", "fa", "fa-af", "fa-ir", "ff", "ff-bf", "ff-cm", "ff-gh", "ff-gm", "ff-gn", "ff-gw", "ff-lr", "ff-mr", "ff-ne", "ff-ng", "ff-sl", "ff-sn", "fi", "fil", "fil-ph", "fi-fi", "fo", "fo-dk", "fo-fo", "fr", "frr", "frr-de", "fr-be", "fr-bf", "fr-bi", "fr-bj", "fr-bl", "fr-ca", "fr-cd", "fr-cf", "fr-cg", "fr-ch", "fr-ci", "fr-cm", "fr-dj", "fr-dz", "fr-fr", "fr-ga", "fr-gf", "fr-gn", "fr-gp", "fr-gq", "fr-ht", "fr-km", "fr-lu", "fr-ma", "fr-mc", "fr-mf", "fr-mg", "fr-ml", "fr-mq", "fr-mr", "fr-mu", "fr-nc", "fr-ne", "fr-pf", "fr-pm", "fr-re", "fr-rw", "fr-sc", "fr-sn", "fr-sy", "fr-td", "fr-tg", "fr-tn", "fr-vu", "fr-wf", "fr-yt", "fur", "fur-it", "fy", "fy-nl", "ga", "ga-gb", "ga-ie", "gd", "gd-gb", "gl", "gl-es", "gsw", "gsw-ch", "gsw-fr", "gsw-li", "gu", "guz", "guz-ke", "gu-in", "gv", "gv-im", "ha", "haw", "haw-us", "ha-gh", "ha-ne", "ha-ng", "he", "hi", "hi-in", "hr", "hr-ba", "hr-hr", "hsb", "hsb-de", "hu", "hu-hu", "hy", "hy-am", "ia", "ia-001", "id", "ig", "ig-ng", "ii", "ii-cn", "id-id", "is", "is-is", "it", "it-ch", "it-it", "it-sm", "it-va", "he-il", "ja", "ja-jp", "jgo", "jgo-cm", "yi", "yi-001", "jmc", "jmc-tz", "jv", "jv-id", "ka", "kab", "kab-dz", "kam", "kam-ke", "ka-ge", "kde", "kde-tz", "kea", "kea-cv", "kgp", "kgp-br", "khq", "khq-ml", "ki", "ki-ke", "kk", "kkj", "kkj-cm", "kk-kz", "kl", "kln", "kln-ke", "kl-gl", "km", "km-kh", "kn", "kn-in", "ko", "kok", "kok-in", "ko-kp", "ko-kr", "ks", "ksb", "ksb-tz", "ksf", "ksf-cm", "ksh", "ksh-de", "ks-in", "ku", "ku-tr", "kw", "kw-gb", "ky", "ky-kg", "lag", "lag-tz", "lb", "lb-lu", "lg", "lg-ug", "lkt", "lkt-us", "ln", "ln-ao", "ln-cd", "ln-cf", "ln-cg", "lo", "lo-la", "lrc", "lrc-iq", "lrc-ir", "lt", "lt-lt", "lu", "luo", "luo-ke", "luy", "luy-ke", "lu-cd", "lv", "lv-lv", "mai", "mai-in", "mas", "mas-ke", "mas-tz", "mdf", "mdf-ru", "mer", "mer-ke", "mfe", "mfe-mu", "mg", "mgh", "mgh-mz", "mgo", "mgo-cm", "mg-mg", "mi", "mi-nz", "mk", "mk-mk", "ml", "ml-in", "mn", "mni", "mni-in", "mn-mn", "mr", "mr-in", "ms", "ms-bn", "ms-id", "ms-my", "ms-sg", "mt", "mt-mt", "mua", "mua-cm", "my", "my-mm", "mzn", "mzn-ir", "naq", "naq-na", "nb", "nb-no", "nb-sj", "nd", "nds", "nds-de", "nds-nl", "nd-zw", "ne", "ne-in", "ne-np", "nl", "nl-aw", "nl-be", "nl-bq", "nl-ch", "nl-cw", "nl-lu", "nl-nl", "nl-sr", "nl-sx", "nmg", "nmg-cm", "nn", "nnh", "nnh-cm", "nn-no", "no", "no-no", "nus", "nus-ss", "nyn", "nyn-ug", "oc", "oc-es", "oc-fr", "om", "om-et", "om-ke", "or", "or-in", "os", "os-ge", "os-ru", "pa", "pa-in", "pa-pk", "pcm", "pcm-ng", "pis", "pis-sb", "pl", "pl-pl", "prg", "prg-001", "ps", "ps-af", "ps-pk", "pt", "pt-ao", "pt-br", "pt-ch", "pt-cv", "pt-gq", "pt-gw", "pt-lu", "pt-mo", "pt-mz", "pt-pt", "pt-st", "pt-tl", "qu", "qu-bo", "qu-ec", "qu-pe", "raj", "raj-in", "rm", "rm-ch", "rn", "rn-bi", "ro", "rof", "rof-tz", "ro-md", "ro-ro", "ru", "ru-by", "ru-kg", "ru-kz", "ru-md", "ru-ru", "ru-ua", "rw", "rwk", "rwk-tz", "rw-rw", "sa", "sah", "sah-ru", "saq", "saq-ke", "sat", "sat-in", "sa-in", "sbp", "sbp-tz", "sc", "sc-it", "sd", "sd-in", "sd-pk", "se", "seh", "seh-mz", "ses", "ses-ml", "se-fi", "se-no", "se-se", "sg", "sg-cf", "shi", "shi-ma", "si", "si-lk", "sk", "sk-sk", "sl", "sl-si", "smn", "smn-fi", "sms", "sms-fi", "sn", "sn-zw", "so", "so-dj", "so-et", "so-ke", "so-so", "sq", "sq-al", "sq-mk", "sq-xk", "sr", "sr-ba", "sr-cs", "sr-me", "sr-rs", "sr-xk", "su", "su-id", "sv", "sv-ax", "sv-fi", "sv-se", "sw", "sw-cd", "sw-ke", "sw-tz", "sw-ug", "sy", "ta", "ta-in", "ta-lk", "ta-my", "ta-sg", "te", "teo", "teo-ke", "teo-ug", "te-in", "tg", "tg-tj", "th", "th-th", "ti", "ti-er", "ti-et", "tk", "tk-tm", "tl", "to", "tok", "tok-001", "to-to", "tr", "tr-cy", "tr-tr", "tt", "tt-ru", "twq", "twq-ne", "tzm", "tzm-ma", "ug", "ug-cn", "uk", "uk-ua", "ur", "ur-in", "ur-pk", "uz", "uz-af", "uz-uz", "vai", "vai-lr", "vi", "vi-vn", "vo", "vo-001", "vun", "vun-tz", "wae", "wae-ch", "wo", "wo-sn", "xh", "xh-za", "xog", "xog-ug", "yav", "yav-cm", "yo", "yo-bj", "yo-ng", "yrl", "yrl-br", "yrl-co", "yrl-ve", "yue", "yue-cn", "yue-hk", "zgh", "zgh-ma", "zh", "zh-cn", "zh-hans", "zh-hant", "zh-hk", "zh-mo", "zh-sg", "zh-tw", "zu", "zu-za"])
unless validator.valid?(language)
fail ArgumentError, "invalid value for \"language\", must be one of #{validator.allowable_values}."
end
@language = language
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] type Object to be assigned
def type=(type)
validator = EnumAttributeValidator.new('String', ["AB_EMAIL", "BATCH_EMAIL", "LOCALTIME_EMAIL", "AUTOMATED_AB_EMAIL", "BLOG_EMAIL", "BLOG_EMAIL_CHILD", "RSS_EMAIL", "RSS_EMAIL_CHILD", "RESUBSCRIBE_EMAIL", "OPTIN_EMAIL", "OPTIN_FOLLOWUP_EMAIL", "AUTOMATED_EMAIL", "FEEDBACK_CES_EMAIL", "FEEDBACK_CUSTOM_EMAIL", "FEEDBACK_CUSTOM_SURVEY_EMAIL", "FEEDBACK_NPS_EMAIL", "FOLLOWUP_EMAIL", "LEADFLOW_EMAIL", "SINGLE_SEND_API", "MARKETING_SINGLE_SEND_API", "SMTP_TOKEN", "TICKET_EMAIL", "MEMBERSHIP_REGISTRATION_EMAIL", "MEMBERSHIP_PASSWORD_SAVED_EMAIL", "MEMBERSHIP_PASSWORD_RESET_EMAIL", "MEMBERSHIP_EMAIL_VERIFICATION_EMAIL", "MEMBERSHIP_PASSWORDLESS_AUTH_EMAIL", "MEMBERSHIP_REGISTRATION_FOLLOW_UP_EMAIL", "MEMBERSHIP_OTP_LOGIN_EMAIL", "MEMBERSHIP_FOLLOW_UP_EMAIL", "MEMBERSHIP_VERIFICATION_EMAIL"])
unless validator.valid?(type)
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
end
@type = type
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] state Object to be assigned
def state=(state)
validator = EnumAttributeValidator.new('String', ["AUTOMATED", "AUTOMATED_DRAFT", "AUTOMATED_SENDING", "AUTOMATED_FOR_FORM", "AUTOMATED_FOR_FORM_BUFFER", "AUTOMATED_FOR_FORM_DRAFT", "AUTOMATED_FOR_FORM_LEGACY", "BLOG_EMAIL_DRAFT", "BLOG_EMAIL_PUBLISHED", "DRAFT", "DRAFT_AB", "DRAFT_AB_VARIANT", "ERROR", "LOSER_AB_VARIANT", "PAGE_STUB", "PRE_PROCESSING", "PROCESSING", "PUBLISHED", "PUBLISHED_AB", "PUBLISHED_AB_VARIANT", "PUBLISHED_OR_SCHEDULED", "RSS_TO_EMAIL_DRAFT", "RSS_TO_EMAIL_PUBLISHED", "SCHEDULED", "SCHEDULED_AB", "SCHEDULED_OR_PUBLISHED", "AUTOMATED_AB", "AUTOMATED_AB_VARIANT", "AUTOMATED_DRAFT_AB", "AUTOMATED_DRAFT_ABVARIANT", "AUTOMATED_LOSER_ABVARIANT"])
unless validator.valid?(state)
fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}."
end
@state = state
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
feedback_survey_id == o.feedback_survey_id &&
subject == o.subject &&
publish_date == o.publish_date &&
is_transactional == o.is_transactional &&
language == o.language &&
type == o.type &&
content == o.content &&
business_unit_id == o.business_unit_id &&
webversion == o.webversion &&
workflow_names == o.workflow_names &&
archived == o.archived &&
created_at == o.created_at &&
stats == o.stats &&
jitter_send_time == o.jitter_send_time &&
from == o.from &&
id == o.id &&
state == o.state &&
created_by_id == o.created_by_id &&
updated_at == o.updated_at &&
rss_data == o.rss_data &&
published_at == o.published_at &&
published_by_id == o.published_by_id &&
is_published == o.is_published &&
testing == o.testing &&
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | true |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/email_create_request.rb | lib/hubspot/codegen/marketing/emails/models/email_create_request.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Properties of a marketing email you can set when creating a marketing email.
class EmailCreateRequest
# The ID of the feedback survey linked to the email.
attr_accessor :feedback_survey_id
attr_accessor :rss_data
# The subject of the email.
attr_accessor :subject
attr_accessor :testing
# The date and time the email is scheduled for, in ISO8601 representation. This is only used in local time or scheduled emails.
attr_accessor :publish_date
attr_accessor :language
attr_accessor :business_unit_id
attr_accessor :content
attr_accessor :webversion
# Determines if the email is archived or not.
attr_accessor :archived
attr_accessor :subscription_details
# The active domain of the email.
attr_accessor :active_domain
# The name of the email, as displayed on the email dashboard.
attr_accessor :name
# The ID of the campaign this email is associated to.
attr_accessor :campaign
attr_accessor :from
attr_accessor :jitter_send_time
# The email state.
attr_accessor :state
attr_accessor :to
# The email subcategory.
attr_accessor :subcategory
# Determines whether the email will be sent immediately on publish.
attr_accessor :send_on_publish
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'feedback_survey_id' => :'feedbackSurveyId',
:'rss_data' => :'rssData',
:'subject' => :'subject',
:'testing' => :'testing',
:'publish_date' => :'publishDate',
:'language' => :'language',
:'business_unit_id' => :'businessUnitId',
:'content' => :'content',
:'webversion' => :'webversion',
:'archived' => :'archived',
:'subscription_details' => :'subscriptionDetails',
:'active_domain' => :'activeDomain',
:'name' => :'name',
:'campaign' => :'campaign',
:'from' => :'from',
:'jitter_send_time' => :'jitterSendTime',
:'state' => :'state',
:'to' => :'to',
:'subcategory' => :'subcategory',
:'send_on_publish' => :'sendOnPublish'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'feedback_survey_id' => :'String',
:'rss_data' => :'PublicRssEmailDetails',
:'subject' => :'String',
:'testing' => :'PublicEmailTestingDetails',
:'publish_date' => :'Time',
:'language' => :'String',
:'business_unit_id' => :'Integer',
:'content' => :'PublicEmailContent',
:'webversion' => :'PublicWebversionDetails',
:'archived' => :'Boolean',
:'subscription_details' => :'PublicEmailSubscriptionDetails',
:'active_domain' => :'String',
:'name' => :'String',
:'campaign' => :'String',
:'from' => :'PublicEmailFromDetails',
:'jitter_send_time' => :'Boolean',
:'state' => :'String',
:'to' => :'PublicEmailToDetails',
:'subcategory' => :'String',
:'send_on_publish' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::EmailCreateRequest` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::EmailCreateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'feedback_survey_id')
self.feedback_survey_id = attributes[:'feedback_survey_id']
end
if attributes.key?(:'rss_data')
self.rss_data = attributes[:'rss_data']
end
if attributes.key?(:'subject')
self.subject = attributes[:'subject']
end
if attributes.key?(:'testing')
self.testing = attributes[:'testing']
end
if attributes.key?(:'publish_date')
self.publish_date = attributes[:'publish_date']
end
if attributes.key?(:'language')
self.language = attributes[:'language']
end
if attributes.key?(:'business_unit_id')
self.business_unit_id = attributes[:'business_unit_id']
end
if attributes.key?(:'content')
self.content = attributes[:'content']
end
if attributes.key?(:'webversion')
self.webversion = attributes[:'webversion']
end
if attributes.key?(:'archived')
self.archived = attributes[:'archived']
end
if attributes.key?(:'subscription_details')
self.subscription_details = attributes[:'subscription_details']
end
if attributes.key?(:'active_domain')
self.active_domain = attributes[:'active_domain']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'campaign')
self.campaign = attributes[:'campaign']
end
if attributes.key?(:'from')
self.from = attributes[:'from']
end
if attributes.key?(:'jitter_send_time')
self.jitter_send_time = attributes[:'jitter_send_time']
end
if attributes.key?(:'state')
self.state = attributes[:'state']
end
if attributes.key?(:'to')
self.to = attributes[:'to']
end
if attributes.key?(:'subcategory')
self.subcategory = attributes[:'subcategory']
end
if attributes.key?(:'send_on_publish')
self.send_on_publish = attributes[:'send_on_publish']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
language_validator = EnumAttributeValidator.new('String', ["af", "af-na", "af-za", "agq", "agq-cm", "ak", "ak-gh", "am", "am-et", "ann", "ann-ng", "ar", "ar-001", "ar-ae", "ar-bh", "ar-dj", "ar-dz", "ar-eg", "ar-eh", "ar-er", "ar-il", "ar-iq", "ar-jo", "ar-km", "ar-kw", "ar-lb", "ar-ly", "ar-ma", "ar-mr", "ar-om", "ar-ps", "ar-qa", "ar-sa", "ar-sd", "ar-so", "ar-ss", "ar-sy", "ar-td", "ar-tn", "ar-ye", "as", "asa", "asa-tz", "ast", "ast-es", "as-in", "az", "az-az", "bas", "bas-cm", "be", "bem", "bem-zm", "bez", "bez-tz", "be-by", "bg", "bgc", "bgc-in", "bg-bg", "bho", "bho-in", "bm", "bm-ml", "bn", "bn-bd", "bn-in", "bo", "bo-cn", "bo-in", "br", "brx", "brx-in", "br-fr", "bs", "bs-ba", "ca", "ca-ad", "ca-es", "ca-fr", "ca-it", "ccp", "ccp-bd", "ccp-in", "ce", "ceb", "ceb-ph", "ce-ru", "cgg", "cgg-ug", "chr", "chr-us", "ckb", "ckb-iq", "ckb-ir", "cs", "cs-cz", "cu", "cu-ru", "cv", "cv-ru", "cy", "cy-gb", "da", "dav", "dav-ke", "da-dk", "da-gl", "de", "de-at", "de-be", "de-ch", "de-de", "de-gr", "de-it", "de-li", "de-lu", "dje", "dje-ne", "doi", "doi-in", "dsb", "dsb-de", "dua", "dua-cm", "dyo", "dyo-sn", "dz", "dz-bt", "ebu", "ebu-ke", "ee", "ee-gh", "ee-tg", "el", "el-cy", "el-gr", "en", "en-001", "en-150", "en-ae", "en-ag", "en-ai", "en-as", "en-at", "en-au", "en-bb", "en-be", "en-bi", "en-bm", "en-bs", "en-bw", "en-bz", "en-ca", "en-cc", "en-ch", "en-ck", "en-cm", "en-cn", "en-cx", "en-cy", "en-de", "en-dg", "en-dk", "en-dm", "en-ee", "en-er", "en-fi", "en-fj", "en-fk", "en-fm", "en-fr", "en-gb", "en-gd", "en-gg", "en-gh", "en-gi", "en-gm", "en-gu", "en-gy", "en-hk", "en-ie", "en-il", "en-im", "en-in", "en-io", "en-je", "en-jm", "en-ke", "en-ki", "en-kn", "en-ky", "en-lc", "en-lr", "en-ls", "en-lu", "en-mg", "en-mh", "en-mo", "en-mp", "en-ms", "en-mt", "en-mu", "en-mv", "en-mw", "en-mx", "en-my", "en-na", "en-nf", "en-ng", "en-nl", "en-nr", "en-nu", "en-nz", "en-pg", "en-ph", "en-pk", "en-pn", "en-pr", "en-pw", "en-rw", "en-sb", "en-sc", "en-sd", "en-se", "en-sg", "en-sh", "en-si", "en-sl", "en-ss", "en-sx", "en-sz", "en-tc", "en-tk", "en-to", "en-tt", "en-tv", "en-tz", "en-ug", "en-um", "en-us", "en-vc", "en-vg", "en-vi", "en-vu", "en-ws", "en-za", "en-zm", "en-zw", "eo", "eo-001", "es", "es-419", "es-ar", "es-bo", "es-br", "es-bz", "es-cl", "es-co", "es-cr", "es-cu", "es-do", "es-ea", "es-ec", "es-es", "es-gq", "es-gt", "es-hn", "es-ic", "es-mx", "es-ni", "es-pa", "es-pe", "es-ph", "es-pr", "es-py", "es-sv", "es-us", "es-uy", "es-ve", "et", "et-ee", "eu", "eu-es", "ewo", "ewo-cm", "fa", "fa-af", "fa-ir", "ff", "ff-bf", "ff-cm", "ff-gh", "ff-gm", "ff-gn", "ff-gw", "ff-lr", "ff-mr", "ff-ne", "ff-ng", "ff-sl", "ff-sn", "fi", "fil", "fil-ph", "fi-fi", "fo", "fo-dk", "fo-fo", "fr", "frr", "frr-de", "fr-be", "fr-bf", "fr-bi", "fr-bj", "fr-bl", "fr-ca", "fr-cd", "fr-cf", "fr-cg", "fr-ch", "fr-ci", "fr-cm", "fr-dj", "fr-dz", "fr-fr", "fr-ga", "fr-gf", "fr-gn", "fr-gp", "fr-gq", "fr-ht", "fr-km", "fr-lu", "fr-ma", "fr-mc", "fr-mf", "fr-mg", "fr-ml", "fr-mq", "fr-mr", "fr-mu", "fr-nc", "fr-ne", "fr-pf", "fr-pm", "fr-re", "fr-rw", "fr-sc", "fr-sn", "fr-sy", "fr-td", "fr-tg", "fr-tn", "fr-vu", "fr-wf", "fr-yt", "fur", "fur-it", "fy", "fy-nl", "ga", "ga-gb", "ga-ie", "gd", "gd-gb", "gl", "gl-es", "gsw", "gsw-ch", "gsw-fr", "gsw-li", "gu", "guz", "guz-ke", "gu-in", "gv", "gv-im", "ha", "haw", "haw-us", "ha-gh", "ha-ne", "ha-ng", "he", "hi", "hi-in", "hr", "hr-ba", "hr-hr", "hsb", "hsb-de", "hu", "hu-hu", "hy", "hy-am", "ia", "ia-001", "id", "ig", "ig-ng", "ii", "ii-cn", "id-id", "is", "is-is", "it", "it-ch", "it-it", "it-sm", "it-va", "he-il", "ja", "ja-jp", "jgo", "jgo-cm", "yi", "yi-001", "jmc", "jmc-tz", "jv", "jv-id", "ka", "kab", "kab-dz", "kam", "kam-ke", "ka-ge", "kde", "kde-tz", "kea", "kea-cv", "kgp", "kgp-br", "khq", "khq-ml", "ki", "ki-ke", "kk", "kkj", "kkj-cm", "kk-kz", "kl", "kln", "kln-ke", "kl-gl", "km", "km-kh", "kn", "kn-in", "ko", "kok", "kok-in", "ko-kp", "ko-kr", "ks", "ksb", "ksb-tz", "ksf", "ksf-cm", "ksh", "ksh-de", "ks-in", "ku", "ku-tr", "kw", "kw-gb", "ky", "ky-kg", "lag", "lag-tz", "lb", "lb-lu", "lg", "lg-ug", "lkt", "lkt-us", "ln", "ln-ao", "ln-cd", "ln-cf", "ln-cg", "lo", "lo-la", "lrc", "lrc-iq", "lrc-ir", "lt", "lt-lt", "lu", "luo", "luo-ke", "luy", "luy-ke", "lu-cd", "lv", "lv-lv", "mai", "mai-in", "mas", "mas-ke", "mas-tz", "mdf", "mdf-ru", "mer", "mer-ke", "mfe", "mfe-mu", "mg", "mgh", "mgh-mz", "mgo", "mgo-cm", "mg-mg", "mi", "mi-nz", "mk", "mk-mk", "ml", "ml-in", "mn", "mni", "mni-in", "mn-mn", "mr", "mr-in", "ms", "ms-bn", "ms-id", "ms-my", "ms-sg", "mt", "mt-mt", "mua", "mua-cm", "my", "my-mm", "mzn", "mzn-ir", "naq", "naq-na", "nb", "nb-no", "nb-sj", "nd", "nds", "nds-de", "nds-nl", "nd-zw", "ne", "ne-in", "ne-np", "nl", "nl-aw", "nl-be", "nl-bq", "nl-ch", "nl-cw", "nl-lu", "nl-nl", "nl-sr", "nl-sx", "nmg", "nmg-cm", "nn", "nnh", "nnh-cm", "nn-no", "no", "no-no", "nus", "nus-ss", "nyn", "nyn-ug", "oc", "oc-es", "oc-fr", "om", "om-et", "om-ke", "or", "or-in", "os", "os-ge", "os-ru", "pa", "pa-in", "pa-pk", "pcm", "pcm-ng", "pis", "pis-sb", "pl", "pl-pl", "prg", "prg-001", "ps", "ps-af", "ps-pk", "pt", "pt-ao", "pt-br", "pt-ch", "pt-cv", "pt-gq", "pt-gw", "pt-lu", "pt-mo", "pt-mz", "pt-pt", "pt-st", "pt-tl", "qu", "qu-bo", "qu-ec", "qu-pe", "raj", "raj-in", "rm", "rm-ch", "rn", "rn-bi", "ro", "rof", "rof-tz", "ro-md", "ro-ro", "ru", "ru-by", "ru-kg", "ru-kz", "ru-md", "ru-ru", "ru-ua", "rw", "rwk", "rwk-tz", "rw-rw", "sa", "sah", "sah-ru", "saq", "saq-ke", "sat", "sat-in", "sa-in", "sbp", "sbp-tz", "sc", "sc-it", "sd", "sd-in", "sd-pk", "se", "seh", "seh-mz", "ses", "ses-ml", "se-fi", "se-no", "se-se", "sg", "sg-cf", "shi", "shi-ma", "si", "si-lk", "sk", "sk-sk", "sl", "sl-si", "smn", "smn-fi", "sms", "sms-fi", "sn", "sn-zw", "so", "so-dj", "so-et", "so-ke", "so-so", "sq", "sq-al", "sq-mk", "sq-xk", "sr", "sr-ba", "sr-cs", "sr-me", "sr-rs", "sr-xk", "su", "su-id", "sv", "sv-ax", "sv-fi", "sv-se", "sw", "sw-cd", "sw-ke", "sw-tz", "sw-ug", "sy", "ta", "ta-in", "ta-lk", "ta-my", "ta-sg", "te", "teo", "teo-ke", "teo-ug", "te-in", "tg", "tg-tj", "th", "th-th", "ti", "ti-er", "ti-et", "tk", "tk-tm", "tl", "to", "tok", "tok-001", "to-to", "tr", "tr-cy", "tr-tr", "tt", "tt-ru", "twq", "twq-ne", "tzm", "tzm-ma", "ug", "ug-cn", "uk", "uk-ua", "ur", "ur-in", "ur-pk", "uz", "uz-af", "uz-uz", "vai", "vai-lr", "vi", "vi-vn", "vo", "vo-001", "vun", "vun-tz", "wae", "wae-ch", "wo", "wo-sn", "xh", "xh-za", "xog", "xog-ug", "yav", "yav-cm", "yo", "yo-bj", "yo-ng", "yrl", "yrl-br", "yrl-co", "yrl-ve", "yue", "yue-cn", "yue-hk", "zgh", "zgh-ma", "zh", "zh-cn", "zh-hans", "zh-hant", "zh-hk", "zh-mo", "zh-sg", "zh-tw", "zu", "zu-za"])
return false unless language_validator.valid?(@language)
return false if @name.nil?
state_validator = EnumAttributeValidator.new('String', ["AUTOMATED", "AUTOMATED_DRAFT", "AUTOMATED_SENDING", "AUTOMATED_FOR_FORM", "AUTOMATED_FOR_FORM_BUFFER", "AUTOMATED_FOR_FORM_DRAFT", "AUTOMATED_FOR_FORM_LEGACY", "BLOG_EMAIL_DRAFT", "BLOG_EMAIL_PUBLISHED", "DRAFT", "DRAFT_AB", "DRAFT_AB_VARIANT", "ERROR", "LOSER_AB_VARIANT", "PAGE_STUB", "PRE_PROCESSING", "PROCESSING", "PUBLISHED", "PUBLISHED_AB", "PUBLISHED_AB_VARIANT", "PUBLISHED_OR_SCHEDULED", "RSS_TO_EMAIL_DRAFT", "RSS_TO_EMAIL_PUBLISHED", "SCHEDULED", "SCHEDULED_AB", "SCHEDULED_OR_PUBLISHED", "AUTOMATED_AB", "AUTOMATED_AB_VARIANT", "AUTOMATED_DRAFT_AB", "AUTOMATED_DRAFT_ABVARIANT", "AUTOMATED_LOSER_ABVARIANT"])
return false unless state_validator.valid?(@state)
subcategory_validator = EnumAttributeValidator.new('String', ["ab_master", "ab_variant", "ab_loser_variant", "page_stub", "landing_page", "site_page", "legacy_page", "ab_master_site_page", "ab_variant_site_page", "ab_loser_variant_site_page", "performable_landing_page", "performable_landing_page_cutover", "staged_page", "automated", "automated_for_deal", "automated_for_form", "automated_for_form_legacy", "automated_for_form_buffer", "automated_for_form_draft", "rss_to_email", "rss_to_email_child", "blog_email", "blog_email_child", "optin_email", "optin_followup_email", "batch", "resubscribe_email", "unsubscribe_confirmation_email", "resubscribe_confirmation_email", "single_send_api", "marketing_single_send_api", "smtp_token", "localtime", "automated_for_ticket", "automated_for_leadflow", "automated_for_feedback_ces", "automated_for_feedback_nps", "automated_for_feedback_custom", "membership_registration", "membership_password_saved", "membership_password_reset", "membership_otp_login", "membership_passwordless_auth", "membership_email_verification", "membership_registration_follow_up", "membership_verification", "membership_follow_up", "ticket_closed_kickback_email", "ticket_opened_kickback_email", "automated_for_custom_survey", "discardable_stub", "normal_blog_post", "legacy_blog_post", "imported_blog_post", "automated_ab_master", "automated_ab_variant", "web_interactive", "portal_content", "page_instance_layout", "kb_article_instance_layout", "kb_listing", "kb_search_results", "kb_support_form", "case_study", "case_study_listing", "case_study_instance_layout", "UNKNOWN"])
return false unless subcategory_validator.valid?(@subcategory)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] language Object to be assigned
def language=(language)
validator = EnumAttributeValidator.new('String', ["af", "af-na", "af-za", "agq", "agq-cm", "ak", "ak-gh", "am", "am-et", "ann", "ann-ng", "ar", "ar-001", "ar-ae", "ar-bh", "ar-dj", "ar-dz", "ar-eg", "ar-eh", "ar-er", "ar-il", "ar-iq", "ar-jo", "ar-km", "ar-kw", "ar-lb", "ar-ly", "ar-ma", "ar-mr", "ar-om", "ar-ps", "ar-qa", "ar-sa", "ar-sd", "ar-so", "ar-ss", "ar-sy", "ar-td", "ar-tn", "ar-ye", "as", "asa", "asa-tz", "ast", "ast-es", "as-in", "az", "az-az", "bas", "bas-cm", "be", "bem", "bem-zm", "bez", "bez-tz", "be-by", "bg", "bgc", "bgc-in", "bg-bg", "bho", "bho-in", "bm", "bm-ml", "bn", "bn-bd", "bn-in", "bo", "bo-cn", "bo-in", "br", "brx", "brx-in", "br-fr", "bs", "bs-ba", "ca", "ca-ad", "ca-es", "ca-fr", "ca-it", "ccp", "ccp-bd", "ccp-in", "ce", "ceb", "ceb-ph", "ce-ru", "cgg", "cgg-ug", "chr", "chr-us", "ckb", "ckb-iq", "ckb-ir", "cs", "cs-cz", "cu", "cu-ru", "cv", "cv-ru", "cy", "cy-gb", "da", "dav", "dav-ke", "da-dk", "da-gl", "de", "de-at", "de-be", "de-ch", "de-de", "de-gr", "de-it", "de-li", "de-lu", "dje", "dje-ne", "doi", "doi-in", "dsb", "dsb-de", "dua", "dua-cm", "dyo", "dyo-sn", "dz", "dz-bt", "ebu", "ebu-ke", "ee", "ee-gh", "ee-tg", "el", "el-cy", "el-gr", "en", "en-001", "en-150", "en-ae", "en-ag", "en-ai", "en-as", "en-at", "en-au", "en-bb", "en-be", "en-bi", "en-bm", "en-bs", "en-bw", "en-bz", "en-ca", "en-cc", "en-ch", "en-ck", "en-cm", "en-cn", "en-cx", "en-cy", "en-de", "en-dg", "en-dk", "en-dm", "en-ee", "en-er", "en-fi", "en-fj", "en-fk", "en-fm", "en-fr", "en-gb", "en-gd", "en-gg", "en-gh", "en-gi", "en-gm", "en-gu", "en-gy", "en-hk", "en-ie", "en-il", "en-im", "en-in", "en-io", "en-je", "en-jm", "en-ke", "en-ki", "en-kn", "en-ky", "en-lc", "en-lr", "en-ls", "en-lu", "en-mg", "en-mh", "en-mo", "en-mp", "en-ms", "en-mt", "en-mu", "en-mv", "en-mw", "en-mx", "en-my", "en-na", "en-nf", "en-ng", "en-nl", "en-nr", "en-nu", "en-nz", "en-pg", "en-ph", "en-pk", "en-pn", "en-pr", "en-pw", "en-rw", "en-sb", "en-sc", "en-sd", "en-se", "en-sg", "en-sh", "en-si", "en-sl", "en-ss", "en-sx", "en-sz", "en-tc", "en-tk", "en-to", "en-tt", "en-tv", "en-tz", "en-ug", "en-um", "en-us", "en-vc", "en-vg", "en-vi", "en-vu", "en-ws", "en-za", "en-zm", "en-zw", "eo", "eo-001", "es", "es-419", "es-ar", "es-bo", "es-br", "es-bz", "es-cl", "es-co", "es-cr", "es-cu", "es-do", "es-ea", "es-ec", "es-es", "es-gq", "es-gt", "es-hn", "es-ic", "es-mx", "es-ni", "es-pa", "es-pe", "es-ph", "es-pr", "es-py", "es-sv", "es-us", "es-uy", "es-ve", "et", "et-ee", "eu", "eu-es", "ewo", "ewo-cm", "fa", "fa-af", "fa-ir", "ff", "ff-bf", "ff-cm", "ff-gh", "ff-gm", "ff-gn", "ff-gw", "ff-lr", "ff-mr", "ff-ne", "ff-ng", "ff-sl", "ff-sn", "fi", "fil", "fil-ph", "fi-fi", "fo", "fo-dk", "fo-fo", "fr", "frr", "frr-de", "fr-be", "fr-bf", "fr-bi", "fr-bj", "fr-bl", "fr-ca", "fr-cd", "fr-cf", "fr-cg", "fr-ch", "fr-ci", "fr-cm", "fr-dj", "fr-dz", "fr-fr", "fr-ga", "fr-gf", "fr-gn", "fr-gp", "fr-gq", "fr-ht", "fr-km", "fr-lu", "fr-ma", "fr-mc", "fr-mf", "fr-mg", "fr-ml", "fr-mq", "fr-mr", "fr-mu", "fr-nc", "fr-ne", "fr-pf", "fr-pm", "fr-re", "fr-rw", "fr-sc", "fr-sn", "fr-sy", "fr-td", "fr-tg", "fr-tn", "fr-vu", "fr-wf", "fr-yt", "fur", "fur-it", "fy", "fy-nl", "ga", "ga-gb", "ga-ie", "gd", "gd-gb", "gl", "gl-es", "gsw", "gsw-ch", "gsw-fr", "gsw-li", "gu", "guz", "guz-ke", "gu-in", "gv", "gv-im", "ha", "haw", "haw-us", "ha-gh", "ha-ne", "ha-ng", "he", "hi", "hi-in", "hr", "hr-ba", "hr-hr", "hsb", "hsb-de", "hu", "hu-hu", "hy", "hy-am", "ia", "ia-001", "id", "ig", "ig-ng", "ii", "ii-cn", "id-id", "is", "is-is", "it", "it-ch", "it-it", "it-sm", "it-va", "he-il", "ja", "ja-jp", "jgo", "jgo-cm", "yi", "yi-001", "jmc", "jmc-tz", "jv", "jv-id", "ka", "kab", "kab-dz", "kam", "kam-ke", "ka-ge", "kde", "kde-tz", "kea", "kea-cv", "kgp", "kgp-br", "khq", "khq-ml", "ki", "ki-ke", "kk", "kkj", "kkj-cm", "kk-kz", "kl", "kln", "kln-ke", "kl-gl", "km", "km-kh", "kn", "kn-in", "ko", "kok", "kok-in", "ko-kp", "ko-kr", "ks", "ksb", "ksb-tz", "ksf", "ksf-cm", "ksh", "ksh-de", "ks-in", "ku", "ku-tr", "kw", "kw-gb", "ky", "ky-kg", "lag", "lag-tz", "lb", "lb-lu", "lg", "lg-ug", "lkt", "lkt-us", "ln", "ln-ao", "ln-cd", "ln-cf", "ln-cg", "lo", "lo-la", "lrc", "lrc-iq", "lrc-ir", "lt", "lt-lt", "lu", "luo", "luo-ke", "luy", "luy-ke", "lu-cd", "lv", "lv-lv", "mai", "mai-in", "mas", "mas-ke", "mas-tz", "mdf", "mdf-ru", "mer", "mer-ke", "mfe", "mfe-mu", "mg", "mgh", "mgh-mz", "mgo", "mgo-cm", "mg-mg", "mi", "mi-nz", "mk", "mk-mk", "ml", "ml-in", "mn", "mni", "mni-in", "mn-mn", "mr", "mr-in", "ms", "ms-bn", "ms-id", "ms-my", "ms-sg", "mt", "mt-mt", "mua", "mua-cm", "my", "my-mm", "mzn", "mzn-ir", "naq", "naq-na", "nb", "nb-no", "nb-sj", "nd", "nds", "nds-de", "nds-nl", "nd-zw", "ne", "ne-in", "ne-np", "nl", "nl-aw", "nl-be", "nl-bq", "nl-ch", "nl-cw", "nl-lu", "nl-nl", "nl-sr", "nl-sx", "nmg", "nmg-cm", "nn", "nnh", "nnh-cm", "nn-no", "no", "no-no", "nus", "nus-ss", "nyn", "nyn-ug", "oc", "oc-es", "oc-fr", "om", "om-et", "om-ke", "or", "or-in", "os", "os-ge", "os-ru", "pa", "pa-in", "pa-pk", "pcm", "pcm-ng", "pis", "pis-sb", "pl", "pl-pl", "prg", "prg-001", "ps", "ps-af", "ps-pk", "pt", "pt-ao", "pt-br", "pt-ch", "pt-cv", "pt-gq", "pt-gw", "pt-lu", "pt-mo", "pt-mz", "pt-pt", "pt-st", "pt-tl", "qu", "qu-bo", "qu-ec", "qu-pe", "raj", "raj-in", "rm", "rm-ch", "rn", "rn-bi", "ro", "rof", "rof-tz", "ro-md", "ro-ro", "ru", "ru-by", "ru-kg", "ru-kz", "ru-md", "ru-ru", "ru-ua", "rw", "rwk", "rwk-tz", "rw-rw", "sa", "sah", "sah-ru", "saq", "saq-ke", "sat", "sat-in", "sa-in", "sbp", "sbp-tz", "sc", "sc-it", "sd", "sd-in", "sd-pk", "se", "seh", "seh-mz", "ses", "ses-ml", "se-fi", "se-no", "se-se", "sg", "sg-cf", "shi", "shi-ma", "si", "si-lk", "sk", "sk-sk", "sl", "sl-si", "smn", "smn-fi", "sms", "sms-fi", "sn", "sn-zw", "so", "so-dj", "so-et", "so-ke", "so-so", "sq", "sq-al", "sq-mk", "sq-xk", "sr", "sr-ba", "sr-cs", "sr-me", "sr-rs", "sr-xk", "su", "su-id", "sv", "sv-ax", "sv-fi", "sv-se", "sw", "sw-cd", "sw-ke", "sw-tz", "sw-ug", "sy", "ta", "ta-in", "ta-lk", "ta-my", "ta-sg", "te", "teo", "teo-ke", "teo-ug", "te-in", "tg", "tg-tj", "th", "th-th", "ti", "ti-er", "ti-et", "tk", "tk-tm", "tl", "to", "tok", "tok-001", "to-to", "tr", "tr-cy", "tr-tr", "tt", "tt-ru", "twq", "twq-ne", "tzm", "tzm-ma", "ug", "ug-cn", "uk", "uk-ua", "ur", "ur-in", "ur-pk", "uz", "uz-af", "uz-uz", "vai", "vai-lr", "vi", "vi-vn", "vo", "vo-001", "vun", "vun-tz", "wae", "wae-ch", "wo", "wo-sn", "xh", "xh-za", "xog", "xog-ug", "yav", "yav-cm", "yo", "yo-bj", "yo-ng", "yrl", "yrl-br", "yrl-co", "yrl-ve", "yue", "yue-cn", "yue-hk", "zgh", "zgh-ma", "zh", "zh-cn", "zh-hans", "zh-hant", "zh-hk", "zh-mo", "zh-sg", "zh-tw", "zu", "zu-za"])
unless validator.valid?(language)
fail ArgumentError, "invalid value for \"language\", must be one of #{validator.allowable_values}."
end
@language = language
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] state Object to be assigned
def state=(state)
validator = EnumAttributeValidator.new('String', ["AUTOMATED", "AUTOMATED_DRAFT", "AUTOMATED_SENDING", "AUTOMATED_FOR_FORM", "AUTOMATED_FOR_FORM_BUFFER", "AUTOMATED_FOR_FORM_DRAFT", "AUTOMATED_FOR_FORM_LEGACY", "BLOG_EMAIL_DRAFT", "BLOG_EMAIL_PUBLISHED", "DRAFT", "DRAFT_AB", "DRAFT_AB_VARIANT", "ERROR", "LOSER_AB_VARIANT", "PAGE_STUB", "PRE_PROCESSING", "PROCESSING", "PUBLISHED", "PUBLISHED_AB", "PUBLISHED_AB_VARIANT", "PUBLISHED_OR_SCHEDULED", "RSS_TO_EMAIL_DRAFT", "RSS_TO_EMAIL_PUBLISHED", "SCHEDULED", "SCHEDULED_AB", "SCHEDULED_OR_PUBLISHED", "AUTOMATED_AB", "AUTOMATED_AB_VARIANT", "AUTOMATED_DRAFT_AB", "AUTOMATED_DRAFT_ABVARIANT", "AUTOMATED_LOSER_ABVARIANT"])
unless validator.valid?(state)
fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}."
end
@state = state
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] subcategory Object to be assigned
def subcategory=(subcategory)
validator = EnumAttributeValidator.new('String', ["ab_master", "ab_variant", "ab_loser_variant", "page_stub", "landing_page", "site_page", "legacy_page", "ab_master_site_page", "ab_variant_site_page", "ab_loser_variant_site_page", "performable_landing_page", "performable_landing_page_cutover", "staged_page", "automated", "automated_for_deal", "automated_for_form", "automated_for_form_legacy", "automated_for_form_buffer", "automated_for_form_draft", "rss_to_email", "rss_to_email_child", "blog_email", "blog_email_child", "optin_email", "optin_followup_email", "batch", "resubscribe_email", "unsubscribe_confirmation_email", "resubscribe_confirmation_email", "single_send_api", "marketing_single_send_api", "smtp_token", "localtime", "automated_for_ticket", "automated_for_leadflow", "automated_for_feedback_ces", "automated_for_feedback_nps", "automated_for_feedback_custom", "membership_registration", "membership_password_saved", "membership_password_reset", "membership_otp_login", "membership_passwordless_auth", "membership_email_verification", "membership_registration_follow_up", "membership_verification", "membership_follow_up", "ticket_closed_kickback_email", "ticket_opened_kickback_email", "automated_for_custom_survey", "discardable_stub", "normal_blog_post", "legacy_blog_post", "imported_blog_post", "automated_ab_master", "automated_ab_variant", "web_interactive", "portal_content", "page_instance_layout", "kb_article_instance_layout", "kb_listing", "kb_search_results", "kb_support_form", "case_study", "case_study_listing", "case_study_instance_layout", "UNKNOWN"])
unless validator.valid?(subcategory)
fail ArgumentError, "invalid value for \"subcategory\", must be one of #{validator.allowable_values}."
end
@subcategory = subcategory
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
feedback_survey_id == o.feedback_survey_id &&
rss_data == o.rss_data &&
subject == o.subject &&
testing == o.testing &&
publish_date == o.publish_date &&
language == o.language &&
business_unit_id == o.business_unit_id &&
content == o.content &&
webversion == o.webversion &&
archived == o.archived &&
subscription_details == o.subscription_details &&
active_domain == o.active_domain &&
name == o.name &&
campaign == o.campaign &&
from == o.from &&
jitter_send_time == o.jitter_send_time &&
state == o.state &&
to == o.to &&
subcategory == o.subcategory &&
send_on_publish == o.send_on_publish
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[feedback_survey_id, rss_data, subject, testing, publish_date, language, business_unit_id, content, webversion, archived, subscription_details, active_domain, name, campaign, from, jitter_send_time, state, to, subcategory, send_on_publish].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | true |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/error_detail.rb | lib/hubspot/codegen/marketing/emails/models/error_detail.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
class ErrorDetail
# A specific category that contains more specific detail about the error
attr_accessor :sub_category
# The status code associated with the error detail
attr_accessor :code
# The name of the field or parameter in which the error was found.
attr_accessor :_in
# Context about the error condition
attr_accessor :context
# A human readable message describing the error along with remediation steps where appropriate
attr_accessor :message
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'code' => :'code',
:'_in' => :'in',
:'context' => :'context',
:'message' => :'message'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'String',
:'code' => :'String',
:'_in' => :'String',
:'context' => :'Hash<String, Array<String>>',
:'message' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::ErrorDetail` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::ErrorDetail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'code')
self.code = attributes[:'code']
end
if attributes.key?(:'_in')
self._in = attributes[:'_in']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @message.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
code == o.code &&
_in == o._in &&
context == o.context &&
message == o.message
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, code, _in, context, message].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_email_testing_details.rb | lib/hubspot/codegen/marketing/emails/models/public_email_testing_details.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# AB testing related data. This property is only returned for AB type emails.
class PublicEmailTestingDetails
# Version of the email that should be sent if the results are inconclusive after the test period, master or variant.
attr_accessor :ab_sampling_default
# Version of the email that should be sent if there are too few recipients to conduct an AB test.
attr_accessor :ab_sample_size_default
# Status of the AB test.
attr_accessor :ab_status
# The size of your test group.
attr_accessor :ab_test_percentage
# Time limit on gathering test results. After this time is up, the winning version will be sent to the remaining contacts.
attr_accessor :hours_to_wait
# The ID of the AB test.
attr_accessor :test_id
# Metric to determine the version that will be sent to the remaining contacts.
attr_accessor :ab_success_metric
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'ab_sampling_default' => :'abSamplingDefault',
:'ab_sample_size_default' => :'abSampleSizeDefault',
:'ab_status' => :'abStatus',
:'ab_test_percentage' => :'abTestPercentage',
:'hours_to_wait' => :'hoursToWait',
:'test_id' => :'testId',
:'ab_success_metric' => :'abSuccessMetric'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'ab_sampling_default' => :'String',
:'ab_sample_size_default' => :'String',
:'ab_status' => :'String',
:'ab_test_percentage' => :'Integer',
:'hours_to_wait' => :'Integer',
:'test_id' => :'String',
:'ab_success_metric' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicEmailTestingDetails` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicEmailTestingDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'ab_sampling_default')
self.ab_sampling_default = attributes[:'ab_sampling_default']
end
if attributes.key?(:'ab_sample_size_default')
self.ab_sample_size_default = attributes[:'ab_sample_size_default']
end
if attributes.key?(:'ab_status')
self.ab_status = attributes[:'ab_status']
end
if attributes.key?(:'ab_test_percentage')
self.ab_test_percentage = attributes[:'ab_test_percentage']
end
if attributes.key?(:'hours_to_wait')
self.hours_to_wait = attributes[:'hours_to_wait']
end
if attributes.key?(:'test_id')
self.test_id = attributes[:'test_id']
end
if attributes.key?(:'ab_success_metric')
self.ab_success_metric = attributes[:'ab_success_metric']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
ab_sampling_default_validator = EnumAttributeValidator.new('String', ["master", "variant", "loser_variant", "mab_master", "mab_variant", "automated_master", "automated_variant", "automated_loser_variant"])
return false unless ab_sampling_default_validator.valid?(@ab_sampling_default)
ab_sample_size_default_validator = EnumAttributeValidator.new('String', ["master", "variant", "loser_variant", "mab_master", "mab_variant", "automated_master", "automated_variant", "automated_loser_variant"])
return false unless ab_sample_size_default_validator.valid?(@ab_sample_size_default)
ab_status_validator = EnumAttributeValidator.new('String', ["master", "variant", "loser_variant", "mab_master", "mab_variant", "automated_master", "automated_variant", "automated_loser_variant"])
return false unless ab_status_validator.valid?(@ab_status)
ab_success_metric_validator = EnumAttributeValidator.new('String', ["CLICKS_BY_OPENS", "CLICKS_BY_DELIVERED", "OPENS_BY_DELIVERED"])
return false unless ab_success_metric_validator.valid?(@ab_success_metric)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] ab_sampling_default Object to be assigned
def ab_sampling_default=(ab_sampling_default)
validator = EnumAttributeValidator.new('String', ["master", "variant", "loser_variant", "mab_master", "mab_variant", "automated_master", "automated_variant", "automated_loser_variant"])
unless validator.valid?(ab_sampling_default)
fail ArgumentError, "invalid value for \"ab_sampling_default\", must be one of #{validator.allowable_values}."
end
@ab_sampling_default = ab_sampling_default
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] ab_sample_size_default Object to be assigned
def ab_sample_size_default=(ab_sample_size_default)
validator = EnumAttributeValidator.new('String', ["master", "variant", "loser_variant", "mab_master", "mab_variant", "automated_master", "automated_variant", "automated_loser_variant"])
unless validator.valid?(ab_sample_size_default)
fail ArgumentError, "invalid value for \"ab_sample_size_default\", must be one of #{validator.allowable_values}."
end
@ab_sample_size_default = ab_sample_size_default
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] ab_status Object to be assigned
def ab_status=(ab_status)
validator = EnumAttributeValidator.new('String', ["master", "variant", "loser_variant", "mab_master", "mab_variant", "automated_master", "automated_variant", "automated_loser_variant"])
unless validator.valid?(ab_status)
fail ArgumentError, "invalid value for \"ab_status\", must be one of #{validator.allowable_values}."
end
@ab_status = ab_status
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] ab_success_metric Object to be assigned
def ab_success_metric=(ab_success_metric)
validator = EnumAttributeValidator.new('String', ["CLICKS_BY_OPENS", "CLICKS_BY_DELIVERED", "OPENS_BY_DELIVERED"])
unless validator.valid?(ab_success_metric)
fail ArgumentError, "invalid value for \"ab_success_metric\", must be one of #{validator.allowable_values}."
end
@ab_success_metric = ab_success_metric
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
ab_sampling_default == o.ab_sampling_default &&
ab_sample_size_default == o.ab_sample_size_default &&
ab_status == o.ab_status &&
ab_test_percentage == o.ab_test_percentage &&
hours_to_wait == o.hours_to_wait &&
test_id == o.test_id &&
ab_success_metric == o.ab_success_metric
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[ab_sampling_default, ab_sample_size_default, ab_status, ab_test_percentage, hours_to_wait, test_id, ab_success_metric].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_webversion_details.rb | lib/hubspot/codegen/marketing/emails/models/public_webversion_details.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
class PublicWebversionDetails
#
attr_accessor :domain
#
attr_accessor :redirect_to_page_id
attr_accessor :is_page_redirected
#
attr_accessor :redirect_to_url
#
attr_accessor :title
#
attr_accessor :meta_description
attr_accessor :page_expiry_enabled
#
attr_accessor :slug
attr_accessor :url
#
attr_accessor :expires_at
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'domain' => :'domain',
:'redirect_to_page_id' => :'redirectToPageId',
:'is_page_redirected' => :'isPageRedirected',
:'redirect_to_url' => :'redirectToUrl',
:'title' => :'title',
:'meta_description' => :'metaDescription',
:'page_expiry_enabled' => :'pageExpiryEnabled',
:'slug' => :'slug',
:'url' => :'url',
:'expires_at' => :'expiresAt'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'domain' => :'String',
:'redirect_to_page_id' => :'String',
:'is_page_redirected' => :'Boolean',
:'redirect_to_url' => :'String',
:'title' => :'String',
:'meta_description' => :'String',
:'page_expiry_enabled' => :'Boolean',
:'slug' => :'String',
:'url' => :'String',
:'expires_at' => :'Time'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicWebversionDetails` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicWebversionDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'domain')
self.domain = attributes[:'domain']
end
if attributes.key?(:'redirect_to_page_id')
self.redirect_to_page_id = attributes[:'redirect_to_page_id']
end
if attributes.key?(:'is_page_redirected')
self.is_page_redirected = attributes[:'is_page_redirected']
end
if attributes.key?(:'redirect_to_url')
self.redirect_to_url = attributes[:'redirect_to_url']
end
if attributes.key?(:'title')
self.title = attributes[:'title']
end
if attributes.key?(:'meta_description')
self.meta_description = attributes[:'meta_description']
end
if attributes.key?(:'page_expiry_enabled')
self.page_expiry_enabled = attributes[:'page_expiry_enabled']
end
if attributes.key?(:'slug')
self.slug = attributes[:'slug']
end
if attributes.key?(:'url')
self.url = attributes[:'url']
end
if attributes.key?(:'expires_at')
self.expires_at = attributes[:'expires_at']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
domain == o.domain &&
redirect_to_page_id == o.redirect_to_page_id &&
is_page_redirected == o.is_page_redirected &&
redirect_to_url == o.redirect_to_url &&
title == o.title &&
meta_description == o.meta_description &&
page_expiry_enabled == o.page_expiry_enabled &&
slug == o.slug &&
url == o.url &&
expires_at == o.expires_at
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[domain, redirect_to_page_id, is_page_redirected, redirect_to_url, title, meta_description, page_expiry_enabled, slug, url, expires_at].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_email_to_details.rb | lib/hubspot/codegen/marketing/emails/models/public_email_to_details.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Data structure representing the to fields of the email.
class PublicEmailToDetails
attr_accessor :contact_ils_lists
#
attr_accessor :limit_send_frequency
#
attr_accessor :suppress_graymail
attr_accessor :contact_ids
attr_accessor :contact_lists
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'contact_ils_lists' => :'contactIlsLists',
:'limit_send_frequency' => :'limitSendFrequency',
:'suppress_graymail' => :'suppressGraymail',
:'contact_ids' => :'contactIds',
:'contact_lists' => :'contactLists'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'contact_ils_lists' => :'PublicEmailRecipients',
:'limit_send_frequency' => :'Boolean',
:'suppress_graymail' => :'Boolean',
:'contact_ids' => :'PublicEmailRecipients',
:'contact_lists' => :'PublicEmailRecipients'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicEmailToDetails` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicEmailToDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'contact_ils_lists')
self.contact_ils_lists = attributes[:'contact_ils_lists']
end
if attributes.key?(:'limit_send_frequency')
self.limit_send_frequency = attributes[:'limit_send_frequency']
end
if attributes.key?(:'suppress_graymail')
self.suppress_graymail = attributes[:'suppress_graymail']
end
if attributes.key?(:'contact_ids')
self.contact_ids = attributes[:'contact_ids']
end
if attributes.key?(:'contact_lists')
self.contact_lists = attributes[:'contact_lists']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
contact_ils_lists == o.contact_ils_lists &&
limit_send_frequency == o.limit_send_frequency &&
suppress_graymail == o.suppress_graymail &&
contact_ids == o.contact_ids &&
contact_lists == o.contact_lists
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[contact_ils_lists, limit_send_frequency, suppress_graymail, contact_ids, contact_lists].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/content_clone_request_v_next.rb | lib/hubspot/codegen/marketing/emails/models/content_clone_request_v_next.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Request body object for cloning marketing emails.
class ContentCloneRequestVNext
# Name of the cloned email.
attr_accessor :clone_name
# ID of the email to be cloned.
attr_accessor :id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'clone_name' => :'cloneName',
:'id' => :'id'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'clone_name' => :'String',
:'id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::ContentCloneRequestVNext` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::ContentCloneRequestVNext`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'clone_name')
self.clone_name = attributes[:'clone_name']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @id.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
clone_name == o.clone_name &&
id == o.id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[clone_name, id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/forward_paging.rb | lib/hubspot/codegen/marketing/emails/models/forward_paging.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
class ForwardPaging
attr_accessor :_next
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'_next' => :'next'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'_next' => :'NextPage'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::ForwardPaging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::ForwardPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'_next')
self._next = attributes[:'_next']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
_next == o._next
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[_next].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_button_style_settings.rb | lib/hubspot/codegen/marketing/emails/models/public_button_style_settings.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
class PublicButtonStyleSettings
attr_accessor :background_color
attr_accessor :font_style
attr_accessor :corner_radius
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'background_color' => :'backgroundColor',
:'font_style' => :'fontStyle',
:'corner_radius' => :'cornerRadius'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'background_color' => :'Object',
:'font_style' => :'PublicFontStyle',
:'corner_radius' => :'Integer'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicButtonStyleSettings` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicButtonStyleSettings`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'background_color')
self.background_color = attributes[:'background_color']
end
if attributes.key?(:'font_style')
self.font_style = attributes[:'font_style']
end
if attributes.key?(:'corner_radius')
self.corner_radius = attributes[:'corner_radius']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
background_color == o.background_color &&
font_style == o.font_style &&
corner_radius == o.corner_radius
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[background_color, font_style, corner_radius].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_font_style.rb | lib/hubspot/codegen/marketing/emails/models/public_font_style.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
class PublicFontStyle
attr_accessor :size
attr_accessor :color
attr_accessor :underline
attr_accessor :bold
attr_accessor :italic
attr_accessor :font
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'size' => :'size',
:'color' => :'color',
:'underline' => :'underline',
:'bold' => :'bold',
:'italic' => :'italic',
:'font' => :'font'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'size' => :'Integer',
:'color' => :'String',
:'underline' => :'Boolean',
:'bold' => :'Boolean',
:'italic' => :'Boolean',
:'font' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicFontStyle` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicFontStyle`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'size')
self.size = attributes[:'size']
end
if attributes.key?(:'color')
self.color = attributes[:'color']
end
if attributes.key?(:'underline')
self.underline = attributes[:'underline']
end
if attributes.key?(:'bold')
self.bold = attributes[:'bold']
end
if attributes.key?(:'italic')
self.italic = attributes[:'italic']
end
if attributes.key?(:'font')
self.font = attributes[:'font']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
size == o.size &&
color == o.color &&
underline == o.underline &&
bold == o.bold &&
italic == o.italic &&
font == o.font
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[size, color, underline, bold, italic, font].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_email_recipients.rb | lib/hubspot/codegen/marketing/emails/models/public_email_recipients.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Data structure representing lists of IDs that should be included and excluded.
class PublicEmailRecipients
# Included IDs.
attr_accessor :include
# Excluded IDs.
attr_accessor :exclude
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'include' => :'include',
:'exclude' => :'exclude'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'include' => :'Array<String>',
:'exclude' => :'Array<String>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicEmailRecipients` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicEmailRecipients`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'include')
if (value = attributes[:'include']).is_a?(Array)
self.include = value
end
end
if attributes.key?(:'exclude')
if (value = attributes[:'exclude']).is_a?(Array)
self.exclude = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
include == o.include &&
exclude == o.exclude
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[include, exclude].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/version_public_email.rb | lib/hubspot/codegen/marketing/emails/models/version_public_email.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Model definition for a marketing email version. Contains metadata describing the version of the marketing email. It can be used to view edit history of a marketing email.
class VersionPublicEmail
# ID of this marketing email version.
attr_accessor :id
attr_accessor :user
attr_accessor :object
attr_accessor :updated_at
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'user' => :'user',
:'object' => :'object',
:'updated_at' => :'updatedAt'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'id' => :'String',
:'user' => :'VersionUser',
:'object' => :'PublicEmail',
:'updated_at' => :'Time'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::VersionPublicEmail` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::VersionPublicEmail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'user')
self.user = attributes[:'user']
end
if attributes.key?(:'object')
self.object = attributes[:'object']
end
if attributes.key?(:'updated_at')
self.updated_at = attributes[:'updated_at']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @user.nil?
invalid_properties.push('invalid value for "user", user cannot be nil.')
end
if @object.nil?
invalid_properties.push('invalid value for "object", object cannot be nil.')
end
if @updated_at.nil?
invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @id.nil?
return false if @user.nil?
return false if @object.nil?
return false if @updated_at.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
id == o.id &&
user == o.user &&
object == o.object &&
updated_at == o.updated_at
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[id, user, object, updated_at].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_divider_style_settings.rb | lib/hubspot/codegen/marketing/emails/models/public_divider_style_settings.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
class PublicDividerStyleSettings
attr_accessor :color
attr_accessor :line_type
attr_accessor :height
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'color' => :'color',
:'line_type' => :'lineType',
:'height' => :'height'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'color' => :'Object',
:'line_type' => :'String',
:'height' => :'Integer'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicDividerStyleSettings` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicDividerStyleSettings`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'color')
self.color = attributes[:'color']
end
if attributes.key?(:'line_type')
self.line_type = attributes[:'line_type']
end
if attributes.key?(:'height')
self.height = attributes[:'height']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
color == o.color &&
line_type == o.line_type &&
height == o.height
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[color, line_type, height].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/interval.rb | lib/hubspot/codegen/marketing/emails/models/interval.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
class Interval
attr_accessor :start
attr_accessor :_end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'start' => :'start',
:'_end' => :'end'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'start' => :'Time',
:'_end' => :'Time'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::Interval` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::Interval`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'start')
self.start = attributes[:'start']
end
if attributes.key?(:'_end')
self._end = attributes[:'_end']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @start.nil?
invalid_properties.push('invalid value for "start", start cannot be nil.')
end
if @_end.nil?
invalid_properties.push('invalid value for "_end", _end cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @start.nil?
return false if @_end.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
start == o.start &&
_end == o._end
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[start, _end].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/email_statistics_data.rb | lib/hubspot/codegen/marketing/emails/models/email_statistics_data.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
class EmailStatisticsData
# Statistics by device.
attr_accessor :device_breakdown
# Number of emails that were dropped and bounced.
attr_accessor :qualifier_stats
# Counters like number of `sent`, `open` or `delivered`.
attr_accessor :counters
# Ratios like `openratio` or `clickratio`
attr_accessor :ratios
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'device_breakdown' => :'deviceBreakdown',
:'qualifier_stats' => :'qualifierStats',
:'counters' => :'counters',
:'ratios' => :'ratios'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'device_breakdown' => :'Hash<String, Hash<String, Integer>>',
:'qualifier_stats' => :'Hash<String, Hash<String, Integer>>',
:'counters' => :'Hash<String, Integer>',
:'ratios' => :'Hash<String, Float>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::EmailStatisticsData` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::EmailStatisticsData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'device_breakdown')
if (value = attributes[:'device_breakdown']).is_a?(Hash)
self.device_breakdown = value
end
end
if attributes.key?(:'qualifier_stats')
if (value = attributes[:'qualifier_stats']).is_a?(Hash)
self.qualifier_stats = value
end
end
if attributes.key?(:'counters')
if (value = attributes[:'counters']).is_a?(Hash)
self.counters = value
end
end
if attributes.key?(:'ratios')
if (value = attributes[:'ratios']).is_a?(Hash)
self.ratios = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @device_breakdown.nil?
invalid_properties.push('invalid value for "device_breakdown", device_breakdown cannot be nil.')
end
if @qualifier_stats.nil?
invalid_properties.push('invalid value for "qualifier_stats", qualifier_stats cannot be nil.')
end
if @counters.nil?
invalid_properties.push('invalid value for "counters", counters cannot be nil.')
end
if @ratios.nil?
invalid_properties.push('invalid value for "ratios", ratios cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @device_breakdown.nil?
return false if @qualifier_stats.nil?
return false if @counters.nil?
return false if @ratios.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
device_breakdown == o.device_breakdown &&
qualifier_stats == o.qualifier_stats &&
counters == o.counters &&
ratios == o.ratios
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[device_breakdown, qualifier_stats, counters, ratios].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/email_statistic_interval.rb | lib/hubspot/codegen/marketing/emails/models/email_statistic_interval.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
class EmailStatisticInterval
attr_accessor :interval
attr_accessor :aggregations
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'interval' => :'interval',
:'aggregations' => :'aggregations'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'interval' => :'Interval',
:'aggregations' => :'EmailStatisticsData'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::EmailStatisticInterval` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::EmailStatisticInterval`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'interval')
self.interval = attributes[:'interval']
end
if attributes.key?(:'aggregations')
self.aggregations = attributes[:'aggregations']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
interval == o.interval &&
aggregations == o.aggregations
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[interval, aggregations].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/collection_response_with_total_public_email_forward_paging.rb | lib/hubspot/codegen/marketing/emails/models/collection_response_with_total_public_email_forward_paging.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Response object for collections of marketing emails with pagination information.
class CollectionResponseWithTotalPublicEmailForwardPaging
# Total number of content emails.
attr_accessor :total
attr_accessor :paging
# Collection of emails.
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'total' => :'total',
:'paging' => :'paging',
:'results' => :'results'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'total' => :'Integer',
:'paging' => :'ForwardPaging',
:'results' => :'Array<PublicEmail>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::CollectionResponseWithTotalPublicEmailForwardPaging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::CollectionResponseWithTotalPublicEmailForwardPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'total')
self.total = attributes[:'total']
end
if attributes.key?(:'paging')
self.paging = attributes[:'paging']
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @total.nil?
invalid_properties.push('invalid value for "total", total cannot be nil.')
end
if @results.nil?
invalid_properties.push('invalid value for "results", results cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @total.nil?
return false if @results.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
total == o.total &&
paging == o.paging &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[total, paging, results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/error.rb | lib/hubspot/codegen/marketing/emails/models/error.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
class Error
# A specific category that contains more specific detail about the error
attr_accessor :sub_category
# Context about the error condition
attr_accessor :context
# A unique identifier for the request. Include this value with any error reports or support tickets
attr_accessor :correlation_id
# A map of link names to associated URIs containing documentation about the error or recommended remediation steps
attr_accessor :links
# A human readable message describing the error along with remediation steps where appropriate
attr_accessor :message
# The error category
attr_accessor :category
# further information about the error
attr_accessor :errors
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'context' => :'context',
:'correlation_id' => :'correlationId',
:'links' => :'links',
:'message' => :'message',
:'category' => :'category',
:'errors' => :'errors'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'String',
:'context' => :'Hash<String, Array<String>>',
:'correlation_id' => :'String',
:'links' => :'Hash<String, String>',
:'message' => :'String',
:'category' => :'String',
:'errors' => :'Array<ErrorDetail>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::Error` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::Error`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'correlation_id')
self.correlation_id = attributes[:'correlation_id']
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
if attributes.key?(:'category')
self.category = attributes[:'category']
end
if attributes.key?(:'errors')
if (value = attributes[:'errors']).is_a?(Array)
self.errors = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @correlation_id.nil?
invalid_properties.push('invalid value for "correlation_id", correlation_id cannot be nil.')
end
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
if @category.nil?
invalid_properties.push('invalid value for "category", category cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @correlation_id.nil?
return false if @message.nil?
return false if @category.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
context == o.context &&
correlation_id == o.correlation_id &&
links == o.links &&
message == o.message &&
category == o.category &&
errors == o.errors
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, context, correlation_id, links, message, category, errors].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_email_from_details.rb | lib/hubspot/codegen/marketing/emails/models/public_email_from_details.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Data structure representing the from fields on the email.
class PublicEmailFromDetails
# The reply to recipients will see.
attr_accessor :custom_reply_to
# The name recipients will see.
attr_accessor :from_name
# The from address and reply to email address (if no customReplyTo defined) recipients will see.
attr_accessor :reply_to
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'custom_reply_to' => :'customReplyTo',
:'from_name' => :'fromName',
:'reply_to' => :'replyTo'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'custom_reply_to' => :'String',
:'from_name' => :'String',
:'reply_to' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicEmailFromDetails` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicEmailFromDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'custom_reply_to')
self.custom_reply_to = attributes[:'custom_reply_to']
end
if attributes.key?(:'from_name')
self.from_name = attributes[:'from_name']
end
if attributes.key?(:'reply_to')
self.reply_to = attributes[:'reply_to']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
custom_reply_to == o.custom_reply_to &&
from_name == o.from_name &&
reply_to == o.reply_to
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[custom_reply_to, from_name, reply_to].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/email_update_request.rb | lib/hubspot/codegen/marketing/emails/models/email_update_request.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Properties of a marketing email you can update via the API.
class EmailUpdateRequest
attr_accessor :rss_data
# The subject of the email.
attr_accessor :subject
attr_accessor :testing
# The date and time the email is scheduled for, in ISO8601 representation. This is only used in local time or scheduled emails.
attr_accessor :publish_date
attr_accessor :language
attr_accessor :business_unit_id
attr_accessor :content
attr_accessor :webversion
# Determines if the email is archived or not.
attr_accessor :archived
attr_accessor :subscription_details
# The active domain of the email.
attr_accessor :active_domain
# The name of the email, as displayed on the email dashboard.
attr_accessor :name
# The ID of the campaign this email is associated to.
attr_accessor :campaign
attr_accessor :from
attr_accessor :jitter_send_time
# The email state.
attr_accessor :state
attr_accessor :to
# The email subcategory.
attr_accessor :subcategory
# Determines whether the email will be sent immediately on publish.
attr_accessor :send_on_publish
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'rss_data' => :'rssData',
:'subject' => :'subject',
:'testing' => :'testing',
:'publish_date' => :'publishDate',
:'language' => :'language',
:'business_unit_id' => :'businessUnitId',
:'content' => :'content',
:'webversion' => :'webversion',
:'archived' => :'archived',
:'subscription_details' => :'subscriptionDetails',
:'active_domain' => :'activeDomain',
:'name' => :'name',
:'campaign' => :'campaign',
:'from' => :'from',
:'jitter_send_time' => :'jitterSendTime',
:'state' => :'state',
:'to' => :'to',
:'subcategory' => :'subcategory',
:'send_on_publish' => :'sendOnPublish'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'rss_data' => :'PublicRssEmailDetails',
:'subject' => :'String',
:'testing' => :'PublicEmailTestingDetails',
:'publish_date' => :'Time',
:'language' => :'String',
:'business_unit_id' => :'Integer',
:'content' => :'PublicEmailContent',
:'webversion' => :'PublicWebversionDetails',
:'archived' => :'Boolean',
:'subscription_details' => :'PublicEmailSubscriptionDetails',
:'active_domain' => :'String',
:'name' => :'String',
:'campaign' => :'String',
:'from' => :'PublicEmailFromDetails',
:'jitter_send_time' => :'Boolean',
:'state' => :'String',
:'to' => :'PublicEmailToDetails',
:'subcategory' => :'String',
:'send_on_publish' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::EmailUpdateRequest` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::EmailUpdateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'rss_data')
self.rss_data = attributes[:'rss_data']
end
if attributes.key?(:'subject')
self.subject = attributes[:'subject']
end
if attributes.key?(:'testing')
self.testing = attributes[:'testing']
end
if attributes.key?(:'publish_date')
self.publish_date = attributes[:'publish_date']
end
if attributes.key?(:'language')
self.language = attributes[:'language']
end
if attributes.key?(:'business_unit_id')
self.business_unit_id = attributes[:'business_unit_id']
end
if attributes.key?(:'content')
self.content = attributes[:'content']
end
if attributes.key?(:'webversion')
self.webversion = attributes[:'webversion']
end
if attributes.key?(:'archived')
self.archived = attributes[:'archived']
end
if attributes.key?(:'subscription_details')
self.subscription_details = attributes[:'subscription_details']
end
if attributes.key?(:'active_domain')
self.active_domain = attributes[:'active_domain']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'campaign')
self.campaign = attributes[:'campaign']
end
if attributes.key?(:'from')
self.from = attributes[:'from']
end
if attributes.key?(:'jitter_send_time')
self.jitter_send_time = attributes[:'jitter_send_time']
end
if attributes.key?(:'state')
self.state = attributes[:'state']
end
if attributes.key?(:'to')
self.to = attributes[:'to']
end
if attributes.key?(:'subcategory')
self.subcategory = attributes[:'subcategory']
end
if attributes.key?(:'send_on_publish')
self.send_on_publish = attributes[:'send_on_publish']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
language_validator = EnumAttributeValidator.new('String', ["af", "af-na", "af-za", "agq", "agq-cm", "ak", "ak-gh", "am", "am-et", "ann", "ann-ng", "ar", "ar-001", "ar-ae", "ar-bh", "ar-dj", "ar-dz", "ar-eg", "ar-eh", "ar-er", "ar-il", "ar-iq", "ar-jo", "ar-km", "ar-kw", "ar-lb", "ar-ly", "ar-ma", "ar-mr", "ar-om", "ar-ps", "ar-qa", "ar-sa", "ar-sd", "ar-so", "ar-ss", "ar-sy", "ar-td", "ar-tn", "ar-ye", "as", "asa", "asa-tz", "ast", "ast-es", "as-in", "az", "az-az", "bas", "bas-cm", "be", "bem", "bem-zm", "bez", "bez-tz", "be-by", "bg", "bgc", "bgc-in", "bg-bg", "bho", "bho-in", "bm", "bm-ml", "bn", "bn-bd", "bn-in", "bo", "bo-cn", "bo-in", "br", "brx", "brx-in", "br-fr", "bs", "bs-ba", "ca", "ca-ad", "ca-es", "ca-fr", "ca-it", "ccp", "ccp-bd", "ccp-in", "ce", "ceb", "ceb-ph", "ce-ru", "cgg", "cgg-ug", "chr", "chr-us", "ckb", "ckb-iq", "ckb-ir", "cs", "cs-cz", "cu", "cu-ru", "cv", "cv-ru", "cy", "cy-gb", "da", "dav", "dav-ke", "da-dk", "da-gl", "de", "de-at", "de-be", "de-ch", "de-de", "de-gr", "de-it", "de-li", "de-lu", "dje", "dje-ne", "doi", "doi-in", "dsb", "dsb-de", "dua", "dua-cm", "dyo", "dyo-sn", "dz", "dz-bt", "ebu", "ebu-ke", "ee", "ee-gh", "ee-tg", "el", "el-cy", "el-gr", "en", "en-001", "en-150", "en-ae", "en-ag", "en-ai", "en-as", "en-at", "en-au", "en-bb", "en-be", "en-bi", "en-bm", "en-bs", "en-bw", "en-bz", "en-ca", "en-cc", "en-ch", "en-ck", "en-cm", "en-cn", "en-cx", "en-cy", "en-de", "en-dg", "en-dk", "en-dm", "en-ee", "en-er", "en-fi", "en-fj", "en-fk", "en-fm", "en-fr", "en-gb", "en-gd", "en-gg", "en-gh", "en-gi", "en-gm", "en-gu", "en-gy", "en-hk", "en-ie", "en-il", "en-im", "en-in", "en-io", "en-je", "en-jm", "en-ke", "en-ki", "en-kn", "en-ky", "en-lc", "en-lr", "en-ls", "en-lu", "en-mg", "en-mh", "en-mo", "en-mp", "en-ms", "en-mt", "en-mu", "en-mv", "en-mw", "en-mx", "en-my", "en-na", "en-nf", "en-ng", "en-nl", "en-nr", "en-nu", "en-nz", "en-pg", "en-ph", "en-pk", "en-pn", "en-pr", "en-pw", "en-rw", "en-sb", "en-sc", "en-sd", "en-se", "en-sg", "en-sh", "en-si", "en-sl", "en-ss", "en-sx", "en-sz", "en-tc", "en-tk", "en-to", "en-tt", "en-tv", "en-tz", "en-ug", "en-um", "en-us", "en-vc", "en-vg", "en-vi", "en-vu", "en-ws", "en-za", "en-zm", "en-zw", "eo", "eo-001", "es", "es-419", "es-ar", "es-bo", "es-br", "es-bz", "es-cl", "es-co", "es-cr", "es-cu", "es-do", "es-ea", "es-ec", "es-es", "es-gq", "es-gt", "es-hn", "es-ic", "es-mx", "es-ni", "es-pa", "es-pe", "es-ph", "es-pr", "es-py", "es-sv", "es-us", "es-uy", "es-ve", "et", "et-ee", "eu", "eu-es", "ewo", "ewo-cm", "fa", "fa-af", "fa-ir", "ff", "ff-bf", "ff-cm", "ff-gh", "ff-gm", "ff-gn", "ff-gw", "ff-lr", "ff-mr", "ff-ne", "ff-ng", "ff-sl", "ff-sn", "fi", "fil", "fil-ph", "fi-fi", "fo", "fo-dk", "fo-fo", "fr", "frr", "frr-de", "fr-be", "fr-bf", "fr-bi", "fr-bj", "fr-bl", "fr-ca", "fr-cd", "fr-cf", "fr-cg", "fr-ch", "fr-ci", "fr-cm", "fr-dj", "fr-dz", "fr-fr", "fr-ga", "fr-gf", "fr-gn", "fr-gp", "fr-gq", "fr-ht", "fr-km", "fr-lu", "fr-ma", "fr-mc", "fr-mf", "fr-mg", "fr-ml", "fr-mq", "fr-mr", "fr-mu", "fr-nc", "fr-ne", "fr-pf", "fr-pm", "fr-re", "fr-rw", "fr-sc", "fr-sn", "fr-sy", "fr-td", "fr-tg", "fr-tn", "fr-vu", "fr-wf", "fr-yt", "fur", "fur-it", "fy", "fy-nl", "ga", "ga-gb", "ga-ie", "gd", "gd-gb", "gl", "gl-es", "gsw", "gsw-ch", "gsw-fr", "gsw-li", "gu", "guz", "guz-ke", "gu-in", "gv", "gv-im", "ha", "haw", "haw-us", "ha-gh", "ha-ne", "ha-ng", "he", "hi", "hi-in", "hr", "hr-ba", "hr-hr", "hsb", "hsb-de", "hu", "hu-hu", "hy", "hy-am", "ia", "ia-001", "id", "ig", "ig-ng", "ii", "ii-cn", "id-id", "is", "is-is", "it", "it-ch", "it-it", "it-sm", "it-va", "he-il", "ja", "ja-jp", "jgo", "jgo-cm", "yi", "yi-001", "jmc", "jmc-tz", "jv", "jv-id", "ka", "kab", "kab-dz", "kam", "kam-ke", "ka-ge", "kde", "kde-tz", "kea", "kea-cv", "kgp", "kgp-br", "khq", "khq-ml", "ki", "ki-ke", "kk", "kkj", "kkj-cm", "kk-kz", "kl", "kln", "kln-ke", "kl-gl", "km", "km-kh", "kn", "kn-in", "ko", "kok", "kok-in", "ko-kp", "ko-kr", "ks", "ksb", "ksb-tz", "ksf", "ksf-cm", "ksh", "ksh-de", "ks-in", "ku", "ku-tr", "kw", "kw-gb", "ky", "ky-kg", "lag", "lag-tz", "lb", "lb-lu", "lg", "lg-ug", "lkt", "lkt-us", "ln", "ln-ao", "ln-cd", "ln-cf", "ln-cg", "lo", "lo-la", "lrc", "lrc-iq", "lrc-ir", "lt", "lt-lt", "lu", "luo", "luo-ke", "luy", "luy-ke", "lu-cd", "lv", "lv-lv", "mai", "mai-in", "mas", "mas-ke", "mas-tz", "mdf", "mdf-ru", "mer", "mer-ke", "mfe", "mfe-mu", "mg", "mgh", "mgh-mz", "mgo", "mgo-cm", "mg-mg", "mi", "mi-nz", "mk", "mk-mk", "ml", "ml-in", "mn", "mni", "mni-in", "mn-mn", "mr", "mr-in", "ms", "ms-bn", "ms-id", "ms-my", "ms-sg", "mt", "mt-mt", "mua", "mua-cm", "my", "my-mm", "mzn", "mzn-ir", "naq", "naq-na", "nb", "nb-no", "nb-sj", "nd", "nds", "nds-de", "nds-nl", "nd-zw", "ne", "ne-in", "ne-np", "nl", "nl-aw", "nl-be", "nl-bq", "nl-ch", "nl-cw", "nl-lu", "nl-nl", "nl-sr", "nl-sx", "nmg", "nmg-cm", "nn", "nnh", "nnh-cm", "nn-no", "no", "no-no", "nus", "nus-ss", "nyn", "nyn-ug", "oc", "oc-es", "oc-fr", "om", "om-et", "om-ke", "or", "or-in", "os", "os-ge", "os-ru", "pa", "pa-in", "pa-pk", "pcm", "pcm-ng", "pis", "pis-sb", "pl", "pl-pl", "prg", "prg-001", "ps", "ps-af", "ps-pk", "pt", "pt-ao", "pt-br", "pt-ch", "pt-cv", "pt-gq", "pt-gw", "pt-lu", "pt-mo", "pt-mz", "pt-pt", "pt-st", "pt-tl", "qu", "qu-bo", "qu-ec", "qu-pe", "raj", "raj-in", "rm", "rm-ch", "rn", "rn-bi", "ro", "rof", "rof-tz", "ro-md", "ro-ro", "ru", "ru-by", "ru-kg", "ru-kz", "ru-md", "ru-ru", "ru-ua", "rw", "rwk", "rwk-tz", "rw-rw", "sa", "sah", "sah-ru", "saq", "saq-ke", "sat", "sat-in", "sa-in", "sbp", "sbp-tz", "sc", "sc-it", "sd", "sd-in", "sd-pk", "se", "seh", "seh-mz", "ses", "ses-ml", "se-fi", "se-no", "se-se", "sg", "sg-cf", "shi", "shi-ma", "si", "si-lk", "sk", "sk-sk", "sl", "sl-si", "smn", "smn-fi", "sms", "sms-fi", "sn", "sn-zw", "so", "so-dj", "so-et", "so-ke", "so-so", "sq", "sq-al", "sq-mk", "sq-xk", "sr", "sr-ba", "sr-cs", "sr-me", "sr-rs", "sr-xk", "su", "su-id", "sv", "sv-ax", "sv-fi", "sv-se", "sw", "sw-cd", "sw-ke", "sw-tz", "sw-ug", "sy", "ta", "ta-in", "ta-lk", "ta-my", "ta-sg", "te", "teo", "teo-ke", "teo-ug", "te-in", "tg", "tg-tj", "th", "th-th", "ti", "ti-er", "ti-et", "tk", "tk-tm", "tl", "to", "tok", "tok-001", "to-to", "tr", "tr-cy", "tr-tr", "tt", "tt-ru", "twq", "twq-ne", "tzm", "tzm-ma", "ug", "ug-cn", "uk", "uk-ua", "ur", "ur-in", "ur-pk", "uz", "uz-af", "uz-uz", "vai", "vai-lr", "vi", "vi-vn", "vo", "vo-001", "vun", "vun-tz", "wae", "wae-ch", "wo", "wo-sn", "xh", "xh-za", "xog", "xog-ug", "yav", "yav-cm", "yo", "yo-bj", "yo-ng", "yrl", "yrl-br", "yrl-co", "yrl-ve", "yue", "yue-cn", "yue-hk", "zgh", "zgh-ma", "zh", "zh-cn", "zh-hans", "zh-hant", "zh-hk", "zh-mo", "zh-sg", "zh-tw", "zu", "zu-za"])
return false unless language_validator.valid?(@language)
state_validator = EnumAttributeValidator.new('String', ["AUTOMATED", "AUTOMATED_DRAFT", "AUTOMATED_SENDING", "AUTOMATED_FOR_FORM", "AUTOMATED_FOR_FORM_BUFFER", "AUTOMATED_FOR_FORM_DRAFT", "AUTOMATED_FOR_FORM_LEGACY", "BLOG_EMAIL_DRAFT", "BLOG_EMAIL_PUBLISHED", "DRAFT", "DRAFT_AB", "DRAFT_AB_VARIANT", "ERROR", "LOSER_AB_VARIANT", "PAGE_STUB", "PRE_PROCESSING", "PROCESSING", "PUBLISHED", "PUBLISHED_AB", "PUBLISHED_AB_VARIANT", "PUBLISHED_OR_SCHEDULED", "RSS_TO_EMAIL_DRAFT", "RSS_TO_EMAIL_PUBLISHED", "SCHEDULED", "SCHEDULED_AB", "SCHEDULED_OR_PUBLISHED", "AUTOMATED_AB", "AUTOMATED_AB_VARIANT", "AUTOMATED_DRAFT_AB", "AUTOMATED_DRAFT_ABVARIANT", "AUTOMATED_LOSER_ABVARIANT"])
return false unless state_validator.valid?(@state)
subcategory_validator = EnumAttributeValidator.new('String', ["ab_master", "ab_variant", "ab_loser_variant", "page_stub", "landing_page", "site_page", "legacy_page", "ab_master_site_page", "ab_variant_site_page", "ab_loser_variant_site_page", "performable_landing_page", "performable_landing_page_cutover", "staged_page", "automated", "automated_for_deal", "automated_for_form", "automated_for_form_legacy", "automated_for_form_buffer", "automated_for_form_draft", "rss_to_email", "rss_to_email_child", "blog_email", "blog_email_child", "optin_email", "optin_followup_email", "batch", "resubscribe_email", "unsubscribe_confirmation_email", "resubscribe_confirmation_email", "single_send_api", "marketing_single_send_api", "smtp_token", "localtime", "automated_for_ticket", "automated_for_leadflow", "automated_for_feedback_ces", "automated_for_feedback_nps", "automated_for_feedback_custom", "membership_registration", "membership_password_saved", "membership_password_reset", "membership_otp_login", "membership_passwordless_auth", "membership_email_verification", "membership_registration_follow_up", "membership_verification", "membership_follow_up", "ticket_closed_kickback_email", "ticket_opened_kickback_email", "automated_for_custom_survey", "discardable_stub", "normal_blog_post", "legacy_blog_post", "imported_blog_post", "automated_ab_master", "automated_ab_variant", "web_interactive", "portal_content", "page_instance_layout", "kb_article_instance_layout", "kb_listing", "kb_search_results", "kb_support_form", "case_study", "case_study_listing", "case_study_instance_layout", "UNKNOWN"])
return false unless subcategory_validator.valid?(@subcategory)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] language Object to be assigned
def language=(language)
validator = EnumAttributeValidator.new('String', ["af", "af-na", "af-za", "agq", "agq-cm", "ak", "ak-gh", "am", "am-et", "ann", "ann-ng", "ar", "ar-001", "ar-ae", "ar-bh", "ar-dj", "ar-dz", "ar-eg", "ar-eh", "ar-er", "ar-il", "ar-iq", "ar-jo", "ar-km", "ar-kw", "ar-lb", "ar-ly", "ar-ma", "ar-mr", "ar-om", "ar-ps", "ar-qa", "ar-sa", "ar-sd", "ar-so", "ar-ss", "ar-sy", "ar-td", "ar-tn", "ar-ye", "as", "asa", "asa-tz", "ast", "ast-es", "as-in", "az", "az-az", "bas", "bas-cm", "be", "bem", "bem-zm", "bez", "bez-tz", "be-by", "bg", "bgc", "bgc-in", "bg-bg", "bho", "bho-in", "bm", "bm-ml", "bn", "bn-bd", "bn-in", "bo", "bo-cn", "bo-in", "br", "brx", "brx-in", "br-fr", "bs", "bs-ba", "ca", "ca-ad", "ca-es", "ca-fr", "ca-it", "ccp", "ccp-bd", "ccp-in", "ce", "ceb", "ceb-ph", "ce-ru", "cgg", "cgg-ug", "chr", "chr-us", "ckb", "ckb-iq", "ckb-ir", "cs", "cs-cz", "cu", "cu-ru", "cv", "cv-ru", "cy", "cy-gb", "da", "dav", "dav-ke", "da-dk", "da-gl", "de", "de-at", "de-be", "de-ch", "de-de", "de-gr", "de-it", "de-li", "de-lu", "dje", "dje-ne", "doi", "doi-in", "dsb", "dsb-de", "dua", "dua-cm", "dyo", "dyo-sn", "dz", "dz-bt", "ebu", "ebu-ke", "ee", "ee-gh", "ee-tg", "el", "el-cy", "el-gr", "en", "en-001", "en-150", "en-ae", "en-ag", "en-ai", "en-as", "en-at", "en-au", "en-bb", "en-be", "en-bi", "en-bm", "en-bs", "en-bw", "en-bz", "en-ca", "en-cc", "en-ch", "en-ck", "en-cm", "en-cn", "en-cx", "en-cy", "en-de", "en-dg", "en-dk", "en-dm", "en-ee", "en-er", "en-fi", "en-fj", "en-fk", "en-fm", "en-fr", "en-gb", "en-gd", "en-gg", "en-gh", "en-gi", "en-gm", "en-gu", "en-gy", "en-hk", "en-ie", "en-il", "en-im", "en-in", "en-io", "en-je", "en-jm", "en-ke", "en-ki", "en-kn", "en-ky", "en-lc", "en-lr", "en-ls", "en-lu", "en-mg", "en-mh", "en-mo", "en-mp", "en-ms", "en-mt", "en-mu", "en-mv", "en-mw", "en-mx", "en-my", "en-na", "en-nf", "en-ng", "en-nl", "en-nr", "en-nu", "en-nz", "en-pg", "en-ph", "en-pk", "en-pn", "en-pr", "en-pw", "en-rw", "en-sb", "en-sc", "en-sd", "en-se", "en-sg", "en-sh", "en-si", "en-sl", "en-ss", "en-sx", "en-sz", "en-tc", "en-tk", "en-to", "en-tt", "en-tv", "en-tz", "en-ug", "en-um", "en-us", "en-vc", "en-vg", "en-vi", "en-vu", "en-ws", "en-za", "en-zm", "en-zw", "eo", "eo-001", "es", "es-419", "es-ar", "es-bo", "es-br", "es-bz", "es-cl", "es-co", "es-cr", "es-cu", "es-do", "es-ea", "es-ec", "es-es", "es-gq", "es-gt", "es-hn", "es-ic", "es-mx", "es-ni", "es-pa", "es-pe", "es-ph", "es-pr", "es-py", "es-sv", "es-us", "es-uy", "es-ve", "et", "et-ee", "eu", "eu-es", "ewo", "ewo-cm", "fa", "fa-af", "fa-ir", "ff", "ff-bf", "ff-cm", "ff-gh", "ff-gm", "ff-gn", "ff-gw", "ff-lr", "ff-mr", "ff-ne", "ff-ng", "ff-sl", "ff-sn", "fi", "fil", "fil-ph", "fi-fi", "fo", "fo-dk", "fo-fo", "fr", "frr", "frr-de", "fr-be", "fr-bf", "fr-bi", "fr-bj", "fr-bl", "fr-ca", "fr-cd", "fr-cf", "fr-cg", "fr-ch", "fr-ci", "fr-cm", "fr-dj", "fr-dz", "fr-fr", "fr-ga", "fr-gf", "fr-gn", "fr-gp", "fr-gq", "fr-ht", "fr-km", "fr-lu", "fr-ma", "fr-mc", "fr-mf", "fr-mg", "fr-ml", "fr-mq", "fr-mr", "fr-mu", "fr-nc", "fr-ne", "fr-pf", "fr-pm", "fr-re", "fr-rw", "fr-sc", "fr-sn", "fr-sy", "fr-td", "fr-tg", "fr-tn", "fr-vu", "fr-wf", "fr-yt", "fur", "fur-it", "fy", "fy-nl", "ga", "ga-gb", "ga-ie", "gd", "gd-gb", "gl", "gl-es", "gsw", "gsw-ch", "gsw-fr", "gsw-li", "gu", "guz", "guz-ke", "gu-in", "gv", "gv-im", "ha", "haw", "haw-us", "ha-gh", "ha-ne", "ha-ng", "he", "hi", "hi-in", "hr", "hr-ba", "hr-hr", "hsb", "hsb-de", "hu", "hu-hu", "hy", "hy-am", "ia", "ia-001", "id", "ig", "ig-ng", "ii", "ii-cn", "id-id", "is", "is-is", "it", "it-ch", "it-it", "it-sm", "it-va", "he-il", "ja", "ja-jp", "jgo", "jgo-cm", "yi", "yi-001", "jmc", "jmc-tz", "jv", "jv-id", "ka", "kab", "kab-dz", "kam", "kam-ke", "ka-ge", "kde", "kde-tz", "kea", "kea-cv", "kgp", "kgp-br", "khq", "khq-ml", "ki", "ki-ke", "kk", "kkj", "kkj-cm", "kk-kz", "kl", "kln", "kln-ke", "kl-gl", "km", "km-kh", "kn", "kn-in", "ko", "kok", "kok-in", "ko-kp", "ko-kr", "ks", "ksb", "ksb-tz", "ksf", "ksf-cm", "ksh", "ksh-de", "ks-in", "ku", "ku-tr", "kw", "kw-gb", "ky", "ky-kg", "lag", "lag-tz", "lb", "lb-lu", "lg", "lg-ug", "lkt", "lkt-us", "ln", "ln-ao", "ln-cd", "ln-cf", "ln-cg", "lo", "lo-la", "lrc", "lrc-iq", "lrc-ir", "lt", "lt-lt", "lu", "luo", "luo-ke", "luy", "luy-ke", "lu-cd", "lv", "lv-lv", "mai", "mai-in", "mas", "mas-ke", "mas-tz", "mdf", "mdf-ru", "mer", "mer-ke", "mfe", "mfe-mu", "mg", "mgh", "mgh-mz", "mgo", "mgo-cm", "mg-mg", "mi", "mi-nz", "mk", "mk-mk", "ml", "ml-in", "mn", "mni", "mni-in", "mn-mn", "mr", "mr-in", "ms", "ms-bn", "ms-id", "ms-my", "ms-sg", "mt", "mt-mt", "mua", "mua-cm", "my", "my-mm", "mzn", "mzn-ir", "naq", "naq-na", "nb", "nb-no", "nb-sj", "nd", "nds", "nds-de", "nds-nl", "nd-zw", "ne", "ne-in", "ne-np", "nl", "nl-aw", "nl-be", "nl-bq", "nl-ch", "nl-cw", "nl-lu", "nl-nl", "nl-sr", "nl-sx", "nmg", "nmg-cm", "nn", "nnh", "nnh-cm", "nn-no", "no", "no-no", "nus", "nus-ss", "nyn", "nyn-ug", "oc", "oc-es", "oc-fr", "om", "om-et", "om-ke", "or", "or-in", "os", "os-ge", "os-ru", "pa", "pa-in", "pa-pk", "pcm", "pcm-ng", "pis", "pis-sb", "pl", "pl-pl", "prg", "prg-001", "ps", "ps-af", "ps-pk", "pt", "pt-ao", "pt-br", "pt-ch", "pt-cv", "pt-gq", "pt-gw", "pt-lu", "pt-mo", "pt-mz", "pt-pt", "pt-st", "pt-tl", "qu", "qu-bo", "qu-ec", "qu-pe", "raj", "raj-in", "rm", "rm-ch", "rn", "rn-bi", "ro", "rof", "rof-tz", "ro-md", "ro-ro", "ru", "ru-by", "ru-kg", "ru-kz", "ru-md", "ru-ru", "ru-ua", "rw", "rwk", "rwk-tz", "rw-rw", "sa", "sah", "sah-ru", "saq", "saq-ke", "sat", "sat-in", "sa-in", "sbp", "sbp-tz", "sc", "sc-it", "sd", "sd-in", "sd-pk", "se", "seh", "seh-mz", "ses", "ses-ml", "se-fi", "se-no", "se-se", "sg", "sg-cf", "shi", "shi-ma", "si", "si-lk", "sk", "sk-sk", "sl", "sl-si", "smn", "smn-fi", "sms", "sms-fi", "sn", "sn-zw", "so", "so-dj", "so-et", "so-ke", "so-so", "sq", "sq-al", "sq-mk", "sq-xk", "sr", "sr-ba", "sr-cs", "sr-me", "sr-rs", "sr-xk", "su", "su-id", "sv", "sv-ax", "sv-fi", "sv-se", "sw", "sw-cd", "sw-ke", "sw-tz", "sw-ug", "sy", "ta", "ta-in", "ta-lk", "ta-my", "ta-sg", "te", "teo", "teo-ke", "teo-ug", "te-in", "tg", "tg-tj", "th", "th-th", "ti", "ti-er", "ti-et", "tk", "tk-tm", "tl", "to", "tok", "tok-001", "to-to", "tr", "tr-cy", "tr-tr", "tt", "tt-ru", "twq", "twq-ne", "tzm", "tzm-ma", "ug", "ug-cn", "uk", "uk-ua", "ur", "ur-in", "ur-pk", "uz", "uz-af", "uz-uz", "vai", "vai-lr", "vi", "vi-vn", "vo", "vo-001", "vun", "vun-tz", "wae", "wae-ch", "wo", "wo-sn", "xh", "xh-za", "xog", "xog-ug", "yav", "yav-cm", "yo", "yo-bj", "yo-ng", "yrl", "yrl-br", "yrl-co", "yrl-ve", "yue", "yue-cn", "yue-hk", "zgh", "zgh-ma", "zh", "zh-cn", "zh-hans", "zh-hant", "zh-hk", "zh-mo", "zh-sg", "zh-tw", "zu", "zu-za"])
unless validator.valid?(language)
fail ArgumentError, "invalid value for \"language\", must be one of #{validator.allowable_values}."
end
@language = language
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] state Object to be assigned
def state=(state)
validator = EnumAttributeValidator.new('String', ["AUTOMATED", "AUTOMATED_DRAFT", "AUTOMATED_SENDING", "AUTOMATED_FOR_FORM", "AUTOMATED_FOR_FORM_BUFFER", "AUTOMATED_FOR_FORM_DRAFT", "AUTOMATED_FOR_FORM_LEGACY", "BLOG_EMAIL_DRAFT", "BLOG_EMAIL_PUBLISHED", "DRAFT", "DRAFT_AB", "DRAFT_AB_VARIANT", "ERROR", "LOSER_AB_VARIANT", "PAGE_STUB", "PRE_PROCESSING", "PROCESSING", "PUBLISHED", "PUBLISHED_AB", "PUBLISHED_AB_VARIANT", "PUBLISHED_OR_SCHEDULED", "RSS_TO_EMAIL_DRAFT", "RSS_TO_EMAIL_PUBLISHED", "SCHEDULED", "SCHEDULED_AB", "SCHEDULED_OR_PUBLISHED", "AUTOMATED_AB", "AUTOMATED_AB_VARIANT", "AUTOMATED_DRAFT_AB", "AUTOMATED_DRAFT_ABVARIANT", "AUTOMATED_LOSER_ABVARIANT"])
unless validator.valid?(state)
fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}."
end
@state = state
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] subcategory Object to be assigned
def subcategory=(subcategory)
validator = EnumAttributeValidator.new('String', ["ab_master", "ab_variant", "ab_loser_variant", "page_stub", "landing_page", "site_page", "legacy_page", "ab_master_site_page", "ab_variant_site_page", "ab_loser_variant_site_page", "performable_landing_page", "performable_landing_page_cutover", "staged_page", "automated", "automated_for_deal", "automated_for_form", "automated_for_form_legacy", "automated_for_form_buffer", "automated_for_form_draft", "rss_to_email", "rss_to_email_child", "blog_email", "blog_email_child", "optin_email", "optin_followup_email", "batch", "resubscribe_email", "unsubscribe_confirmation_email", "resubscribe_confirmation_email", "single_send_api", "marketing_single_send_api", "smtp_token", "localtime", "automated_for_ticket", "automated_for_leadflow", "automated_for_feedback_ces", "automated_for_feedback_nps", "automated_for_feedback_custom", "membership_registration", "membership_password_saved", "membership_password_reset", "membership_otp_login", "membership_passwordless_auth", "membership_email_verification", "membership_registration_follow_up", "membership_verification", "membership_follow_up", "ticket_closed_kickback_email", "ticket_opened_kickback_email", "automated_for_custom_survey", "discardable_stub", "normal_blog_post", "legacy_blog_post", "imported_blog_post", "automated_ab_master", "automated_ab_variant", "web_interactive", "portal_content", "page_instance_layout", "kb_article_instance_layout", "kb_listing", "kb_search_results", "kb_support_form", "case_study", "case_study_listing", "case_study_instance_layout", "UNKNOWN"])
unless validator.valid?(subcategory)
fail ArgumentError, "invalid value for \"subcategory\", must be one of #{validator.allowable_values}."
end
@subcategory = subcategory
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
rss_data == o.rss_data &&
subject == o.subject &&
testing == o.testing &&
publish_date == o.publish_date &&
language == o.language &&
business_unit_id == o.business_unit_id &&
content == o.content &&
webversion == o.webversion &&
archived == o.archived &&
subscription_details == o.subscription_details &&
active_domain == o.active_domain &&
name == o.name &&
campaign == o.campaign &&
from == o.from &&
jitter_send_time == o.jitter_send_time &&
state == o.state &&
to == o.to &&
subcategory == o.subcategory &&
send_on_publish == o.send_on_publish
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[rss_data, subject, testing, publish_date, language, business_unit_id, content, webversion, archived, subscription_details, active_domain, name, campaign, from, jitter_send_time, state, to, subcategory, send_on_publish].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | true |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/ab_test_create_request_v_next.rb | lib/hubspot/codegen/marketing/emails/models/ab_test_create_request_v_next.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Request body object for creating A/B tests.
class AbTestCreateRequestVNext
attr_accessor :variation_name
# ID of the object to test.
attr_accessor :content_id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'variation_name' => :'variationName',
:'content_id' => :'contentId'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'variation_name' => :'String',
:'content_id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::AbTestCreateRequestVNext` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::AbTestCreateRequestVNext`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'variation_name')
self.variation_name = attributes[:'variation_name']
end
if attributes.key?(:'content_id')
self.content_id = attributes[:'content_id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @variation_name.nil?
invalid_properties.push('invalid value for "variation_name", variation_name cannot be nil.')
end
if @content_id.nil?
invalid_properties.push('invalid value for "content_id", content_id cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @variation_name.nil?
return false if @content_id.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
variation_name == o.variation_name &&
content_id == o.content_id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[variation_name, content_id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/models/public_email_subscription_details.rb | lib/hubspot/codegen/marketing/emails/models/public_email_subscription_details.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Emails
# Data structure representing the subscription fields of the email.
class PublicEmailSubscriptionDetails
# ID of the selected office location.
attr_accessor :office_location_id
#
attr_accessor :preferences_group_id
# ID of the subscription.
attr_accessor :subscription_id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'office_location_id' => :'officeLocationId',
:'preferences_group_id' => :'preferencesGroupId',
:'subscription_id' => :'subscriptionId'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'office_location_id' => :'String',
:'preferences_group_id' => :'String',
:'subscription_id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Emails::PublicEmailSubscriptionDetails` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Emails::PublicEmailSubscriptionDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'office_location_id')
self.office_location_id = attributes[:'office_location_id']
end
if attributes.key?(:'preferences_group_id')
self.preferences_group_id = attributes[:'preferences_group_id']
end
if attributes.key?(:'subscription_id')
self.subscription_id = attributes[:'subscription_id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
office_location_id == o.office_location_id &&
preferences_group_id == o.preferences_group_id &&
subscription_id == o.subscription_id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[office_location_id, preferences_group_id, subscription_id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Emails.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/api/marketing_emails_api.rb | lib/hubspot/codegen/marketing/emails/api/marketing_emails_api.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module Hubspot
module Marketing
module Emails
class MarketingEmailsApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Delete a marketing email.
# @param email_id [String] The ID of the marketing email to delete.
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :archived Whether to return only results that have been archived.
# @return [nil]
def archive(email_id, opts = {})
archive_with_http_info(email_id, opts)
nil
end
# Delete a marketing email.
# @param email_id [String] The ID of the marketing email to delete.
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :archived Whether to return only results that have been archived.
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def archive_with_http_info(email_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MarketingEmailsApi.archive ...'
end
# verify the required parameter 'email_id' is set
if @api_client.config.client_side_validation && email_id.nil?
fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.archive"
end
# resource path
local_var_path = '/marketing/v3/emails/{emailId}'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MarketingEmailsApi.archive",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: MarketingEmailsApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Clone a marketing email.
# This will create a duplicate email with the same properties as the original, with the exception of a unique ID.
# @param content_clone_request_v_next [ContentCloneRequestVNext]
# @param [Hash] opts the optional parameters
# @return [PublicEmail]
def clone(content_clone_request_v_next, opts = {})
data, _status_code, _headers = clone_with_http_info(content_clone_request_v_next, opts)
data
end
# Clone a marketing email.
# This will create a duplicate email with the same properties as the original, with the exception of a unique ID.
# @param content_clone_request_v_next [ContentCloneRequestVNext]
# @param [Hash] opts the optional parameters
# @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
def clone_with_http_info(content_clone_request_v_next, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MarketingEmailsApi.clone ...'
end
# verify the required parameter 'content_clone_request_v_next' is set
if @api_client.config.client_side_validation && content_clone_request_v_next.nil?
fail ArgumentError, "Missing the required parameter 'content_clone_request_v_next' when calling MarketingEmailsApi.clone"
end
# resource path
local_var_path = '/marketing/v3/emails/clone'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(content_clone_request_v_next)
# return_type
return_type = opts[:debug_return_type] || 'PublicEmail'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MarketingEmailsApi.clone",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: MarketingEmailsApi#clone\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Create a new marketing email.
# Use this endpoint to create a new marketing email.
# @param email_create_request [EmailCreateRequest]
# @param [Hash] opts the optional parameters
# @return [PublicEmail]
def create(email_create_request, opts = {})
data, _status_code, _headers = create_with_http_info(email_create_request, opts)
data
end
# Create a new marketing email.
# Use this endpoint to create a new marketing email.
# @param email_create_request [EmailCreateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
def create_with_http_info(email_create_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MarketingEmailsApi.create ...'
end
# verify the required parameter 'email_create_request' is set
if @api_client.config.client_side_validation && email_create_request.nil?
fail ArgumentError, "Missing the required parameter 'email_create_request' when calling MarketingEmailsApi.create"
end
# resource path
local_var_path = '/marketing/v3/emails/'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(email_create_request)
# return_type
return_type = opts[:debug_return_type] || 'PublicEmail'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MarketingEmailsApi.create",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: MarketingEmailsApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Create an A/B test variation of a marketing email.
# Create a variation of a marketing email for an A/B test. The new variation will be created as a draft. If an active variation already exists, a new one won't be created.
# @param ab_test_create_request_v_next [AbTestCreateRequestVNext]
# @param [Hash] opts the optional parameters
# @return [PublicEmail]
def create_ab_test_variation(ab_test_create_request_v_next, opts = {})
data, _status_code, _headers = create_ab_test_variation_with_http_info(ab_test_create_request_v_next, opts)
data
end
# Create an A/B test variation of a marketing email.
# Create a variation of a marketing email for an A/B test. The new variation will be created as a draft. If an active variation already exists, a new one won't be created.
# @param ab_test_create_request_v_next [AbTestCreateRequestVNext]
# @param [Hash] opts the optional parameters
# @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
def create_ab_test_variation_with_http_info(ab_test_create_request_v_next, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MarketingEmailsApi.create_ab_test_variation ...'
end
# verify the required parameter 'ab_test_create_request_v_next' is set
if @api_client.config.client_side_validation && ab_test_create_request_v_next.nil?
fail ArgumentError, "Missing the required parameter 'ab_test_create_request_v_next' when calling MarketingEmailsApi.create_ab_test_variation"
end
# resource path
local_var_path = '/marketing/v3/emails/ab-test/create-variation'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(ab_test_create_request_v_next)
# return_type
return_type = opts[:debug_return_type] || 'PublicEmail'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MarketingEmailsApi.create_ab_test_variation",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: MarketingEmailsApi#create_ab_test_variation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get the variation of a an A/B marketing email
# This endpoint lets you obtain the variation of an A/B marketing email. If the email is variation A (master) it will return variation B (variant) and vice versa.
# @param email_id [String] The ID of an A/B marketing email.
# @param [Hash] opts the optional parameters
# @return [PublicEmail]
def get_ab_test_variation(email_id, opts = {})
data, _status_code, _headers = get_ab_test_variation_with_http_info(email_id, opts)
data
end
# Get the variation of a an A/B marketing email
# This endpoint lets you obtain the variation of an A/B marketing email. If the email is variation A (master) it will return variation B (variant) and vice versa.
# @param email_id [String] The ID of an A/B marketing email.
# @param [Hash] opts the optional parameters
# @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
def get_ab_test_variation_with_http_info(email_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MarketingEmailsApi.get_ab_test_variation ...'
end
# verify the required parameter 'email_id' is set
if @api_client.config.client_side_validation && email_id.nil?
fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.get_ab_test_variation"
end
# resource path
local_var_path = '/marketing/v3/emails/{emailId}/ab-test/get-variation'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'PublicEmail'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MarketingEmailsApi.get_ab_test_variation",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: MarketingEmailsApi#get_ab_test_variation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get the details of a specified marketing email.
# Get the details for a marketing email.
# @param email_id [String] The marketing email ID.
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :include_stats Include statistics with email
# @option opts [Boolean] :marketing_campaign_names
# @option opts [Boolean] :workflow_names
# @option opts [Array<String>] :included_properties
# @option opts [Boolean] :archived Whether to return only results that have been archived.
# @return [PublicEmail]
def get_by_id(email_id, opts = {})
data, _status_code, _headers = get_by_id_with_http_info(email_id, opts)
data
end
# Get the details of a specified marketing email.
# Get the details for a marketing email.
# @param email_id [String] The marketing email ID.
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :include_stats Include statistics with email
# @option opts [Boolean] :marketing_campaign_names
# @option opts [Boolean] :workflow_names
# @option opts [Array<String>] :included_properties
# @option opts [Boolean] :archived Whether to return only results that have been archived.
# @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
def get_by_id_with_http_info(email_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MarketingEmailsApi.get_by_id ...'
end
# verify the required parameter 'email_id' is set
if @api_client.config.client_side_validation && email_id.nil?
fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.get_by_id"
end
# resource path
local_var_path = '/marketing/v3/emails/{emailId}'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'includeStats'] = opts[:'include_stats'] if !opts[:'include_stats'].nil?
query_params[:'marketingCampaignNames'] = opts[:'marketing_campaign_names'] if !opts[:'marketing_campaign_names'].nil?
query_params[:'workflowNames'] = opts[:'workflow_names'] if !opts[:'workflow_names'].nil?
query_params[:'includedProperties'] = @api_client.build_collection_param(opts[:'included_properties'], :multi) if !opts[:'included_properties'].nil?
query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'PublicEmail'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MarketingEmailsApi.get_by_id",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: MarketingEmailsApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get draft version of a marketing email
# Get the draft version of an email (if it exists). If no draft version exists, the published email is returned.
# @param email_id [String] The marketing email ID.
# @param [Hash] opts the optional parameters
# @return [PublicEmail]
def get_draft(email_id, opts = {})
data, _status_code, _headers = get_draft_with_http_info(email_id, opts)
data
end
# Get draft version of a marketing email
# Get the draft version of an email (if it exists). If no draft version exists, the published email is returned.
# @param email_id [String] The marketing email ID.
# @param [Hash] opts the optional parameters
# @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
def get_draft_with_http_info(email_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MarketingEmailsApi.get_draft ...'
end
# verify the required parameter 'email_id' is set
if @api_client.config.client_side_validation && email_id.nil?
fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.get_draft"
end
# resource path
local_var_path = '/marketing/v3/emails/{emailId}/draft'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'PublicEmail'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MarketingEmailsApi.get_draft",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: MarketingEmailsApi#get_draft\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get all marketing emails for a HubSpot account.
# The results can be filtered, allowing you to find a specific set of emails. See the table below for a full list of filtering options.
# @param [Hash] opts the optional parameters
# @option opts [Time] :created_at Only return emails created at exactly the specified time.
# @option opts [Time] :created_after Only return emails created after the specified time.
# @option opts [Time] :created_before Only return emails created before the specified time.
# @option opts [Time] :updated_at Only return emails last updated at exactly the specified time.
# @option opts [Time] :updated_after Only return emails last updated after the specified time.
# @option opts [Time] :updated_before Only return emails last updated before the specified time.
# @option opts [Array<String>] :sort Specifies which fields to use for sorting results. Valid fields are `name`, `createdAt`, `updatedAt`, `createdBy`, `updatedBy`. `createdAt` will be used by default.
# @option opts [String] :after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results.
# @option opts [Integer] :limit The maximum number of results to return. Default is 100.
# @option opts [Boolean] :include_stats Include statistics with emails.
# @option opts [Boolean] :marketing_campaign_names
# @option opts [Boolean] :workflow_names
# @option opts [String] :type Email types to be filtered by. Multiple types can be included. All emails will be returned if not present.
# @option opts [Boolean] :is_published Filter by published/draft emails. All emails will be returned if not present.
# @option opts [Array<String>] :included_properties
# @option opts [Boolean] :archived Specifies whether to return archived emails. Defaults to `false`.
# @return [CollectionResponseWithTotalPublicEmailForwardPaging]
def get_page(opts = {})
data, _status_code, _headers = get_page_with_http_info(opts)
data
end
# Get all marketing emails for a HubSpot account.
# The results can be filtered, allowing you to find a specific set of emails. See the table below for a full list of filtering options.
# @param [Hash] opts the optional parameters
# @option opts [Time] :created_at Only return emails created at exactly the specified time.
# @option opts [Time] :created_after Only return emails created after the specified time.
# @option opts [Time] :created_before Only return emails created before the specified time.
# @option opts [Time] :updated_at Only return emails last updated at exactly the specified time.
# @option opts [Time] :updated_after Only return emails last updated after the specified time.
# @option opts [Time] :updated_before Only return emails last updated before the specified time.
# @option opts [Array<String>] :sort Specifies which fields to use for sorting results. Valid fields are `name`, `createdAt`, `updatedAt`, `createdBy`, `updatedBy`. `createdAt` will be used by default.
# @option opts [String] :after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results.
# @option opts [Integer] :limit The maximum number of results to return. Default is 100.
# @option opts [Boolean] :include_stats Include statistics with emails.
# @option opts [Boolean] :marketing_campaign_names
# @option opts [Boolean] :workflow_names
# @option opts [String] :type Email types to be filtered by. Multiple types can be included. All emails will be returned if not present.
# @option opts [Boolean] :is_published Filter by published/draft emails. All emails will be returned if not present.
# @option opts [Array<String>] :included_properties
# @option opts [Boolean] :archived Specifies whether to return archived emails. Defaults to `false`.
# @return [Array<(CollectionResponseWithTotalPublicEmailForwardPaging, Integer, Hash)>] CollectionResponseWithTotalPublicEmailForwardPaging data, response status code and response headers
def get_page_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MarketingEmailsApi.get_page ...'
end
allowable_values = ["AB_EMAIL", "BATCH_EMAIL", "LOCALTIME_EMAIL", "AUTOMATED_AB_EMAIL", "BLOG_EMAIL", "BLOG_EMAIL_CHILD", "RSS_EMAIL", "RSS_EMAIL_CHILD", "RESUBSCRIBE_EMAIL", "OPTIN_EMAIL", "OPTIN_FOLLOWUP_EMAIL", "AUTOMATED_EMAIL", "FEEDBACK_CES_EMAIL", "FEEDBACK_CUSTOM_EMAIL", "FEEDBACK_CUSTOM_SURVEY_EMAIL", "FEEDBACK_NPS_EMAIL", "FOLLOWUP_EMAIL", "LEADFLOW_EMAIL", "SINGLE_SEND_API", "MARKETING_SINGLE_SEND_API", "SMTP_TOKEN", "TICKET_EMAIL", "MEMBERSHIP_REGISTRATION_EMAIL", "MEMBERSHIP_PASSWORD_SAVED_EMAIL", "MEMBERSHIP_PASSWORD_RESET_EMAIL", "MEMBERSHIP_EMAIL_VERIFICATION_EMAIL", "MEMBERSHIP_PASSWORDLESS_AUTH_EMAIL", "MEMBERSHIP_REGISTRATION_FOLLOW_UP_EMAIL", "MEMBERSHIP_OTP_LOGIN_EMAIL", "MEMBERSHIP_FOLLOW_UP_EMAIL", "MEMBERSHIP_VERIFICATION_EMAIL"]
if @api_client.config.client_side_validation && opts[:'type'] && !allowable_values.include?(opts[:'type'])
fail ArgumentError, "invalid value for \"type\", must be one of #{allowable_values}"
end
# resource path
local_var_path = '/marketing/v3/emails/'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'createdAt'] = opts[:'created_at'] if !opts[:'created_at'].nil?
query_params[:'createdAfter'] = opts[:'created_after'] if !opts[:'created_after'].nil?
query_params[:'createdBefore'] = opts[:'created_before'] if !opts[:'created_before'].nil?
query_params[:'updatedAt'] = opts[:'updated_at'] if !opts[:'updated_at'].nil?
query_params[:'updatedAfter'] = opts[:'updated_after'] if !opts[:'updated_after'].nil?
query_params[:'updatedBefore'] = opts[:'updated_before'] if !opts[:'updated_before'].nil?
query_params[:'sort'] = @api_client.build_collection_param(opts[:'sort'], :multi) if !opts[:'sort'].nil?
query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
query_params[:'includeStats'] = opts[:'include_stats'] if !opts[:'include_stats'].nil?
query_params[:'marketingCampaignNames'] = opts[:'marketing_campaign_names'] if !opts[:'marketing_campaign_names'].nil?
query_params[:'workflowNames'] = opts[:'workflow_names'] if !opts[:'workflow_names'].nil?
query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
query_params[:'isPublished'] = opts[:'is_published'] if !opts[:'is_published'].nil?
query_params[:'includedProperties'] = @api_client.build_collection_param(opts[:'included_properties'], :multi) if !opts[:'included_properties'].nil?
query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'CollectionResponseWithTotalPublicEmailForwardPaging'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MarketingEmailsApi.get_page",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: MarketingEmailsApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get a revision of a marketing email.
# Get a specific revision of a marketing email.
# @param email_id [String] The marketing email ID.
# @param revision_id [String] The ID of a revision.
# @param [Hash] opts the optional parameters
# @return [VersionPublicEmail]
def get_revision_by_id(email_id, revision_id, opts = {})
data, _status_code, _headers = get_revision_by_id_with_http_info(email_id, revision_id, opts)
data
end
# Get a revision of a marketing email.
# Get a specific revision of a marketing email.
# @param email_id [String] The marketing email ID.
# @param revision_id [String] The ID of a revision.
# @param [Hash] opts the optional parameters
# @return [Array<(VersionPublicEmail, Integer, Hash)>] VersionPublicEmail data, response status code and response headers
def get_revision_by_id_with_http_info(email_id, revision_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MarketingEmailsApi.get_revision_by_id ...'
end
# verify the required parameter 'email_id' is set
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | true |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/emails/api/statistics_api.rb | lib/hubspot/codegen/marketing/emails/api/statistics_api.rb | =begin
#Marketing Emails
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module Hubspot
module Marketing
module Emails
class StatisticsApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Get aggregated statistics.
# Use this endpoint to get aggregated statistics of emails sent in a specified time span. It also returns the list of emails that were sent during the time span.
# @param [Hash] opts the optional parameters
# @option opts [String] :start_timestamp The start timestamp of the time span, in ISO8601 representation.
# @option opts [String] :end_timestamp The end timestamp of the time span, in ISO8601 representation.
# @option opts [Array<Integer>] :email_ids Filter by email IDs. Only include statistics of emails with these IDs.
# @option opts [String] :property Specifies which email properties should be returned. All properties will be returned by default.
# @return [AggregateEmailStatistics]
def get_emails_list(opts = {})
data, _status_code, _headers = get_emails_list_with_http_info(opts)
data
end
# Get aggregated statistics.
# Use this endpoint to get aggregated statistics of emails sent in a specified time span. It also returns the list of emails that were sent during the time span.
# @param [Hash] opts the optional parameters
# @option opts [String] :start_timestamp The start timestamp of the time span, in ISO8601 representation.
# @option opts [String] :end_timestamp The end timestamp of the time span, in ISO8601 representation.
# @option opts [Array<Integer>] :email_ids Filter by email IDs. Only include statistics of emails with these IDs.
# @option opts [String] :property Specifies which email properties should be returned. All properties will be returned by default.
# @return [Array<(AggregateEmailStatistics, Integer, Hash)>] AggregateEmailStatistics data, response status code and response headers
def get_emails_list_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: StatisticsApi.get_emails_list ...'
end
# resource path
local_var_path = '/marketing/v3/emails/statistics/list'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'startTimestamp'] = opts[:'start_timestamp'] if !opts[:'start_timestamp'].nil?
query_params[:'endTimestamp'] = opts[:'end_timestamp'] if !opts[:'end_timestamp'].nil?
query_params[:'emailIds'] = @api_client.build_collection_param(opts[:'email_ids'], :multi) if !opts[:'email_ids'].nil?
query_params[:'property'] = opts[:'property'] if !opts[:'property'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'AggregateEmailStatistics'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"StatisticsApi.get_emails_list",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StatisticsApi#get_emails_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get aggregated statistic intervals.
# Get aggregated statistics in intervals for a specified time span. Each interval contains aggregated statistics of the emails that were sent in that time.
# @param [Hash] opts the optional parameters
# @option opts [String] :interval The interval to aggregate statistics for.
# @option opts [String] :start_timestamp The start timestamp of the time span, in ISO8601 representation.
# @option opts [String] :end_timestamp The end timestamp of the time span, in ISO8601 representation.
# @option opts [Array<Integer>] :email_ids Filter by email IDs. Only include statistics of emails with these IDs.
# @return [CollectionResponseWithTotalEmailStatisticIntervalNoPaging]
def get_histogram(opts = {})
data, _status_code, _headers = get_histogram_with_http_info(opts)
data
end
# Get aggregated statistic intervals.
# Get aggregated statistics in intervals for a specified time span. Each interval contains aggregated statistics of the emails that were sent in that time.
# @param [Hash] opts the optional parameters
# @option opts [String] :interval The interval to aggregate statistics for.
# @option opts [String] :start_timestamp The start timestamp of the time span, in ISO8601 representation.
# @option opts [String] :end_timestamp The end timestamp of the time span, in ISO8601 representation.
# @option opts [Array<Integer>] :email_ids Filter by email IDs. Only include statistics of emails with these IDs.
# @return [Array<(CollectionResponseWithTotalEmailStatisticIntervalNoPaging, Integer, Hash)>] CollectionResponseWithTotalEmailStatisticIntervalNoPaging data, response status code and response headers
def get_histogram_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: StatisticsApi.get_histogram ...'
end
allowable_values = ["YEAR", "QUARTER", "MONTH", "WEEK", "DAY", "HOUR", "QUARTER_HOUR", "MINUTE", "SECOND"]
if @api_client.config.client_side_validation && opts[:'interval'] && !allowable_values.include?(opts[:'interval'])
fail ArgumentError, "invalid value for \"interval\", must be one of #{allowable_values}"
end
# resource path
local_var_path = '/marketing/v3/emails/statistics/histogram'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'interval'] = opts[:'interval'] if !opts[:'interval'].nil?
query_params[:'startTimestamp'] = opts[:'start_timestamp'] if !opts[:'start_timestamp'].nil?
query_params[:'endTimestamp'] = opts[:'end_timestamp'] if !opts[:'end_timestamp'].nil?
query_params[:'emailIds'] = @api_client.build_collection_param(opts[:'email_ids'], :multi) if !opts[:'email_ids'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'CollectionResponseWithTotalEmailStatisticIntervalNoPaging'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"StatisticsApi.get_histogram",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StatisticsApi#get_histogram\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/api_error.rb | lib/hubspot/codegen/marketing/forms/api_error.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Marketing
module Forms
class ApiError < ::StandardError
attr_reader :code, :response_headers, :response_body
# Usage examples:
# ApiError.new
# ApiError.new("message")
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
# ApiError.new(:code => 404, :message => "Not Found")
def initialize(arg = nil)
if arg.is_a? Hash
if arg.key?(:message) || arg.key?('message')
super(arg[:message] || arg['message'])
else
super arg
end
arg.each do |k, v|
instance_variable_set "@#{k}", v
end
else
super arg
end
end
# Override to_s to display a friendly error message
def to_s
message
end
def message
if @message.nil?
msg = "Error message: the server returns an error"
else
msg = @message
end
msg += "\nHTTP status code: #{code}" if code
msg += "\nResponse headers: #{response_headers}" if response_headers
msg += "\nResponse body: #{response_body}" if response_body
msg
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/configuration.rb | lib/hubspot/codegen/marketing/forms/configuration.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Marketing
module Forms
class Configuration
# Defines url scheme
attr_accessor :scheme
# Defines url host
attr_accessor :host
# Defines url base path
attr_accessor :base_path
# Define server configuration index
attr_accessor :server_index
# Define server operation configuration index
attr_accessor :server_operation_index
# Default server variables
attr_accessor :server_variables
# Default server operation variables
attr_accessor :server_operation_variables
# Defines API keys used with API Key authentications.
#
# @return [Hash] key: parameter name, value: parameter value (API key)
#
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
# config.api_key['api_key'] = 'xxx'
attr_accessor :api_key
# Defines API key prefixes used with API Key authentications.
#
# @return [Hash] key: parameter name, value: API key prefix
#
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
# config.api_key_prefix['api_key'] = 'Token'
attr_accessor :api_key_prefix
# Defines the username used with HTTP basic authentication.
#
# @return [String]
attr_accessor :username
# Defines the password used with HTTP basic authentication.
#
# @return [String]
attr_accessor :password
# Defines the access token (Bearer) used with OAuth2.
attr_accessor :access_token
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
# details will be logged with `logger.debug` (see the `logger` attribute).
# Default to false.
#
# @return [true, false]
attr_accessor :debugging
# Defines the logger used for debugging.
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
#
# @return [#debug]
attr_accessor :logger
# Defines the temporary folder to store downloaded files
# (for API endpoints that have file response).
# Default to use `Tempfile`.
#
# @return [String]
attr_accessor :temp_folder_path
# The time limit for HTTP request in seconds.
# Default to 0 (never times out).
attr_accessor :timeout
# Set this to false to skip client side validation in the operation.
# Default to true.
# @return [true, false]
attr_accessor :client_side_validation
### TLS/SSL setting
# Set this to false to skip verifying SSL certificate when calling API from https server.
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl
### TLS/SSL setting
# Set this to false to skip verifying SSL host name
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl_host
### TLS/SSL setting
# Set this to customize the certificate file to verify the peer.
#
# @return [String] the path to the certificate file
#
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
attr_accessor :ssl_ca_cert
### TLS/SSL setting
# Client certificate file (for client certificate)
attr_accessor :cert_file
### TLS/SSL setting
# Client private key file (for client certificate)
attr_accessor :key_file
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
# Default to nil.
#
# @see The params_encoding option of Ethon. Related source code:
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
attr_accessor :params_encoding
attr_accessor :inject_format
attr_accessor :force_ending_format
attr_accessor :error_handler
def initialize
@scheme = 'https'
@host = 'api.hubapi.com'
@base_path = ''
@server_index = 0
@server_operation_index = {}
@server_variables = {}
@server_operation_variables = {}
@api_key = {}
@api_key_prefix = {}
@client_side_validation = true
@verify_ssl = true
@verify_ssl_host = true
@cert_file = nil
@key_file = nil
@timeout = 0
@params_encoding = nil
@debugging = false
@inject_format = false
@force_ending_format = false
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
# error_handler params: { 'status_code': { max_retries: ..., seconds_delay: ... }, ... }
@error_handler = {}
yield(self) if block_given?
end
# The default Configuration object.
def self.default
@@default ||= Configuration.new
end
def configure
yield(self) if block_given?
end
def scheme=(scheme)
# remove :// from scheme
@scheme = scheme.sub(/:\/\//, '')
end
def host=(host)
# remove http(s):// and anything after a slash
@host = host.sub(/https?:\/\//, '').split('/').first
end
def base_path=(base_path)
# Add leading and trailing slashes to base_path
@base_path = "/#{base_path}".gsub(/\/+/, '/')
@base_path = '' if @base_path == '/'
end
# Returns base URL for specified operation based on server settings
def base_url(operation = nil)
index = server_operation_index.fetch(operation, server_index)
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
end
# Gets API key (with prefix if set).
# @param [String] param_name the parameter name of API key auth
def api_key_with_prefix(param_name, param_alias = nil)
key = @api_key[param_name]
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
if @api_key_prefix[param_name]
"#{@api_key_prefix[param_name]} #{key}"
else
key
end
end
# Gets Basic Auth token string
def basic_auth_token
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
end
# Returns Auth Settings hash for api client.
def auth_settings
{
'oauth2' =>
{
type: 'oauth2',
in: 'header',
key: 'Authorization',
value: "Bearer #{access_token}"
},
}
end
# Returns an array of Server setting
def server_settings
[
{
url: "https://api.hubapi.com",
description: "No description provided",
}
]
end
def operation_server_settings
{
}
end
# Returns URL based on server settings
#
# @param index array index of the server settings
# @param variables hash of variable and the corresponding value
def server_url(index, variables = {}, servers = nil)
servers = server_settings if servers == nil
# check array index out of bound
if (index < 0 || index >= servers.size)
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
end
server = servers[index]
url = server[:url]
return url unless server.key? :variables
# go through variable and assign a value
server[:variables].each do |name, variable|
if variables.key?(name)
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
url.gsub! "{" + name.to_s + "}", variables[name]
else
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
end
else
# use default value
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
end
end
url
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/api_client.rb | lib/hubspot/codegen/marketing/forms/api_client.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'json'
require 'logger'
require 'tempfile'
require 'time'
require 'typhoeus'
module Hubspot
module Marketing
module Forms
class ApiClient
# The Configuration object holding settings to be used in the API client.
attr_accessor :config
# Defines the headers to be used in HTTP requests of all API calls by default.
#
# @return [Hash]
attr_accessor :default_headers
# Initializes the ApiClient
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
def initialize(config = Configuration.default)
@config = config
@user_agent = "hubspot-api-client-ruby; #{VERSION}"
@default_headers = {
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
}
end
def self.default
@@default ||= ApiClient.new
end
# Call an API with given options.
#
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
# the data deserialized from response body (could be nil), response status code and response headers.
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
if !response.success? && config.error_handler.any?
config.error_handler.each do |statuses, opts|
statuses = statuses.is_a?(Integer) ? [statuses] : statuses
retries = opts[:max_retries] || 5
while retries > 0 && statuses.include?(response.code)
sleep opts[:seconds_delay] if opts[:seconds_delay]
response = request.run
opts[:retry_block].call if opts[:retry_block]
retries -= 1
end
end
end
unless response.success?
if response.timed_out?
fail ApiError.new('Connection timed out')
elsif response.code == 0
# Errors from libcurl will be made visible here
fail ApiError.new(:code => 0,
:message => response.return_message)
else
fail ApiError.new(:code => response.code,
:response_headers => response.headers,
:response_body => response.body),
response.status_message
end
end
if opts[:return_type]
data = deserialize(response, opts[:return_type])
else
data = nil
end
return data, response.code, response.headers
end
# Builds the HTTP request
#
# @param [String] http_method HTTP method/verb (e.g. POST)
# @param [String] path URL path (e.g. /account/new)
# @option opts [Hash] :header_params Header parameters
# @option opts [Hash] :query_params Query parameters
# @option opts [Hash] :form_params Query parameters
# @option opts [Object] :body HTTP body (JSON/XML)
# @return [Typhoeus::Request] A Typhoeus Request
def build_request(http_method, path, opts = {})
url = build_request_url(path, opts)
http_method = http_method.to_sym.downcase
header_params = @default_headers.merge(opts[:header_params] || {})
query_params = opts[:query_params] || {}
form_params = opts[:form_params] || {}
follow_location = opts[:follow_location] || true
update_params_for_auth! header_params, query_params, opts[:auth_names]
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
req_opts = {
:method => http_method,
:headers => header_params,
:params => query_params,
:params_encoding => @config.params_encoding,
:timeout => @config.timeout,
:ssl_verifypeer => @config.verify_ssl,
:ssl_verifyhost => _verify_ssl_host,
:sslcert => @config.cert_file,
:sslkey => @config.key_file,
:verbose => @config.debugging,
:followlocation => follow_location
}
# set custom cert, if provided
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
if [:post, :patch, :put, :delete].include?(http_method)
req_body = build_request_body(header_params, form_params, opts[:body])
req_opts.update :body => req_body
if @config.debugging
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
end
end
request = Typhoeus::Request.new(url, req_opts)
download_file(request) if opts[:return_type] == 'File'
request
end
# Builds the HTTP request body
#
# @param [Hash] header_params Header parameters
# @param [Hash] form_params Query parameters
# @param [Object] body HTTP body (JSON/XML)
# @return [String] HTTP body data in the form of string
def build_request_body(header_params, form_params, body)
# http form
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
header_params['Content-Type'] == 'multipart/form-data'
data = {}
form_params.each do |key, value|
case value
when ::File, ::Array, nil
# let typhoeus handle File, Array and nil parameters
data[key] = value
else
data[key] = value.to_s
end
end
elsif body
data = body.is_a?(String) ? body : body.to_json
else
data = nil
end
data
end
# Save response body into a file in (the defined) temporary folder, using the filename
# from the "Content-Disposition" header if provided, otherwise a random filename.
# The response body is written to the file in chunks in order to handle files which
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
# process can use.
#
# @see Configuration#temp_folder_path
def download_file(request)
tempfile = nil
encoding = nil
request.on_headers do |response|
content_disposition = response.headers['Content-Disposition']
if content_disposition && content_disposition =~ /filename=/i
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
prefix = sanitize_filename(filename)
else
prefix = 'download-'
end
prefix = prefix + '-' unless prefix.end_with?('-')
encoding = response.body.encoding
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
@tempfile = tempfile
end
request.on_body do |chunk|
chunk.force_encoding(encoding)
tempfile.write(chunk)
end
request.on_complete do |response|
if tempfile
tempfile.close
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
"explicitly with `tempfile.delete`"
end
end
end
# Check if the given MIME is a JSON MIME.
# JSON MIME examples:
# application/json
# application/json; charset=UTF8
# APPLICATION/JSON
# */*
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end
# Deserialize the response to the given return type.
#
# @param [Response] response HTTP response
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
def deserialize(response, return_type)
body = response.body
# handle file downloading - return the File instance processed in request callbacks
# note that response body is empty when the file is written in chunks in request on_body callback
return @tempfile if return_type == 'File'
return nil if body.nil? || body.empty?
# return response body directly for String return type
return body if return_type == 'String'
# ensuring a default content type
content_type = response.headers['Content-Type'] || 'application/json'
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
begin
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
rescue JSON::ParserError => e
if %w(String Date Time).include?(return_type)
data = body
else
raise e
end
end
convert_to_type data, return_type
end
# Convert data to the given return type.
# @param [Object] data Data to be converted
# @param [String] return_type Return type
# @return [Mixed] Data in a particular type
def convert_to_type(data, return_type)
return nil if data.nil?
case return_type
when 'String'
data.to_s
when 'Integer'
data.to_i
when 'Float'
data.to_f
when 'Boolean'
data == true
when 'Time'
# parse date time (expecting ISO 8601 format)
Time.parse data
when 'Date'
# parse date time (expecting ISO 8601 format)
Date.parse data
when 'Object'
# generic object (usually a Hash), return directly
data
when /\AArray<(.+)>\z/
# e.g. Array<Pet>
sub_type = $1
data.map { |item| convert_to_type(item, sub_type) }
when /\AHash\<String, (.+)\>\z/
# e.g. Hash<String, Integer>
sub_type = $1
{}.tap do |hash|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
end
else
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(return_type)
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
end
end
# Sanitize filename by removing path.
# e.g. ../../sun.gif becomes sun.gif
#
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
end
def build_request_url(path, opts = {})
# Add leading and trailing slashes to path
path = "/#{path}".gsub(/\/+/, '/')
@config.base_url(opts[:operation]) + path
end
# Update header and query params based on authentication settings.
#
# @param [Hash] header_params Header parameters
# @param [Hash] query_params Query parameters
# @param [String] auth_names Authentication scheme name
def update_params_for_auth!(header_params, query_params, auth_names)
Array(auth_names).each do |auth_name|
auth_setting = @config.auth_settings[auth_name]
next unless auth_setting
case auth_setting[:in]
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
end
end
end
# Sets user agent in HTTP header
#
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
def user_agent=(user_agent)
@user_agent = user_agent
@default_headers['User-Agent'] = @user_agent
end
# Return Accept header based on an array of accepts provided.
# @param [Array] accepts array for Accept
# @return [String] the Accept header (e.g. application/json)
def select_header_accept(accepts)
return nil if accepts.nil? || accepts.empty?
# use JSON when present, otherwise use all of the provided
json_accept = accepts.find { |s| json_mime?(s) }
json_accept || accepts.join(',')
end
# Return Content-Type header based on an array of content types provided.
# @param [Array] content_types array for Content-Type
# @return [String] the Content-Type header (e.g. application/json)
def select_header_content_type(content_types)
# return nil by default
return if content_types.nil? || content_types.empty?
# use JSON when present, otherwise use the first one
json_content_type = content_types.find { |s| json_mime?(s) }
json_content_type || content_types.first
end
# Convert object (array, hash, object, etc) to JSON string.
# @param [Object] model object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_http_body(model)
return model if model.nil? || model.is_a?(String)
local_body = nil
if model.is_a?(Array)
local_body = model.map { |m| object_to_hash(m) }
else
local_body = object_to_hash(model)
end
local_body.to_json
end
# Convert object(non-array) to hash.
# @param [Object] obj object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_hash(obj)
if obj.respond_to?(:to_hash)
obj.to_hash
else
obj
end
end
# Build parameter value according to the given collection format.
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
def build_collection_param(param, collection_format)
case collection_format
when :csv
param.join(',')
when :ssv
param.join(' ')
when :tsv
param.join("\t")
when :pipes
param.join('|')
when :multi
# return the array directly as typhoeus will handle it as expected
param
else
fail "unknown collection format: #{collection_format.inspect}"
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/collection_response_form_definition_base_forward_paging_results_inner.rb | lib/hubspot/codegen/marketing/forms/models/collection_response_form_definition_base_forward_paging_results_inner.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
module CollectionResponseFormDefinitionBaseForwardPagingResultsInner
class << self
# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'HubSpotFormDefinition'
]
end
# Builds the object
# @param [Mixed] Data to be matched against the list of oneOf items
# @return [Object] Returns the model or the data itself
def build(data)
# Go through the list of oneOf items and attempt to identify the appropriate one.
# Note:
# - We do not attempt to check whether exactly one item matches.
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
# - TODO: scalar values are de facto behaving as if they were nullable.
# - TODO: logging when debugging is set.
openapi_one_of.each do |klass|
begin
next if klass == :AnyType # "nullable: true"
typed_data = find_and_cast_into_type(klass, data)
return typed_data if typed_data
rescue # rescue all errors so we keep iterating even if the current item lookup raises
end
end
openapi_one_of.include?(:AnyType) ? data : nil
end
private
SchemaMismatchError = Class.new(StandardError)
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
def find_and_cast_into_type(klass, data)
return if data.nil?
case klass.to_s
when 'Boolean'
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
when 'Float'
return data if data.instance_of?(Float)
when 'Integer'
return data if data.instance_of?(Integer)
when 'Time'
return Time.parse(data)
when 'Date'
return Date.parse(data)
when 'String'
return data if data.instance_of?(String)
when 'Object' # "type: object"
return data if data.instance_of?(Hash)
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
if data.instance_of?(Array)
sub_type = Regexp.last_match[:sub_type]
return data.map { |item| find_and_cast_into_type(sub_type, item) }
end
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
sub_type = Regexp.last_match[:sub_type]
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
end
else # model
const = Hubspot::Marketing::Forms.const_get(klass)
if const
if const.respond_to?(:openapi_one_of) # nested oneOf model
model = const.build(data)
return model if model
else
# raise if data contains keys that are not known to the model
raise unless (data.keys - const.acceptable_attributes).empty?
model = const.build_from_hash(data)
return model if model && model.valid?
end
end
end
raise # if no match by now, raise
rescue
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/legal_consent_checkbox.rb | lib/hubspot/codegen/marketing/forms/models/legal_consent_checkbox.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class LegalConsentCheckbox
#
attr_accessor :subscription_type_id
# The main label for the form field.
attr_accessor :label
# Whether this checkbox is required when submitting the form.
attr_accessor :required
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'subscription_type_id' => :'subscriptionTypeId',
:'label' => :'label',
:'required' => :'required'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'subscription_type_id' => :'Integer',
:'label' => :'String',
:'required' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::LegalConsentCheckbox` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::LegalConsentCheckbox`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'subscription_type_id')
self.subscription_type_id = attributes[:'subscription_type_id']
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @subscription_type_id.nil?
invalid_properties.push('invalid value for "subscription_type_id", subscription_type_id cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @subscription_type_id.nil?
return false if @label.nil?
return false if @required.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
subscription_type_id == o.subscription_type_id &&
label == o.label &&
required == o.required
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[subscription_type_id, label, required].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/form_display_options.rb | lib/hubspot/codegen/marketing/forms/models/form_display_options.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# Options for styling the form.
class FormDisplayOptions
# Whether the form will render as raw HTML as opposed to inside an iFrame.
attr_accessor :render_raw_html
#
attr_accessor :css_class
# The theme used for styling the input fields. This will not apply if the form is added to a HubSpot CMS page.
attr_accessor :theme
# The text displayed on the form submit button.
attr_accessor :submit_button_text
attr_accessor :style
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'render_raw_html' => :'renderRawHtml',
:'css_class' => :'cssClass',
:'theme' => :'theme',
:'submit_button_text' => :'submitButtonText',
:'style' => :'style'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'render_raw_html' => :'Boolean',
:'css_class' => :'String',
:'theme' => :'String',
:'submit_button_text' => :'String',
:'style' => :'FormStyle'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::FormDisplayOptions` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::FormDisplayOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'render_raw_html')
self.render_raw_html = attributes[:'render_raw_html']
end
if attributes.key?(:'css_class')
self.css_class = attributes[:'css_class']
end
if attributes.key?(:'theme')
self.theme = attributes[:'theme']
end
if attributes.key?(:'submit_button_text')
self.submit_button_text = attributes[:'submit_button_text']
end
if attributes.key?(:'style')
self.style = attributes[:'style']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @render_raw_html.nil?
invalid_properties.push('invalid value for "render_raw_html", render_raw_html cannot be nil.')
end
if @theme.nil?
invalid_properties.push('invalid value for "theme", theme cannot be nil.')
end
if @submit_button_text.nil?
invalid_properties.push('invalid value for "submit_button_text", submit_button_text cannot be nil.')
end
if @style.nil?
invalid_properties.push('invalid value for "style", style cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @render_raw_html.nil?
return false if @theme.nil?
theme_validator = EnumAttributeValidator.new('String', ["default_style", "canvas", "linear", "round", "sharp", "legacy"])
return false unless theme_validator.valid?(@theme)
return false if @submit_button_text.nil?
return false if @style.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] theme Object to be assigned
def theme=(theme)
validator = EnumAttributeValidator.new('String', ["default_style", "canvas", "linear", "round", "sharp", "legacy"])
unless validator.valid?(theme)
fail ArgumentError, "invalid value for \"theme\", must be one of #{validator.allowable_values}."
end
@theme = theme
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
render_raw_html == o.render_raw_html &&
css_class == o.css_class &&
theme == o.theme &&
submit_button_text == o.submit_button_text &&
style == o.style
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[render_raw_html, css_class, theme, submit_button_text, style].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/form_post_submit_action.rb | lib/hubspot/codegen/marketing/forms/models/form_post_submit_action.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# What should happen after the customer submits the form.
class FormPostSubmitAction
# The action to take after submit. The default action is displaying a thank you message.
attr_accessor :type
# The thank you text or the page to redirect to.
attr_accessor :value
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'type' => :'type',
:'value' => :'value'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'type' => :'String',
:'value' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::FormPostSubmitAction` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::FormPostSubmitAction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'type')
self.type = attributes[:'type']
end
if attributes.key?(:'value')
self.value = attributes[:'value']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @type.nil?
invalid_properties.push('invalid value for "type", type cannot be nil.')
end
if @value.nil?
invalid_properties.push('invalid value for "value", value cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @type.nil?
type_validator = EnumAttributeValidator.new('String', ["thank_you", "redirect_url"])
return false unless type_validator.valid?(@type)
return false if @value.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] type Object to be assigned
def type=(type)
validator = EnumAttributeValidator.new('String', ["thank_you", "redirect_url"])
unless validator.valid?(type)
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
end
@type = type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
type == o.type &&
value == o.value
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[type, value].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/form_style.rb | lib/hubspot/codegen/marketing/forms/models/form_style.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# Styling options for the form
class FormStyle
#
attr_accessor :label_text_size
#
attr_accessor :legal_consent_text_color
#
attr_accessor :font_family
#
attr_accessor :legal_consent_text_size
#
attr_accessor :background_width
#
attr_accessor :help_text_size
#
attr_accessor :submit_font_color
#
attr_accessor :label_text_color
#
attr_accessor :submit_alignment
#
attr_accessor :submit_size
#
attr_accessor :help_text_color
#
attr_accessor :submit_color
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'label_text_size' => :'labelTextSize',
:'legal_consent_text_color' => :'legalConsentTextColor',
:'font_family' => :'fontFamily',
:'legal_consent_text_size' => :'legalConsentTextSize',
:'background_width' => :'backgroundWidth',
:'help_text_size' => :'helpTextSize',
:'submit_font_color' => :'submitFontColor',
:'label_text_color' => :'labelTextColor',
:'submit_alignment' => :'submitAlignment',
:'submit_size' => :'submitSize',
:'help_text_color' => :'helpTextColor',
:'submit_color' => :'submitColor'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'label_text_size' => :'String',
:'legal_consent_text_color' => :'String',
:'font_family' => :'String',
:'legal_consent_text_size' => :'String',
:'background_width' => :'String',
:'help_text_size' => :'String',
:'submit_font_color' => :'String',
:'label_text_color' => :'String',
:'submit_alignment' => :'String',
:'submit_size' => :'String',
:'help_text_color' => :'String',
:'submit_color' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::FormStyle` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::FormStyle`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'label_text_size')
self.label_text_size = attributes[:'label_text_size']
end
if attributes.key?(:'legal_consent_text_color')
self.legal_consent_text_color = attributes[:'legal_consent_text_color']
end
if attributes.key?(:'font_family')
self.font_family = attributes[:'font_family']
end
if attributes.key?(:'legal_consent_text_size')
self.legal_consent_text_size = attributes[:'legal_consent_text_size']
end
if attributes.key?(:'background_width')
self.background_width = attributes[:'background_width']
end
if attributes.key?(:'help_text_size')
self.help_text_size = attributes[:'help_text_size']
end
if attributes.key?(:'submit_font_color')
self.submit_font_color = attributes[:'submit_font_color']
end
if attributes.key?(:'label_text_color')
self.label_text_color = attributes[:'label_text_color']
end
if attributes.key?(:'submit_alignment')
self.submit_alignment = attributes[:'submit_alignment']
end
if attributes.key?(:'submit_size')
self.submit_size = attributes[:'submit_size']
end
if attributes.key?(:'help_text_color')
self.help_text_color = attributes[:'help_text_color']
end
if attributes.key?(:'submit_color')
self.submit_color = attributes[:'submit_color']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @label_text_size.nil?
invalid_properties.push('invalid value for "label_text_size", label_text_size cannot be nil.')
end
if @legal_consent_text_color.nil?
invalid_properties.push('invalid value for "legal_consent_text_color", legal_consent_text_color cannot be nil.')
end
if @font_family.nil?
invalid_properties.push('invalid value for "font_family", font_family cannot be nil.')
end
if @legal_consent_text_size.nil?
invalid_properties.push('invalid value for "legal_consent_text_size", legal_consent_text_size cannot be nil.')
end
if @background_width.nil?
invalid_properties.push('invalid value for "background_width", background_width cannot be nil.')
end
if @help_text_size.nil?
invalid_properties.push('invalid value for "help_text_size", help_text_size cannot be nil.')
end
if @submit_font_color.nil?
invalid_properties.push('invalid value for "submit_font_color", submit_font_color cannot be nil.')
end
if @label_text_color.nil?
invalid_properties.push('invalid value for "label_text_color", label_text_color cannot be nil.')
end
if @submit_alignment.nil?
invalid_properties.push('invalid value for "submit_alignment", submit_alignment cannot be nil.')
end
if @submit_size.nil?
invalid_properties.push('invalid value for "submit_size", submit_size cannot be nil.')
end
if @help_text_color.nil?
invalid_properties.push('invalid value for "help_text_color", help_text_color cannot be nil.')
end
if @submit_color.nil?
invalid_properties.push('invalid value for "submit_color", submit_color cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @label_text_size.nil?
return false if @legal_consent_text_color.nil?
return false if @font_family.nil?
return false if @legal_consent_text_size.nil?
return false if @background_width.nil?
return false if @help_text_size.nil?
return false if @submit_font_color.nil?
return false if @label_text_color.nil?
return false if @submit_alignment.nil?
submit_alignment_validator = EnumAttributeValidator.new('String', ["left", "right", "center"])
return false unless submit_alignment_validator.valid?(@submit_alignment)
return false if @submit_size.nil?
return false if @help_text_color.nil?
return false if @submit_color.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] submit_alignment Object to be assigned
def submit_alignment=(submit_alignment)
validator = EnumAttributeValidator.new('String', ["left", "right", "center"])
unless validator.valid?(submit_alignment)
fail ArgumentError, "invalid value for \"submit_alignment\", must be one of #{validator.allowable_values}."
end
@submit_alignment = submit_alignment
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
label_text_size == o.label_text_size &&
legal_consent_text_color == o.legal_consent_text_color &&
font_family == o.font_family &&
legal_consent_text_size == o.legal_consent_text_size &&
background_width == o.background_width &&
help_text_size == o.help_text_size &&
submit_font_color == o.submit_font_color &&
label_text_color == o.label_text_color &&
submit_alignment == o.submit_alignment &&
submit_size == o.submit_size &&
help_text_color == o.help_text_color &&
submit_color == o.submit_color
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[label_text_size, legal_consent_text_color, font_family, legal_consent_text_size, background_width, help_text_size, submit_font_color, label_text_color, submit_alignment, submit_size, help_text_color, submit_color].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/legal_consent_options_legitimate_interest.rb | lib/hubspot/codegen/marketing/forms/models/legal_consent_options_legitimate_interest.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class LegalConsentOptionsLegitimateInterest
#
attr_accessor :subscription_type_ids
#
attr_accessor :lawful_basis
#
attr_accessor :type
#
attr_accessor :privacy_text
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'subscription_type_ids' => :'subscriptionTypeIds',
:'lawful_basis' => :'lawfulBasis',
:'type' => :'type',
:'privacy_text' => :'privacyText'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'subscription_type_ids' => :'Array<Integer>',
:'lawful_basis' => :'String',
:'type' => :'String',
:'privacy_text' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::LegalConsentOptionsLegitimateInterest` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::LegalConsentOptionsLegitimateInterest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'subscription_type_ids')
if (value = attributes[:'subscription_type_ids']).is_a?(Array)
self.subscription_type_ids = value
end
end
if attributes.key?(:'lawful_basis')
self.lawful_basis = attributes[:'lawful_basis']
end
if attributes.key?(:'type')
self.type = attributes[:'type']
else
self.type = 'legitimate_interest'
end
if attributes.key?(:'privacy_text')
self.privacy_text = attributes[:'privacy_text']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @subscription_type_ids.nil?
invalid_properties.push('invalid value for "subscription_type_ids", subscription_type_ids cannot be nil.')
end
if @lawful_basis.nil?
invalid_properties.push('invalid value for "lawful_basis", lawful_basis cannot be nil.')
end
if @type.nil?
invalid_properties.push('invalid value for "type", type cannot be nil.')
end
if @privacy_text.nil?
invalid_properties.push('invalid value for "privacy_text", privacy_text cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @subscription_type_ids.nil?
return false if @lawful_basis.nil?
lawful_basis_validator = EnumAttributeValidator.new('String', ["lead", "client", "other"])
return false unless lawful_basis_validator.valid?(@lawful_basis)
return false if @type.nil?
type_validator = EnumAttributeValidator.new('String', ["legitimate_interest"])
return false unless type_validator.valid?(@type)
return false if @privacy_text.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] lawful_basis Object to be assigned
def lawful_basis=(lawful_basis)
validator = EnumAttributeValidator.new('String', ["lead", "client", "other"])
unless validator.valid?(lawful_basis)
fail ArgumentError, "invalid value for \"lawful_basis\", must be one of #{validator.allowable_values}."
end
@lawful_basis = lawful_basis
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] type Object to be assigned
def type=(type)
validator = EnumAttributeValidator.new('String', ["legitimate_interest"])
unless validator.valid?(type)
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
end
@type = type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
subscription_type_ids == o.subscription_type_ids &&
lawful_basis == o.lawful_basis &&
type == o.type &&
privacy_text == o.privacy_text
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[subscription_type_ids, lawful_basis, type, privacy_text].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition_create_request.rb | lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition_create_request.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class HubSpotFormDefinitionCreateRequest
attr_accessor :form_type
attr_accessor :name
attr_accessor :created_at
attr_accessor :updated_at
attr_accessor :archived
attr_accessor :archived_at
attr_accessor :field_groups
attr_accessor :configuration
attr_accessor :display_options
attr_accessor :legal_consent_options
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'form_type' => :'formType',
:'name' => :'name',
:'created_at' => :'createdAt',
:'updated_at' => :'updatedAt',
:'archived' => :'archived',
:'archived_at' => :'archivedAt',
:'field_groups' => :'fieldGroups',
:'configuration' => :'configuration',
:'display_options' => :'displayOptions',
:'legal_consent_options' => :'legalConsentOptions'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'form_type' => :'String',
:'name' => :'String',
:'created_at' => :'Time',
:'updated_at' => :'Time',
:'archived' => :'Boolean',
:'archived_at' => :'Time',
:'field_groups' => :'Array<FieldGroup>',
:'configuration' => :'HubSpotFormConfiguration',
:'display_options' => :'FormDisplayOptions',
:'legal_consent_options' => :'OneOfLegalConsentOptionsNoneLegalConsentOptionsLegitimateInterestLegalConsentOptionsExplicitConsentToProcessLegalConsentOptionsImplicitConsentToProcess'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
:'legal_consent_options'
])
end
# List of class defined in allOf (OpenAPI v3)
def self.openapi_all_of
[
:'HubSpotFormDefinitionCreateRequestAllOf'
]
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::HubSpotFormDefinitionCreateRequest` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::HubSpotFormDefinitionCreateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'form_type')
self.form_type = attributes[:'form_type']
else
self.form_type = 'hubspot'
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'created_at')
self.created_at = attributes[:'created_at']
end
if attributes.key?(:'updated_at')
self.updated_at = attributes[:'updated_at']
end
if attributes.key?(:'archived')
self.archived = attributes[:'archived']
end
if attributes.key?(:'archived_at')
self.archived_at = attributes[:'archived_at']
end
if attributes.key?(:'field_groups')
if (value = attributes[:'field_groups']).is_a?(Array)
self.field_groups = value
end
end
if attributes.key?(:'configuration')
self.configuration = attributes[:'configuration']
end
if attributes.key?(:'display_options')
self.display_options = attributes[:'display_options']
end
if attributes.key?(:'legal_consent_options')
self.legal_consent_options = attributes[:'legal_consent_options']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @form_type.nil?
invalid_properties.push('invalid value for "form_type", form_type cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @created_at.nil?
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
end
if @updated_at.nil?
invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
end
if @archived.nil?
invalid_properties.push('invalid value for "archived", archived cannot be nil.')
end
if @field_groups.nil?
invalid_properties.push('invalid value for "field_groups", field_groups cannot be nil.')
end
if @configuration.nil?
invalid_properties.push('invalid value for "configuration", configuration cannot be nil.')
end
if @display_options.nil?
invalid_properties.push('invalid value for "display_options", display_options cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @form_type.nil?
form_type_validator = EnumAttributeValidator.new('String', ["hubspot"])
return false unless form_type_validator.valid?(@form_type)
return false if @name.nil?
return false if @created_at.nil?
return false if @updated_at.nil?
return false if @archived.nil?
return false if @field_groups.nil?
return false if @configuration.nil?
return false if @display_options.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] form_type Object to be assigned
def form_type=(form_type)
validator = EnumAttributeValidator.new('String', ["hubspot"])
unless validator.valid?(form_type)
fail ArgumentError, "invalid value for \"form_type\", must be one of #{validator.allowable_values}."
end
@form_type = form_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
form_type == o.form_type &&
name == o.name &&
created_at == o.created_at &&
updated_at == o.updated_at &&
archived == o.archived &&
archived_at == o.archived_at &&
field_groups == o.field_groups &&
configuration == o.configuration &&
display_options == o.display_options &&
legal_consent_options == o.legal_consent_options
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[form_type, name, created_at, updated_at, archived, archived_at, field_groups, configuration, display_options, legal_consent_options].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/email_field.rb | lib/hubspot/codegen/marketing/forms/models/email_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field used for collecting an email address.
class EmailField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The value filled in by default. This value will be submitted unless the customer modifies it.
attr_accessor :default_value
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# Additional text helping the customer to complete the field.
attr_accessor :description
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# The prompt text showing when the field isn't filled in.
attr_accessor :placeholder
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
attr_accessor :validation
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'default_value' => :'defaultValue',
:'name' => :'name',
:'description' => :'description',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'placeholder' => :'placeholder',
:'field_type' => :'fieldType',
:'required' => :'required',
:'validation' => :'validation'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'default_value' => :'String',
:'name' => :'String',
:'description' => :'String',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'placeholder' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean',
:'validation' => :'EmailFieldValidation'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::EmailField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::EmailField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'default_value')
self.default_value = attributes[:'default_value']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'placeholder')
self.placeholder = attributes[:'placeholder']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'email'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
if attributes.key?(:'validation')
self.validation = attributes[:'validation']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
if @validation.nil?
invalid_properties.push('invalid value for "validation", validation cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["email"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
return false if @validation.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["email"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
default_value == o.default_value &&
name == o.name &&
description == o.description &&
dependent_fields == o.dependent_fields &&
label == o.label &&
placeholder == o.placeholder &&
field_type == o.field_type &&
required == o.required &&
validation == o.validation
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, default_value, name, description, dependent_fields, label, placeholder, field_type, required, validation].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/enumerated_field_option.rb | lib/hubspot/codegen/marketing/forms/models/enumerated_field_option.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class EnumeratedFieldOption
# The order the choices will be displayed in.
attr_accessor :display_order
#
attr_accessor :description
# The visible label for this choice.
attr_accessor :label
# The value which will be submitted if this choice is selected.
attr_accessor :value
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'display_order' => :'displayOrder',
:'description' => :'description',
:'label' => :'label',
:'value' => :'value'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'display_order' => :'Integer',
:'description' => :'String',
:'label' => :'String',
:'value' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::EnumeratedFieldOption` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::EnumeratedFieldOption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'display_order')
self.display_order = attributes[:'display_order']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'value')
self.value = attributes[:'value']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @display_order.nil?
invalid_properties.push('invalid value for "display_order", display_order cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @value.nil?
invalid_properties.push('invalid value for "value", value cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @display_order.nil?
return false if @label.nil?
return false if @value.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
display_order == o.display_order &&
description == o.description &&
label == o.label &&
value == o.value
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[display_order, description, label, value].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/form_definition_base.rb | lib/hubspot/codegen/marketing/forms/models/form_definition_base.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
module FormDefinitionBase
class << self
# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'HubSpotFormDefinition'
]
end
# Builds the object
# @param [Mixed] Data to be matched against the list of oneOf items
# @return [Object] Returns the model or the data itself
def build(data)
# Go through the list of oneOf items and attempt to identify the appropriate one.
# Note:
# - We do not attempt to check whether exactly one item matches.
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
# - TODO: scalar values are de facto behaving as if they were nullable.
# - TODO: logging when debugging is set.
openapi_one_of.each do |klass|
begin
next if klass == :AnyType # "nullable: true"
typed_data = find_and_cast_into_type(klass, data)
return typed_data if typed_data
rescue # rescue all errors so we keep iterating even if the current item lookup raises
end
end
openapi_one_of.include?(:AnyType) ? data : nil
end
private
SchemaMismatchError = Class.new(StandardError)
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
def find_and_cast_into_type(klass, data)
return if data.nil?
case klass.to_s
when 'Boolean'
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
when 'Float'
return data if data.instance_of?(Float)
when 'Integer'
return data if data.instance_of?(Integer)
when 'Time'
return Time.parse(data)
when 'Date'
return Date.parse(data)
when 'String'
return data if data.instance_of?(String)
when 'Object' # "type: object"
return data if data.instance_of?(Hash)
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
if data.instance_of?(Array)
sub_type = Regexp.last_match[:sub_type]
return data.map { |item| find_and_cast_into_type(sub_type, item) }
end
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
sub_type = Regexp.last_match[:sub_type]
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
end
else # model
const = Hubspot::Marketing::Forms.const_get(klass)
if const
if const.respond_to?(:openapi_one_of) # nested oneOf model
model = const.build(data)
return model if model
else
# raise if data contains keys that are not known to the model
raise unless (data.keys - const.acceptable_attributes).empty?
model = const.build_from_hash(data)
return model if model && model.valid?
end
end
end
raise # if no match by now, raise
rescue
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/dependent_field.rb | lib/hubspot/codegen/marketing/forms/models/dependent_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field that will be displayed based on what the customer entered in another field.
class DependentField
attr_accessor :dependent_condition
attr_accessor :dependent_field
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'dependent_condition' => :'dependentCondition',
:'dependent_field' => :'dependentField'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'dependent_condition' => :'DependentFieldFilter',
:'dependent_field' => :'DependentFieldDependentField'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::DependentField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::DependentField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'dependent_condition')
self.dependent_condition = attributes[:'dependent_condition']
end
if attributes.key?(:'dependent_field')
self.dependent_field = attributes[:'dependent_field']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @dependent_condition.nil?
invalid_properties.push('invalid value for "dependent_condition", dependent_condition cannot be nil.')
end
if @dependent_field.nil?
invalid_properties.push('invalid value for "dependent_field", dependent_field cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @dependent_condition.nil?
return false if @dependent_field.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
dependent_condition == o.dependent_condition &&
dependent_field == o.dependent_field
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[dependent_condition, dependent_field].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/phone_field.rb | lib/hubspot/codegen/marketing/forms/models/phone_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field used for collecting a phone number.
class PhoneField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The value filled in by default. This value will be submitted unless the customer modifies it.
attr_accessor :default_value
# Whether to display a country code drop down next to the phone field.
attr_accessor :use_country_code_select
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# Additional text helping the customer to complete the field.
attr_accessor :description
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# The prompt text showing when the field isn't filled in.
attr_accessor :placeholder
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
attr_accessor :validation
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'default_value' => :'defaultValue',
:'use_country_code_select' => :'useCountryCodeSelect',
:'name' => :'name',
:'description' => :'description',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'placeholder' => :'placeholder',
:'field_type' => :'fieldType',
:'required' => :'required',
:'validation' => :'validation'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'default_value' => :'String',
:'use_country_code_select' => :'Boolean',
:'name' => :'String',
:'description' => :'String',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'placeholder' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean',
:'validation' => :'PhoneFieldValidation'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::PhoneField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::PhoneField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'default_value')
self.default_value = attributes[:'default_value']
end
if attributes.key?(:'use_country_code_select')
self.use_country_code_select = attributes[:'use_country_code_select']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'placeholder')
self.placeholder = attributes[:'placeholder']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'phone'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
if attributes.key?(:'validation')
self.validation = attributes[:'validation']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @use_country_code_select.nil?
invalid_properties.push('invalid value for "use_country_code_select", use_country_code_select cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
if @validation.nil?
invalid_properties.push('invalid value for "validation", validation cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @use_country_code_select.nil?
return false if @name.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["phone"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
return false if @validation.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["phone"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
default_value == o.default_value &&
use_country_code_select == o.use_country_code_select &&
name == o.name &&
description == o.description &&
dependent_fields == o.dependent_fields &&
label == o.label &&
placeholder == o.placeholder &&
field_type == o.field_type &&
required == o.required &&
validation == o.validation
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, default_value, use_country_code_select, name, description, dependent_fields, label, placeholder, field_type, required, validation].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/legal_consent_options_none.rb | lib/hubspot/codegen/marketing/forms/models/legal_consent_options_none.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class LegalConsentOptionsNone
#
attr_accessor :type
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'type' => :'type'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'type' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::LegalConsentOptionsNone` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::LegalConsentOptionsNone`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'type')
self.type = attributes[:'type']
else
self.type = 'none'
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @type.nil?
invalid_properties.push('invalid value for "type", type cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @type.nil?
type_validator = EnumAttributeValidator.new('String', ["none"])
return false unless type_validator.valid?(@type)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] type Object to be assigned
def type=(type)
validator = EnumAttributeValidator.new('String', ["none"])
unless validator.valid?(type)
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
end
@type = type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
type == o.type
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[type].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/dropdown_field.rb | lib/hubspot/codegen/marketing/forms/models/dropdown_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A field consisting of a drop down with multiple choices.
class DropdownField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# The list of available choices for this field.
attr_accessor :options
# Additional text helping the customer to complete the field.
attr_accessor :description
# The values selected by default. Those values will be submitted unless the customer modifies them.
attr_accessor :default_values
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# The prompt text showing when the field isn't filled in.
attr_accessor :placeholder
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'name' => :'name',
:'options' => :'options',
:'description' => :'description',
:'default_values' => :'defaultValues',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'placeholder' => :'placeholder',
:'field_type' => :'fieldType',
:'required' => :'required'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'name' => :'String',
:'options' => :'Array<EnumeratedFieldOption>',
:'description' => :'String',
:'default_values' => :'Array<String>',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'placeholder' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::DropdownField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::DropdownField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'options')
if (value = attributes[:'options']).is_a?(Array)
self.options = value
end
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'default_values')
if (value = attributes[:'default_values']).is_a?(Array)
self.default_values = value
end
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'placeholder')
self.placeholder = attributes[:'placeholder']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'dropdown'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @options.nil?
invalid_properties.push('invalid value for "options", options cannot be nil.')
end
if @default_values.nil?
invalid_properties.push('invalid value for "default_values", default_values cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @options.nil?
return false if @default_values.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["dropdown"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["dropdown"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
name == o.name &&
options == o.options &&
description == o.description &&
default_values == o.default_values &&
dependent_fields == o.dependent_fields &&
label == o.label &&
placeholder == o.placeholder &&
field_type == o.field_type &&
required == o.required
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, name, options, description, default_values, dependent_fields, label, placeholder, field_type, required].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition_patch_request_legal_consent_options.rb | lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition_patch_request_legal_consent_options.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
module HubSpotFormDefinitionPatchRequestLegalConsentOptions
class << self
# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'LegalConsentOptionsExplicitConsentToProcess',
:'LegalConsentOptionsImplicitConsentToProcess',
:'LegalConsentOptionsLegitimateInterest',
:'LegalConsentOptionsNone'
]
end
# Builds the object
# @param [Mixed] Data to be matched against the list of oneOf items
# @return [Object] Returns the model or the data itself
def build(data)
# Go through the list of oneOf items and attempt to identify the appropriate one.
# Note:
# - We do not attempt to check whether exactly one item matches.
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
# - TODO: scalar values are de facto behaving as if they were nullable.
# - TODO: logging when debugging is set.
openapi_one_of.each do |klass|
begin
next if klass == :AnyType # "nullable: true"
typed_data = find_and_cast_into_type(klass, data)
return typed_data if typed_data
rescue # rescue all errors so we keep iterating even if the current item lookup raises
end
end
openapi_one_of.include?(:AnyType) ? data : nil
end
private
SchemaMismatchError = Class.new(StandardError)
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
def find_and_cast_into_type(klass, data)
return if data.nil?
case klass.to_s
when 'Boolean'
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
when 'Float'
return data if data.instance_of?(Float)
when 'Integer'
return data if data.instance_of?(Integer)
when 'Time'
return Time.parse(data)
when 'Date'
return Date.parse(data)
when 'String'
return data if data.instance_of?(String)
when 'Object' # "type: object"
return data if data.instance_of?(Hash)
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
if data.instance_of?(Array)
sub_type = Regexp.last_match[:sub_type]
return data.map { |item| find_and_cast_into_type(sub_type, item) }
end
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
sub_type = Regexp.last_match[:sub_type]
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
end
else # model
const = Hubspot::Marketing::Forms.const_get(klass)
if const
if const.respond_to?(:openapi_one_of) # nested oneOf model
model = const.build(data)
return model if model
else
# raise if data contains keys that are not known to the model
raise unless (data.keys - const.acceptable_attributes).empty?
model = const.build_from_hash(data)
return model if model && model.valid?
end
end
end
raise # if no match by now, raise
rescue
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/next_page.rb | lib/hubspot/codegen/marketing/forms/models/next_page.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class NextPage
#
attr_accessor :link
#
attr_accessor :after
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'link' => :'link',
:'after' => :'after'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'link' => :'String',
:'after' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::NextPage` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::NextPage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'link')
self.link = attributes[:'link']
end
if attributes.key?(:'after')
self.after = attributes[:'after']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @after.nil?
invalid_properties.push('invalid value for "after", after cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @after.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
link == o.link &&
after == o.after
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[link, after].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/mobile_phone_field.rb | lib/hubspot/codegen/marketing/forms/models/mobile_phone_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field used for collecting a mobile phone number.
class MobilePhoneField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The value filled in by default. This value will be submitted unless the customer modifies it.
attr_accessor :default_value
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# Additional text helping the customer to complete the field.
attr_accessor :description
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# The prompt text showing when the field isn't filled in.
attr_accessor :placeholder
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
attr_accessor :validation
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'default_value' => :'defaultValue',
:'name' => :'name',
:'description' => :'description',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'placeholder' => :'placeholder',
:'field_type' => :'fieldType',
:'required' => :'required',
:'validation' => :'validation'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'default_value' => :'String',
:'name' => :'String',
:'description' => :'String',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'placeholder' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean',
:'validation' => :'PhoneFieldValidation'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::MobilePhoneField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::MobilePhoneField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'default_value')
self.default_value = attributes[:'default_value']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'placeholder')
self.placeholder = attributes[:'placeholder']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'mobile_phone'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
if attributes.key?(:'validation')
self.validation = attributes[:'validation']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
if @validation.nil?
invalid_properties.push('invalid value for "validation", validation cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["mobile_phone"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
return false if @validation.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["mobile_phone"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
default_value == o.default_value &&
name == o.name &&
description == o.description &&
dependent_fields == o.dependent_fields &&
label == o.label &&
placeholder == o.placeholder &&
field_type == o.field_type &&
required == o.required &&
validation == o.validation
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, default_value, name, description, dependent_fields, label, placeholder, field_type, required, validation].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/single_checkbox_field.rb | lib/hubspot/codegen/marketing/forms/models/single_checkbox_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field consisting of a single checkbox.
class SingleCheckboxField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The value filled in by default. This value will be submitted unless the customer modifies it.
attr_accessor :default_value
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# Additional text helping the customer to complete the field.
attr_accessor :description
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'default_value' => :'defaultValue',
:'name' => :'name',
:'description' => :'description',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'field_type' => :'fieldType',
:'required' => :'required'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'default_value' => :'String',
:'name' => :'String',
:'description' => :'String',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::SingleCheckboxField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::SingleCheckboxField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'default_value')
self.default_value = attributes[:'default_value']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'single_checkbox'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["single_checkbox"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["single_checkbox"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
default_value == o.default_value &&
name == o.name &&
description == o.description &&
dependent_fields == o.dependent_fields &&
label == o.label &&
field_type == o.field_type &&
required == o.required
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, default_value, name, description, dependent_fields, label, field_type, required].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/multi_line_text_field.rb | lib/hubspot/codegen/marketing/forms/models/multi_line_text_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field consisting of a multiple-line text box.
class MultiLineTextField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The value filled in by default. This value will be submitted unless the customer modifies it.
attr_accessor :default_value
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# Additional text helping the customer to complete the field.
attr_accessor :description
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# The prompt text showing when the field isn't filled in.
attr_accessor :placeholder
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'default_value' => :'defaultValue',
:'name' => :'name',
:'description' => :'description',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'placeholder' => :'placeholder',
:'field_type' => :'fieldType',
:'required' => :'required'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'default_value' => :'String',
:'name' => :'String',
:'description' => :'String',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'placeholder' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::MultiLineTextField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::MultiLineTextField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'default_value')
self.default_value = attributes[:'default_value']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'placeholder')
self.placeholder = attributes[:'placeholder']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'multi_line_text'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["multi_line_text"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["multi_line_text"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
default_value == o.default_value &&
name == o.name &&
description == o.description &&
dependent_fields == o.dependent_fields &&
label == o.label &&
placeholder == o.placeholder &&
field_type == o.field_type &&
required == o.required
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, default_value, name, description, dependent_fields, label, placeholder, field_type, required].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/number_field.rb | lib/hubspot/codegen/marketing/forms/models/number_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field used for collecting a numeric value.
class NumberField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The value filled in by default. This value will be submitted unless the customer modifies it.
attr_accessor :default_value
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# Additional text helping the customer to complete the field.
attr_accessor :description
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# The prompt text showing when the field isn't filled in.
attr_accessor :placeholder
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
attr_accessor :validation
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'default_value' => :'defaultValue',
:'name' => :'name',
:'description' => :'description',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'placeholder' => :'placeholder',
:'field_type' => :'fieldType',
:'required' => :'required',
:'validation' => :'validation'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'default_value' => :'String',
:'name' => :'String',
:'description' => :'String',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'placeholder' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean',
:'validation' => :'NumberFieldValidation'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::NumberField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::NumberField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'default_value')
self.default_value = attributes[:'default_value']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'placeholder')
self.placeholder = attributes[:'placeholder']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'number'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
if attributes.key?(:'validation')
self.validation = attributes[:'validation']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["number"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["number"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
default_value == o.default_value &&
name == o.name &&
description == o.description &&
dependent_fields == o.dependent_fields &&
label == o.label &&
placeholder == o.placeholder &&
field_type == o.field_type &&
required == o.required &&
validation == o.validation
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, default_value, name, description, dependent_fields, label, placeholder, field_type, required, validation].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/error_detail.rb | lib/hubspot/codegen/marketing/forms/models/error_detail.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class ErrorDetail
# A specific category that contains more specific detail about the error
attr_accessor :sub_category
# The status code associated with the error detail
attr_accessor :code
# The name of the field or parameter in which the error was found.
attr_accessor :_in
# Context about the error condition
attr_accessor :context
# A human readable message describing the error along with remediation steps where appropriate
attr_accessor :message
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'code' => :'code',
:'_in' => :'in',
:'context' => :'context',
:'message' => :'message'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'String',
:'code' => :'String',
:'_in' => :'String',
:'context' => :'Hash<String, Array<String>>',
:'message' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::ErrorDetail` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::ErrorDetail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'code')
self.code = attributes[:'code']
end
if attributes.key?(:'_in')
self._in = attributes[:'_in']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @message.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
code == o.code &&
_in == o._in &&
context == o.context &&
message == o.message
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, code, _in, context, message].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition_patch_request.rb | lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition_patch_request.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class HubSpotFormDefinitionPatchRequest
# The fields in the form, grouped in rows.
attr_accessor :field_groups
# Whether this form is archived.
attr_accessor :archived
attr_accessor :configuration
# The name of the form. Expected to be unique for a hub.
attr_accessor :name
attr_accessor :legal_consent_options
attr_accessor :display_options
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'field_groups' => :'fieldGroups',
:'archived' => :'archived',
:'configuration' => :'configuration',
:'name' => :'name',
:'legal_consent_options' => :'legalConsentOptions',
:'display_options' => :'displayOptions'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'field_groups' => :'Array<FieldGroup>',
:'archived' => :'Boolean',
:'configuration' => :'HubSpotFormConfiguration',
:'name' => :'String',
:'legal_consent_options' => :'HubSpotFormDefinitionPatchRequestLegalConsentOptions',
:'display_options' => :'FormDisplayOptions'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::HubSpotFormDefinitionPatchRequest` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::HubSpotFormDefinitionPatchRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'field_groups')
if (value = attributes[:'field_groups']).is_a?(Array)
self.field_groups = value
end
end
if attributes.key?(:'archived')
self.archived = attributes[:'archived']
end
if attributes.key?(:'configuration')
self.configuration = attributes[:'configuration']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'legal_consent_options')
self.legal_consent_options = attributes[:'legal_consent_options']
end
if attributes.key?(:'display_options')
self.display_options = attributes[:'display_options']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
field_groups == o.field_groups &&
archived == o.archived &&
configuration == o.configuration &&
name == o.name &&
legal_consent_options == o.legal_consent_options &&
display_options == o.display_options
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[field_groups, archived, configuration, name, legal_consent_options, display_options].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/radio_field.rb | lib/hubspot/codegen/marketing/forms/models/radio_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field consisting of a set of radio options, out of which one can be selected at a time.
class RadioField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# The list of available choices for this field.
attr_accessor :options
# Additional text helping the customer to complete the field.
attr_accessor :description
# The values selected by default. Those values will be submitted unless the customer modifies them.
attr_accessor :default_values
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# The prompt text showing when the field isn't filled in.
attr_accessor :placeholder
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'name' => :'name',
:'options' => :'options',
:'description' => :'description',
:'default_values' => :'defaultValues',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'placeholder' => :'placeholder',
:'field_type' => :'fieldType',
:'required' => :'required'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'name' => :'String',
:'options' => :'Array<EnumeratedFieldOption>',
:'description' => :'String',
:'default_values' => :'Array<String>',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'placeholder' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::RadioField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::RadioField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'options')
if (value = attributes[:'options']).is_a?(Array)
self.options = value
end
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'default_values')
if (value = attributes[:'default_values']).is_a?(Array)
self.default_values = value
end
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'placeholder')
self.placeholder = attributes[:'placeholder']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'radio'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @options.nil?
invalid_properties.push('invalid value for "options", options cannot be nil.')
end
if @default_values.nil?
invalid_properties.push('invalid value for "default_values", default_values cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @options.nil?
return false if @default_values.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["radio"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["radio"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
name == o.name &&
options == o.options &&
description == o.description &&
default_values == o.default_values &&
dependent_fields == o.dependent_fields &&
label == o.label &&
placeholder == o.placeholder &&
field_type == o.field_type &&
required == o.required
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, name, options, description, default_values, dependent_fields, label, placeholder, field_type, required].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/legal_consent_options_implicit_consent_to_process.rb | lib/hubspot/codegen/marketing/forms/models/legal_consent_options_implicit_consent_to_process.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class LegalConsentOptionsImplicitConsentToProcess
#
attr_accessor :communications_checkboxes
#
attr_accessor :communication_consent_text
#
attr_accessor :type
#
attr_accessor :privacy_text
#
attr_accessor :consent_to_process_text
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'communications_checkboxes' => :'communicationsCheckboxes',
:'communication_consent_text' => :'communicationConsentText',
:'type' => :'type',
:'privacy_text' => :'privacyText',
:'consent_to_process_text' => :'consentToProcessText'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'communications_checkboxes' => :'Array<LegalConsentCheckbox>',
:'communication_consent_text' => :'String',
:'type' => :'String',
:'privacy_text' => :'String',
:'consent_to_process_text' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::LegalConsentOptionsImplicitConsentToProcess` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::LegalConsentOptionsImplicitConsentToProcess`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'communications_checkboxes')
if (value = attributes[:'communications_checkboxes']).is_a?(Array)
self.communications_checkboxes = value
end
end
if attributes.key?(:'communication_consent_text')
self.communication_consent_text = attributes[:'communication_consent_text']
end
if attributes.key?(:'type')
self.type = attributes[:'type']
else
self.type = 'implicit_consent_to_process'
end
if attributes.key?(:'privacy_text')
self.privacy_text = attributes[:'privacy_text']
end
if attributes.key?(:'consent_to_process_text')
self.consent_to_process_text = attributes[:'consent_to_process_text']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @communications_checkboxes.nil?
invalid_properties.push('invalid value for "communications_checkboxes", communications_checkboxes cannot be nil.')
end
if @type.nil?
invalid_properties.push('invalid value for "type", type cannot be nil.')
end
if @privacy_text.nil?
invalid_properties.push('invalid value for "privacy_text", privacy_text cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @communications_checkboxes.nil?
return false if @type.nil?
type_validator = EnumAttributeValidator.new('String', ["implicit_consent_to_process"])
return false unless type_validator.valid?(@type)
return false if @privacy_text.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] type Object to be assigned
def type=(type)
validator = EnumAttributeValidator.new('String', ["implicit_consent_to_process"])
unless validator.valid?(type)
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
end
@type = type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
communications_checkboxes == o.communications_checkboxes &&
communication_consent_text == o.communication_consent_text &&
type == o.type &&
privacy_text == o.privacy_text &&
consent_to_process_text == o.consent_to_process_text
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[communications_checkboxes, communication_consent_text, type, privacy_text, consent_to_process_text].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/payment_link_radio_field.rb | lib/hubspot/codegen/marketing/forms/models/payment_link_radio_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class PaymentLinkRadioField
attr_accessor :object_type_id
attr_accessor :hidden
attr_accessor :name
attr_accessor :options
attr_accessor :description
attr_accessor :default_values
attr_accessor :dependent_fields
attr_accessor :label
attr_accessor :field_type
attr_accessor :required
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'name' => :'name',
:'options' => :'options',
:'description' => :'description',
:'default_values' => :'defaultValues',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'field_type' => :'fieldType',
:'required' => :'required'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'name' => :'String',
:'options' => :'Array<EnumeratedFieldOption>',
:'description' => :'String',
:'default_values' => :'Array<String>',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::PaymentLinkRadioField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::PaymentLinkRadioField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'options')
if (value = attributes[:'options']).is_a?(Array)
self.options = value
end
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'default_values')
if (value = attributes[:'default_values']).is_a?(Array)
self.default_values = value
end
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'payment_link_radio'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @options.nil?
invalid_properties.push('invalid value for "options", options cannot be nil.')
end
if @default_values.nil?
invalid_properties.push('invalid value for "default_values", default_values cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @options.nil?
return false if @default_values.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["payment_link_radio"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["payment_link_radio"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
name == o.name &&
options == o.options &&
description == o.description &&
default_values == o.default_values &&
dependent_fields == o.dependent_fields &&
label == o.label &&
field_type == o.field_type &&
required == o.required
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, name, options, description, default_values, dependent_fields, label, field_type, required].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/collection_response_form_definition_base_forward_paging.rb | lib/hubspot/codegen/marketing/forms/models/collection_response_form_definition_base_forward_paging.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class CollectionResponseFormDefinitionBaseForwardPaging
attr_accessor :paging
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'paging' => :'paging',
:'results' => :'results'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'paging' => :'ForwardPaging',
:'results' => :'Array<CollectionResponseFormDefinitionBaseForwardPagingResultsInner>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::CollectionResponseFormDefinitionBaseForwardPaging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::CollectionResponseFormDefinitionBaseForwardPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'paging')
self.paging = attributes[:'paging']
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @results.nil?
invalid_properties.push('invalid value for "results", results cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @results.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
paging == o.paging &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[paging, results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/legal_consent_options_explicit_consent_to_process.rb | lib/hubspot/codegen/marketing/forms/models/legal_consent_options_explicit_consent_to_process.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class LegalConsentOptionsExplicitConsentToProcess
#
attr_accessor :communications_checkboxes
#
attr_accessor :communication_consent_text
#
attr_accessor :consent_to_process_checkbox_label
#
attr_accessor :consent_to_process_footer_text
#
attr_accessor :type
#
attr_accessor :privacy_text
#
attr_accessor :consent_to_process_text
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'communications_checkboxes' => :'communicationsCheckboxes',
:'communication_consent_text' => :'communicationConsentText',
:'consent_to_process_checkbox_label' => :'consentToProcessCheckboxLabel',
:'consent_to_process_footer_text' => :'consentToProcessFooterText',
:'type' => :'type',
:'privacy_text' => :'privacyText',
:'consent_to_process_text' => :'consentToProcessText'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'communications_checkboxes' => :'Array<LegalConsentCheckbox>',
:'communication_consent_text' => :'String',
:'consent_to_process_checkbox_label' => :'String',
:'consent_to_process_footer_text' => :'String',
:'type' => :'String',
:'privacy_text' => :'String',
:'consent_to_process_text' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::LegalConsentOptionsExplicitConsentToProcess` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::LegalConsentOptionsExplicitConsentToProcess`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'communications_checkboxes')
if (value = attributes[:'communications_checkboxes']).is_a?(Array)
self.communications_checkboxes = value
end
end
if attributes.key?(:'communication_consent_text')
self.communication_consent_text = attributes[:'communication_consent_text']
end
if attributes.key?(:'consent_to_process_checkbox_label')
self.consent_to_process_checkbox_label = attributes[:'consent_to_process_checkbox_label']
end
if attributes.key?(:'consent_to_process_footer_text')
self.consent_to_process_footer_text = attributes[:'consent_to_process_footer_text']
end
if attributes.key?(:'type')
self.type = attributes[:'type']
else
self.type = 'explicit_consent_to_process'
end
if attributes.key?(:'privacy_text')
self.privacy_text = attributes[:'privacy_text']
end
if attributes.key?(:'consent_to_process_text')
self.consent_to_process_text = attributes[:'consent_to_process_text']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @communications_checkboxes.nil?
invalid_properties.push('invalid value for "communications_checkboxes", communications_checkboxes cannot be nil.')
end
if @type.nil?
invalid_properties.push('invalid value for "type", type cannot be nil.')
end
if @privacy_text.nil?
invalid_properties.push('invalid value for "privacy_text", privacy_text cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @communications_checkboxes.nil?
return false if @type.nil?
type_validator = EnumAttributeValidator.new('String', ["explicit_consent_to_process"])
return false unless type_validator.valid?(@type)
return false if @privacy_text.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] type Object to be assigned
def type=(type)
validator = EnumAttributeValidator.new('String', ["explicit_consent_to_process"])
unless validator.valid?(type)
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
end
@type = type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
communications_checkboxes == o.communications_checkboxes &&
communication_consent_text == o.communication_consent_text &&
consent_to_process_checkbox_label == o.consent_to_process_checkbox_label &&
consent_to_process_footer_text == o.consent_to_process_footer_text &&
type == o.type &&
privacy_text == o.privacy_text &&
consent_to_process_text == o.consent_to_process_text
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[communications_checkboxes, communication_consent_text, consent_to_process_checkbox_label, consent_to_process_footer_text, type, privacy_text, consent_to_process_text].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition_create_request_all_of.rb | lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition_create_request_all_of.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class HubSpotFormDefinitionCreateRequestAllOf
attr_accessor :form_type
attr_accessor :name
attr_accessor :created_at
attr_accessor :updated_at
attr_accessor :archived
attr_accessor :archived_at
attr_accessor :field_groups
attr_accessor :configuration
attr_accessor :display_options
attr_accessor :legal_consent_options
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'form_type' => :'formType',
:'name' => :'name',
:'created_at' => :'createdAt',
:'updated_at' => :'updatedAt',
:'archived' => :'archived',
:'archived_at' => :'archivedAt',
:'field_groups' => :'fieldGroups',
:'configuration' => :'configuration',
:'display_options' => :'displayOptions',
:'legal_consent_options' => :'legalConsentOptions'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'form_type' => :'String',
:'name' => :'String',
:'created_at' => :'Time',
:'updated_at' => :'Time',
:'archived' => :'Boolean',
:'archived_at' => :'Time',
:'field_groups' => :'Array<FieldGroup>',
:'configuration' => :'HubSpotFormConfiguration',
:'display_options' => :'FormDisplayOptions',
:'legal_consent_options' => :'OneOfLegalConsentOptionsNoneLegalConsentOptionsLegitimateInterestLegalConsentOptionsExplicitConsentToProcessLegalConsentOptionsImplicitConsentToProcess'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
:'legal_consent_options'
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::HubSpotFormDefinitionCreateRequestAllOf` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::HubSpotFormDefinitionCreateRequestAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'form_type')
self.form_type = attributes[:'form_type']
else
self.form_type = 'hubspot'
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'created_at')
self.created_at = attributes[:'created_at']
end
if attributes.key?(:'updated_at')
self.updated_at = attributes[:'updated_at']
end
if attributes.key?(:'archived')
self.archived = attributes[:'archived']
end
if attributes.key?(:'archived_at')
self.archived_at = attributes[:'archived_at']
end
if attributes.key?(:'field_groups')
if (value = attributes[:'field_groups']).is_a?(Array)
self.field_groups = value
end
end
if attributes.key?(:'configuration')
self.configuration = attributes[:'configuration']
end
if attributes.key?(:'display_options')
self.display_options = attributes[:'display_options']
end
if attributes.key?(:'legal_consent_options')
self.legal_consent_options = attributes[:'legal_consent_options']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @form_type.nil?
invalid_properties.push('invalid value for "form_type", form_type cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @created_at.nil?
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
end
if @updated_at.nil?
invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
end
if @archived.nil?
invalid_properties.push('invalid value for "archived", archived cannot be nil.')
end
if @field_groups.nil?
invalid_properties.push('invalid value for "field_groups", field_groups cannot be nil.')
end
if @configuration.nil?
invalid_properties.push('invalid value for "configuration", configuration cannot be nil.')
end
if @display_options.nil?
invalid_properties.push('invalid value for "display_options", display_options cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @form_type.nil?
form_type_validator = EnumAttributeValidator.new('String', ["hubspot"])
return false unless form_type_validator.valid?(@form_type)
return false if @name.nil?
return false if @created_at.nil?
return false if @updated_at.nil?
return false if @archived.nil?
return false if @field_groups.nil?
return false if @configuration.nil?
return false if @display_options.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] form_type Object to be assigned
def form_type=(form_type)
validator = EnumAttributeValidator.new('String', ["hubspot"])
unless validator.valid?(form_type)
fail ArgumentError, "invalid value for \"form_type\", must be one of #{validator.allowable_values}."
end
@form_type = form_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
form_type == o.form_type &&
name == o.name &&
created_at == o.created_at &&
updated_at == o.updated_at &&
archived == o.archived &&
archived_at == o.archived_at &&
field_groups == o.field_groups &&
configuration == o.configuration &&
display_options == o.display_options &&
legal_consent_options == o.legal_consent_options
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[form_type, name, created_at, updated_at, archived, archived_at, field_groups, configuration, display_options, legal_consent_options].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/forward_paging.rb | lib/hubspot/codegen/marketing/forms/models/forward_paging.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class ForwardPaging
attr_accessor :_next
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'_next' => :'next'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'_next' => :'NextPage'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::ForwardPaging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::ForwardPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'_next')
self._next = attributes[:'_next']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
_next == o._next
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[_next].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/number_field_validation.rb | lib/hubspot/codegen/marketing/forms/models/number_field_validation.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# Describes how a numeric value should be validated.
class NumberFieldValidation
#
attr_accessor :min_allowed_digits
#
attr_accessor :max_allowed_digits
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'min_allowed_digits' => :'minAllowedDigits',
:'max_allowed_digits' => :'maxAllowedDigits'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'min_allowed_digits' => :'Integer',
:'max_allowed_digits' => :'Integer'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::NumberFieldValidation` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::NumberFieldValidation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'min_allowed_digits')
self.min_allowed_digits = attributes[:'min_allowed_digits']
end
if attributes.key?(:'max_allowed_digits')
self.max_allowed_digits = attributes[:'max_allowed_digits']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @min_allowed_digits.nil?
invalid_properties.push('invalid value for "min_allowed_digits", min_allowed_digits cannot be nil.')
end
if @max_allowed_digits.nil?
invalid_properties.push('invalid value for "max_allowed_digits", max_allowed_digits cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @min_allowed_digits.nil?
return false if @max_allowed_digits.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
min_allowed_digits == o.min_allowed_digits &&
max_allowed_digits == o.max_allowed_digits
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[min_allowed_digits, max_allowed_digits].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/form_definition_create_request_base.rb | lib/hubspot/codegen/marketing/forms/models/form_definition_create_request_base.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
module FormDefinitionCreateRequestBase
class << self
# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'HubSpotFormDefinitionCreateRequest'
]
end
# Builds the object
# @param [Mixed] Data to be matched against the list of oneOf items
# @return [Object] Returns the model or the data itself
def build(data)
# Go through the list of oneOf items and attempt to identify the appropriate one.
# Note:
# - We do not attempt to check whether exactly one item matches.
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
# - TODO: scalar values are de facto behaving as if they were nullable.
# - TODO: logging when debugging is set.
openapi_one_of.each do |klass|
begin
next if klass == :AnyType # "nullable: true"
typed_data = find_and_cast_into_type(klass, data)
return typed_data if typed_data
rescue # rescue all errors so we keep iterating even if the current item lookup raises
end
end
openapi_one_of.include?(:AnyType) ? data : nil
end
private
SchemaMismatchError = Class.new(StandardError)
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
def find_and_cast_into_type(klass, data)
return if data.nil?
case klass.to_s
when 'Boolean'
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
when 'Float'
return data if data.instance_of?(Float)
when 'Integer'
return data if data.instance_of?(Integer)
when 'Time'
return Time.parse(data)
when 'Date'
return Date.parse(data)
when 'String'
return data if data.instance_of?(String)
when 'Object' # "type: object"
return data if data.instance_of?(Hash)
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
if data.instance_of?(Array)
sub_type = Regexp.last_match[:sub_type]
return data.map { |item| find_and_cast_into_type(sub_type, item) }
end
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
sub_type = Regexp.last_match[:sub_type]
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
end
else # model
const = Hubspot::Marketing::Forms.const_get(klass)
if const
if const.respond_to?(:openapi_one_of) # nested oneOf model
model = const.build(data)
return model if model
else
# raise if data contains keys that are not known to the model
raise unless (data.keys - const.acceptable_attributes).empty?
model = const.build_from_hash(data)
return model if model && model.valid?
end
end
end
raise # if no match by now, raise
rescue
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/dependent_field_filter.rb | lib/hubspot/codegen/marketing/forms/models/dependent_field_filter.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A condition based on customer input
class DependentFieldFilter
#
attr_accessor :range_start
#
attr_accessor :values
#
attr_accessor :value
#
attr_accessor :operator
#
attr_accessor :range_end
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'range_start' => :'rangeStart',
:'values' => :'values',
:'value' => :'value',
:'operator' => :'operator',
:'range_end' => :'rangeEnd'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'range_start' => :'String',
:'values' => :'Array<String>',
:'value' => :'String',
:'operator' => :'String',
:'range_end' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::DependentFieldFilter` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::DependentFieldFilter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'range_start')
self.range_start = attributes[:'range_start']
end
if attributes.key?(:'values')
if (value = attributes[:'values']).is_a?(Array)
self.values = value
end
end
if attributes.key?(:'value')
self.value = attributes[:'value']
end
if attributes.key?(:'operator')
self.operator = attributes[:'operator']
end
if attributes.key?(:'range_end')
self.range_end = attributes[:'range_end']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @range_start.nil?
invalid_properties.push('invalid value for "range_start", range_start cannot be nil.')
end
if @values.nil?
invalid_properties.push('invalid value for "values", values cannot be nil.')
end
if @value.nil?
invalid_properties.push('invalid value for "value", value cannot be nil.')
end
if @operator.nil?
invalid_properties.push('invalid value for "operator", operator cannot be nil.')
end
if @range_end.nil?
invalid_properties.push('invalid value for "range_end", range_end cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @range_start.nil?
return false if @values.nil?
return false if @value.nil?
return false if @operator.nil?
operator_validator = EnumAttributeValidator.new('String', ["eq", "neq", "contains", "doesnt_contain", "str_starts_with", "str_ends_with", "lt", "lte", "gt", "gte", "between", "not_between", "within_time_reverse", "within_time", "set_any", "set_not_any", "set_all", "set_not_all", "set_eq", "set_neq", "is_not_empty"])
return false unless operator_validator.valid?(@operator)
return false if @range_end.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] operator Object to be assigned
def operator=(operator)
validator = EnumAttributeValidator.new('String', ["eq", "neq", "contains", "doesnt_contain", "str_starts_with", "str_ends_with", "lt", "lte", "gt", "gte", "between", "not_between", "within_time_reverse", "within_time", "set_any", "set_not_any", "set_all", "set_not_all", "set_eq", "set_neq", "is_not_empty"])
unless validator.valid?(operator)
fail ArgumentError, "invalid value for \"operator\", must be one of #{validator.allowable_values}."
end
@operator = operator
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
range_start == o.range_start &&
values == o.values &&
value == o.value &&
operator == o.operator &&
range_end == o.range_end
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[range_start, values, value, operator, range_end].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/hub_spot_form_configuration.rb | lib/hubspot/codegen/marketing/forms/models/hub_spot_form_configuration.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class HubSpotFormConfiguration
# Whether to create a new contact when a form is submitted with an email address that doesn’t match any in your existing contacts records.
attr_accessor :create_new_contact_for_new_email
# Whether the form can be edited.
attr_accessor :editable
# Whether to add a reset link to the form. This removes any pre-populated content on the form and creates a new contact on submission.
attr_accessor :allow_link_to_reset_known_values
attr_accessor :lifecycle_stages
attr_accessor :post_submit_action
# The language of the form.
attr_accessor :language
# Whether contact fields should pre-populate with known information when a contact returns to your site.
attr_accessor :pre_populate_known_values
# Whether the form can be cloned.
attr_accessor :cloneable
# Whether to send a notification email to the contact owner when a submission is received.
attr_accessor :notify_contact_owner
# Whether CAPTCHA (spam prevention) is enabled.
attr_accessor :recaptcha_enabled
# Whether the form can be archived.
attr_accessor :archivable
# The list of user IDs to receive a notification email when a submission is received.
attr_accessor :notify_recipients
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'create_new_contact_for_new_email' => :'createNewContactForNewEmail',
:'editable' => :'editable',
:'allow_link_to_reset_known_values' => :'allowLinkToResetKnownValues',
:'lifecycle_stages' => :'lifecycleStages',
:'post_submit_action' => :'postSubmitAction',
:'language' => :'language',
:'pre_populate_known_values' => :'prePopulateKnownValues',
:'cloneable' => :'cloneable',
:'notify_contact_owner' => :'notifyContactOwner',
:'recaptcha_enabled' => :'recaptchaEnabled',
:'archivable' => :'archivable',
:'notify_recipients' => :'notifyRecipients'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'create_new_contact_for_new_email' => :'Boolean',
:'editable' => :'Boolean',
:'allow_link_to_reset_known_values' => :'Boolean',
:'lifecycle_stages' => :'Array<LifecycleStage>',
:'post_submit_action' => :'FormPostSubmitAction',
:'language' => :'String',
:'pre_populate_known_values' => :'Boolean',
:'cloneable' => :'Boolean',
:'notify_contact_owner' => :'Boolean',
:'recaptcha_enabled' => :'Boolean',
:'archivable' => :'Boolean',
:'notify_recipients' => :'Array<String>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::HubSpotFormConfiguration` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::HubSpotFormConfiguration`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'create_new_contact_for_new_email')
self.create_new_contact_for_new_email = attributes[:'create_new_contact_for_new_email']
end
if attributes.key?(:'editable')
self.editable = attributes[:'editable']
end
if attributes.key?(:'allow_link_to_reset_known_values')
self.allow_link_to_reset_known_values = attributes[:'allow_link_to_reset_known_values']
end
if attributes.key?(:'lifecycle_stages')
if (value = attributes[:'lifecycle_stages']).is_a?(Array)
self.lifecycle_stages = value
end
end
if attributes.key?(:'post_submit_action')
self.post_submit_action = attributes[:'post_submit_action']
end
if attributes.key?(:'language')
self.language = attributes[:'language']
end
if attributes.key?(:'pre_populate_known_values')
self.pre_populate_known_values = attributes[:'pre_populate_known_values']
end
if attributes.key?(:'cloneable')
self.cloneable = attributes[:'cloneable']
end
if attributes.key?(:'notify_contact_owner')
self.notify_contact_owner = attributes[:'notify_contact_owner']
end
if attributes.key?(:'recaptcha_enabled')
self.recaptcha_enabled = attributes[:'recaptcha_enabled']
end
if attributes.key?(:'archivable')
self.archivable = attributes[:'archivable']
end
if attributes.key?(:'notify_recipients')
if (value = attributes[:'notify_recipients']).is_a?(Array)
self.notify_recipients = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @create_new_contact_for_new_email.nil?
invalid_properties.push('invalid value for "create_new_contact_for_new_email", create_new_contact_for_new_email cannot be nil.')
end
if @editable.nil?
invalid_properties.push('invalid value for "editable", editable cannot be nil.')
end
if @allow_link_to_reset_known_values.nil?
invalid_properties.push('invalid value for "allow_link_to_reset_known_values", allow_link_to_reset_known_values cannot be nil.')
end
if @post_submit_action.nil?
invalid_properties.push('invalid value for "post_submit_action", post_submit_action cannot be nil.')
end
if @language.nil?
invalid_properties.push('invalid value for "language", language cannot be nil.')
end
if @pre_populate_known_values.nil?
invalid_properties.push('invalid value for "pre_populate_known_values", pre_populate_known_values cannot be nil.')
end
if @cloneable.nil?
invalid_properties.push('invalid value for "cloneable", cloneable cannot be nil.')
end
if @notify_contact_owner.nil?
invalid_properties.push('invalid value for "notify_contact_owner", notify_contact_owner cannot be nil.')
end
if @recaptcha_enabled.nil?
invalid_properties.push('invalid value for "recaptcha_enabled", recaptcha_enabled cannot be nil.')
end
if @archivable.nil?
invalid_properties.push('invalid value for "archivable", archivable cannot be nil.')
end
if @notify_recipients.nil?
invalid_properties.push('invalid value for "notify_recipients", notify_recipients cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @create_new_contact_for_new_email.nil?
return false if @editable.nil?
return false if @allow_link_to_reset_known_values.nil?
return false if @post_submit_action.nil?
return false if @language.nil?
language_validator = EnumAttributeValidator.new('String', ["af", "ar-eg", "bg", "bn", "ca-es", "cs", "da", "de", "el", "en", "es", "es-mx", "fi", "fr", "fr-ca", "he-il", "hr", "hu", "id", "it", "ja", "ko", "lt", "ms", "nl", "no-no", "pl", "pt", "pt-br", "ro", "ru", "sk", "sl", "sv", "th", "tl", "tr", "uk", "vi", "zh-cn", "zh-hk", "zh-tw"])
return false unless language_validator.valid?(@language)
return false if @pre_populate_known_values.nil?
return false if @cloneable.nil?
return false if @notify_contact_owner.nil?
return false if @recaptcha_enabled.nil?
return false if @archivable.nil?
return false if @notify_recipients.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] language Object to be assigned
def language=(language)
validator = EnumAttributeValidator.new('String', ["af", "ar-eg", "bg", "bn", "ca-es", "cs", "da", "de", "el", "en", "es", "es-mx", "fi", "fr", "fr-ca", "he-il", "hr", "hu", "id", "it", "ja", "ko", "lt", "ms", "nl", "no-no", "pl", "pt", "pt-br", "ro", "ru", "sk", "sl", "sv", "th", "tl", "tr", "uk", "vi", "zh-cn", "zh-hk", "zh-tw"])
unless validator.valid?(language)
fail ArgumentError, "invalid value for \"language\", must be one of #{validator.allowable_values}."
end
@language = language
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
create_new_contact_for_new_email == o.create_new_contact_for_new_email &&
editable == o.editable &&
allow_link_to_reset_known_values == o.allow_link_to_reset_known_values &&
lifecycle_stages == o.lifecycle_stages &&
post_submit_action == o.post_submit_action &&
language == o.language &&
pre_populate_known_values == o.pre_populate_known_values &&
cloneable == o.cloneable &&
notify_contact_owner == o.notify_contact_owner &&
recaptcha_enabled == o.recaptcha_enabled &&
archivable == o.archivable &&
notify_recipients == o.notify_recipients
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[create_new_contact_for_new_email, editable, allow_link_to_reset_known_values, lifecycle_stages, post_submit_action, language, pre_populate_known_values, cloneable, notify_contact_owner, recaptcha_enabled, archivable, notify_recipients].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/dependent_field_dependent_field.rb | lib/hubspot/codegen/marketing/forms/models/dependent_field_dependent_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
module DependentFieldDependentField
class << self
# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'DatepickerField',
:'DropdownField',
:'EmailField',
:'FileField',
:'MobilePhoneField',
:'MultiLineTextField',
:'MultipleCheckboxesField',
:'NumberField',
:'PaymentLinkRadioField',
:'PhoneField',
:'RadioField',
:'SingleCheckboxField',
:'SingleLineTextField'
]
end
# Builds the object
# @param [Mixed] Data to be matched against the list of oneOf items
# @return [Object] Returns the model or the data itself
def build(data)
# Go through the list of oneOf items and attempt to identify the appropriate one.
# Note:
# - We do not attempt to check whether exactly one item matches.
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
# - TODO: scalar values are de facto behaving as if they were nullable.
# - TODO: logging when debugging is set.
openapi_one_of.each do |klass|
begin
next if klass == :AnyType # "nullable: true"
typed_data = find_and_cast_into_type(klass, data)
return typed_data if typed_data
rescue # rescue all errors so we keep iterating even if the current item lookup raises
end
end
openapi_one_of.include?(:AnyType) ? data : nil
end
private
SchemaMismatchError = Class.new(StandardError)
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
def find_and_cast_into_type(klass, data)
return if data.nil?
case klass.to_s
when 'Boolean'
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
when 'Float'
return data if data.instance_of?(Float)
when 'Integer'
return data if data.instance_of?(Integer)
when 'Time'
return Time.parse(data)
when 'Date'
return Date.parse(data)
when 'String'
return data if data.instance_of?(String)
when 'Object' # "type: object"
return data if data.instance_of?(Hash)
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
if data.instance_of?(Array)
sub_type = Regexp.last_match[:sub_type]
return data.map { |item| find_and_cast_into_type(sub_type, item) }
end
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
sub_type = Regexp.last_match[:sub_type]
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
end
else # model
const = Hubspot::Marketing::Forms.const_get(klass)
if const
if const.respond_to?(:openapi_one_of) # nested oneOf model
model = const.build(data)
return model if model
else
# raise if data contains keys that are not known to the model
raise unless (data.keys - const.acceptable_attributes).empty?
model = const.build_from_hash(data)
return model if model && model.valid?
end
end
end
raise # if no match by now, raise
rescue
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/lifecycle_stage.rb | lib/hubspot/codegen/marketing/forms/models/lifecycle_stage.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class LifecycleStage
# The objectTypeId for both contact and company
attr_accessor :object_type_id
# The internal name of the contact's lifecycle stage set when submitting a form
attr_accessor :value
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'value' => :'value'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'value' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::LifecycleStage` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::LifecycleStage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'value')
self.value = attributes[:'value']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @value.nil?
invalid_properties.push('invalid value for "value", value cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @value.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
value == o.value
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, value].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/datepicker_field.rb | lib/hubspot/codegen/marketing/forms/models/datepicker_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field used to select a date
class DatepickerField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The value filled in by default. This value will be submitted unless the customer modifies it.
attr_accessor :default_value
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# Additional text helping the customer to complete the field.
attr_accessor :description
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# The prompt text showing when the field isn't filled in.
attr_accessor :placeholder
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'default_value' => :'defaultValue',
:'name' => :'name',
:'description' => :'description',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'placeholder' => :'placeholder',
:'field_type' => :'fieldType',
:'required' => :'required'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'default_value' => :'String',
:'name' => :'String',
:'description' => :'String',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'placeholder' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::DatepickerField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::DatepickerField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'default_value')
self.default_value = attributes[:'default_value']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'placeholder')
self.placeholder = attributes[:'placeholder']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'datepicker'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["datepicker"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["datepicker"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
default_value == o.default_value &&
name == o.name &&
description == o.description &&
dependent_fields == o.dependent_fields &&
label == o.label &&
placeholder == o.placeholder &&
field_type == o.field_type &&
required == o.required
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, default_value, name, description, dependent_fields, label, placeholder, field_type, required].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/file_field.rb | lib/hubspot/codegen/marketing/forms/models/file_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field used for uploading one or more files.
class FileField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether to allow the upload of multiple files.
attr_accessor :allow_multiple_files
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The value filled in by default. This value will be submitted unless the customer modifies it.
attr_accessor :default_value
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# Additional text helping the customer to complete the field.
attr_accessor :description
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# The prompt text showing when the field isn't filled in.
attr_accessor :placeholder
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'allow_multiple_files' => :'allowMultipleFiles',
:'hidden' => :'hidden',
:'default_value' => :'defaultValue',
:'name' => :'name',
:'description' => :'description',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'placeholder' => :'placeholder',
:'field_type' => :'fieldType',
:'required' => :'required'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'allow_multiple_files' => :'Boolean',
:'hidden' => :'Boolean',
:'default_value' => :'String',
:'name' => :'String',
:'description' => :'String',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'placeholder' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::FileField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::FileField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'allow_multiple_files')
self.allow_multiple_files = attributes[:'allow_multiple_files']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'default_value')
self.default_value = attributes[:'default_value']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'placeholder')
self.placeholder = attributes[:'placeholder']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'file'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @allow_multiple_files.nil?
invalid_properties.push('invalid value for "allow_multiple_files", allow_multiple_files cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @allow_multiple_files.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["file"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["file"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
allow_multiple_files == o.allow_multiple_files &&
hidden == o.hidden &&
default_value == o.default_value &&
name == o.name &&
description == o.description &&
dependent_fields == o.dependent_fields &&
label == o.label &&
placeholder == o.placeholder &&
field_type == o.field_type &&
required == o.required
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, allow_multiple_files, hidden, default_value, name, description, dependent_fields, label, placeholder, field_type, required].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/multiple_checkboxes_field.rb | lib/hubspot/codegen/marketing/forms/models/multiple_checkboxes_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field consisting of a set of checkboxes allowing multiple choices to be selected at one time.
class MultipleCheckboxesField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# The list of available choices for this field.
attr_accessor :options
# Additional text helping the customer to complete the field.
attr_accessor :description
# The values selected by default. Those values will be submitted unless the customer modifies them.
attr_accessor :default_values
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'name' => :'name',
:'options' => :'options',
:'description' => :'description',
:'default_values' => :'defaultValues',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'field_type' => :'fieldType',
:'required' => :'required'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'name' => :'String',
:'options' => :'Array<EnumeratedFieldOption>',
:'description' => :'String',
:'default_values' => :'Array<String>',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::MultipleCheckboxesField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::MultipleCheckboxesField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'options')
if (value = attributes[:'options']).is_a?(Array)
self.options = value
end
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'default_values')
if (value = attributes[:'default_values']).is_a?(Array)
self.default_values = value
end
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'multiple_checkboxes'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @options.nil?
invalid_properties.push('invalid value for "options", options cannot be nil.')
end
if @default_values.nil?
invalid_properties.push('invalid value for "default_values", default_values cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @options.nil?
return false if @default_values.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["multiple_checkboxes"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["multiple_checkboxes"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
name == o.name &&
options == o.options &&
description == o.description &&
default_values == o.default_values &&
dependent_fields == o.dependent_fields &&
label == o.label &&
field_type == o.field_type &&
required == o.required
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, name, options, description, default_values, dependent_fields, label, field_type, required].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/field_group.rb | lib/hubspot/codegen/marketing/forms/models/field_group.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A collection of up to three form fields usually displayed in a row.
class FieldGroup
#
attr_accessor :group_type
# The type of rich text included. The default value is text.
attr_accessor :rich_text_type
# A block of rich text or an image. Those can be used to add extra information for the customers filling in the form. If the field group includes fields, the rich text will be displayed before the fields.
attr_accessor :rich_text
# The form fields included in the group
attr_accessor :fields
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'group_type' => :'groupType',
:'rich_text_type' => :'richTextType',
:'rich_text' => :'richText',
:'fields' => :'fields'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'group_type' => :'String',
:'rich_text_type' => :'String',
:'rich_text' => :'String',
:'fields' => :'Array<DependentFieldDependentField>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::FieldGroup` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::FieldGroup`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'group_type')
self.group_type = attributes[:'group_type']
end
if attributes.key?(:'rich_text_type')
self.rich_text_type = attributes[:'rich_text_type']
end
if attributes.key?(:'rich_text')
self.rich_text = attributes[:'rich_text']
end
if attributes.key?(:'fields')
if (value = attributes[:'fields']).is_a?(Array)
self.fields = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @group_type.nil?
invalid_properties.push('invalid value for "group_type", group_type cannot be nil.')
end
if @rich_text_type.nil?
invalid_properties.push('invalid value for "rich_text_type", rich_text_type cannot be nil.')
end
if @fields.nil?
invalid_properties.push('invalid value for "fields", fields cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @group_type.nil?
group_type_validator = EnumAttributeValidator.new('String', ["default_group", "progressive", "queued"])
return false unless group_type_validator.valid?(@group_type)
return false if @rich_text_type.nil?
rich_text_type_validator = EnumAttributeValidator.new('String', ["text", "image"])
return false unless rich_text_type_validator.valid?(@rich_text_type)
return false if @fields.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] group_type Object to be assigned
def group_type=(group_type)
validator = EnumAttributeValidator.new('String', ["default_group", "progressive", "queued"])
unless validator.valid?(group_type)
fail ArgumentError, "invalid value for \"group_type\", must be one of #{validator.allowable_values}."
end
@group_type = group_type
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] rich_text_type Object to be assigned
def rich_text_type=(rich_text_type)
validator = EnumAttributeValidator.new('String', ["text", "image"])
unless validator.valid?(rich_text_type)
fail ArgumentError, "invalid value for \"rich_text_type\", must be one of #{validator.allowable_values}."
end
@rich_text_type = rich_text_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
group_type == o.group_type &&
rich_text_type == o.rich_text_type &&
rich_text == o.rich_text &&
fields == o.fields
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[group_type, rich_text_type, rich_text, fields].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/email_field_validation.rb | lib/hubspot/codegen/marketing/forms/models/email_field_validation.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# Describes how an email address should be validated.
class EmailFieldValidation
# Whether to block the free email providers.
attr_accessor :use_default_block_list
# A list of email domains to block.
attr_accessor :blocked_email_domains
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'use_default_block_list' => :'useDefaultBlockList',
:'blocked_email_domains' => :'blockedEmailDomains'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'use_default_block_list' => :'Boolean',
:'blocked_email_domains' => :'Array<String>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::EmailFieldValidation` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::EmailFieldValidation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'use_default_block_list')
self.use_default_block_list = attributes[:'use_default_block_list']
end
if attributes.key?(:'blocked_email_domains')
if (value = attributes[:'blocked_email_domains']).is_a?(Array)
self.blocked_email_domains = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @use_default_block_list.nil?
invalid_properties.push('invalid value for "use_default_block_list", use_default_block_list cannot be nil.')
end
if @blocked_email_domains.nil?
invalid_properties.push('invalid value for "blocked_email_domains", blocked_email_domains cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @use_default_block_list.nil?
return false if @blocked_email_domains.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
use_default_block_list == o.use_default_block_list &&
blocked_email_domains == o.blocked_email_domains
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[use_default_block_list, blocked_email_domains].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition.rb | lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class HubSpotFormDefinition
attr_accessor :form_type
attr_accessor :id
attr_accessor :name
attr_accessor :created_at
attr_accessor :updated_at
attr_accessor :archived
attr_accessor :archived_at
attr_accessor :field_groups
attr_accessor :configuration
attr_accessor :display_options
attr_accessor :legal_consent_options
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'form_type' => :'formType',
:'id' => :'id',
:'name' => :'name',
:'created_at' => :'createdAt',
:'updated_at' => :'updatedAt',
:'archived' => :'archived',
:'archived_at' => :'archivedAt',
:'field_groups' => :'fieldGroups',
:'configuration' => :'configuration',
:'display_options' => :'displayOptions',
:'legal_consent_options' => :'legalConsentOptions'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'form_type' => :'String',
:'id' => :'String',
:'name' => :'String',
:'created_at' => :'Time',
:'updated_at' => :'Time',
:'archived' => :'Boolean',
:'archived_at' => :'Time',
:'field_groups' => :'Array<FieldGroup>',
:'configuration' => :'HubSpotFormConfiguration',
:'display_options' => :'FormDisplayOptions',
:'legal_consent_options' => :'OneOfLegalConsentOptionsNoneLegalConsentOptionsLegitimateInterestLegalConsentOptionsExplicitConsentToProcessLegalConsentOptionsImplicitConsentToProcess'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
:'legal_consent_options'
])
end
# List of class defined in allOf (OpenAPI v3)
def self.openapi_all_of
[
:'HubSpotFormDefinitionAllOf'
]
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::HubSpotFormDefinition` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::HubSpotFormDefinition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'form_type')
self.form_type = attributes[:'form_type']
else
self.form_type = 'hubspot'
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'created_at')
self.created_at = attributes[:'created_at']
end
if attributes.key?(:'updated_at')
self.updated_at = attributes[:'updated_at']
end
if attributes.key?(:'archived')
self.archived = attributes[:'archived']
end
if attributes.key?(:'archived_at')
self.archived_at = attributes[:'archived_at']
end
if attributes.key?(:'field_groups')
if (value = attributes[:'field_groups']).is_a?(Array)
self.field_groups = value
end
end
if attributes.key?(:'configuration')
self.configuration = attributes[:'configuration']
end
if attributes.key?(:'display_options')
self.display_options = attributes[:'display_options']
end
if attributes.key?(:'legal_consent_options')
self.legal_consent_options = attributes[:'legal_consent_options']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @form_type.nil?
invalid_properties.push('invalid value for "form_type", form_type cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @created_at.nil?
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
end
if @updated_at.nil?
invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
end
if @archived.nil?
invalid_properties.push('invalid value for "archived", archived cannot be nil.')
end
if @field_groups.nil?
invalid_properties.push('invalid value for "field_groups", field_groups cannot be nil.')
end
if @configuration.nil?
invalid_properties.push('invalid value for "configuration", configuration cannot be nil.')
end
if @display_options.nil?
invalid_properties.push('invalid value for "display_options", display_options cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @form_type.nil?
form_type_validator = EnumAttributeValidator.new('String', ["hubspot"])
return false unless form_type_validator.valid?(@form_type)
return false if @id.nil?
return false if @name.nil?
return false if @created_at.nil?
return false if @updated_at.nil?
return false if @archived.nil?
return false if @field_groups.nil?
return false if @configuration.nil?
return false if @display_options.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] form_type Object to be assigned
def form_type=(form_type)
validator = EnumAttributeValidator.new('String', ["hubspot"])
unless validator.valid?(form_type)
fail ArgumentError, "invalid value for \"form_type\", must be one of #{validator.allowable_values}."
end
@form_type = form_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
form_type == o.form_type &&
id == o.id &&
name == o.name &&
created_at == o.created_at &&
updated_at == o.updated_at &&
archived == o.archived &&
archived_at == o.archived_at &&
field_groups == o.field_groups &&
configuration == o.configuration &&
display_options == o.display_options &&
legal_consent_options == o.legal_consent_options
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[form_type, id, name, created_at, updated_at, archived, archived_at, field_groups, configuration, display_options, legal_consent_options].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/error.rb | lib/hubspot/codegen/marketing/forms/models/error.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class Error
# A specific category that contains more specific detail about the error
attr_accessor :sub_category
# Context about the error condition
attr_accessor :context
# A unique identifier for the request. Include this value with any error reports or support tickets
attr_accessor :correlation_id
# A map of link names to associated URIs containing documentation about the error or recommended remediation steps
attr_accessor :links
# A human readable message describing the error along with remediation steps where appropriate
attr_accessor :message
# The error category
attr_accessor :category
# further information about the error
attr_accessor :errors
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'context' => :'context',
:'correlation_id' => :'correlationId',
:'links' => :'links',
:'message' => :'message',
:'category' => :'category',
:'errors' => :'errors'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'String',
:'context' => :'Hash<String, Array<String>>',
:'correlation_id' => :'String',
:'links' => :'Hash<String, String>',
:'message' => :'String',
:'category' => :'String',
:'errors' => :'Array<ErrorDetail>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::Error` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::Error`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'correlation_id')
self.correlation_id = attributes[:'correlation_id']
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
if attributes.key?(:'category')
self.category = attributes[:'category']
end
if attributes.key?(:'errors')
if (value = attributes[:'errors']).is_a?(Array)
self.errors = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @correlation_id.nil?
invalid_properties.push('invalid value for "correlation_id", correlation_id cannot be nil.')
end
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
if @category.nil?
invalid_properties.push('invalid value for "category", category cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @correlation_id.nil?
return false if @message.nil?
return false if @category.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
context == o.context &&
correlation_id == o.correlation_id &&
links == o.links &&
message == o.message &&
category == o.category &&
errors == o.errors
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, context, correlation_id, links, message, category, errors].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition_all_of.rb | lib/hubspot/codegen/marketing/forms/models/hub_spot_form_definition_all_of.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
class HubSpotFormDefinitionAllOf
attr_accessor :form_type
attr_accessor :id
attr_accessor :name
attr_accessor :created_at
attr_accessor :updated_at
attr_accessor :archived
attr_accessor :archived_at
attr_accessor :field_groups
attr_accessor :configuration
attr_accessor :display_options
attr_accessor :legal_consent_options
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'form_type' => :'formType',
:'id' => :'id',
:'name' => :'name',
:'created_at' => :'createdAt',
:'updated_at' => :'updatedAt',
:'archived' => :'archived',
:'archived_at' => :'archivedAt',
:'field_groups' => :'fieldGroups',
:'configuration' => :'configuration',
:'display_options' => :'displayOptions',
:'legal_consent_options' => :'legalConsentOptions'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'form_type' => :'String',
:'id' => :'String',
:'name' => :'String',
:'created_at' => :'Time',
:'updated_at' => :'Time',
:'archived' => :'Boolean',
:'archived_at' => :'Time',
:'field_groups' => :'Array<FieldGroup>',
:'configuration' => :'HubSpotFormConfiguration',
:'display_options' => :'FormDisplayOptions',
:'legal_consent_options' => :'OneOfLegalConsentOptionsNoneLegalConsentOptionsLegitimateInterestLegalConsentOptionsExplicitConsentToProcessLegalConsentOptionsImplicitConsentToProcess'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
:'legal_consent_options'
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::HubSpotFormDefinitionAllOf` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::HubSpotFormDefinitionAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'form_type')
self.form_type = attributes[:'form_type']
else
self.form_type = 'hubspot'
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'created_at')
self.created_at = attributes[:'created_at']
end
if attributes.key?(:'updated_at')
self.updated_at = attributes[:'updated_at']
end
if attributes.key?(:'archived')
self.archived = attributes[:'archived']
end
if attributes.key?(:'archived_at')
self.archived_at = attributes[:'archived_at']
end
if attributes.key?(:'field_groups')
if (value = attributes[:'field_groups']).is_a?(Array)
self.field_groups = value
end
end
if attributes.key?(:'configuration')
self.configuration = attributes[:'configuration']
end
if attributes.key?(:'display_options')
self.display_options = attributes[:'display_options']
end
if attributes.key?(:'legal_consent_options')
self.legal_consent_options = attributes[:'legal_consent_options']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @form_type.nil?
invalid_properties.push('invalid value for "form_type", form_type cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @created_at.nil?
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
end
if @updated_at.nil?
invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
end
if @archived.nil?
invalid_properties.push('invalid value for "archived", archived cannot be nil.')
end
if @field_groups.nil?
invalid_properties.push('invalid value for "field_groups", field_groups cannot be nil.')
end
if @configuration.nil?
invalid_properties.push('invalid value for "configuration", configuration cannot be nil.')
end
if @display_options.nil?
invalid_properties.push('invalid value for "display_options", display_options cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @form_type.nil?
form_type_validator = EnumAttributeValidator.new('String', ["hubspot"])
return false unless form_type_validator.valid?(@form_type)
return false if @id.nil?
return false if @name.nil?
return false if @created_at.nil?
return false if @updated_at.nil?
return false if @archived.nil?
return false if @field_groups.nil?
return false if @configuration.nil?
return false if @display_options.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] form_type Object to be assigned
def form_type=(form_type)
validator = EnumAttributeValidator.new('String', ["hubspot"])
unless validator.valid?(form_type)
fail ArgumentError, "invalid value for \"form_type\", must be one of #{validator.allowable_values}."
end
@form_type = form_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
form_type == o.form_type &&
id == o.id &&
name == o.name &&
created_at == o.created_at &&
updated_at == o.updated_at &&
archived == o.archived &&
archived_at == o.archived_at &&
field_groups == o.field_groups &&
configuration == o.configuration &&
display_options == o.display_options &&
legal_consent_options == o.legal_consent_options
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[form_type, id, name, created_at, updated_at, archived, archived_at, field_groups, configuration, display_options, legal_consent_options].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/single_line_text_field.rb | lib/hubspot/codegen/marketing/forms/models/single_line_text_field.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# A form field consisting of a single-line text box.
class SingleLineTextField
# A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1.
attr_accessor :object_type_id
# Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in.
attr_accessor :hidden
# The value filled in by default. This value will be submitted unless the customer modifies it.
attr_accessor :default_value
# The identifier of the field. In combination with the object type ID, it must be unique.
attr_accessor :name
# Additional text helping the customer to complete the field.
attr_accessor :description
# A list of other fields to make visible based on the value filled in for this field.
attr_accessor :dependent_fields
# The main label for the form field.
attr_accessor :label
# The prompt text showing when the field isn't filled in.
attr_accessor :placeholder
# Determines how the field will be displayed and validated.
attr_accessor :field_type
# Whether a value for this field is required when submitting the form.
attr_accessor :required
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'hidden' => :'hidden',
:'default_value' => :'defaultValue',
:'name' => :'name',
:'description' => :'description',
:'dependent_fields' => :'dependentFields',
:'label' => :'label',
:'placeholder' => :'placeholder',
:'field_type' => :'fieldType',
:'required' => :'required'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_type_id' => :'String',
:'hidden' => :'Boolean',
:'default_value' => :'String',
:'name' => :'String',
:'description' => :'String',
:'dependent_fields' => :'Array<DependentField>',
:'label' => :'String',
:'placeholder' => :'String',
:'field_type' => :'String',
:'required' => :'Boolean'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::SingleLineTextField` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::SingleLineTextField`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'default_value')
self.default_value = attributes[:'default_value']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'dependent_fields')
if (value = attributes[:'dependent_fields']).is_a?(Array)
self.dependent_fields = value
end
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'placeholder')
self.placeholder = attributes[:'placeholder']
end
if attributes.key?(:'field_type')
self.field_type = attributes[:'field_type']
else
self.field_type = 'single_line_text'
end
if attributes.key?(:'required')
self.required = attributes[:'required']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @dependent_fields.nil?
invalid_properties.push('invalid value for "dependent_fields", dependent_fields cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @field_type.nil?
invalid_properties.push('invalid value for "field_type", field_type cannot be nil.')
end
if @required.nil?
invalid_properties.push('invalid value for "required", required cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_type_id.nil?
return false if @hidden.nil?
return false if @name.nil?
return false if @dependent_fields.nil?
return false if @label.nil?
return false if @field_type.nil?
field_type_validator = EnumAttributeValidator.new('String', ["single_line_text"])
return false unless field_type_validator.valid?(@field_type)
return false if @required.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] field_type Object to be assigned
def field_type=(field_type)
validator = EnumAttributeValidator.new('String', ["single_line_text"])
unless validator.valid?(field_type)
fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}."
end
@field_type = field_type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_type_id == o.object_type_id &&
hidden == o.hidden &&
default_value == o.default_value &&
name == o.name &&
description == o.description &&
dependent_fields == o.dependent_fields &&
label == o.label &&
placeholder == o.placeholder &&
field_type == o.field_type &&
required == o.required
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_type_id, hidden, default_value, name, description, dependent_fields, label, placeholder, field_type, required].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/models/phone_field_validation.rb | lib/hubspot/codegen/marketing/forms/models/phone_field_validation.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Forms
# Describes how a phone number should be validated.
class PhoneFieldValidation
#
attr_accessor :min_allowed_digits
#
attr_accessor :max_allowed_digits
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'min_allowed_digits' => :'minAllowedDigits',
:'max_allowed_digits' => :'maxAllowedDigits'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'min_allowed_digits' => :'Integer',
:'max_allowed_digits' => :'Integer'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Forms::PhoneFieldValidation` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Forms::PhoneFieldValidation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'min_allowed_digits')
self.min_allowed_digits = attributes[:'min_allowed_digits']
end
if attributes.key?(:'max_allowed_digits')
self.max_allowed_digits = attributes[:'max_allowed_digits']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @min_allowed_digits.nil?
invalid_properties.push('invalid value for "min_allowed_digits", min_allowed_digits cannot be nil.')
end
if @max_allowed_digits.nil?
invalid_properties.push('invalid value for "max_allowed_digits", max_allowed_digits cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @min_allowed_digits.nil?
return false if @max_allowed_digits.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
min_allowed_digits == o.min_allowed_digits &&
max_allowed_digits == o.max_allowed_digits
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[min_allowed_digits, max_allowed_digits].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Forms.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/forms/api/forms_api.rb | lib/hubspot/codegen/marketing/forms/api/forms_api.rb | =begin
#Forms
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module Hubspot
module Marketing
module Forms
class FormsApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Archive a form definition
# Archive a form definition. New submissions will not be accepted and the form definition will be permanently deleted after 3 months.
# @param form_id [String] The ID of the form to archive.
# @param [Hash] opts the optional parameters
# @return [nil]
def archive(form_id, opts = {})
archive_with_http_info(form_id, opts)
nil
end
# Archive a form definition
# Archive a form definition. New submissions will not be accepted and the form definition will be permanently deleted after 3 months.
# @param form_id [String] The ID of the form to archive.
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def archive_with_http_info(form_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FormsApi.archive ...'
end
# verify the required parameter 'form_id' is set
if @api_client.config.client_side_validation && form_id.nil?
fail ArgumentError, "Missing the required parameter 'form_id' when calling FormsApi.archive"
end
# resource path
local_var_path = '/marketing/v3/forms/{formId}'.sub('{' + 'formId' + '}', CGI.escape(form_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FormsApi.archive",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FormsApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Create a form
# Add a new `hubspot` form
# @param form_definition_create_request_base [FormDefinitionCreateRequestBase]
# @param [Hash] opts the optional parameters
# @return [FormDefinitionBase]
def create(form_definition_create_request_base, opts = {})
data, _status_code, _headers = create_with_http_info(form_definition_create_request_base, opts)
data
end
# Create a form
# Add a new `hubspot` form
# @param form_definition_create_request_base [FormDefinitionCreateRequestBase]
# @param [Hash] opts the optional parameters
# @return [Array<(FormDefinitionBase, Integer, Hash)>] FormDefinitionBase data, response status code and response headers
def create_with_http_info(form_definition_create_request_base, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FormsApi.create ...'
end
# verify the required parameter 'form_definition_create_request_base' is set
if @api_client.config.client_side_validation && form_definition_create_request_base.nil?
fail ArgumentError, "Missing the required parameter 'form_definition_create_request_base' when calling FormsApi.create"
end
# resource path
local_var_path = '/marketing/v3/forms/'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(form_definition_create_request_base)
# return_type
return_type = opts[:debug_return_type] || 'FormDefinitionBase'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FormsApi.create",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FormsApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get a form definition
# Returns a form based on the form ID provided.
# @param form_id [String] The unique identifier of the form
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :archived Whether to return only results that have been archived.
# @return [FormDefinitionBase]
def get_by_id(form_id, opts = {})
data, _status_code, _headers = get_by_id_with_http_info(form_id, opts)
data
end
# Get a form definition
# Returns a form based on the form ID provided.
# @param form_id [String] The unique identifier of the form
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :archived Whether to return only results that have been archived.
# @return [Array<(FormDefinitionBase, Integer, Hash)>] FormDefinitionBase data, response status code and response headers
def get_by_id_with_http_info(form_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FormsApi.get_by_id ...'
end
# verify the required parameter 'form_id' is set
if @api_client.config.client_side_validation && form_id.nil?
fail ArgumentError, "Missing the required parameter 'form_id' when calling FormsApi.get_by_id"
end
# resource path
local_var_path = '/marketing/v3/forms/{formId}'.sub('{' + 'formId' + '}', CGI.escape(form_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'FormDefinitionBase'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FormsApi.get_by_id",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FormsApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get a list of forms
# Returns a list of forms based on the search filters. By default, it returns the first 20 `hubspot` forms
# @param [Hash] opts the optional parameters
# @option opts [String] :after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results.
# @option opts [Integer] :limit The maximum number of results to display per page.
# @option opts [Boolean] :archived Whether to return only results that have been archived.
# @option opts [Array<String>] :form_types The form types to be included in the results.
# @return [CollectionResponseFormDefinitionBaseForwardPaging]
def get_page(opts = {})
data, _status_code, _headers = get_page_with_http_info(opts)
data
end
# Get a list of forms
# Returns a list of forms based on the search filters. By default, it returns the first 20 `hubspot` forms
# @param [Hash] opts the optional parameters
# @option opts [String] :after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results.
# @option opts [Integer] :limit The maximum number of results to display per page.
# @option opts [Boolean] :archived Whether to return only results that have been archived.
# @option opts [Array<String>] :form_types The form types to be included in the results.
# @return [Array<(CollectionResponseFormDefinitionBaseForwardPaging, Integer, Hash)>] CollectionResponseFormDefinitionBaseForwardPaging data, response status code and response headers
def get_page_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FormsApi.get_page ...'
end
allowable_values = ["hubspot", "captured", "flow", "blog_comment", "all"]
if @api_client.config.client_side_validation && opts[:'form_types'] && !opts[:'form_types'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"form_types\", must include one of #{allowable_values}"
end
# resource path
local_var_path = '/marketing/v3/forms/'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil?
query_params[:'formTypes'] = @api_client.build_collection_param(opts[:'form_types'], :multi) if !opts[:'form_types'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'CollectionResponseFormDefinitionBaseForwardPaging'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FormsApi.get_page",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FormsApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Update a form definition
# Update all fields of a hubspot form definition.
# @param form_id [String]
# @param hub_spot_form_definition [HubSpotFormDefinition]
# @param [Hash] opts the optional parameters
# @return [FormDefinitionBase]
def replace(form_id, hub_spot_form_definition, opts = {})
data, _status_code, _headers = replace_with_http_info(form_id, hub_spot_form_definition, opts)
data
end
# Update a form definition
# Update all fields of a hubspot form definition.
# @param form_id [String]
# @param hub_spot_form_definition [HubSpotFormDefinition]
# @param [Hash] opts the optional parameters
# @return [Array<(FormDefinitionBase, Integer, Hash)>] FormDefinitionBase data, response status code and response headers
def replace_with_http_info(form_id, hub_spot_form_definition, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FormsApi.replace ...'
end
# verify the required parameter 'form_id' is set
if @api_client.config.client_side_validation && form_id.nil?
fail ArgumentError, "Missing the required parameter 'form_id' when calling FormsApi.replace"
end
# verify the required parameter 'hub_spot_form_definition' is set
if @api_client.config.client_side_validation && hub_spot_form_definition.nil?
fail ArgumentError, "Missing the required parameter 'hub_spot_form_definition' when calling FormsApi.replace"
end
# resource path
local_var_path = '/marketing/v3/forms/{formId}'.sub('{' + 'formId' + '}', CGI.escape(form_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(hub_spot_form_definition)
# return_type
return_type = opts[:debug_return_type] || 'FormDefinitionBase'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FormsApi.replace",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FormsApi#replace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Partially update a form definition
# Update some of the form definition components
# @param form_id [String] The ID of the form to update.
# @param hub_spot_form_definition_patch_request [HubSpotFormDefinitionPatchRequest]
# @param [Hash] opts the optional parameters
# @return [FormDefinitionBase]
def update(form_id, hub_spot_form_definition_patch_request, opts = {})
data, _status_code, _headers = update_with_http_info(form_id, hub_spot_form_definition_patch_request, opts)
data
end
# Partially update a form definition
# Update some of the form definition components
# @param form_id [String] The ID of the form to update.
# @param hub_spot_form_definition_patch_request [HubSpotFormDefinitionPatchRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(FormDefinitionBase, Integer, Hash)>] FormDefinitionBase data, response status code and response headers
def update_with_http_info(form_id, hub_spot_form_definition_patch_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FormsApi.update ...'
end
# verify the required parameter 'form_id' is set
if @api_client.config.client_side_validation && form_id.nil?
fail ArgumentError, "Missing the required parameter 'form_id' when calling FormsApi.update"
end
# verify the required parameter 'hub_spot_form_definition_patch_request' is set
if @api_client.config.client_side_validation && hub_spot_form_definition_patch_request.nil?
fail ArgumentError, "Missing the required parameter 'hub_spot_form_definition_patch_request' when calling FormsApi.update"
end
# resource path
local_var_path = '/marketing/v3/forms/{formId}'.sub('{' + 'formId' + '}', CGI.escape(form_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(hub_spot_form_definition_patch_request)
# return_type
return_type = opts[:debug_return_type] || 'FormDefinitionBase'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FormsApi.update",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FormsApi#update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/api_error.rb | lib/hubspot/codegen/marketing/events/api_error.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Marketing
module Events
class ApiError < ::StandardError
attr_reader :code, :response_headers, :response_body
# Usage examples:
# ApiError.new
# ApiError.new("message")
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
# ApiError.new(:code => 404, :message => "Not Found")
def initialize(arg = nil)
if arg.is_a? Hash
if arg.key?(:message) || arg.key?('message')
super(arg[:message] || arg['message'])
else
super arg
end
arg.each do |k, v|
instance_variable_set "@#{k}", v
end
else
super arg
end
end
# Override to_s to display a friendly error message
def to_s
message
end
def message
if @message.nil?
msg = "Error message: the server returns an error"
else
msg = @message
end
msg += "\nHTTP status code: #{code}" if code
msg += "\nResponse headers: #{response_headers}" if response_headers
msg += "\nResponse body: #{response_body}" if response_body
msg
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/configuration.rb | lib/hubspot/codegen/marketing/events/configuration.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Marketing
module Events
class Configuration
# Defines url scheme
attr_accessor :scheme
# Defines url host
attr_accessor :host
# Defines url base path
attr_accessor :base_path
# Define server configuration index
attr_accessor :server_index
# Define server operation configuration index
attr_accessor :server_operation_index
# Default server variables
attr_accessor :server_variables
# Default server operation variables
attr_accessor :server_operation_variables
# Defines API keys used with API Key authentications.
#
# @return [Hash] key: parameter name, value: parameter value (API key)
#
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
# config.api_key['api_key'] = 'xxx'
attr_accessor :api_key
# Defines API key prefixes used with API Key authentications.
#
# @return [Hash] key: parameter name, value: API key prefix
#
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
# config.api_key_prefix['api_key'] = 'Token'
attr_accessor :api_key_prefix
# Defines the username used with HTTP basic authentication.
#
# @return [String]
attr_accessor :username
# Defines the password used with HTTP basic authentication.
#
# @return [String]
attr_accessor :password
# Defines the access token (Bearer) used with OAuth2.
attr_accessor :access_token
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
# details will be logged with `logger.debug` (see the `logger` attribute).
# Default to false.
#
# @return [true, false]
attr_accessor :debugging
# Defines the logger used for debugging.
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
#
# @return [#debug]
attr_accessor :logger
# Defines the temporary folder to store downloaded files
# (for API endpoints that have file response).
# Default to use `Tempfile`.
#
# @return [String]
attr_accessor :temp_folder_path
# The time limit for HTTP request in seconds.
# Default to 0 (never times out).
attr_accessor :timeout
# Set this to false to skip client side validation in the operation.
# Default to true.
# @return [true, false]
attr_accessor :client_side_validation
### TLS/SSL setting
# Set this to false to skip verifying SSL certificate when calling API from https server.
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl
### TLS/SSL setting
# Set this to false to skip verifying SSL host name
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl_host
### TLS/SSL setting
# Set this to customize the certificate file to verify the peer.
#
# @return [String] the path to the certificate file
#
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
attr_accessor :ssl_ca_cert
### TLS/SSL setting
# Client certificate file (for client certificate)
attr_accessor :cert_file
### TLS/SSL setting
# Client private key file (for client certificate)
attr_accessor :key_file
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
# Default to nil.
#
# @see The params_encoding option of Ethon. Related source code:
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
attr_accessor :params_encoding
attr_accessor :inject_format
attr_accessor :force_ending_format
attr_accessor :error_handler
def initialize
@scheme = 'https'
@host = 'api.hubapi.com'
@base_path = ''
@server_index = 0
@server_operation_index = {}
@server_variables = {}
@server_operation_variables = {}
@api_key = {}
@api_key_prefix = {}
@client_side_validation = true
@verify_ssl = true
@verify_ssl_host = true
@cert_file = nil
@key_file = nil
@timeout = 0
@params_encoding = nil
@debugging = false
@inject_format = false
@force_ending_format = false
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
# error_handler params: { 'status_code': { max_retries: ..., seconds_delay: ... }, ... }
@error_handler = {}
yield(self) if block_given?
end
# The default Configuration object.
def self.default
@@default ||= Configuration.new
end
def configure
yield(self) if block_given?
end
def scheme=(scheme)
# remove :// from scheme
@scheme = scheme.sub(/:\/\//, '')
end
def host=(host)
# remove http(s):// and anything after a slash
@host = host.sub(/https?:\/\//, '').split('/').first
end
def base_path=(base_path)
# Add leading and trailing slashes to base_path
@base_path = "/#{base_path}".gsub(/\/+/, '/')
@base_path = '' if @base_path == '/'
end
# Returns base URL for specified operation based on server settings
def base_url(operation = nil)
index = server_operation_index.fetch(operation, server_index)
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
end
# Gets API key (with prefix if set).
# @param [String] param_name the parameter name of API key auth
def api_key_with_prefix(param_name, param_alias = nil)
key = @api_key[param_name]
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
if @api_key_prefix[param_name]
"#{@api_key_prefix[param_name]} #{key}"
else
key
end
end
# Gets Basic Auth token string
def basic_auth_token
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
end
# Returns Auth Settings hash for api client.
def auth_settings
{
'developer_hapikey' =>
{
type: 'api_key',
in: 'query',
key: 'hapikey',
value: api_key_with_prefix('developer_hapikey')
},
'oauth2' =>
{
type: 'oauth2',
in: 'header',
key: 'Authorization',
value: "Bearer #{access_token}"
},
}
end
# Returns an array of Server setting
def server_settings
[
{
url: "https://api.hubapi.com",
description: "No description provided",
}
]
end
def operation_server_settings
{
}
end
# Returns URL based on server settings
#
# @param index array index of the server settings
# @param variables hash of variable and the corresponding value
def server_url(index, variables = {}, servers = nil)
servers = server_settings if servers == nil
# check array index out of bound
if (index < 0 || index >= servers.size)
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
end
server = servers[index]
url = server[:url]
return url unless server.key? :variables
# go through variable and assign a value
server[:variables].each do |name, variable|
if variables.key?(name)
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
url.gsub! "{" + name.to_s + "}", variables[name]
else
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
end
else
# use default value
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
end
end
url
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/api_client.rb | lib/hubspot/codegen/marketing/events/api_client.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'json'
require 'logger'
require 'tempfile'
require 'time'
require 'typhoeus'
module Hubspot
module Marketing
module Events
class ApiClient
# The Configuration object holding settings to be used in the API client.
attr_accessor :config
# Defines the headers to be used in HTTP requests of all API calls by default.
#
# @return [Hash]
attr_accessor :default_headers
# Initializes the ApiClient
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
def initialize(config = Configuration.default)
@config = config
@user_agent = "hubspot-api-client-ruby; #{VERSION}"
@default_headers = {
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
}
end
def self.default
@@default ||= ApiClient.new
end
# Call an API with given options.
#
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
# the data deserialized from response body (could be nil), response status code and response headers.
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
if !response.success? && config.error_handler.any?
config.error_handler.each do |statuses, opts|
statuses = statuses.is_a?(Integer) ? [statuses] : statuses
retries = opts[:max_retries] || 5
while retries > 0 && statuses.include?(response.code)
sleep opts[:seconds_delay] if opts[:seconds_delay]
response = request.run
opts[:retry_block].call if opts[:retry_block]
retries -= 1
end
end
end
unless response.success?
if response.timed_out?
fail ApiError.new('Connection timed out')
elsif response.code == 0
# Errors from libcurl will be made visible here
fail ApiError.new(:code => 0,
:message => response.return_message)
else
fail ApiError.new(:code => response.code,
:response_headers => response.headers,
:response_body => response.body),
response.status_message
end
end
if opts[:return_type]
data = deserialize(response, opts[:return_type])
else
data = nil
end
return data, response.code, response.headers
end
# Builds the HTTP request
#
# @param [String] http_method HTTP method/verb (e.g. POST)
# @param [String] path URL path (e.g. /account/new)
# @option opts [Hash] :header_params Header parameters
# @option opts [Hash] :query_params Query parameters
# @option opts [Hash] :form_params Query parameters
# @option opts [Object] :body HTTP body (JSON/XML)
# @return [Typhoeus::Request] A Typhoeus Request
def build_request(http_method, path, opts = {})
url = build_request_url(path, opts)
http_method = http_method.to_sym.downcase
header_params = @default_headers.merge(opts[:header_params] || {})
query_params = opts[:query_params] || {}
form_params = opts[:form_params] || {}
follow_location = opts[:follow_location] || true
update_params_for_auth! header_params, query_params, opts[:auth_names]
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
req_opts = {
:method => http_method,
:headers => header_params,
:params => query_params,
:params_encoding => @config.params_encoding,
:timeout => @config.timeout,
:ssl_verifypeer => @config.verify_ssl,
:ssl_verifyhost => _verify_ssl_host,
:sslcert => @config.cert_file,
:sslkey => @config.key_file,
:verbose => @config.debugging,
:followlocation => follow_location
}
# set custom cert, if provided
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
if [:post, :patch, :put, :delete].include?(http_method)
req_body = build_request_body(header_params, form_params, opts[:body])
req_opts.update :body => req_body
if @config.debugging
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
end
end
request = Typhoeus::Request.new(url, req_opts)
download_file(request) if opts[:return_type] == 'File'
request
end
# Builds the HTTP request body
#
# @param [Hash] header_params Header parameters
# @param [Hash] form_params Query parameters
# @param [Object] body HTTP body (JSON/XML)
# @return [String] HTTP body data in the form of string
def build_request_body(header_params, form_params, body)
# http form
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
header_params['Content-Type'] == 'multipart/form-data'
data = {}
form_params.each do |key, value|
case value
when ::File, ::Array, nil
# let typhoeus handle File, Array and nil parameters
data[key] = value
else
data[key] = value.to_s
end
end
elsif body
data = body.is_a?(String) ? body : body.to_json
else
data = nil
end
data
end
# Save response body into a file in (the defined) temporary folder, using the filename
# from the "Content-Disposition" header if provided, otherwise a random filename.
# The response body is written to the file in chunks in order to handle files which
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
# process can use.
#
# @see Configuration#temp_folder_path
def download_file(request)
tempfile = nil
encoding = nil
request.on_headers do |response|
content_disposition = response.headers['Content-Disposition']
if content_disposition && content_disposition =~ /filename=/i
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
prefix = sanitize_filename(filename)
else
prefix = 'download-'
end
prefix = prefix + '-' unless prefix.end_with?('-')
encoding = response.body.encoding
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
@tempfile = tempfile
end
request.on_body do |chunk|
chunk.force_encoding(encoding)
tempfile.write(chunk)
end
request.on_complete do |response|
if tempfile
tempfile.close
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
"explicitly with `tempfile.delete`"
end
end
end
# Check if the given MIME is a JSON MIME.
# JSON MIME examples:
# application/json
# application/json; charset=UTF8
# APPLICATION/JSON
# */*
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end
# Deserialize the response to the given return type.
#
# @param [Response] response HTTP response
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
def deserialize(response, return_type)
body = response.body
# handle file downloading - return the File instance processed in request callbacks
# note that response body is empty when the file is written in chunks in request on_body callback
return @tempfile if return_type == 'File'
return nil if body.nil? || body.empty?
# return response body directly for String return type
return body if return_type == 'String'
# ensuring a default content type
content_type = response.headers['Content-Type'] || 'application/json'
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
begin
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
rescue JSON::ParserError => e
if %w(String Date Time).include?(return_type)
data = body
else
raise e
end
end
convert_to_type data, return_type
end
# Convert data to the given return type.
# @param [Object] data Data to be converted
# @param [String] return_type Return type
# @return [Mixed] Data in a particular type
def convert_to_type(data, return_type)
return nil if data.nil?
case return_type
when 'String'
data.to_s
when 'Integer'
data.to_i
when 'Float'
data.to_f
when 'Boolean'
data == true
when 'Time'
# parse date time (expecting ISO 8601 format)
Time.parse data
when 'Date'
# parse date time (expecting ISO 8601 format)
Date.parse data
when 'Object'
# generic object (usually a Hash), return directly
data
when /\AArray<(.+)>\z/
# e.g. Array<Pet>
sub_type = $1
data.map { |item| convert_to_type(item, sub_type) }
when /\AHash\<String, (.+)\>\z/
# e.g. Hash<String, Integer>
sub_type = $1
{}.tap do |hash|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
end
else
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Events.const_get(return_type)
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
end
end
# Sanitize filename by removing path.
# e.g. ../../sun.gif becomes sun.gif
#
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
end
def build_request_url(path, opts = {})
# Add leading and trailing slashes to path
path = "/#{path}".gsub(/\/+/, '/')
@config.base_url(opts[:operation]) + path
end
# Update header and query params based on authentication settings.
#
# @param [Hash] header_params Header parameters
# @param [Hash] query_params Query parameters
# @param [String] auth_names Authentication scheme name
def update_params_for_auth!(header_params, query_params, auth_names)
Array(auth_names).each do |auth_name|
auth_setting = @config.auth_settings[auth_name]
next unless auth_setting
case auth_setting[:in]
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
end
end
end
# Sets user agent in HTTP header
#
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
def user_agent=(user_agent)
@user_agent = user_agent
@default_headers['User-Agent'] = @user_agent
end
# Return Accept header based on an array of accepts provided.
# @param [Array] accepts array for Accept
# @return [String] the Accept header (e.g. application/json)
def select_header_accept(accepts)
return nil if accepts.nil? || accepts.empty?
# use JSON when present, otherwise use all of the provided
json_accept = accepts.find { |s| json_mime?(s) }
json_accept || accepts.join(',')
end
# Return Content-Type header based on an array of content types provided.
# @param [Array] content_types array for Content-Type
# @return [String] the Content-Type header (e.g. application/json)
def select_header_content_type(content_types)
# return nil by default
return if content_types.nil? || content_types.empty?
# use JSON when present, otherwise use the first one
json_content_type = content_types.find { |s| json_mime?(s) }
json_content_type || content_types.first
end
# Convert object (array, hash, object, etc) to JSON string.
# @param [Object] model object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_http_body(model)
return model if model.nil? || model.is_a?(String)
local_body = nil
if model.is_a?(Array)
local_body = model.map { |m| object_to_hash(m) }
else
local_body = object_to_hash(model)
end
local_body.to_json
end
# Convert object(non-array) to hash.
# @param [Object] obj object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_hash(obj)
if obj.respond_to?(:to_hash)
obj.to_hash
else
obj
end
end
# Build parameter value according to the given collection format.
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
def build_collection_param(param, collection_format)
case collection_format
when :csv
param.join(',')
when :ssv
param.join(' ')
when :tsv
param.join("\t")
when :pipes
param.join('|')
when :multi
# return the array directly as typhoeus will handle it as expected
param
else
fail "unknown collection format: #{collection_format.inspect}"
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/models/marketing_event_complete_request_params.rb | lib/hubspot/codegen/marketing/events/models/marketing_event_complete_request_params.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Events
class MarketingEventCompleteRequestParams
attr_accessor :start_date_time
attr_accessor :end_date_time
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'start_date_time' => :'startDateTime',
:'end_date_time' => :'endDateTime'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'start_date_time' => :'Time',
:'end_date_time' => :'Time'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Events::MarketingEventCompleteRequestParams` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Events::MarketingEventCompleteRequestParams`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'start_date_time')
self.start_date_time = attributes[:'start_date_time']
end
if attributes.key?(:'end_date_time')
self.end_date_time = attributes[:'end_date_time']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @start_date_time.nil?
invalid_properties.push('invalid value for "start_date_time", start_date_time cannot be nil.')
end
if @end_date_time.nil?
invalid_properties.push('invalid value for "end_date_time", end_date_time cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @start_date_time.nil?
return false if @end_date_time.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
start_date_time == o.start_date_time &&
end_date_time == o.end_date_time
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[start_date_time, end_date_time].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Events.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/models/marketing_event_public_update_request_full_v2.rb | lib/hubspot/codegen/marketing/events/models/marketing_event_public_update_request_full_v2.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Events
class MarketingEventPublicUpdateRequestFullV2
attr_accessor :start_date_time
attr_accessor :custom_properties
attr_accessor :event_cancelled
attr_accessor :event_organizer
attr_accessor :event_url
attr_accessor :event_description
attr_accessor :event_name
attr_accessor :event_type
attr_accessor :end_date_time
attr_accessor :object_id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'start_date_time' => :'startDateTime',
:'custom_properties' => :'customProperties',
:'event_cancelled' => :'eventCancelled',
:'event_organizer' => :'eventOrganizer',
:'event_url' => :'eventUrl',
:'event_description' => :'eventDescription',
:'event_name' => :'eventName',
:'event_type' => :'eventType',
:'end_date_time' => :'endDateTime',
:'object_id' => :'objectId'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'start_date_time' => :'Time',
:'custom_properties' => :'Array<PropertyValue>',
:'event_cancelled' => :'Boolean',
:'event_organizer' => :'String',
:'event_url' => :'String',
:'event_description' => :'String',
:'event_name' => :'String',
:'event_type' => :'String',
:'end_date_time' => :'Time',
:'object_id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Events::MarketingEventPublicUpdateRequestFullV2` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Events::MarketingEventPublicUpdateRequestFullV2`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'start_date_time')
self.start_date_time = attributes[:'start_date_time']
end
if attributes.key?(:'custom_properties')
if (value = attributes[:'custom_properties']).is_a?(Array)
self.custom_properties = value
end
end
if attributes.key?(:'event_cancelled')
self.event_cancelled = attributes[:'event_cancelled']
end
if attributes.key?(:'event_organizer')
self.event_organizer = attributes[:'event_organizer']
end
if attributes.key?(:'event_url')
self.event_url = attributes[:'event_url']
end
if attributes.key?(:'event_description')
self.event_description = attributes[:'event_description']
end
if attributes.key?(:'event_name')
self.event_name = attributes[:'event_name']
end
if attributes.key?(:'event_type')
self.event_type = attributes[:'event_type']
end
if attributes.key?(:'end_date_time')
self.end_date_time = attributes[:'end_date_time']
end
if attributes.key?(:'object_id')
self.object_id = attributes[:'object_id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @custom_properties.nil?
invalid_properties.push('invalid value for "custom_properties", custom_properties cannot be nil.')
end
if @object_id.nil?
invalid_properties.push('invalid value for "object_id", object_id cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @custom_properties.nil?
return false if @object_id.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
start_date_time == o.start_date_time &&
custom_properties == o.custom_properties &&
event_cancelled == o.event_cancelled &&
event_organizer == o.event_organizer &&
event_url == o.event_url &&
event_description == o.event_description &&
event_name == o.event_name &&
event_type == o.event_type &&
end_date_time == o.end_date_time &&
object_id == o.object_id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[start_date_time, custom_properties, event_cancelled, event_organizer, event_url, event_description, event_name, event_type, end_date_time, object_id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Events.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/models/marketing_event_public_default_response.rb | lib/hubspot/codegen/marketing/events/models/marketing_event_public_default_response.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Events
class MarketingEventPublicDefaultResponse
# The name of the organizer of the marketing event.
attr_accessor :event_organizer
# A URL in the external event application where the marketing event can be managed.
attr_accessor :event_url
# The type of the marketing event.
attr_accessor :event_type
attr_accessor :event_completed
# The end date and time of the marketing event.
attr_accessor :end_date_time
#
attr_accessor :created_at
# The start date and time of the marketing event.
attr_accessor :start_date_time
# A list of PropertyValues. These can be whatever kind of property names and values you want. However, they must already exist on the HubSpot account's definition of the MarketingEvent Object. If they don't they will be filtered out and not set. In order to do this you'll need to create a new PropertyGroup on the HubSpot account's MarketingEvent object for your specific app and create the Custom Property you want to track on that HubSpot account. Do not create any new default properties on the MarketingEvent object as that will apply to all HubSpot accounts.
attr_accessor :custom_properties
# Indicates if the marketing event has been cancelled.
attr_accessor :event_cancelled
# The description of the marketing event.
attr_accessor :event_description
# The name of the marketing event.
attr_accessor :event_name
#
attr_accessor :id
attr_accessor :object_id
#
attr_accessor :updated_at
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'event_organizer' => :'eventOrganizer',
:'event_url' => :'eventUrl',
:'event_type' => :'eventType',
:'event_completed' => :'eventCompleted',
:'end_date_time' => :'endDateTime',
:'created_at' => :'createdAt',
:'start_date_time' => :'startDateTime',
:'custom_properties' => :'customProperties',
:'event_cancelled' => :'eventCancelled',
:'event_description' => :'eventDescription',
:'event_name' => :'eventName',
:'id' => :'id',
:'object_id' => :'objectId',
:'updated_at' => :'updatedAt'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'event_organizer' => :'String',
:'event_url' => :'String',
:'event_type' => :'String',
:'event_completed' => :'Boolean',
:'end_date_time' => :'Time',
:'created_at' => :'Time',
:'start_date_time' => :'Time',
:'custom_properties' => :'Array<PropertyValue>',
:'event_cancelled' => :'Boolean',
:'event_description' => :'String',
:'event_name' => :'String',
:'id' => :'String',
:'object_id' => :'String',
:'updated_at' => :'Time'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Events::MarketingEventPublicDefaultResponse` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Events::MarketingEventPublicDefaultResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'event_organizer')
self.event_organizer = attributes[:'event_organizer']
end
if attributes.key?(:'event_url')
self.event_url = attributes[:'event_url']
end
if attributes.key?(:'event_type')
self.event_type = attributes[:'event_type']
end
if attributes.key?(:'event_completed')
self.event_completed = attributes[:'event_completed']
end
if attributes.key?(:'end_date_time')
self.end_date_time = attributes[:'end_date_time']
end
if attributes.key?(:'created_at')
self.created_at = attributes[:'created_at']
end
if attributes.key?(:'start_date_time')
self.start_date_time = attributes[:'start_date_time']
end
if attributes.key?(:'custom_properties')
if (value = attributes[:'custom_properties']).is_a?(Array)
self.custom_properties = value
end
end
if attributes.key?(:'event_cancelled')
self.event_cancelled = attributes[:'event_cancelled']
end
if attributes.key?(:'event_description')
self.event_description = attributes[:'event_description']
end
if attributes.key?(:'event_name')
self.event_name = attributes[:'event_name']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'object_id')
self.object_id = attributes[:'object_id']
end
if attributes.key?(:'updated_at')
self.updated_at = attributes[:'updated_at']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @event_organizer.nil?
invalid_properties.push('invalid value for "event_organizer", event_organizer cannot be nil.')
end
if @created_at.nil?
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
end
if @event_name.nil?
invalid_properties.push('invalid value for "event_name", event_name cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @updated_at.nil?
invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @event_organizer.nil?
return false if @created_at.nil?
return false if @event_name.nil?
return false if @id.nil?
return false if @updated_at.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
event_organizer == o.event_organizer &&
event_url == o.event_url &&
event_type == o.event_type &&
event_completed == o.event_completed &&
end_date_time == o.end_date_time &&
created_at == o.created_at &&
start_date_time == o.start_date_time &&
custom_properties == o.custom_properties &&
event_cancelled == o.event_cancelled &&
event_description == o.event_description &&
event_name == o.event_name &&
id == o.id &&
object_id == o.object_id &&
updated_at == o.updated_at
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[event_organizer, event_url, event_type, event_completed, end_date_time, created_at, start_date_time, custom_properties, event_cancelled, event_description, event_name, id, object_id, updated_at].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Events.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/models/marketing_event_email_subscriber.rb | lib/hubspot/codegen/marketing/events/models/marketing_event_email_subscriber.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Events
class MarketingEventEmailSubscriber
attr_accessor :contact_properties
attr_accessor :properties
# The email address of the contact in HubSpot to associate with the event.
attr_accessor :email
# Timestamp in milliseconds at which the contact subscribed to the event.
attr_accessor :interaction_date_time
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'contact_properties' => :'contactProperties',
:'properties' => :'properties',
:'email' => :'email',
:'interaction_date_time' => :'interactionDateTime'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'contact_properties' => :'Hash<String, String>',
:'properties' => :'Hash<String, String>',
:'email' => :'String',
:'interaction_date_time' => :'Integer'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Events::MarketingEventEmailSubscriber` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Events::MarketingEventEmailSubscriber`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'contact_properties')
if (value = attributes[:'contact_properties']).is_a?(Hash)
self.contact_properties = value
end
end
if attributes.key?(:'properties')
if (value = attributes[:'properties']).is_a?(Hash)
self.properties = value
end
end
if attributes.key?(:'email')
self.email = attributes[:'email']
end
if attributes.key?(:'interaction_date_time')
self.interaction_date_time = attributes[:'interaction_date_time']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @email.nil?
invalid_properties.push('invalid value for "email", email cannot be nil.')
end
if @interaction_date_time.nil?
invalid_properties.push('invalid value for "interaction_date_time", interaction_date_time cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @email.nil?
return false if @interaction_date_time.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
contact_properties == o.contact_properties &&
properties == o.properties &&
email == o.email &&
interaction_date_time == o.interaction_date_time
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[contact_properties, properties, email, interaction_date_time].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Events.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/models/standard_error.rb | lib/hubspot/codegen/marketing/events/models/standard_error.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Events
class StandardError
#
attr_accessor :sub_category
#
attr_accessor :context
#
attr_accessor :links
#
attr_accessor :id
#
attr_accessor :category
#
attr_accessor :message
#
attr_accessor :errors
#
attr_accessor :status
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'context' => :'context',
:'links' => :'links',
:'id' => :'id',
:'category' => :'category',
:'message' => :'message',
:'errors' => :'errors',
:'status' => :'status'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'Object',
:'context' => :'Hash<String, Array<String>>',
:'links' => :'Hash<String, String>',
:'id' => :'String',
:'category' => :'String',
:'message' => :'String',
:'errors' => :'Array<ErrorDetail>',
:'status' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Events::StandardError` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Events::StandardError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'category')
self.category = attributes[:'category']
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
if attributes.key?(:'errors')
if (value = attributes[:'errors']).is_a?(Array)
self.errors = value
end
end
if attributes.key?(:'status')
self.status = attributes[:'status']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @context.nil?
invalid_properties.push('invalid value for "context", context cannot be nil.')
end
if @links.nil?
invalid_properties.push('invalid value for "links", links cannot be nil.')
end
if @category.nil?
invalid_properties.push('invalid value for "category", category cannot be nil.')
end
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
if @errors.nil?
invalid_properties.push('invalid value for "errors", errors cannot be nil.')
end
if @status.nil?
invalid_properties.push('invalid value for "status", status cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @context.nil?
return false if @links.nil?
return false if @category.nil?
return false if @message.nil?
return false if @errors.nil?
return false if @status.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
context == o.context &&
links == o.links &&
id == o.id &&
category == o.category &&
message == o.message &&
errors == o.errors &&
status == o.status
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, context, links, id, category, message, errors, status].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Events.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/models/contact_association.rb | lib/hubspot/codegen/marketing/events/models/contact_association.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Events
class ContactAssociation
attr_accessor :firstname
attr_accessor :contact_id
attr_accessor :email
attr_accessor :lastname
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'firstname' => :'firstname',
:'contact_id' => :'contactId',
:'email' => :'email',
:'lastname' => :'lastname'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'firstname' => :'String',
:'contact_id' => :'String',
:'email' => :'String',
:'lastname' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Events::ContactAssociation` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Events::ContactAssociation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'firstname')
self.firstname = attributes[:'firstname']
end
if attributes.key?(:'contact_id')
self.contact_id = attributes[:'contact_id']
end
if attributes.key?(:'email')
self.email = attributes[:'email']
end
if attributes.key?(:'lastname')
self.lastname = attributes[:'lastname']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @contact_id.nil?
invalid_properties.push('invalid value for "contact_id", contact_id cannot be nil.')
end
if @email.nil?
invalid_properties.push('invalid value for "email", email cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @contact_id.nil?
return false if @email.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
firstname == o.firstname &&
contact_id == o.contact_id &&
email == o.email &&
lastname == o.lastname
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[firstname, contact_id, email, lastname].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Events.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/models/marketing_event_public_object_id_delete_request.rb | lib/hubspot/codegen/marketing/events/models/marketing_event_public_object_id_delete_request.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Events
class MarketingEventPublicObjectIdDeleteRequest
attr_accessor :object_id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_id' => :'objectId'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'object_id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Events::MarketingEventPublicObjectIdDeleteRequest` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Events::MarketingEventPublicObjectIdDeleteRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'object_id')
self.object_id = attributes[:'object_id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @object_id.nil?
invalid_properties.push('invalid value for "object_id", object_id cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @object_id.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
object_id == o.object_id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[object_id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Events.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/models/marketing_event_create_request_params.rb | lib/hubspot/codegen/marketing/events/models/marketing_event_create_request_params.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Events
class MarketingEventCreateRequestParams
# The start date and time of the marketing event.
attr_accessor :start_date_time
# A list of PropertyValues. These can be whatever kind of property names and values you want. However, they must already exist on the HubSpot account's definition of the MarketingEvent Object. If they don't they will be filtered out and not set. In order to do this you'll need to create a new PropertyGroup on the HubSpot account's MarketingEvent object for your specific app and create the Custom Property you want to track on that HubSpot account. Do not create any new default properties on the MarketingEvent object as that will apply to all HubSpot accounts.
attr_accessor :custom_properties
# The accountId that is associated with this marketing event in the external event application.
attr_accessor :external_account_id
# Indicates if the marketing event has been cancelled. Defaults to `false`
attr_accessor :event_cancelled
# The name of the organizer of the marketing event.
attr_accessor :event_organizer
# A URL in the external event application where the marketing event can be managed.
attr_accessor :event_url
# The id of the marketing event in the external event application.
attr_accessor :external_event_id
# The description of the marketing event.
attr_accessor :event_description
# The name of the marketing event.
attr_accessor :event_name
# Describes what type of event this is. For example: `WEBINAR`, `CONFERENCE`, `WORKSHOP`
attr_accessor :event_type
attr_accessor :event_completed
# The end date and time of the marketing event.
attr_accessor :end_date_time
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'start_date_time' => :'startDateTime',
:'custom_properties' => :'customProperties',
:'external_account_id' => :'externalAccountId',
:'event_cancelled' => :'eventCancelled',
:'event_organizer' => :'eventOrganizer',
:'event_url' => :'eventUrl',
:'external_event_id' => :'externalEventId',
:'event_description' => :'eventDescription',
:'event_name' => :'eventName',
:'event_type' => :'eventType',
:'event_completed' => :'eventCompleted',
:'end_date_time' => :'endDateTime'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'start_date_time' => :'Time',
:'custom_properties' => :'Array<PropertyValue>',
:'external_account_id' => :'String',
:'event_cancelled' => :'Boolean',
:'event_organizer' => :'String',
:'event_url' => :'String',
:'external_event_id' => :'String',
:'event_description' => :'String',
:'event_name' => :'String',
:'event_type' => :'String',
:'event_completed' => :'Boolean',
:'end_date_time' => :'Time'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Events::MarketingEventCreateRequestParams` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Events::MarketingEventCreateRequestParams`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'start_date_time')
self.start_date_time = attributes[:'start_date_time']
end
if attributes.key?(:'custom_properties')
if (value = attributes[:'custom_properties']).is_a?(Array)
self.custom_properties = value
end
end
if attributes.key?(:'external_account_id')
self.external_account_id = attributes[:'external_account_id']
end
if attributes.key?(:'event_cancelled')
self.event_cancelled = attributes[:'event_cancelled']
end
if attributes.key?(:'event_organizer')
self.event_organizer = attributes[:'event_organizer']
end
if attributes.key?(:'event_url')
self.event_url = attributes[:'event_url']
end
if attributes.key?(:'external_event_id')
self.external_event_id = attributes[:'external_event_id']
end
if attributes.key?(:'event_description')
self.event_description = attributes[:'event_description']
end
if attributes.key?(:'event_name')
self.event_name = attributes[:'event_name']
end
if attributes.key?(:'event_type')
self.event_type = attributes[:'event_type']
end
if attributes.key?(:'event_completed')
self.event_completed = attributes[:'event_completed']
end
if attributes.key?(:'end_date_time')
self.end_date_time = attributes[:'end_date_time']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @external_account_id.nil?
invalid_properties.push('invalid value for "external_account_id", external_account_id cannot be nil.')
end
if @event_organizer.nil?
invalid_properties.push('invalid value for "event_organizer", event_organizer cannot be nil.')
end
if @external_event_id.nil?
invalid_properties.push('invalid value for "external_event_id", external_event_id cannot be nil.')
end
if @event_name.nil?
invalid_properties.push('invalid value for "event_name", event_name cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @external_account_id.nil?
return false if @event_organizer.nil?
return false if @external_event_id.nil?
return false if @event_name.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
start_date_time == o.start_date_time &&
custom_properties == o.custom_properties &&
external_account_id == o.external_account_id &&
event_cancelled == o.event_cancelled &&
event_organizer == o.event_organizer &&
event_url == o.event_url &&
external_event_id == o.external_event_id &&
event_description == o.event_description &&
event_name == o.event_name &&
event_type == o.event_type &&
event_completed == o.event_completed &&
end_date_time == o.end_date_time
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[start_date_time, custom_properties, external_account_id, event_cancelled, event_organizer, event_url, external_event_id, event_description, event_name, event_type, event_completed, end_date_time].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Events.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/models/collection_response_with_total_participation_breakdown_forward_paging.rb | lib/hubspot/codegen/marketing/events/models/collection_response_with_total_participation_breakdown_forward_paging.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Events
class CollectionResponseWithTotalParticipationBreakdownForwardPaging
attr_accessor :total
attr_accessor :paging
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'total' => :'total',
:'paging' => :'paging',
:'results' => :'results'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'total' => :'Integer',
:'paging' => :'ForwardPaging',
:'results' => :'Array<ParticipationBreakdown>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Events::CollectionResponseWithTotalParticipationBreakdownForwardPaging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Events::CollectionResponseWithTotalParticipationBreakdownForwardPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'total')
self.total = attributes[:'total']
end
if attributes.key?(:'paging')
self.paging = attributes[:'paging']
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @total.nil?
invalid_properties.push('invalid value for "total", total cannot be nil.')
end
if @results.nil?
invalid_properties.push('invalid value for "results", results cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @total.nil?
return false if @results.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
total == o.total &&
paging == o.paging &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[total, paging, results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Events.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/marketing/events/models/marketing_event_default_response.rb | lib/hubspot/codegen/marketing/events/models/marketing_event_default_response.rb | =begin
#Marketing Events
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Marketing
module Events
class MarketingEventDefaultResponse
# The start date and time of the marketing event.
attr_accessor :start_date_time
# A list of PropertyValues. These can be whatever kind of property names and values you want. However, they must already exist on the HubSpot account's definition of the MarketingEvent Object. If they don't they will be filtered out and not set. In order to do this you'll need to create a new PropertyGroup on the HubSpot account's MarketingEvent object for your specific app and create the Custom Property you want to track on that HubSpot account. Do not create any new default properties on the MarketingEvent object as that will apply to all HubSpot accounts.
attr_accessor :custom_properties
# Indicates if the marketing event has been cancelled.
attr_accessor :event_cancelled
# The name of the organizer of the marketing event.
attr_accessor :event_organizer
# The URL in the external event application where the marketing event can be managed.
attr_accessor :event_url
# The description of the marketing event.
attr_accessor :event_description
# The name of the marketing event.
attr_accessor :event_name
# The type of the marketing event.
attr_accessor :event_type
attr_accessor :event_completed
# The end date and time of the marketing event.
attr_accessor :end_date_time
attr_accessor :object_id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'start_date_time' => :'startDateTime',
:'custom_properties' => :'customProperties',
:'event_cancelled' => :'eventCancelled',
:'event_organizer' => :'eventOrganizer',
:'event_url' => :'eventUrl',
:'event_description' => :'eventDescription',
:'event_name' => :'eventName',
:'event_type' => :'eventType',
:'event_completed' => :'eventCompleted',
:'end_date_time' => :'endDateTime',
:'object_id' => :'objectId'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'start_date_time' => :'Time',
:'custom_properties' => :'Array<PropertyValue>',
:'event_cancelled' => :'Boolean',
:'event_organizer' => :'String',
:'event_url' => :'String',
:'event_description' => :'String',
:'event_name' => :'String',
:'event_type' => :'String',
:'event_completed' => :'Boolean',
:'end_date_time' => :'Time',
:'object_id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Marketing::Events::MarketingEventDefaultResponse` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Marketing::Events::MarketingEventDefaultResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'start_date_time')
self.start_date_time = attributes[:'start_date_time']
end
if attributes.key?(:'custom_properties')
if (value = attributes[:'custom_properties']).is_a?(Array)
self.custom_properties = value
end
end
if attributes.key?(:'event_cancelled')
self.event_cancelled = attributes[:'event_cancelled']
end
if attributes.key?(:'event_organizer')
self.event_organizer = attributes[:'event_organizer']
end
if attributes.key?(:'event_url')
self.event_url = attributes[:'event_url']
end
if attributes.key?(:'event_description')
self.event_description = attributes[:'event_description']
end
if attributes.key?(:'event_name')
self.event_name = attributes[:'event_name']
end
if attributes.key?(:'event_type')
self.event_type = attributes[:'event_type']
end
if attributes.key?(:'event_completed')
self.event_completed = attributes[:'event_completed']
end
if attributes.key?(:'end_date_time')
self.end_date_time = attributes[:'end_date_time']
end
if attributes.key?(:'object_id')
self.object_id = attributes[:'object_id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @event_organizer.nil?
invalid_properties.push('invalid value for "event_organizer", event_organizer cannot be nil.')
end
if @event_name.nil?
invalid_properties.push('invalid value for "event_name", event_name cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @event_organizer.nil?
return false if @event_name.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
start_date_time == o.start_date_time &&
custom_properties == o.custom_properties &&
event_cancelled == o.event_cancelled &&
event_organizer == o.event_organizer &&
event_url == o.event_url &&
event_description == o.event_description &&
event_name == o.event_name &&
event_type == o.event_type &&
event_completed == o.event_completed &&
end_date_time == o.end_date_time &&
object_id == o.object_id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[start_date_time, custom_properties, event_cancelled, event_organizer, event_url, event_description, event_name, event_type, event_completed, end_date_time, object_id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Marketing::Events.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.