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/crm/lists/models/list_folder_create_request.rb | lib/hubspot/codegen/crm/lists/models/list_folder_create_request.rb | =begin
#Lists
#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 Crm
module Lists
class ListFolderCreateRequest
# The folder this should be created in, if not specified will be created in the root folder 0.
attr_accessor :parent_folder_id
# The name of the folder to be created.
attr_accessor :name
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'parent_folder_id' => :'parentFolderId',
:'name' => :'name'
}
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
{
:'parent_folder_id' => :'String',
:'name' => :'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::Crm::Lists::ListFolderCreateRequest` 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::Crm::Lists::ListFolderCreateRequest`. 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?(:'parent_folder_id')
self.parent_folder_id = attributes[:'parent_folder_id']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
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?
return false if @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 &&
parent_folder_id == o.parent_folder_id &&
name == o.name
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
[parent_folder_id, name].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::Crm::Lists.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/crm/lists/models/public_communication_subscription_filter.rb | lib/hubspot/codegen/crm/lists/models/public_communication_subscription_filter.rb | =begin
#Lists
#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 Crm
module Lists
class PublicCommunicationSubscriptionFilter
attr_accessor :subscription_type
attr_accessor :subscription_ids
attr_accessor :channel
attr_accessor :accepted_opt_states
attr_accessor :filter_type
attr_accessor :business_unit_id
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' => :'subscriptionType',
:'subscription_ids' => :'subscriptionIds',
:'channel' => :'channel',
:'accepted_opt_states' => :'acceptedOptStates',
:'filter_type' => :'filterType',
:'business_unit_id' => :'businessUnitId'
}
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' => :'String',
:'subscription_ids' => :'Array<String>',
:'channel' => :'String',
:'accepted_opt_states' => :'Array<String>',
:'filter_type' => :'String',
:'business_unit_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::Crm::Lists::PublicCommunicationSubscriptionFilter` 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::Crm::Lists::PublicCommunicationSubscriptionFilter`. 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')
self.subscription_type = attributes[:'subscription_type']
end
if attributes.key?(:'subscription_ids')
if (value = attributes[:'subscription_ids']).is_a?(Array)
self.subscription_ids = value
end
end
if attributes.key?(:'channel')
self.channel = attributes[:'channel']
end
if attributes.key?(:'accepted_opt_states')
if (value = attributes[:'accepted_opt_states']).is_a?(Array)
self.accepted_opt_states = value
end
end
if attributes.key?(:'filter_type')
self.filter_type = attributes[:'filter_type']
else
self.filter_type = 'COMMUNICATION_SUBSCRIPTION'
end
if attributes.key?(:'business_unit_id')
self.business_unit_id = attributes[:'business_unit_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 @subscription_type.nil?
invalid_properties.push('invalid value for "subscription_type", subscription_type cannot be nil.')
end
if @subscription_ids.nil?
invalid_properties.push('invalid value for "subscription_ids", subscription_ids cannot be nil.')
end
if @channel.nil?
invalid_properties.push('invalid value for "channel", channel cannot be nil.')
end
if @accepted_opt_states.nil?
invalid_properties.push('invalid value for "accepted_opt_states", accepted_opt_states cannot be nil.')
end
if @filter_type.nil?
invalid_properties.push('invalid value for "filter_type", filter_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 @subscription_type.nil?
return false if @subscription_ids.nil?
return false if @channel.nil?
return false if @accepted_opt_states.nil?
return false if @filter_type.nil?
filter_type_validator = EnumAttributeValidator.new('String', ["COMMUNICATION_SUBSCRIPTION"])
return false unless filter_type_validator.valid?(@filter_type)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] filter_type Object to be assigned
def filter_type=(filter_type)
validator = EnumAttributeValidator.new('String', ["COMMUNICATION_SUBSCRIPTION"])
unless validator.valid?(filter_type)
fail ArgumentError, "invalid value for \"filter_type\", must be one of #{validator.allowable_values}."
end
@filter_type = filter_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 == o.subscription_type &&
subscription_ids == o.subscription_ids &&
channel == o.channel &&
accepted_opt_states == o.accepted_opt_states &&
filter_type == o.filter_type &&
business_unit_id == o.business_unit_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
[subscription_type, subscription_ids, channel, accepted_opt_states, filter_type, business_unit_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::Crm::Lists.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/crm/lists/models/public_year_reference.rb | lib/hubspot/codegen/crm/lists/models/public_year_reference.rb | =begin
#Lists
#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 Crm
module Lists
class PublicYearReference
attr_accessor :hour
attr_accessor :month
attr_accessor :millisecond
attr_accessor :reference_type
attr_accessor :day
attr_accessor :minute
attr_accessor :second
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
{
:'hour' => :'hour',
:'month' => :'month',
:'millisecond' => :'millisecond',
:'reference_type' => :'referenceType',
:'day' => :'day',
:'minute' => :'minute',
:'second' => :'second'
}
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
{
:'hour' => :'Integer',
:'month' => :'Integer',
:'millisecond' => :'Integer',
:'reference_type' => :'String',
:'day' => :'Integer',
:'minute' => :'Integer',
:'second' => :'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::Crm::Lists::PublicYearReference` 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::Crm::Lists::PublicYearReference`. 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?(:'hour')
self.hour = attributes[:'hour']
end
if attributes.key?(:'month')
self.month = attributes[:'month']
end
if attributes.key?(:'millisecond')
self.millisecond = attributes[:'millisecond']
end
if attributes.key?(:'reference_type')
self.reference_type = attributes[:'reference_type']
else
self.reference_type = 'YEAR'
end
if attributes.key?(:'day')
self.day = attributes[:'day']
end
if attributes.key?(:'minute')
self.minute = attributes[:'minute']
end
if attributes.key?(:'second')
self.second = attributes[:'second']
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 @month.nil?
invalid_properties.push('invalid value for "month", month cannot be nil.')
end
if @reference_type.nil?
invalid_properties.push('invalid value for "reference_type", reference_type cannot be nil.')
end
if @day.nil?
invalid_properties.push('invalid value for "day", day 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 @month.nil?
return false if @reference_type.nil?
reference_type_validator = EnumAttributeValidator.new('String', ["YEAR"])
return false unless reference_type_validator.valid?(@reference_type)
return false if @day.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] reference_type Object to be assigned
def reference_type=(reference_type)
validator = EnumAttributeValidator.new('String', ["YEAR"])
unless validator.valid?(reference_type)
fail ArgumentError, "invalid value for \"reference_type\", must be one of #{validator.allowable_values}."
end
@reference_type = reference_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 &&
hour == o.hour &&
month == o.month &&
millisecond == o.millisecond &&
reference_type == o.reference_type &&
day == o.day &&
minute == o.minute &&
second == o.second
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
[hour, month, millisecond, reference_type, day, minute, second].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::Crm::Lists.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/crm/lists/models/public_date_time_property_operation.rb | lib/hubspot/codegen/crm/lists/models/public_date_time_property_operation.rb | =begin
#Lists
#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 Crm
module Lists
class PublicDateTimePropertyOperation
attr_accessor :include_objects_with_no_value_set
attr_accessor :requires_time_zone_conversion
attr_accessor :operation_type
attr_accessor :operator
attr_accessor :timestamp
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
{
:'include_objects_with_no_value_set' => :'includeObjectsWithNoValueSet',
:'requires_time_zone_conversion' => :'requiresTimeZoneConversion',
:'operation_type' => :'operationType',
:'operator' => :'operator',
:'timestamp' => :'timestamp'
}
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_objects_with_no_value_set' => :'Boolean',
:'requires_time_zone_conversion' => :'Boolean',
:'operation_type' => :'String',
:'operator' => :'String',
:'timestamp' => :'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::Crm::Lists::PublicDateTimePropertyOperation` 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::Crm::Lists::PublicDateTimePropertyOperation`. 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_objects_with_no_value_set')
self.include_objects_with_no_value_set = attributes[:'include_objects_with_no_value_set']
end
if attributes.key?(:'requires_time_zone_conversion')
self.requires_time_zone_conversion = attributes[:'requires_time_zone_conversion']
end
if attributes.key?(:'operation_type')
self.operation_type = attributes[:'operation_type']
else
self.operation_type = 'DATETIME'
end
if attributes.key?(:'operator')
self.operator = attributes[:'operator']
end
if attributes.key?(:'timestamp')
self.timestamp = attributes[:'timestamp']
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 @include_objects_with_no_value_set.nil?
invalid_properties.push('invalid value for "include_objects_with_no_value_set", include_objects_with_no_value_set cannot be nil.')
end
if @requires_time_zone_conversion.nil?
invalid_properties.push('invalid value for "requires_time_zone_conversion", requires_time_zone_conversion cannot be nil.')
end
if @operation_type.nil?
invalid_properties.push('invalid value for "operation_type", operation_type cannot be nil.')
end
if @operator.nil?
invalid_properties.push('invalid value for "operator", operator cannot be nil.')
end
if @timestamp.nil?
invalid_properties.push('invalid value for "timestamp", timestamp 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 @include_objects_with_no_value_set.nil?
return false if @requires_time_zone_conversion.nil?
return false if @operation_type.nil?
operation_type_validator = EnumAttributeValidator.new('String', ["DATETIME"])
return false unless operation_type_validator.valid?(@operation_type)
return false if @operator.nil?
return false if @timestamp.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] operation_type Object to be assigned
def operation_type=(operation_type)
validator = EnumAttributeValidator.new('String', ["DATETIME"])
unless validator.valid?(operation_type)
fail ArgumentError, "invalid value for \"operation_type\", must be one of #{validator.allowable_values}."
end
@operation_type = operation_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 &&
include_objects_with_no_value_set == o.include_objects_with_no_value_set &&
requires_time_zone_conversion == o.requires_time_zone_conversion &&
operation_type == o.operation_type &&
operator == o.operator &&
timestamp == o.timestamp
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_objects_with_no_value_set, requires_time_zone_conversion, operation_type, operator, timestamp].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::Crm::Lists.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/crm/lists/models/public_restricted_filter_branch.rb | lib/hubspot/codegen/crm/lists/models/public_restricted_filter_branch.rb | =begin
#Lists
#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 Crm
module Lists
class PublicRestrictedFilterBranch
attr_accessor :filter_branch_type
attr_accessor :filter_branches
attr_accessor :filter_branch_operator
attr_accessor :filters
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
{
:'filter_branch_type' => :'filterBranchType',
:'filter_branches' => :'filterBranches',
:'filter_branch_operator' => :'filterBranchOperator',
:'filters' => :'filters'
}
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
{
:'filter_branch_type' => :'String',
:'filter_branches' => :'Array<PublicPropertyAssociationFilterBranchFilterBranchesInner>',
:'filter_branch_operator' => :'String',
:'filters' => :'Array<PublicPropertyAssociationFilterBranchFiltersInner>'
}
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::Crm::Lists::PublicRestrictedFilterBranch` 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::Crm::Lists::PublicRestrictedFilterBranch`. 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?(:'filter_branch_type')
self.filter_branch_type = attributes[:'filter_branch_type']
else
self.filter_branch_type = 'RESTRICTED'
end
if attributes.key?(:'filter_branches')
if (value = attributes[:'filter_branches']).is_a?(Array)
self.filter_branches = value
end
end
if attributes.key?(:'filter_branch_operator')
self.filter_branch_operator = attributes[:'filter_branch_operator']
end
if attributes.key?(:'filters')
if (value = attributes[:'filters']).is_a?(Array)
self.filters = 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 @filter_branch_type.nil?
invalid_properties.push('invalid value for "filter_branch_type", filter_branch_type cannot be nil.')
end
if @filter_branches.nil?
invalid_properties.push('invalid value for "filter_branches", filter_branches cannot be nil.')
end
if @filter_branch_operator.nil?
invalid_properties.push('invalid value for "filter_branch_operator", filter_branch_operator cannot be nil.')
end
if @filters.nil?
invalid_properties.push('invalid value for "filters", filters 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 @filter_branch_type.nil?
filter_branch_type_validator = EnumAttributeValidator.new('String', ["RESTRICTED"])
return false unless filter_branch_type_validator.valid?(@filter_branch_type)
return false if @filter_branches.nil?
return false if @filter_branch_operator.nil?
return false if @filters.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] filter_branch_type Object to be assigned
def filter_branch_type=(filter_branch_type)
validator = EnumAttributeValidator.new('String', ["RESTRICTED"])
unless validator.valid?(filter_branch_type)
fail ArgumentError, "invalid value for \"filter_branch_type\", must be one of #{validator.allowable_values}."
end
@filter_branch_type = filter_branch_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 &&
filter_branch_type == o.filter_branch_type &&
filter_branches == o.filter_branches &&
filter_branch_operator == o.filter_branch_operator &&
filters == o.filters
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
[filter_branch_type, filter_branches, filter_branch_operator, filters].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::Crm::Lists.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/crm/lists/models/public_email_subscription_filter.rb | lib/hubspot/codegen/crm/lists/models/public_email_subscription_filter.rb | =begin
#Lists
#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 Crm
module Lists
class PublicEmailSubscriptionFilter
attr_accessor :subscription_type
attr_accessor :subscription_ids
attr_accessor :filter_type
attr_accessor :accepted_statuses
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' => :'subscriptionType',
:'subscription_ids' => :'subscriptionIds',
:'filter_type' => :'filterType',
:'accepted_statuses' => :'acceptedStatuses'
}
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' => :'String',
:'subscription_ids' => :'Array<String>',
:'filter_type' => :'String',
:'accepted_statuses' => :'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::Crm::Lists::PublicEmailSubscriptionFilter` 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::Crm::Lists::PublicEmailSubscriptionFilter`. 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')
self.subscription_type = attributes[:'subscription_type']
end
if attributes.key?(:'subscription_ids')
if (value = attributes[:'subscription_ids']).is_a?(Array)
self.subscription_ids = value
end
end
if attributes.key?(:'filter_type')
self.filter_type = attributes[:'filter_type']
else
self.filter_type = 'EMAIL_SUBSCRIPTION'
end
if attributes.key?(:'accepted_statuses')
if (value = attributes[:'accepted_statuses']).is_a?(Array)
self.accepted_statuses = 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 @subscription_ids.nil?
invalid_properties.push('invalid value for "subscription_ids", subscription_ids cannot be nil.')
end
if @filter_type.nil?
invalid_properties.push('invalid value for "filter_type", filter_type cannot be nil.')
end
if @accepted_statuses.nil?
invalid_properties.push('invalid value for "accepted_statuses", accepted_statuses 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_ids.nil?
return false if @filter_type.nil?
filter_type_validator = EnumAttributeValidator.new('String', ["EMAIL_SUBSCRIPTION"])
return false unless filter_type_validator.valid?(@filter_type)
return false if @accepted_statuses.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] filter_type Object to be assigned
def filter_type=(filter_type)
validator = EnumAttributeValidator.new('String', ["EMAIL_SUBSCRIPTION"])
unless validator.valid?(filter_type)
fail ArgumentError, "invalid value for \"filter_type\", must be one of #{validator.allowable_values}."
end
@filter_type = filter_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 == o.subscription_type &&
subscription_ids == o.subscription_ids &&
filter_type == o.filter_type &&
accepted_statuses == o.accepted_statuses
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, subscription_ids, filter_type, accepted_statuses].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::Crm::Lists.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/crm/lists/models/public_absolute_comparative_timestamp_refine_by.rb | lib/hubspot/codegen/crm/lists/models/public_absolute_comparative_timestamp_refine_by.rb | =begin
#Lists
#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 Crm
module Lists
class PublicAbsoluteComparativeTimestampRefineBy
attr_accessor :comparison
attr_accessor :type
attr_accessor :timestamp
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
{
:'comparison' => :'comparison',
:'type' => :'type',
:'timestamp' => :'timestamp'
}
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
{
:'comparison' => :'String',
:'type' => :'String',
:'timestamp' => :'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::Crm::Lists::PublicAbsoluteComparativeTimestampRefineBy` 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::Crm::Lists::PublicAbsoluteComparativeTimestampRefineBy`. 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?(:'comparison')
self.comparison = attributes[:'comparison']
end
if attributes.key?(:'type')
self.type = attributes[:'type']
else
self.type = 'ABSOLUTE_COMPARATIVE'
end
if attributes.key?(:'timestamp')
self.timestamp = attributes[:'timestamp']
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 @comparison.nil?
invalid_properties.push('invalid value for "comparison", comparison cannot be nil.')
end
if @type.nil?
invalid_properties.push('invalid value for "type", type cannot be nil.')
end
if @timestamp.nil?
invalid_properties.push('invalid value for "timestamp", timestamp 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 @comparison.nil?
return false if @type.nil?
type_validator = EnumAttributeValidator.new('String', ["ABSOLUTE_COMPARATIVE"])
return false unless type_validator.valid?(@type)
return false if @timestamp.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', ["ABSOLUTE_COMPARATIVE"])
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 &&
comparison == o.comparison &&
type == o.type &&
timestamp == o.timestamp
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
[comparison, type, timestamp].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::Crm::Lists.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/crm/lists/models/public_form_submission_filter_coalescing_refine_by.rb | lib/hubspot/codegen/crm/lists/models/public_form_submission_filter_coalescing_refine_by.rb | =begin
#Lists
#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 Crm
module Lists
module PublicFormSubmissionFilterCoalescingRefineBy
class << self
# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'PublicAbsoluteComparativeTimestampRefineBy',
:'PublicAbsoluteRangedTimestampRefineBy',
:'PublicAllHistoryRefineBy',
:'PublicNumOccurrencesRefineBy',
:'PublicRangedTimeOperation',
:'PublicRelativeComparativeTimestampRefineBy',
:'PublicRelativeRangedTimestampRefineBy',
:'PublicSetOccurrencesRefineBy',
:'PublicTimePointOperation'
]
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::Crm::Lists.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/crm/lists/models/public_association_filter_branch.rb | lib/hubspot/codegen/crm/lists/models/public_association_filter_branch.rb | =begin
#Lists
#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 Crm
module Lists
class PublicAssociationFilterBranch
attr_accessor :filter_branch_type
attr_accessor :filter_branches
attr_accessor :object_type_id
attr_accessor :filter_branch_operator
attr_accessor :association_type_id
attr_accessor :association_category
attr_accessor :filters
attr_accessor :operator
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
{
:'filter_branch_type' => :'filterBranchType',
:'filter_branches' => :'filterBranches',
:'object_type_id' => :'objectTypeId',
:'filter_branch_operator' => :'filterBranchOperator',
:'association_type_id' => :'associationTypeId',
:'association_category' => :'associationCategory',
:'filters' => :'filters',
:'operator' => :'operator'
}
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
{
:'filter_branch_type' => :'String',
:'filter_branches' => :'Array<PublicPropertyAssociationFilterBranchFilterBranchesInner>',
:'object_type_id' => :'String',
:'filter_branch_operator' => :'String',
:'association_type_id' => :'Integer',
:'association_category' => :'String',
:'filters' => :'Array<PublicPropertyAssociationFilterBranchFiltersInner>',
:'operator' => :'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::Crm::Lists::PublicAssociationFilterBranch` 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::Crm::Lists::PublicAssociationFilterBranch`. 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?(:'filter_branch_type')
self.filter_branch_type = attributes[:'filter_branch_type']
else
self.filter_branch_type = 'ASSOCIATION'
end
if attributes.key?(:'filter_branches')
if (value = attributes[:'filter_branches']).is_a?(Array)
self.filter_branches = value
end
end
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'filter_branch_operator')
self.filter_branch_operator = attributes[:'filter_branch_operator']
end
if attributes.key?(:'association_type_id')
self.association_type_id = attributes[:'association_type_id']
end
if attributes.key?(:'association_category')
self.association_category = attributes[:'association_category']
end
if attributes.key?(:'filters')
if (value = attributes[:'filters']).is_a?(Array)
self.filters = value
end
end
if attributes.key?(:'operator')
self.operator = attributes[:'operator']
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 @filter_branch_type.nil?
invalid_properties.push('invalid value for "filter_branch_type", filter_branch_type cannot be nil.')
end
if @filter_branches.nil?
invalid_properties.push('invalid value for "filter_branches", filter_branches cannot be nil.')
end
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @filter_branch_operator.nil?
invalid_properties.push('invalid value for "filter_branch_operator", filter_branch_operator cannot be nil.')
end
if @association_type_id.nil?
invalid_properties.push('invalid value for "association_type_id", association_type_id cannot be nil.')
end
if @association_category.nil?
invalid_properties.push('invalid value for "association_category", association_category cannot be nil.')
end
if @filters.nil?
invalid_properties.push('invalid value for "filters", filters cannot be nil.')
end
if @operator.nil?
invalid_properties.push('invalid value for "operator", operator 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 @filter_branch_type.nil?
filter_branch_type_validator = EnumAttributeValidator.new('String', ["ASSOCIATION"])
return false unless filter_branch_type_validator.valid?(@filter_branch_type)
return false if @filter_branches.nil?
return false if @object_type_id.nil?
return false if @filter_branch_operator.nil?
return false if @association_type_id.nil?
return false if @association_category.nil?
return false if @filters.nil?
return false if @operator.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] filter_branch_type Object to be assigned
def filter_branch_type=(filter_branch_type)
validator = EnumAttributeValidator.new('String', ["ASSOCIATION"])
unless validator.valid?(filter_branch_type)
fail ArgumentError, "invalid value for \"filter_branch_type\", must be one of #{validator.allowable_values}."
end
@filter_branch_type = filter_branch_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 &&
filter_branch_type == o.filter_branch_type &&
filter_branches == o.filter_branches &&
object_type_id == o.object_type_id &&
filter_branch_operator == o.filter_branch_operator &&
association_type_id == o.association_type_id &&
association_category == o.association_category &&
filters == o.filters &&
operator == o.operator
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
[filter_branch_type, filter_branches, object_type_id, filter_branch_operator, association_type_id, association_category, filters, operator].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::Crm::Lists.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/crm/lists/models/list_create_request.rb | lib/hubspot/codegen/crm/lists/models/list_create_request.rb | =begin
#Lists
#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 Crm
module Lists
class ListCreateRequest
# The object type ID of the type of objects that the list will store.
attr_accessor :object_type_id
# The processing type of the list. One of: `SNAPSHOT`, `MANUAL`, or `DYNAMIC`.
attr_accessor :processing_type
# The list of custom properties to tie to the list. Custom property name is the key, the value is the value.
attr_accessor :custom_properties
# The ID of the folder that the list should be created in. If left blank, then the list will be created in the root of the list folder structure.
attr_accessor :list_folder_id
# The name of the list, which must be globally unique across all public lists in the portal.
attr_accessor :name
attr_accessor :filter_branch
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_type_id' => :'objectTypeId',
:'processing_type' => :'processingType',
:'custom_properties' => :'customProperties',
:'list_folder_id' => :'listFolderId',
:'name' => :'name',
:'filter_branch' => :'filterBranch'
}
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',
:'processing_type' => :'String',
:'custom_properties' => :'Hash<String, String>',
:'list_folder_id' => :'Integer',
:'name' => :'String',
:'filter_branch' => :'PublicPropertyAssociationFilterBranchFilterBranchesInner'
}
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::Crm::Lists::ListCreateRequest` 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::Crm::Lists::ListCreateRequest`. 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?(:'processing_type')
self.processing_type = attributes[:'processing_type']
end
if attributes.key?(:'custom_properties')
if (value = attributes[:'custom_properties']).is_a?(Hash)
self.custom_properties = value
end
end
if attributes.key?(:'list_folder_id')
self.list_folder_id = attributes[:'list_folder_id']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'filter_branch')
self.filter_branch = attributes[:'filter_branch']
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 @processing_type.nil?
invalid_properties.push('invalid value for "processing_type", processing_type cannot be nil.')
end
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?
return false if @object_type_id.nil?
return false if @processing_type.nil?
return false if @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 &&
object_type_id == o.object_type_id &&
processing_type == o.processing_type &&
custom_properties == o.custom_properties &&
list_folder_id == o.list_folder_id &&
name == o.name &&
filter_branch == o.filter_branch
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, processing_type, custom_properties, list_folder_id, name, filter_branch].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::Crm::Lists.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/crm/lists/models/public_page_view_analytics_filter.rb | lib/hubspot/codegen/crm/lists/models/public_page_view_analytics_filter.rb | =begin
#Lists
#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 Crm
module Lists
class PublicPageViewAnalyticsFilter
attr_accessor :coalescing_refine_by
attr_accessor :enable_tracking
attr_accessor :pruning_refine_by
attr_accessor :page_url
attr_accessor :filter_type
attr_accessor :operator
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
{
:'coalescing_refine_by' => :'coalescingRefineBy',
:'enable_tracking' => :'enableTracking',
:'pruning_refine_by' => :'pruningRefineBy',
:'page_url' => :'pageUrl',
:'filter_type' => :'filterType',
:'operator' => :'operator'
}
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
{
:'coalescing_refine_by' => :'PublicFormSubmissionFilterCoalescingRefineBy',
:'enable_tracking' => :'Boolean',
:'pruning_refine_by' => :'PublicFormSubmissionFilterCoalescingRefineBy',
:'page_url' => :'String',
:'filter_type' => :'String',
:'operator' => :'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::Crm::Lists::PublicPageViewAnalyticsFilter` 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::Crm::Lists::PublicPageViewAnalyticsFilter`. 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?(:'coalescing_refine_by')
self.coalescing_refine_by = attributes[:'coalescing_refine_by']
end
if attributes.key?(:'enable_tracking')
self.enable_tracking = attributes[:'enable_tracking']
end
if attributes.key?(:'pruning_refine_by')
self.pruning_refine_by = attributes[:'pruning_refine_by']
end
if attributes.key?(:'page_url')
self.page_url = attributes[:'page_url']
end
if attributes.key?(:'filter_type')
self.filter_type = attributes[:'filter_type']
else
self.filter_type = 'PAGE_VIEW'
end
if attributes.key?(:'operator')
self.operator = attributes[:'operator']
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 @page_url.nil?
invalid_properties.push('invalid value for "page_url", page_url cannot be nil.')
end
if @filter_type.nil?
invalid_properties.push('invalid value for "filter_type", filter_type cannot be nil.')
end
if @operator.nil?
invalid_properties.push('invalid value for "operator", operator 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 @page_url.nil?
return false if @filter_type.nil?
filter_type_validator = EnumAttributeValidator.new('String', ["PAGE_VIEW"])
return false unless filter_type_validator.valid?(@filter_type)
return false if @operator.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] filter_type Object to be assigned
def filter_type=(filter_type)
validator = EnumAttributeValidator.new('String', ["PAGE_VIEW"])
unless validator.valid?(filter_type)
fail ArgumentError, "invalid value for \"filter_type\", must be one of #{validator.allowable_values}."
end
@filter_type = filter_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 &&
coalescing_refine_by == o.coalescing_refine_by &&
enable_tracking == o.enable_tracking &&
pruning_refine_by == o.pruning_refine_by &&
page_url == o.page_url &&
filter_type == o.filter_type &&
operator == o.operator
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
[coalescing_refine_by, enable_tracking, pruning_refine_by, page_url, filter_type, operator].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::Crm::Lists.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/crm/lists/models/public_ranged_number_property_operation.rb | lib/hubspot/codegen/crm/lists/models/public_ranged_number_property_operation.rb | =begin
#Lists
#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 Crm
module Lists
class PublicRangedNumberPropertyOperation
attr_accessor :include_objects_with_no_value_set
attr_accessor :upper_bound
attr_accessor :operation_type
attr_accessor :lower_bound
attr_accessor :operator
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
{
:'include_objects_with_no_value_set' => :'includeObjectsWithNoValueSet',
:'upper_bound' => :'upperBound',
:'operation_type' => :'operationType',
:'lower_bound' => :'lowerBound',
:'operator' => :'operator'
}
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_objects_with_no_value_set' => :'Boolean',
:'upper_bound' => :'Integer',
:'operation_type' => :'String',
:'lower_bound' => :'Integer',
:'operator' => :'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::Crm::Lists::PublicRangedNumberPropertyOperation` 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::Crm::Lists::PublicRangedNumberPropertyOperation`. 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_objects_with_no_value_set')
self.include_objects_with_no_value_set = attributes[:'include_objects_with_no_value_set']
end
if attributes.key?(:'upper_bound')
self.upper_bound = attributes[:'upper_bound']
end
if attributes.key?(:'operation_type')
self.operation_type = attributes[:'operation_type']
else
self.operation_type = 'NUMBER_RANGED'
end
if attributes.key?(:'lower_bound')
self.lower_bound = attributes[:'lower_bound']
end
if attributes.key?(:'operator')
self.operator = attributes[:'operator']
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 @include_objects_with_no_value_set.nil?
invalid_properties.push('invalid value for "include_objects_with_no_value_set", include_objects_with_no_value_set cannot be nil.')
end
if @upper_bound.nil?
invalid_properties.push('invalid value for "upper_bound", upper_bound cannot be nil.')
end
if @operation_type.nil?
invalid_properties.push('invalid value for "operation_type", operation_type cannot be nil.')
end
if @lower_bound.nil?
invalid_properties.push('invalid value for "lower_bound", lower_bound cannot be nil.')
end
if @operator.nil?
invalid_properties.push('invalid value for "operator", operator 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 @include_objects_with_no_value_set.nil?
return false if @upper_bound.nil?
return false if @operation_type.nil?
operation_type_validator = EnumAttributeValidator.new('String', ["NUMBER_RANGED"])
return false unless operation_type_validator.valid?(@operation_type)
return false if @lower_bound.nil?
return false if @operator.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] operation_type Object to be assigned
def operation_type=(operation_type)
validator = EnumAttributeValidator.new('String', ["NUMBER_RANGED"])
unless validator.valid?(operation_type)
fail ArgumentError, "invalid value for \"operation_type\", must be one of #{validator.allowable_values}."
end
@operation_type = operation_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 &&
include_objects_with_no_value_set == o.include_objects_with_no_value_set &&
upper_bound == o.upper_bound &&
operation_type == o.operation_type &&
lower_bound == o.lower_bound &&
operator == o.operator
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_objects_with_no_value_set, upper_bound, operation_type, lower_bound, operator].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::Crm::Lists.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/crm/lists/models/public_property_referenced_time.rb | lib/hubspot/codegen/crm/lists/models/public_property_referenced_time.rb | =begin
#Lists
#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 Crm
module Lists
class PublicPropertyReferencedTime
attr_accessor :timezone_source
attr_accessor :property
attr_accessor :time_type
attr_accessor :zone_id
attr_accessor :reference_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
{
:'timezone_source' => :'timezoneSource',
:'property' => :'property',
:'time_type' => :'timeType',
:'zone_id' => :'zoneId',
:'reference_type' => :'referenceType'
}
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
{
:'timezone_source' => :'String',
:'property' => :'String',
:'time_type' => :'String',
:'zone_id' => :'String',
:'reference_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::Crm::Lists::PublicPropertyReferencedTime` 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::Crm::Lists::PublicPropertyReferencedTime`. 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?(:'timezone_source')
self.timezone_source = attributes[:'timezone_source']
end
if attributes.key?(:'property')
self.property = attributes[:'property']
end
if attributes.key?(:'time_type')
self.time_type = attributes[:'time_type']
else
self.time_type = 'PROPERTY_REFERENCED'
end
if attributes.key?(:'zone_id')
self.zone_id = attributes[:'zone_id']
end
if attributes.key?(:'reference_type')
self.reference_type = attributes[:'reference_type']
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 @property.nil?
invalid_properties.push('invalid value for "property", property cannot be nil.')
end
if @time_type.nil?
invalid_properties.push('invalid value for "time_type", time_type cannot be nil.')
end
if @zone_id.nil?
invalid_properties.push('invalid value for "zone_id", zone_id cannot be nil.')
end
if @reference_type.nil?
invalid_properties.push('invalid value for "reference_type", reference_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 @property.nil?
return false if @time_type.nil?
time_type_validator = EnumAttributeValidator.new('String', ["PROPERTY_REFERENCED"])
return false unless time_type_validator.valid?(@time_type)
return false if @zone_id.nil?
return false if @reference_type.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] time_type Object to be assigned
def time_type=(time_type)
validator = EnumAttributeValidator.new('String', ["PROPERTY_REFERENCED"])
unless validator.valid?(time_type)
fail ArgumentError, "invalid value for \"time_type\", must be one of #{validator.allowable_values}."
end
@time_type = time_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 &&
timezone_source == o.timezone_source &&
property == o.property &&
time_type == o.time_type &&
zone_id == o.zone_id &&
reference_type == o.reference_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
[timezone_source, property, time_type, zone_id, reference_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::Crm::Lists.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/crm/lists/models/list_move_request.rb | lib/hubspot/codegen/crm/lists/models/list_move_request.rb | =begin
#Lists
#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 Crm
module Lists
class ListMoveRequest
# The Id of the list to move.
attr_accessor :list_id
# The Id of folder to move the list to, the root folder is Id 0.
attr_accessor :new_folder_id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'list_id' => :'listId',
:'new_folder_id' => :'newFolderId'
}
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
{
:'list_id' => :'String',
:'new_folder_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::Crm::Lists::ListMoveRequest` 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::Crm::Lists::ListMoveRequest`. 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?(:'list_id')
self.list_id = attributes[:'list_id']
end
if attributes.key?(:'new_folder_id')
self.new_folder_id = attributes[:'new_folder_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 @list_id.nil?
invalid_properties.push('invalid value for "list_id", list_id cannot be nil.')
end
if @new_folder_id.nil?
invalid_properties.push('invalid value for "new_folder_id", new_folder_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 @list_id.nil?
return false if @new_folder_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 &&
list_id == o.list_id &&
new_folder_id == o.new_folder_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
[list_id, new_folder_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::Crm::Lists.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/crm/lists/models/public_migration_mapping.rb | lib/hubspot/codegen/crm/lists/models/public_migration_mapping.rb | =begin
#Lists
#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 Crm
module Lists
class PublicMigrationMapping
# The V3 list id for the list
attr_accessor :list_id
# The legacy list id for the list
attr_accessor :legacy_list_id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'list_id' => :'listId',
:'legacy_list_id' => :'legacyListId'
}
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
{
:'list_id' => :'String',
:'legacy_list_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::Crm::Lists::PublicMigrationMapping` 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::Crm::Lists::PublicMigrationMapping`. 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?(:'list_id')
self.list_id = attributes[:'list_id']
end
if attributes.key?(:'legacy_list_id')
self.legacy_list_id = attributes[:'legacy_list_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 @list_id.nil?
invalid_properties.push('invalid value for "list_id", list_id cannot be nil.')
end
if @legacy_list_id.nil?
invalid_properties.push('invalid value for "legacy_list_id", legacy_list_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 @list_id.nil?
return false if @legacy_list_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 &&
list_id == o.list_id &&
legacy_list_id == o.legacy_list_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
[list_id, legacy_list_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::Crm::Lists.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/crm/lists/models/api_collection_response_join_time_and_record_id.rb | lib/hubspot/codegen/crm/lists/models/api_collection_response_join_time_and_record_id.rb | =begin
#Lists
#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 Crm
module Lists
class ApiCollectionResponseJoinTimeAndRecordId
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' => :'Paging',
:'results' => :'Array<JoinTimeAndRecordId>'
}
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::Crm::Lists::ApiCollectionResponseJoinTimeAndRecordId` 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::Crm::Lists::ApiCollectionResponseJoinTimeAndRecordId`. 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 @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 &&
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::Crm::Lists.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/crm/lists/models/public_date_point.rb | lib/hubspot/codegen/crm/lists/models/public_date_point.rb | =begin
#Lists
#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 Crm
module Lists
class PublicDatePoint
attr_accessor :month
attr_accessor :hour
attr_accessor :year
attr_accessor :timezone_source
attr_accessor :millisecond
attr_accessor :time_type
attr_accessor :zone_id
attr_accessor :day
attr_accessor :minute
attr_accessor :second
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
{
:'month' => :'month',
:'hour' => :'hour',
:'year' => :'year',
:'timezone_source' => :'timezoneSource',
:'millisecond' => :'millisecond',
:'time_type' => :'timeType',
:'zone_id' => :'zoneId',
:'day' => :'day',
:'minute' => :'minute',
:'second' => :'second'
}
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
{
:'month' => :'Integer',
:'hour' => :'Integer',
:'year' => :'Integer',
:'timezone_source' => :'String',
:'millisecond' => :'Integer',
:'time_type' => :'String',
:'zone_id' => :'String',
:'day' => :'Integer',
:'minute' => :'Integer',
:'second' => :'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::Crm::Lists::PublicDatePoint` 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::Crm::Lists::PublicDatePoint`. 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?(:'month')
self.month = attributes[:'month']
end
if attributes.key?(:'hour')
self.hour = attributes[:'hour']
end
if attributes.key?(:'year')
self.year = attributes[:'year']
end
if attributes.key?(:'timezone_source')
self.timezone_source = attributes[:'timezone_source']
end
if attributes.key?(:'millisecond')
self.millisecond = attributes[:'millisecond']
end
if attributes.key?(:'time_type')
self.time_type = attributes[:'time_type']
else
self.time_type = 'DATE'
end
if attributes.key?(:'zone_id')
self.zone_id = attributes[:'zone_id']
end
if attributes.key?(:'day')
self.day = attributes[:'day']
end
if attributes.key?(:'minute')
self.minute = attributes[:'minute']
end
if attributes.key?(:'second')
self.second = attributes[:'second']
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 @month.nil?
invalid_properties.push('invalid value for "month", month cannot be nil.')
end
if @year.nil?
invalid_properties.push('invalid value for "year", year cannot be nil.')
end
if @time_type.nil?
invalid_properties.push('invalid value for "time_type", time_type cannot be nil.')
end
if @zone_id.nil?
invalid_properties.push('invalid value for "zone_id", zone_id cannot be nil.')
end
if @day.nil?
invalid_properties.push('invalid value for "day", day 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 @month.nil?
return false if @year.nil?
return false if @time_type.nil?
time_type_validator = EnumAttributeValidator.new('String', ["DATE"])
return false unless time_type_validator.valid?(@time_type)
return false if @zone_id.nil?
return false if @day.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] time_type Object to be assigned
def time_type=(time_type)
validator = EnumAttributeValidator.new('String', ["DATE"])
unless validator.valid?(time_type)
fail ArgumentError, "invalid value for \"time_type\", must be one of #{validator.allowable_values}."
end
@time_type = time_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 &&
month == o.month &&
hour == o.hour &&
year == o.year &&
timezone_source == o.timezone_source &&
millisecond == o.millisecond &&
time_type == o.time_type &&
zone_id == o.zone_id &&
day == o.day &&
minute == o.minute &&
second == o.second
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
[month, hour, year, timezone_source, millisecond, time_type, zone_id, day, minute, second].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::Crm::Lists.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/crm/lists/models/public_bool_property_operation.rb | lib/hubspot/codegen/crm/lists/models/public_bool_property_operation.rb | =begin
#Lists
#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 Crm
module Lists
class PublicBoolPropertyOperation
attr_accessor :include_objects_with_no_value_set
attr_accessor :operation_type
attr_accessor :value
attr_accessor :operator
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
{
:'include_objects_with_no_value_set' => :'includeObjectsWithNoValueSet',
:'operation_type' => :'operationType',
:'value' => :'value',
:'operator' => :'operator'
}
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_objects_with_no_value_set' => :'Boolean',
:'operation_type' => :'String',
:'value' => :'Boolean',
:'operator' => :'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::Crm::Lists::PublicBoolPropertyOperation` 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::Crm::Lists::PublicBoolPropertyOperation`. 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_objects_with_no_value_set')
self.include_objects_with_no_value_set = attributes[:'include_objects_with_no_value_set']
end
if attributes.key?(:'operation_type')
self.operation_type = attributes[:'operation_type']
else
self.operation_type = 'BOOL'
end
if attributes.key?(:'value')
self.value = attributes[:'value']
end
if attributes.key?(:'operator')
self.operator = attributes[:'operator']
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 @include_objects_with_no_value_set.nil?
invalid_properties.push('invalid value for "include_objects_with_no_value_set", include_objects_with_no_value_set cannot be nil.')
end
if @operation_type.nil?
invalid_properties.push('invalid value for "operation_type", operation_type 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
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 @include_objects_with_no_value_set.nil?
return false if @operation_type.nil?
operation_type_validator = EnumAttributeValidator.new('String', ["BOOL"])
return false unless operation_type_validator.valid?(@operation_type)
return false if @value.nil?
return false if @operator.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] operation_type Object to be assigned
def operation_type=(operation_type)
validator = EnumAttributeValidator.new('String', ["BOOL"])
unless validator.valid?(operation_type)
fail ArgumentError, "invalid value for \"operation_type\", must be one of #{validator.allowable_values}."
end
@operation_type = operation_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 &&
include_objects_with_no_value_set == o.include_objects_with_no_value_set &&
operation_type == o.operation_type &&
value == o.value &&
operator == o.operator
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_objects_with_no_value_set, operation_type, value, operator].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::Crm::Lists.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/crm/lists/models/public_survey_monkey_value_filter_value_comparison.rb | lib/hubspot/codegen/crm/lists/models/public_survey_monkey_value_filter_value_comparison.rb | =begin
#Lists
#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 Crm
module Lists
module PublicSurveyMonkeyValueFilterValueComparison
class << self
# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'PublicAllPropertyTypesOperation',
:'PublicBoolPropertyOperation',
:'PublicCalendarDatePropertyOperation',
:'PublicComparativeDatePropertyOperation',
:'PublicComparativePropertyUpdatedOperation',
:'PublicDatePropertyOperation',
:'PublicDateTimePropertyOperation',
:'PublicEnumerationPropertyOperation',
:'PublicMultiStringPropertyOperation',
:'PublicNumberPropertyOperation',
:'PublicRangedDatePropertyOperation',
:'PublicRangedNumberPropertyOperation',
:'PublicRangedTimeOperation',
:'PublicRollingDateRangePropertyOperation',
:'PublicRollingPropertyUpdatedOperation',
:'PublicStringPropertyOperation',
:'PublicTimePointOperation'
]
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::Crm::Lists.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/crm/lists/models/public_not_any_filter_branch.rb | lib/hubspot/codegen/crm/lists/models/public_not_any_filter_branch.rb | =begin
#Lists
#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 Crm
module Lists
class PublicNotAnyFilterBranch
attr_accessor :filter_branch_type
attr_accessor :filter_branches
attr_accessor :filter_branch_operator
attr_accessor :filters
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
{
:'filter_branch_type' => :'filterBranchType',
:'filter_branches' => :'filterBranches',
:'filter_branch_operator' => :'filterBranchOperator',
:'filters' => :'filters'
}
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
{
:'filter_branch_type' => :'String',
:'filter_branches' => :'Array<PublicPropertyAssociationFilterBranchFilterBranchesInner>',
:'filter_branch_operator' => :'String',
:'filters' => :'Array<PublicPropertyAssociationFilterBranchFiltersInner>'
}
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::Crm::Lists::PublicNotAnyFilterBranch` 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::Crm::Lists::PublicNotAnyFilterBranch`. 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?(:'filter_branch_type')
self.filter_branch_type = attributes[:'filter_branch_type']
else
self.filter_branch_type = 'NOT_ANY'
end
if attributes.key?(:'filter_branches')
if (value = attributes[:'filter_branches']).is_a?(Array)
self.filter_branches = value
end
end
if attributes.key?(:'filter_branch_operator')
self.filter_branch_operator = attributes[:'filter_branch_operator']
end
if attributes.key?(:'filters')
if (value = attributes[:'filters']).is_a?(Array)
self.filters = 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 @filter_branch_type.nil?
invalid_properties.push('invalid value for "filter_branch_type", filter_branch_type cannot be nil.')
end
if @filter_branches.nil?
invalid_properties.push('invalid value for "filter_branches", filter_branches cannot be nil.')
end
if @filter_branch_operator.nil?
invalid_properties.push('invalid value for "filter_branch_operator", filter_branch_operator cannot be nil.')
end
if @filters.nil?
invalid_properties.push('invalid value for "filters", filters 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 @filter_branch_type.nil?
filter_branch_type_validator = EnumAttributeValidator.new('String', ["NOT_ANY"])
return false unless filter_branch_type_validator.valid?(@filter_branch_type)
return false if @filter_branches.nil?
return false if @filter_branch_operator.nil?
return false if @filters.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] filter_branch_type Object to be assigned
def filter_branch_type=(filter_branch_type)
validator = EnumAttributeValidator.new('String', ["NOT_ANY"])
unless validator.valid?(filter_branch_type)
fail ArgumentError, "invalid value for \"filter_branch_type\", must be one of #{validator.allowable_values}."
end
@filter_branch_type = filter_branch_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 &&
filter_branch_type == o.filter_branch_type &&
filter_branches == o.filter_branches &&
filter_branch_operator == o.filter_branch_operator &&
filters == o.filters
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
[filter_branch_type, filter_branches, filter_branch_operator, filters].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::Crm::Lists.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/crm/lists/models/error.rb | lib/hubspot/codegen/crm/lists/models/error.rb | =begin
#Lists
#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 Crm
module Lists
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::Crm::Lists::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::Crm::Lists::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::Crm::Lists.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/crm/lists/models/public_string_property_operation.rb | lib/hubspot/codegen/crm/lists/models/public_string_property_operation.rb | =begin
#Lists
#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 Crm
module Lists
class PublicStringPropertyOperation
attr_accessor :include_objects_with_no_value_set
attr_accessor :operation_type
attr_accessor :value
attr_accessor :operator
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
{
:'include_objects_with_no_value_set' => :'includeObjectsWithNoValueSet',
:'operation_type' => :'operationType',
:'value' => :'value',
:'operator' => :'operator'
}
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_objects_with_no_value_set' => :'Boolean',
:'operation_type' => :'String',
:'value' => :'String',
:'operator' => :'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::Crm::Lists::PublicStringPropertyOperation` 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::Crm::Lists::PublicStringPropertyOperation`. 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_objects_with_no_value_set')
self.include_objects_with_no_value_set = attributes[:'include_objects_with_no_value_set']
end
if attributes.key?(:'operation_type')
self.operation_type = attributes[:'operation_type']
else
self.operation_type = 'STRING'
end
if attributes.key?(:'value')
self.value = attributes[:'value']
end
if attributes.key?(:'operator')
self.operator = attributes[:'operator']
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 @include_objects_with_no_value_set.nil?
invalid_properties.push('invalid value for "include_objects_with_no_value_set", include_objects_with_no_value_set cannot be nil.')
end
if @operation_type.nil?
invalid_properties.push('invalid value for "operation_type", operation_type 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
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 @include_objects_with_no_value_set.nil?
return false if @operation_type.nil?
operation_type_validator = EnumAttributeValidator.new('String', ["STRING"])
return false unless operation_type_validator.valid?(@operation_type)
return false if @value.nil?
return false if @operator.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] operation_type Object to be assigned
def operation_type=(operation_type)
validator = EnumAttributeValidator.new('String', ["STRING"])
unless validator.valid?(operation_type)
fail ArgumentError, "invalid value for \"operation_type\", must be one of #{validator.allowable_values}."
end
@operation_type = operation_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 &&
include_objects_with_no_value_set == o.include_objects_with_no_value_set &&
operation_type == o.operation_type &&
value == o.value &&
operator == o.operator
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_objects_with_no_value_set, operation_type, value, operator].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::Crm::Lists.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/crm/lists/models/public_property_association_filter_branch_filter_branches_inner.rb | lib/hubspot/codegen/crm/lists/models/public_property_association_filter_branch_filter_branches_inner.rb | =begin
#Lists
#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 Crm
module Lists
module PublicPropertyAssociationFilterBranchFilterBranchesInner
class << self
# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'PublicAndFilterBranch',
:'PublicAssociationFilterBranch',
:'PublicNotAllFilterBranch',
:'PublicNotAnyFilterBranch',
:'PublicOrFilterBranch',
:'PublicPropertyAssociationFilterBranch',
:'PublicRestrictedFilterBranch',
:'PublicUnifiedEventsFilterBranch'
]
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::Crm::Lists.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/crm/lists/models/list_update_response.rb | lib/hubspot/codegen/crm/lists/models/list_update_response.rb | =begin
#Lists
#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 Crm
module Lists
class ListUpdateResponse
attr_accessor :updated_list
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'updated_list' => :'updatedList'
}
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
{
:'updated_list' => :'PublicObjectList'
}
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::Crm::Lists::ListUpdateResponse` 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::Crm::Lists::ListUpdateResponse`. 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?(:'updated_list')
self.updated_list = attributes[:'updated_list']
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 &&
updated_list == o.updated_list
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
[updated_list].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::Crm::Lists.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/crm/lists/api/folders_api.rb | lib/hubspot/codegen/crm/lists/api/folders_api.rb | =begin
#Lists
#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 Crm
module Lists
class FoldersApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Creates a folder
# Creates a folder with the given information.
# @param list_folder_create_request [ListFolderCreateRequest]
# @param [Hash] opts the optional parameters
# @return [ListFolderCreateResponse]
def create(list_folder_create_request, opts = {})
data, _status_code, _headers = create_with_http_info(list_folder_create_request, opts)
data
end
# Creates a folder
# Creates a folder with the given information.
# @param list_folder_create_request [ListFolderCreateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(ListFolderCreateResponse, Integer, Hash)>] ListFolderCreateResponse data, response status code and response headers
def create_with_http_info(list_folder_create_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.create ...'
end
# verify the required parameter 'list_folder_create_request' is set
if @api_client.config.client_side_validation && list_folder_create_request.nil?
fail ArgumentError, "Missing the required parameter 'list_folder_create_request' when calling FoldersApi.create"
end
# resource path
local_var_path = '/crm/v3/lists/folders'
# 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(list_folder_create_request)
# return_type
return_type = opts[:debug_return_type] || 'ListFolderCreateResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.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: FoldersApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Retrieves a folder.
# Retrieves a folder and recursively includes all folders via the childNodes attribute. The child lists field will be empty in all child nodes. Only the folder retrieved will include the child lists in that folder.
# @param [Hash] opts the optional parameters
# @option opts [String] :folder_id The Id of the folder to retrieve. (default to '0')
# @return [ListFolderFetchResponse]
def get_all(opts = {})
data, _status_code, _headers = get_all_with_http_info(opts)
data
end
# Retrieves a folder.
# Retrieves a folder and recursively includes all folders via the childNodes attribute. The child lists field will be empty in all child nodes. Only the folder retrieved will include the child lists in that folder.
# @param [Hash] opts the optional parameters
# @option opts [String] :folder_id The Id of the folder to retrieve. (default to '0')
# @return [Array<(ListFolderFetchResponse, Integer, Hash)>] ListFolderFetchResponse data, response status code and response headers
def get_all_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.get_all ...'
end
# resource path
local_var_path = '/crm/v3/lists/folders'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'folderId'] = opts[:'folder_id'] if !opts[:'folder_id'].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] || 'ListFolderFetchResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.get_all",
: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: FoldersApi#get_all\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Moves a folder
# This moves the folder from its current location to a new location. It updates the parent of this folder to the new Id given.
# @param folder_id [String]
# @param new_parent_folder_id [String]
# @param [Hash] opts the optional parameters
# @return [ListFolderFetchResponse]
def move(folder_id, new_parent_folder_id, opts = {})
data, _status_code, _headers = move_with_http_info(folder_id, new_parent_folder_id, opts)
data
end
# Moves a folder
# This moves the folder from its current location to a new location. It updates the parent of this folder to the new Id given.
# @param folder_id [String]
# @param new_parent_folder_id [String]
# @param [Hash] opts the optional parameters
# @return [Array<(ListFolderFetchResponse, Integer, Hash)>] ListFolderFetchResponse data, response status code and response headers
def move_with_http_info(folder_id, new_parent_folder_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.move ...'
end
# verify the required parameter 'folder_id' is set
if @api_client.config.client_side_validation && folder_id.nil?
fail ArgumentError, "Missing the required parameter 'folder_id' when calling FoldersApi.move"
end
# verify the required parameter 'new_parent_folder_id' is set
if @api_client.config.client_side_validation && new_parent_folder_id.nil?
fail ArgumentError, "Missing the required parameter 'new_parent_folder_id' when calling FoldersApi.move"
end
# resource path
local_var_path = '/crm/v3/lists/folders/{folderId}/move/{newParentFolderId}'.sub('{' + 'folderId' + '}', CGI.escape(folder_id.to_s)).sub('{' + 'newParentFolderId' + '}', CGI.escape(new_parent_folder_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] || 'ListFolderFetchResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.move",
: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: FoldersApi#move\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Moves a list to a given folder
# Given a list and a folder, the list will be moved to that folder.
# @param list_move_request [ListMoveRequest]
# @param [Hash] opts the optional parameters
# @return [nil]
def move_list(list_move_request, opts = {})
move_list_with_http_info(list_move_request, opts)
nil
end
# Moves a list to a given folder
# Given a list and a folder, the list will be moved to that folder.
# @param list_move_request [ListMoveRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def move_list_with_http_info(list_move_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.move_list ...'
end
# verify the required parameter 'list_move_request' is set
if @api_client.config.client_side_validation && list_move_request.nil?
fail ArgumentError, "Missing the required parameter 'list_move_request' when calling FoldersApi.move_list"
end
# resource path
local_var_path = '/crm/v3/lists/folders/move-list'
# 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(['*/*'])
# 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(list_move_request)
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.move_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(:PUT, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FoldersApi#move_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Deletes a folder
# Deletes the folder with the given Id.
# @param folder_id [String]
# @param [Hash] opts the optional parameters
# @return [nil]
def remove(folder_id, opts = {})
remove_with_http_info(folder_id, opts)
nil
end
# Deletes a folder
# Deletes the folder with the given Id.
# @param folder_id [String]
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def remove_with_http_info(folder_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.remove ...'
end
# verify the required parameter 'folder_id' is set
if @api_client.config.client_side_validation && folder_id.nil?
fail ArgumentError, "Missing the required parameter 'folder_id' when calling FoldersApi.remove"
end
# resource path
local_var_path = '/crm/v3/lists/folders/{folderId}'.sub('{' + 'folderId' + '}', CGI.escape(folder_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(['*/*'])
# 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 => :"FoldersApi.remove",
: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: FoldersApi#remove\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Rename a folder
# Renames the given folderId with a new name.
# @param folder_id [String]
# @param [Hash] opts the optional parameters
# @option opts [String] :new_folder_name
# @return [ListFolderFetchResponse]
def rename(folder_id, opts = {})
data, _status_code, _headers = rename_with_http_info(folder_id, opts)
data
end
# Rename a folder
# Renames the given folderId with a new name.
# @param folder_id [String]
# @param [Hash] opts the optional parameters
# @option opts [String] :new_folder_name
# @return [Array<(ListFolderFetchResponse, Integer, Hash)>] ListFolderFetchResponse data, response status code and response headers
def rename_with_http_info(folder_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.rename ...'
end
# verify the required parameter 'folder_id' is set
if @api_client.config.client_side_validation && folder_id.nil?
fail ArgumentError, "Missing the required parameter 'folder_id' when calling FoldersApi.rename"
end
# resource path
local_var_path = '/crm/v3/lists/folders/{folderId}/rename'.sub('{' + 'folderId' + '}', CGI.escape(folder_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'newFolderName'] = opts[:'new_folder_name'] if !opts[:'new_folder_name'].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] || 'ListFolderFetchResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.rename",
: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: FoldersApi#rename\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/crm/lists/api/mapping_api.rb | lib/hubspot/codegen/crm/lists/api/mapping_api.rb | =begin
#Lists
#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 Crm
module Lists
class MappingApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Translate Legacy List Id to Modern List Id
# This API allows translation of legacy list id to list id. This is a temporary API allowed for mapping old id's to new id's and will expire on May 30th, 2025.
# @param [Hash] opts the optional parameters
# @option opts [String] :legacy_list_id The legacy list id from lists v1 API.
# @return [PublicMigrationMapping]
def translate_legacy_list_id_to_list_id(opts = {})
data, _status_code, _headers = translate_legacy_list_id_to_list_id_with_http_info(opts)
data
end
# Translate Legacy List Id to Modern List Id
# This API allows translation of legacy list id to list id. This is a temporary API allowed for mapping old id's to new id's and will expire on May 30th, 2025.
# @param [Hash] opts the optional parameters
# @option opts [String] :legacy_list_id The legacy list id from lists v1 API.
# @return [Array<(PublicMigrationMapping, Integer, Hash)>] PublicMigrationMapping data, response status code and response headers
def translate_legacy_list_id_to_list_id_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MappingApi.translate_legacy_list_id_to_list_id ...'
end
# resource path
local_var_path = '/crm/v3/lists/idmapping'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'legacyListId'] = opts[:'legacy_list_id'] if !opts[:'legacy_list_id'].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] || 'PublicMigrationMapping'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MappingApi.translate_legacy_list_id_to_list_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: MappingApi#translate_legacy_list_id_to_list_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Translate Legacy List Id to Modern List Id in Batch
# This API allows translation of a batch of legacy list id's to list id's. This allows for a maximum of 10,000 id's. This is a temporary API allowed for mapping old id's to new id's and will expire on May 30th, 2025.
# @param request_body [Array<String>]
# @param [Hash] opts the optional parameters
# @return [PublicBatchMigrationMapping]
def translate_legacy_list_id_to_list_id_batch(request_body, opts = {})
data, _status_code, _headers = translate_legacy_list_id_to_list_id_batch_with_http_info(request_body, opts)
data
end
# Translate Legacy List Id to Modern List Id in Batch
# This API allows translation of a batch of legacy list id's to list id's. This allows for a maximum of 10,000 id's. This is a temporary API allowed for mapping old id's to new id's and will expire on May 30th, 2025.
# @param request_body [Array<String>]
# @param [Hash] opts the optional parameters
# @return [Array<(PublicBatchMigrationMapping, Integer, Hash)>] PublicBatchMigrationMapping data, response status code and response headers
def translate_legacy_list_id_to_list_id_batch_with_http_info(request_body, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MappingApi.translate_legacy_list_id_to_list_id_batch ...'
end
# verify the required parameter 'request_body' is set
if @api_client.config.client_side_validation && request_body.nil?
fail ArgumentError, "Missing the required parameter 'request_body' when calling MappingApi.translate_legacy_list_id_to_list_id_batch"
end
# resource path
local_var_path = '/crm/v3/lists/idmapping'
# 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(request_body)
# return_type
return_type = opts[:debug_return_type] || 'PublicBatchMigrationMapping'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MappingApi.translate_legacy_list_id_to_list_id_batch",
: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: MappingApi#translate_legacy_list_id_to_list_id_batch\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/crm/lists/api/lists_api.rb | lib/hubspot/codegen/crm/lists/api/lists_api.rb | =begin
#Lists
#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 Crm
module Lists
class ListsApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Create List
# Create a new list with the provided object list definition.
# @param list_create_request [ListCreateRequest]
# @param [Hash] opts the optional parameters
# @return [ListCreateResponse]
def create(list_create_request, opts = {})
data, _status_code, _headers = create_with_http_info(list_create_request, opts)
data
end
# Create List
# Create a new list with the provided object list definition.
# @param list_create_request [ListCreateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(ListCreateResponse, Integer, Hash)>] ListCreateResponse data, response status code and response headers
def create_with_http_info(list_create_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.create ...'
end
# verify the required parameter 'list_create_request' is set
if @api_client.config.client_side_validation && list_create_request.nil?
fail ArgumentError, "Missing the required parameter 'list_create_request' when calling ListsApi.create"
end
# resource path
local_var_path = '/crm/v3/lists/'
# 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(list_create_request)
# return_type
return_type = opts[:debug_return_type] || 'ListCreateResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"ListsApi.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: ListsApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Search Lists
# Search lists by list name or page through all lists by providing an empty `query` value.
# @param list_search_request [ListSearchRequest]
# @param [Hash] opts the optional parameters
# @return [ListSearchResponse]
def do_search(list_search_request, opts = {})
data, _status_code, _headers = do_search_with_http_info(list_search_request, opts)
data
end
# Search Lists
# Search lists by list name or page through all lists by providing an empty `query` value.
# @param list_search_request [ListSearchRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(ListSearchResponse, Integer, Hash)>] ListSearchResponse data, response status code and response headers
def do_search_with_http_info(list_search_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.do_search ...'
end
# verify the required parameter 'list_search_request' is set
if @api_client.config.client_side_validation && list_search_request.nil?
fail ArgumentError, "Missing the required parameter 'list_search_request' when calling ListsApi.do_search"
end
# resource path
local_var_path = '/crm/v3/lists/search'
# 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(list_search_request)
# return_type
return_type = opts[:debug_return_type] || 'ListSearchResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"ListsApi.do_search",
: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: ListsApi#do_search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Fetch Multiple Lists
# Fetch multiple lists in a single request by **ILS list ID**. The response will include the definitions of all lists that exist for the `listIds` provided.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :list_ids The **ILS IDs** of the lists to fetch.
# @option opts [Boolean] :include_filters A flag indicating whether or not the response object list definitions should include a filter branch definition. By default, object list definitions will not have their filter branch definitions included in the response. (default to false)
# @return [ListsByIdResponse]
def get_all(opts = {})
data, _status_code, _headers = get_all_with_http_info(opts)
data
end
# Fetch Multiple Lists
# Fetch multiple lists in a single request by **ILS list ID**. The response will include the definitions of all lists that exist for the `listIds` provided.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :list_ids The **ILS IDs** of the lists to fetch.
# @option opts [Boolean] :include_filters A flag indicating whether or not the response object list definitions should include a filter branch definition. By default, object list definitions will not have their filter branch definitions included in the response. (default to false)
# @return [Array<(ListsByIdResponse, Integer, Hash)>] ListsByIdResponse data, response status code and response headers
def get_all_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.get_all ...'
end
# resource path
local_var_path = '/crm/v3/lists/'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'listIds'] = @api_client.build_collection_param(opts[:'list_ids'], :multi) if !opts[:'list_ids'].nil?
query_params[:'includeFilters'] = opts[:'include_filters'] if !opts[:'include_filters'].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] || 'ListsByIdResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"ListsApi.get_all",
: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: ListsApi#get_all\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Fetch List by ID
# Fetch a single list by **ILS list ID**.
# @param list_id [String] The **ILS ID** of the list to fetch.
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :include_filters A flag indicating whether or not the response object list definition should include a filter branch definition. By default, object list definitions will not have their filter branch definitions included in the response. (default to false)
# @return [ListFetchResponse]
def get_by_id(list_id, opts = {})
data, _status_code, _headers = get_by_id_with_http_info(list_id, opts)
data
end
# Fetch List by ID
# Fetch a single list by **ILS list ID**.
# @param list_id [String] The **ILS ID** of the list to fetch.
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :include_filters A flag indicating whether or not the response object list definition should include a filter branch definition. By default, object list definitions will not have their filter branch definitions included in the response. (default to false)
# @return [Array<(ListFetchResponse, Integer, Hash)>] ListFetchResponse data, response status code and response headers
def get_by_id_with_http_info(list_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.get_by_id ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling ListsApi.get_by_id"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'includeFilters'] = opts[:'include_filters'] if !opts[:'include_filters'].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] || 'ListFetchResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"ListsApi.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: ListsApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Fetch List by Name
# Fetch a single list by list name and object type.
# @param list_name [String] The name of the list to fetch. This is **not** case sensitive.
# @param object_type_id [String] The object type ID of the object types stored by the list to fetch. For example, `0-1` for a `CONTACT` list.
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :include_filters A flag indicating whether or not the response object list definition should include a filter branch definition. By default, object list definitions will not have their filter branch definitions included in the response. (default to false)
# @return [ListFetchResponse]
def get_by_name(list_name, object_type_id, opts = {})
data, _status_code, _headers = get_by_name_with_http_info(list_name, object_type_id, opts)
data
end
# Fetch List by Name
# Fetch a single list by list name and object type.
# @param list_name [String] The name of the list to fetch. This is **not** case sensitive.
# @param object_type_id [String] The object type ID of the object types stored by the list to fetch. For example, `0-1` for a `CONTACT` list.
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :include_filters A flag indicating whether or not the response object list definition should include a filter branch definition. By default, object list definitions will not have their filter branch definitions included in the response. (default to false)
# @return [Array<(ListFetchResponse, Integer, Hash)>] ListFetchResponse data, response status code and response headers
def get_by_name_with_http_info(list_name, object_type_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.get_by_name ...'
end
# verify the required parameter 'list_name' is set
if @api_client.config.client_side_validation && list_name.nil?
fail ArgumentError, "Missing the required parameter 'list_name' when calling ListsApi.get_by_name"
end
# verify the required parameter 'object_type_id' is set
if @api_client.config.client_side_validation && object_type_id.nil?
fail ArgumentError, "Missing the required parameter 'object_type_id' when calling ListsApi.get_by_name"
end
# resource path
local_var_path = '/crm/v3/lists/object-type-id/{objectTypeId}/name/{listName}'.sub('{' + 'listName' + '}', CGI.escape(list_name.to_s)).sub('{' + 'objectTypeId' + '}', CGI.escape(object_type_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'includeFilters'] = opts[:'include_filters'] if !opts[:'include_filters'].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] || 'ListFetchResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"ListsApi.get_by_name",
: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: ListsApi#get_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Delete a List
# Delete a list by **ILS list ID**. Lists deleted through this endpoint can be restored up to 90-days following the delete. After 90-days, the list is purged and can no longer be restored.
# @param list_id [String] The **ILS ID** of the list to delete.
# @param [Hash] opts the optional parameters
# @return [nil]
def remove(list_id, opts = {})
remove_with_http_info(list_id, opts)
nil
end
# Delete a List
# Delete a list by **ILS list ID**. Lists deleted through this endpoint can be restored up to 90-days following the delete. After 90-days, the list is purged and can no longer be restored.
# @param list_id [String] The **ILS ID** of the list to delete.
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def remove_with_http_info(list_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.remove ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling ListsApi.remove"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}'.sub('{' + 'listId' + '}', CGI.escape(list_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(['*/*'])
# 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 => :"ListsApi.remove",
: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: ListsApi#remove\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Restore a List
# Restore a previously deleted list by **ILS list ID**. Deleted lists are eligible to be restored up-to 90-days after the list has been deleted.
# @param list_id [String] The **ILS ID** of the list to restore.
# @param [Hash] opts the optional parameters
# @return [nil]
def restore(list_id, opts = {})
restore_with_http_info(list_id, opts)
nil
end
# Restore a List
# Restore a previously deleted list by **ILS list ID**. Deleted lists are eligible to be restored up-to 90-days after the list has been deleted.
# @param list_id [String] The **ILS ID** of the list to restore.
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def restore_with_http_info(list_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.restore ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling ListsApi.restore"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}/restore'.sub('{' + 'listId' + '}', CGI.escape(list_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(['*/*'])
# 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 => :"ListsApi.restore",
: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: ListsApi#restore\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Update List Filter Definition
# Update the filter branch definition of a `DYNAMIC` list. Once updated, the list memberships will be re-evaluated and updated to match the new definition.
# @param list_id [String] The **ILS ID** of the list to update.
# @param list_filter_update_request [ListFilterUpdateRequest]
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :enroll_objects_in_workflows A flag indicating whether or not the memberships added to the list as a result of the filter change should be enrolled in workflows that are relevant to this list. (default to false)
# @return [ListUpdateResponse]
def update_list_filters(list_id, list_filter_update_request, opts = {})
data, _status_code, _headers = update_list_filters_with_http_info(list_id, list_filter_update_request, opts)
data
end
# Update List Filter Definition
# Update the filter branch definition of a `DYNAMIC` list. Once updated, the list memberships will be re-evaluated and updated to match the new definition.
# @param list_id [String] The **ILS ID** of the list to update.
# @param list_filter_update_request [ListFilterUpdateRequest]
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :enroll_objects_in_workflows A flag indicating whether or not the memberships added to the list as a result of the filter change should be enrolled in workflows that are relevant to this list. (default to false)
# @return [Array<(ListUpdateResponse, Integer, Hash)>] ListUpdateResponse data, response status code and response headers
def update_list_filters_with_http_info(list_id, list_filter_update_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.update_list_filters ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling ListsApi.update_list_filters"
end
# verify the required parameter 'list_filter_update_request' is set
if @api_client.config.client_side_validation && list_filter_update_request.nil?
fail ArgumentError, "Missing the required parameter 'list_filter_update_request' when calling ListsApi.update_list_filters"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}/update-list-filters'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'enrollObjectsInWorkflows'] = opts[:'enroll_objects_in_workflows'] if !opts[:'enroll_objects_in_workflows'].nil?
# 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(list_filter_update_request)
# return_type
return_type = opts[:debug_return_type] || 'ListUpdateResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"ListsApi.update_list_filters",
: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: ListsApi#update_list_filters\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Update List Name
# Update the name of a list. The name must be globally unique relative to all other public lists in the portal.
# @param list_id [String] The **ILS ID** of the list to update.
# @param [Hash] opts the optional parameters
# @option opts [String] :list_name The name to update the list to.
# @option opts [Boolean] :include_filters A flag indicating whether or not the response object list definition should include a filter branch definition. By default, object list definitions will not have their filter branch definitions included in the response. (default to false)
# @return [ListUpdateResponse]
def update_name(list_id, opts = {})
data, _status_code, _headers = update_name_with_http_info(list_id, opts)
data
end
# Update List Name
# Update the name of a list. The name must be globally unique relative to all other public lists in the portal.
# @param list_id [String] The **ILS ID** of the list to update.
# @param [Hash] opts the optional parameters
# @option opts [String] :list_name The name to update the list to.
# @option opts [Boolean] :include_filters A flag indicating whether or not the response object list definition should include a filter branch definition. By default, object list definitions will not have their filter branch definitions included in the response. (default to false)
# @return [Array<(ListUpdateResponse, Integer, Hash)>] ListUpdateResponse data, response status code and response headers
def update_name_with_http_info(list_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.update_name ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling ListsApi.update_name"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}/update-list-name'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'listName'] = opts[:'list_name'] if !opts[:'list_name'].nil?
query_params[:'includeFilters'] = opts[:'include_filters'] if !opts[:'include_filters'].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] || 'ListUpdateResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"ListsApi.update_name",
: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: ListsApi#update_name\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/crm/lists/api/memberships_api.rb | lib/hubspot/codegen/crm/lists/api/memberships_api.rb | =begin
#Lists
#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 Crm
module Lists
class MembershipsApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Add Records to a List
# Add the records provided to the list. Records that do not exist or that are already members of the list are ignored. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.
# @param list_id [String] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list.
# @param request_body [Array<String>]
# @param [Hash] opts the optional parameters
# @return [MembershipsUpdateResponse]
def add(list_id, request_body, opts = {})
data, _status_code, _headers = add_with_http_info(list_id, request_body, opts)
data
end
# Add Records to a List
# Add the records provided to the list. Records that do not exist or that are already members of the list are ignored. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.
# @param list_id [String] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list.
# @param request_body [Array<String>]
# @param [Hash] opts the optional parameters
# @return [Array<(MembershipsUpdateResponse, Integer, Hash)>] MembershipsUpdateResponse data, response status code and response headers
def add_with_http_info(list_id, request_body, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MembershipsApi.add ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.add"
end
# verify the required parameter 'request_body' is set
if @api_client.config.client_side_validation && request_body.nil?
fail ArgumentError, "Missing the required parameter 'request_body' when calling MembershipsApi.add"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}/memberships/add'.sub('{' + 'listId' + '}', CGI.escape(list_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(request_body)
# return_type
return_type = opts[:debug_return_type] || 'MembershipsUpdateResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MembershipsApi.add",
: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: MembershipsApi#add\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Add All Records from a Source List to a Destination List
# Add all of the records from a *source list* (specified by the `sourceListId`) to a *destination list* (specified by the `listId`). Records that are already members of the *destination list* will be ignored. The *destination* and *source list* IDs must be different. The *destination* and *source lists* must contain records of the same type (e.g. contacts, companies, etc.). This endpoint only works for *destination lists* that have a `processingType` of `MANUAL` or `SNAPSHOT`. The *source list* can have any `processingType`. This endpoint only supports a `sourceListId` for lists with less than 100,000 memberships.
# @param list_id [String] The **ILS ID** of the `MANUAL` or `SNAPSHOT` *destination list*, which the *source list* records are added to.
# @param source_list_id [String] The **ILS ID** of the *source list* to grab the records from, which are then added to the *destination list*.
# @param [Hash] opts the optional parameters
# @return [nil]
def add_all_from_list(list_id, source_list_id, opts = {})
add_all_from_list_with_http_info(list_id, source_list_id, opts)
nil
end
# Add All Records from a Source List to a Destination List
# Add all of the records from a *source list* (specified by the `sourceListId`) to a *destination list* (specified by the `listId`). Records that are already members of the *destination list* will be ignored. The *destination* and *source list* IDs must be different. The *destination* and *source lists* must contain records of the same type (e.g. contacts, companies, etc.). This endpoint only works for *destination lists* that have a `processingType` of `MANUAL` or `SNAPSHOT`. The *source list* can have any `processingType`. This endpoint only supports a `sourceListId` for lists with less than 100,000 memberships.
# @param list_id [String] The **ILS ID** of the `MANUAL` or `SNAPSHOT` *destination list*, which the *source list* records are added to.
# @param source_list_id [String] The **ILS ID** of the *source list* to grab the records from, which are then added to the *destination list*.
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def add_all_from_list_with_http_info(list_id, source_list_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MembershipsApi.add_all_from_list ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.add_all_from_list"
end
# verify the required parameter 'source_list_id' is set
if @api_client.config.client_side_validation && source_list_id.nil?
fail ArgumentError, "Missing the required parameter 'source_list_id' when calling MembershipsApi.add_all_from_list"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}/memberships/add-from/{sourceListId}'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s)).sub('{' + 'sourceListId' + '}', CGI.escape(source_list_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(['*/*'])
# 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 => :"MembershipsApi.add_all_from_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(:PUT, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: MembershipsApi#add_all_from_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Add and/or Remove Records from a List
# Add and/or remove records that have already been created in the system to and/or from a list. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.
# @param list_id [String] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list.
# @param membership_change_request [MembershipChangeRequest]
# @param [Hash] opts the optional parameters
# @return [MembershipsUpdateResponse]
def add_and_remove(list_id, membership_change_request, opts = {})
data, _status_code, _headers = add_and_remove_with_http_info(list_id, membership_change_request, opts)
data
end
# Add and/or Remove Records from a List
# Add and/or remove records that have already been created in the system to and/or from a list. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.
# @param list_id [String] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list.
# @param membership_change_request [MembershipChangeRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(MembershipsUpdateResponse, Integer, Hash)>] MembershipsUpdateResponse data, response status code and response headers
def add_and_remove_with_http_info(list_id, membership_change_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MembershipsApi.add_and_remove ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.add_and_remove"
end
# verify the required parameter 'membership_change_request' is set
if @api_client.config.client_side_validation && membership_change_request.nil?
fail ArgumentError, "Missing the required parameter 'membership_change_request' when calling MembershipsApi.add_and_remove"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}/memberships/add-and-remove'.sub('{' + 'listId' + '}', CGI.escape(list_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(membership_change_request)
# return_type
return_type = opts[:debug_return_type] || 'MembershipsUpdateResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MembershipsApi.add_and_remove",
: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: MembershipsApi#add_and_remove\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get lists record is member of
# For given record provide lists this record is member of.
# @param object_type_id [String] Object type id of the record
# @param record_id [String] Id of the record
# @param [Hash] opts the optional parameters
# @return [ApiCollectionResponseRecordListMembershipNoPaging]
def get_lists(object_type_id, record_id, opts = {})
data, _status_code, _headers = get_lists_with_http_info(object_type_id, record_id, opts)
data
end
# Get lists record is member of
# For given record provide lists this record is member of.
# @param object_type_id [String] Object type id of the record
# @param record_id [String] Id of the record
# @param [Hash] opts the optional parameters
# @return [Array<(ApiCollectionResponseRecordListMembershipNoPaging, Integer, Hash)>] ApiCollectionResponseRecordListMembershipNoPaging data, response status code and response headers
def get_lists_with_http_info(object_type_id, record_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MembershipsApi.get_lists ...'
end
# verify the required parameter 'object_type_id' is set
if @api_client.config.client_side_validation && object_type_id.nil?
fail ArgumentError, "Missing the required parameter 'object_type_id' when calling MembershipsApi.get_lists"
end
# verify the required parameter 'record_id' is set
if @api_client.config.client_side_validation && record_id.nil?
fail ArgumentError, "Missing the required parameter 'record_id' when calling MembershipsApi.get_lists"
end
# resource path
local_var_path = '/crm/v3/lists/records/{objectTypeId}/{recordId}/memberships'.sub('{' + 'objectTypeId' + '}', CGI.escape(object_type_id.to_s)).sub('{' + 'recordId' + '}', CGI.escape(record_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] || 'ApiCollectionResponseRecordListMembershipNoPaging'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MembershipsApi.get_lists",
: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: MembershipsApi#get_lists\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Fetch List Memberships Ordered by ID
# Fetch the memberships of a list in order sorted by the `recordId` of the records in the list. The `recordId`s are sorted in *ascending* order if an `after` offset or no offset is provided. If only a `before` offset is provided, then the records are sorted in *descending* order. The `after` offset parameter will take precedence over the `before` offset in a case where both are provided.
# @param list_id [String] The **ILS ID** of the list.
# @param [Hash] opts the optional parameters
# @option opts [String] :after The paging offset token for the page that comes `after` the previously requested records. If provided, then the records in the response will be the records following the offset, sorted in *ascending* order. Takes precedence over the `before` offset.
# @option opts [String] :before The paging offset token for the page that comes `before` the previously requested records. If provided, then the records in the response will be the records preceding the offset, sorted in *descending* order.
# @option opts [Integer] :limit The number of records to return in the response. The maximum `limit` is 250. (default to 100)
# @return [ApiCollectionResponseJoinTimeAndRecordId]
def get_page(list_id, opts = {})
data, _status_code, _headers = get_page_with_http_info(list_id, opts)
data
end
# Fetch List Memberships Ordered by ID
# Fetch the memberships of a list in order sorted by the `recordId` of the records in the list. The `recordId`s are sorted in *ascending* order if an `after` offset or no offset is provided. If only a `before` offset is provided, then the records are sorted in *descending* order. The `after` offset parameter will take precedence over the `before` offset in a case where both are provided.
# @param list_id [String] The **ILS ID** of the list.
# @param [Hash] opts the optional parameters
# @option opts [String] :after The paging offset token for the page that comes `after` the previously requested records. If provided, then the records in the response will be the records following the offset, sorted in *ascending* order. Takes precedence over the `before` offset.
# @option opts [String] :before The paging offset token for the page that comes `before` the previously requested records. If provided, then the records in the response will be the records preceding the offset, sorted in *descending* order.
# @option opts [Integer] :limit The number of records to return in the response. The maximum `limit` is 250. (default to 100)
# @return [Array<(ApiCollectionResponseJoinTimeAndRecordId, Integer, Hash)>] ApiCollectionResponseJoinTimeAndRecordId data, response status code and response headers
def get_page_with_http_info(list_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MembershipsApi.get_page ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.get_page"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}/memberships'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].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] || 'ApiCollectionResponseJoinTimeAndRecordId'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MembershipsApi.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: MembershipsApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Fetch List Memberships Ordered by Added to List Date
# Fetch the memberships of a list in order sorted by the time the records were added to the list. The `recordId`s are sorted in *ascending* order if an `after` offset or no offset is provided. If only a `before` offset is provided, then the records are sorted in *descending* order. The `after` offset parameter will take precedence over the `before` offset in a case where both are provided.
# @param list_id [String] The **ILS ID** of the list.
# @param [Hash] opts the optional parameters
# @option opts [String] :after The paging offset token for the page that comes `after` the previously requested records. If provided, then the records in the response will be the records following the offset, sorted in *ascending* order. Takes precedence over the `before` offset.
# @option opts [String] :before The paging offset token for the page that comes `before` the previously requested records. If provided, then the records in the response will be the records preceding the offset, sorted in *descending* order.
# @option opts [Integer] :limit The number of records to return in the response. The maximum `limit` is 250. (default to 100)
# @return [ApiCollectionResponseJoinTimeAndRecordId]
def get_page_ordered_by_added_to_list_date(list_id, opts = {})
data, _status_code, _headers = get_page_ordered_by_added_to_list_date_with_http_info(list_id, opts)
data
end
# Fetch List Memberships Ordered by Added to List Date
# Fetch the memberships of a list in order sorted by the time the records were added to the list. The `recordId`s are sorted in *ascending* order if an `after` offset or no offset is provided. If only a `before` offset is provided, then the records are sorted in *descending* order. The `after` offset parameter will take precedence over the `before` offset in a case where both are provided.
# @param list_id [String] The **ILS ID** of the list.
# @param [Hash] opts the optional parameters
# @option opts [String] :after The paging offset token for the page that comes `after` the previously requested records. If provided, then the records in the response will be the records following the offset, sorted in *ascending* order. Takes precedence over the `before` offset.
# @option opts [String] :before The paging offset token for the page that comes `before` the previously requested records. If provided, then the records in the response will be the records preceding the offset, sorted in *descending* order.
# @option opts [Integer] :limit The number of records to return in the response. The maximum `limit` is 250. (default to 100)
# @return [Array<(ApiCollectionResponseJoinTimeAndRecordId, Integer, Hash)>] ApiCollectionResponseJoinTimeAndRecordId data, response status code and response headers
def get_page_ordered_by_added_to_list_date_with_http_info(list_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MembershipsApi.get_page_ordered_by_added_to_list_date ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.get_page_ordered_by_added_to_list_date"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}/memberships/join-order'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].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] || 'ApiCollectionResponseJoinTimeAndRecordId'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MembershipsApi.get_page_ordered_by_added_to_list_date",
: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: MembershipsApi#get_page_ordered_by_added_to_list_date\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Remove Records from a List
# Remove the records provided from the list. Records that do not exist or that are not members of the list are ignored. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.
# @param list_id [String] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list.
# @param request_body [Array<String>]
# @param [Hash] opts the optional parameters
# @return [MembershipsUpdateResponse]
def remove(list_id, request_body, opts = {})
data, _status_code, _headers = remove_with_http_info(list_id, request_body, opts)
data
end
# Remove Records from a List
# Remove the records provided from the list. Records that do not exist or that are not members of the list are ignored. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.
# @param list_id [String] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list.
# @param request_body [Array<String>]
# @param [Hash] opts the optional parameters
# @return [Array<(MembershipsUpdateResponse, Integer, Hash)>] MembershipsUpdateResponse data, response status code and response headers
def remove_with_http_info(list_id, request_body, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MembershipsApi.remove ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.remove"
end
# verify the required parameter 'request_body' is set
if @api_client.config.client_side_validation && request_body.nil?
fail ArgumentError, "Missing the required parameter 'request_body' when calling MembershipsApi.remove"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}/memberships/remove'.sub('{' + 'listId' + '}', CGI.escape(list_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(request_body)
# return_type
return_type = opts[:debug_return_type] || 'MembershipsUpdateResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"MembershipsApi.remove",
: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: MembershipsApi#remove\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Delete All Records from a List
# Remove **all** of the records from a list. ***Note:*** *The list is not deleted.* This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`. This endpoint only supports lists that have less than 100,000 memberships.
# @param list_id [String] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list.
# @param [Hash] opts the optional parameters
# @return [nil]
def remove_all(list_id, opts = {})
remove_all_with_http_info(list_id, opts)
nil
end
# Delete All Records from a List
# Remove **all** of the records from a list. ***Note:*** *The list is not deleted.* This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`. This endpoint only supports lists that have less than 100,000 memberships.
# @param list_id [String] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list.
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def remove_all_with_http_info(list_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: MembershipsApi.remove_all ...'
end
# verify the required parameter 'list_id' is set
if @api_client.config.client_side_validation && list_id.nil?
fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.remove_all"
end
# resource path
local_var_path = '/crm/v3/lists/{listId}/memberships'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s))
# query parameters
| 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/crm/line_items/api_error.rb | lib/hubspot/codegen/crm/line_items/api_error.rb | =begin
#Line Items
#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 Crm
module LineItems
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/crm/line_items/configuration.rb | lib/hubspot/codegen/crm/line_items/configuration.rb | =begin
#Line Items
#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 Crm
module LineItems
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/crm/line_items/api_client.rb | lib/hubspot/codegen/crm/line_items/api_client.rb | =begin
#Line Items
#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 Crm
module LineItems
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::Crm::LineItems.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/crm/line_items/models/batch_response_simple_public_object.rb | lib/hubspot/codegen/crm/line_items/models/batch_response_simple_public_object.rb | =begin
#Line Items
#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 Crm
module LineItems
class BatchResponseSimplePublicObject
attr_accessor :completed_at
attr_accessor :requested_at
attr_accessor :started_at
attr_accessor :links
attr_accessor :results
attr_accessor :status
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
{
:'completed_at' => :'completedAt',
:'requested_at' => :'requestedAt',
:'started_at' => :'startedAt',
:'links' => :'links',
:'results' => :'results',
:'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
{
:'completed_at' => :'Time',
:'requested_at' => :'Time',
:'started_at' => :'Time',
:'links' => :'Hash<String, String>',
:'results' => :'Array<SimplePublicObject>',
:'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::Crm::LineItems::BatchResponseSimplePublicObject` 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::Crm::LineItems::BatchResponseSimplePublicObject`. 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?(:'completed_at')
self.completed_at = attributes[:'completed_at']
end
if attributes.key?(:'requested_at')
self.requested_at = attributes[:'requested_at']
end
if attributes.key?(:'started_at')
self.started_at = attributes[:'started_at']
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = 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 @completed_at.nil?
invalid_properties.push('invalid value for "completed_at", completed_at cannot be nil.')
end
if @started_at.nil?
invalid_properties.push('invalid value for "started_at", started_at cannot be nil.')
end
if @results.nil?
invalid_properties.push('invalid value for "results", results 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 @completed_at.nil?
return false if @started_at.nil?
return false if @results.nil?
return false if @status.nil?
status_validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
return false unless status_validator.valid?(@status)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] status Object to be assigned
def status=(status)
validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
unless validator.valid?(status)
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
end
@status = status
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 &&
completed_at == o.completed_at &&
requested_at == o.requested_at &&
started_at == o.started_at &&
links == o.links &&
results == o.results &&
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
[completed_at, requested_at, started_at, links, results, 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::Crm::LineItems.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/crm/line_items/models/simple_public_object_id.rb | lib/hubspot/codegen/crm/line_items/models/simple_public_object_id.rb | =begin
#Line Items
#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 Crm
module LineItems
class SimplePublicObjectId
attr_accessor :id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'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
{
:'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::Crm::LineItems::SimplePublicObjectId` 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::Crm::LineItems::SimplePublicObjectId`. 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
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 &&
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
[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::Crm::LineItems.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/crm/line_items/models/value_with_timestamp.rb | lib/hubspot/codegen/crm/line_items/models/value_with_timestamp.rb | =begin
#Line Items
#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 Crm
module LineItems
class ValueWithTimestamp
attr_accessor :source_id
attr_accessor :source_type
attr_accessor :source_label
attr_accessor :updated_by_user_id
attr_accessor :value
attr_accessor :timestamp
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'source_id' => :'sourceId',
:'source_type' => :'sourceType',
:'source_label' => :'sourceLabel',
:'updated_by_user_id' => :'updatedByUserId',
:'value' => :'value',
:'timestamp' => :'timestamp'
}
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
{
:'source_id' => :'String',
:'source_type' => :'String',
:'source_label' => :'String',
:'updated_by_user_id' => :'Integer',
:'value' => :'String',
:'timestamp' => :'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::Crm::LineItems::ValueWithTimestamp` 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::Crm::LineItems::ValueWithTimestamp`. 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?(:'source_id')
self.source_id = attributes[:'source_id']
end
if attributes.key?(:'source_type')
self.source_type = attributes[:'source_type']
end
if attributes.key?(:'source_label')
self.source_label = attributes[:'source_label']
end
if attributes.key?(:'updated_by_user_id')
self.updated_by_user_id = attributes[:'updated_by_user_id']
end
if attributes.key?(:'value')
self.value = attributes[:'value']
end
if attributes.key?(:'timestamp')
self.timestamp = attributes[:'timestamp']
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 @source_type.nil?
invalid_properties.push('invalid value for "source_type", source_type cannot be nil.')
end
if @value.nil?
invalid_properties.push('invalid value for "value", value cannot be nil.')
end
if @timestamp.nil?
invalid_properties.push('invalid value for "timestamp", timestamp 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 @source_type.nil?
return false if @value.nil?
return false if @timestamp.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 &&
source_id == o.source_id &&
source_type == o.source_type &&
source_label == o.source_label &&
updated_by_user_id == o.updated_by_user_id &&
value == o.value &&
timestamp == o.timestamp
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
[source_id, source_type, source_label, updated_by_user_id, value, timestamp].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::Crm::LineItems.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/crm/line_items/models/standard_error.rb | lib/hubspot/codegen/crm/line_items/models/standard_error.rb | =begin
#Line Items
#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 Crm
module LineItems
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::Crm::LineItems::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::Crm::LineItems::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::Crm::LineItems.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/crm/line_items/models/collection_response_with_total_simple_public_object_forward_paging.rb | lib/hubspot/codegen/crm/line_items/models/collection_response_with_total_simple_public_object_forward_paging.rb | =begin
#Line Items
#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 Crm
module LineItems
class CollectionResponseWithTotalSimplePublicObjectForwardPaging
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<SimplePublicObject>'
}
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::Crm::LineItems::CollectionResponseWithTotalSimplePublicObjectForwardPaging` 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::Crm::LineItems::CollectionResponseWithTotalSimplePublicObjectForwardPaging`. 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::Crm::LineItems.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/crm/line_items/models/collection_response_simple_public_object_with_associations_forward_paging.rb | lib/hubspot/codegen/crm/line_items/models/collection_response_simple_public_object_with_associations_forward_paging.rb | =begin
#Line Items
#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 Crm
module LineItems
class CollectionResponseSimplePublicObjectWithAssociationsForwardPaging
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<SimplePublicObjectWithAssociations>'
}
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::Crm::LineItems::CollectionResponseSimplePublicObjectWithAssociationsForwardPaging` 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::Crm::LineItems::CollectionResponseSimplePublicObjectWithAssociationsForwardPaging`. 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::Crm::LineItems.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/crm/line_items/models/association_spec.rb | lib/hubspot/codegen/crm/line_items/models/association_spec.rb | =begin
#Line Items
#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 Crm
module LineItems
class AssociationSpec
attr_accessor :association_category
attr_accessor :association_type_id
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
{
:'association_category' => :'associationCategory',
:'association_type_id' => :'associationTypeId'
}
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
{
:'association_category' => :'String',
:'association_type_id' => :'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::Crm::LineItems::AssociationSpec` 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::Crm::LineItems::AssociationSpec`. 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?(:'association_category')
self.association_category = attributes[:'association_category']
end
if attributes.key?(:'association_type_id')
self.association_type_id = attributes[:'association_type_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 @association_category.nil?
invalid_properties.push('invalid value for "association_category", association_category cannot be nil.')
end
if @association_type_id.nil?
invalid_properties.push('invalid value for "association_type_id", association_type_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 @association_category.nil?
association_category_validator = EnumAttributeValidator.new('String', ["HUBSPOT_DEFINED", "USER_DEFINED", "INTEGRATOR_DEFINED"])
return false unless association_category_validator.valid?(@association_category)
return false if @association_type_id.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] association_category Object to be assigned
def association_category=(association_category)
validator = EnumAttributeValidator.new('String', ["HUBSPOT_DEFINED", "USER_DEFINED", "INTEGRATOR_DEFINED"])
unless validator.valid?(association_category)
fail ArgumentError, "invalid value for \"association_category\", must be one of #{validator.allowable_values}."
end
@association_category = association_category
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 &&
association_category == o.association_category &&
association_type_id == o.association_type_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
[association_category, association_type_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::Crm::LineItems.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/crm/line_items/models/simple_public_object_with_associations.rb | lib/hubspot/codegen/crm/line_items/models/simple_public_object_with_associations.rb | =begin
#Line Items
#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 Crm
module LineItems
class SimplePublicObjectWithAssociations
attr_accessor :associations
attr_accessor :created_at
attr_accessor :archived
attr_accessor :archived_at
attr_accessor :properties_with_history
attr_accessor :id
attr_accessor :object_write_trace_id
attr_accessor :properties
attr_accessor :updated_at
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'associations' => :'associations',
:'created_at' => :'createdAt',
:'archived' => :'archived',
:'archived_at' => :'archivedAt',
:'properties_with_history' => :'propertiesWithHistory',
:'id' => :'id',
:'object_write_trace_id' => :'objectWriteTraceId',
:'properties' => :'properties',
:'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
{
:'associations' => :'Hash<String, CollectionResponseAssociatedId>',
:'created_at' => :'Time',
:'archived' => :'Boolean',
:'archived_at' => :'Time',
:'properties_with_history' => :'Hash<String, Array<ValueWithTimestamp>>',
:'id' => :'String',
:'object_write_trace_id' => :'String',
:'properties' => :'Hash<String, 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::Crm::LineItems::SimplePublicObjectWithAssociations` 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::Crm::LineItems::SimplePublicObjectWithAssociations`. 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?(:'associations')
if (value = attributes[:'associations']).is_a?(Hash)
self.associations = value
end
end
if attributes.key?(:'created_at')
self.created_at = attributes[:'created_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?(:'properties_with_history')
if (value = attributes[:'properties_with_history']).is_a?(Hash)
self.properties_with_history = value
end
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'object_write_trace_id')
self.object_write_trace_id = attributes[:'object_write_trace_id']
end
if attributes.key?(:'properties')
if (value = attributes[:'properties']).is_a?(Hash)
self.properties = value
end
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 @created_at.nil?
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @properties.nil?
invalid_properties.push('invalid value for "properties", properties 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 @created_at.nil?
return false if @id.nil?
return false if @properties.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 &&
associations == o.associations &&
created_at == o.created_at &&
archived == o.archived &&
archived_at == o.archived_at &&
properties_with_history == o.properties_with_history &&
id == o.id &&
object_write_trace_id == o.object_write_trace_id &&
properties == o.properties &&
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
[associations, created_at, archived, archived_at, properties_with_history, id, object_write_trace_id, properties, 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::Crm::LineItems.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/crm/line_items/models/simple_public_object_batch_input_upsert.rb | lib/hubspot/codegen/crm/line_items/models/simple_public_object_batch_input_upsert.rb | =begin
#Line Items
#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 Crm
module LineItems
class SimplePublicObjectBatchInputUpsert
# The name of a property whose values are unique for this object
attr_accessor :id_property
attr_accessor :object_write_trace_id
attr_accessor :id
attr_accessor :properties
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id_property' => :'idProperty',
:'object_write_trace_id' => :'objectWriteTraceId',
:'id' => :'id',
:'properties' => :'properties'
}
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_property' => :'String',
:'object_write_trace_id' => :'String',
:'id' => :'String',
:'properties' => :'Hash<String, 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::Crm::LineItems::SimplePublicObjectBatchInputUpsert` 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::Crm::LineItems::SimplePublicObjectBatchInputUpsert`. 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_property')
self.id_property = attributes[:'id_property']
end
if attributes.key?(:'object_write_trace_id')
self.object_write_trace_id = attributes[:'object_write_trace_id']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'properties')
if (value = attributes[:'properties']).is_a?(Hash)
self.properties = 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 @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @properties.nil?
invalid_properties.push('invalid value for "properties", properties 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 @properties.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_property == o.id_property &&
object_write_trace_id == o.object_write_trace_id &&
id == o.id &&
properties == o.properties
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_property, object_write_trace_id, id, properties].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::Crm::LineItems.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/crm/line_items/models/batch_read_input_simple_public_object_id.rb | lib/hubspot/codegen/crm/line_items/models/batch_read_input_simple_public_object_id.rb | =begin
#Line Items
#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 Crm
module LineItems
class BatchReadInputSimplePublicObjectId
attr_accessor :properties_with_history
# When using a custom unique value property to retrieve records, the name of the property. Do not include this parameter if retrieving by record ID.
attr_accessor :id_property
attr_accessor :inputs
attr_accessor :properties
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'properties_with_history' => :'propertiesWithHistory',
:'id_property' => :'idProperty',
:'inputs' => :'inputs',
:'properties' => :'properties'
}
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
{
:'properties_with_history' => :'Array<String>',
:'id_property' => :'String',
:'inputs' => :'Array<SimplePublicObjectId>',
:'properties' => :'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::Crm::LineItems::BatchReadInputSimplePublicObjectId` 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::Crm::LineItems::BatchReadInputSimplePublicObjectId`. 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?(:'properties_with_history')
if (value = attributes[:'properties_with_history']).is_a?(Array)
self.properties_with_history = value
end
end
if attributes.key?(:'id_property')
self.id_property = attributes[:'id_property']
end
if attributes.key?(:'inputs')
if (value = attributes[:'inputs']).is_a?(Array)
self.inputs = value
end
end
if attributes.key?(:'properties')
if (value = attributes[:'properties']).is_a?(Array)
self.properties = 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 @properties_with_history.nil?
invalid_properties.push('invalid value for "properties_with_history", properties_with_history cannot be nil.')
end
if @inputs.nil?
invalid_properties.push('invalid value for "inputs", inputs cannot be nil.')
end
if @properties.nil?
invalid_properties.push('invalid value for "properties", properties 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 @properties_with_history.nil?
return false if @inputs.nil?
return false if @properties.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 &&
properties_with_history == o.properties_with_history &&
id_property == o.id_property &&
inputs == o.inputs &&
properties == o.properties
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
[properties_with_history, id_property, inputs, properties].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::Crm::LineItems.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/crm/line_items/models/previous_page.rb | lib/hubspot/codegen/crm/line_items/models/previous_page.rb | =begin
#Line Items
#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 Crm
module LineItems
class PreviousPage
attr_accessor :before
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::Crm::LineItems::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::Crm::LineItems::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::Crm::LineItems.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/crm/line_items/models/next_page.rb | lib/hubspot/codegen/crm/line_items/models/next_page.rb | =begin
#Line Items
#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 Crm
module LineItems
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::Crm::LineItems::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::Crm::LineItems::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::Crm::LineItems.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/crm/line_items/models/public_associations_for_object.rb | lib/hubspot/codegen/crm/line_items/models/public_associations_for_object.rb | =begin
#Line Items
#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 Crm
module LineItems
class PublicAssociationsForObject
attr_accessor :types
attr_accessor :to
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'types' => :'types',
:'to' => :'to'
}
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
{
:'types' => :'Array<AssociationSpec>',
:'to' => :'PublicObjectId'
}
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::Crm::LineItems::PublicAssociationsForObject` 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::Crm::LineItems::PublicAssociationsForObject`. 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?(:'types')
if (value = attributes[:'types']).is_a?(Array)
self.types = value
end
end
if attributes.key?(:'to')
self.to = attributes[:'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
if @types.nil?
invalid_properties.push('invalid value for "types", types cannot be nil.')
end
if @to.nil?
invalid_properties.push('invalid value for "to", to 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 @types.nil?
return false if @to.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 &&
types == o.types &&
to == o.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
[types, 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::Crm::LineItems.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/crm/line_items/models/batch_response_simple_public_object_with_errors.rb | lib/hubspot/codegen/crm/line_items/models/batch_response_simple_public_object_with_errors.rb | =begin
#Line Items
#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 Crm
module LineItems
class BatchResponseSimplePublicObjectWithErrors
attr_accessor :completed_at
attr_accessor :num_errors
attr_accessor :requested_at
attr_accessor :started_at
attr_accessor :links
attr_accessor :results
attr_accessor :errors
attr_accessor :status
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
{
:'completed_at' => :'completedAt',
:'num_errors' => :'numErrors',
:'requested_at' => :'requestedAt',
:'started_at' => :'startedAt',
:'links' => :'links',
:'results' => :'results',
:'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
{
:'completed_at' => :'Time',
:'num_errors' => :'Integer',
:'requested_at' => :'Time',
:'started_at' => :'Time',
:'links' => :'Hash<String, String>',
:'results' => :'Array<SimplePublicObject>',
:'errors' => :'Array<StandardError>',
:'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::Crm::LineItems::BatchResponseSimplePublicObjectWithErrors` 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::Crm::LineItems::BatchResponseSimplePublicObjectWithErrors`. 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?(:'completed_at')
self.completed_at = attributes[:'completed_at']
end
if attributes.key?(:'num_errors')
self.num_errors = attributes[:'num_errors']
end
if attributes.key?(:'requested_at')
self.requested_at = attributes[:'requested_at']
end
if attributes.key?(:'started_at')
self.started_at = attributes[:'started_at']
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
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 @completed_at.nil?
invalid_properties.push('invalid value for "completed_at", completed_at cannot be nil.')
end
if @started_at.nil?
invalid_properties.push('invalid value for "started_at", started_at cannot be nil.')
end
if @results.nil?
invalid_properties.push('invalid value for "results", results 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 @completed_at.nil?
return false if @started_at.nil?
return false if @results.nil?
return false if @status.nil?
status_validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
return false unless status_validator.valid?(@status)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] status Object to be assigned
def status=(status)
validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
unless validator.valid?(status)
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
end
@status = status
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 &&
completed_at == o.completed_at &&
num_errors == o.num_errors &&
requested_at == o.requested_at &&
started_at == o.started_at &&
links == o.links &&
results == o.results &&
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
[completed_at, num_errors, requested_at, started_at, links, results, 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::Crm::LineItems.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/crm/line_items/models/collection_response_associated_id.rb | lib/hubspot/codegen/crm/line_items/models/collection_response_associated_id.rb | =begin
#Line Items
#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 Crm
module LineItems
class CollectionResponseAssociatedId
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' => :'Paging',
:'results' => :'Array<AssociatedId>'
}
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::Crm::LineItems::CollectionResponseAssociatedId` 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::Crm::LineItems::CollectionResponseAssociatedId`. 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::Crm::LineItems.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/crm/line_items/models/batch_input_simple_public_object_id.rb | lib/hubspot/codegen/crm/line_items/models/batch_input_simple_public_object_id.rb | =begin
#Line Items
#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 Crm
module LineItems
class BatchInputSimplePublicObjectId
attr_accessor :inputs
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'inputs' => :'inputs'
}
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
{
:'inputs' => :'Array<SimplePublicObjectId>'
}
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::Crm::LineItems::BatchInputSimplePublicObjectId` 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::Crm::LineItems::BatchInputSimplePublicObjectId`. 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?(:'inputs')
if (value = attributes[:'inputs']).is_a?(Array)
self.inputs = 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 @inputs.nil?
invalid_properties.push('invalid value for "inputs", inputs 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 @inputs.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 &&
inputs == o.inputs
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
[inputs].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::Crm::LineItems.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/crm/line_items/models/batch_input_simple_public_object_batch_input_upsert.rb | lib/hubspot/codegen/crm/line_items/models/batch_input_simple_public_object_batch_input_upsert.rb | =begin
#Line Items
#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 Crm
module LineItems
class BatchInputSimplePublicObjectBatchInputUpsert
attr_accessor :inputs
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'inputs' => :'inputs'
}
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
{
:'inputs' => :'Array<SimplePublicObjectBatchInputUpsert>'
}
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::Crm::LineItems::BatchInputSimplePublicObjectBatchInputUpsert` 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::Crm::LineItems::BatchInputSimplePublicObjectBatchInputUpsert`. 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?(:'inputs')
if (value = attributes[:'inputs']).is_a?(Array)
self.inputs = 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 @inputs.nil?
invalid_properties.push('invalid value for "inputs", inputs 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 @inputs.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 &&
inputs == o.inputs
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
[inputs].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::Crm::LineItems.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/crm/line_items/models/filter.rb | lib/hubspot/codegen/crm/line_items/models/filter.rb | =begin
#Line Items
#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 Crm
module LineItems
class Filter
attr_accessor :high_value
attr_accessor :property_name
attr_accessor :values
attr_accessor :value
# null
attr_accessor :operator
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
{
:'high_value' => :'highValue',
:'property_name' => :'propertyName',
:'values' => :'values',
:'value' => :'value',
:'operator' => :'operator'
}
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
{
:'high_value' => :'String',
:'property_name' => :'String',
:'values' => :'Array<String>',
:'value' => :'String',
:'operator' => :'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::Crm::LineItems::Filter` 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::Crm::LineItems::Filter`. 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?(:'high_value')
self.high_value = attributes[:'high_value']
end
if attributes.key?(:'property_name')
self.property_name = attributes[:'property_name']
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
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 @property_name.nil?
invalid_properties.push('invalid value for "property_name", property_name cannot be nil.')
end
if @operator.nil?
invalid_properties.push('invalid value for "operator", operator 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 @property_name.nil?
return false if @operator.nil?
operator_validator = EnumAttributeValidator.new('String', ["EQ", "NEQ", "LT", "LTE", "GT", "GTE", "BETWEEN", "IN", "NOT_IN", "HAS_PROPERTY", "NOT_HAS_PROPERTY", "CONTAINS_TOKEN", "NOT_CONTAINS_TOKEN"])
return false unless operator_validator.valid?(@operator)
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", "LT", "LTE", "GT", "GTE", "BETWEEN", "IN", "NOT_IN", "HAS_PROPERTY", "NOT_HAS_PROPERTY", "CONTAINS_TOKEN", "NOT_CONTAINS_TOKEN"])
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 &&
high_value == o.high_value &&
property_name == o.property_name &&
values == o.values &&
value == o.value &&
operator == o.operator
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
[high_value, property_name, values, value, operator].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::Crm::LineItems.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/crm/line_items/models/paging.rb | lib/hubspot/codegen/crm/line_items/models/paging.rb | =begin
#Line Items
#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 Crm
module LineItems
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::Crm::LineItems::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::Crm::LineItems::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
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 &&
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::Crm::LineItems.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/crm/line_items/models/public_object_search_request.rb | lib/hubspot/codegen/crm/line_items/models/public_object_search_request.rb | =begin
#Line Items
#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 Crm
module LineItems
class PublicObjectSearchRequest
attr_accessor :query
attr_accessor :limit
attr_accessor :after
attr_accessor :sorts
attr_accessor :properties
attr_accessor :filter_groups
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'query' => :'query',
:'limit' => :'limit',
:'after' => :'after',
:'sorts' => :'sorts',
:'properties' => :'properties',
:'filter_groups' => :'filterGroups'
}
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
{
:'query' => :'String',
:'limit' => :'Integer',
:'after' => :'String',
:'sorts' => :'Array<String>',
:'properties' => :'Array<String>',
:'filter_groups' => :'Array<FilterGroup>'
}
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::Crm::LineItems::PublicObjectSearchRequest` 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::Crm::LineItems::PublicObjectSearchRequest`. 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?(:'query')
self.query = attributes[:'query']
end
if attributes.key?(:'limit')
self.limit = attributes[:'limit']
end
if attributes.key?(:'after')
self.after = attributes[:'after']
end
if attributes.key?(:'sorts')
if (value = attributes[:'sorts']).is_a?(Array)
self.sorts = value
end
end
if attributes.key?(:'properties')
if (value = attributes[:'properties']).is_a?(Array)
self.properties = value
end
end
if attributes.key?(:'filter_groups')
if (value = attributes[:'filter_groups']).is_a?(Array)
self.filter_groups = 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 &&
query == o.query &&
limit == o.limit &&
after == o.after &&
sorts == o.sorts &&
properties == o.properties &&
filter_groups == o.filter_groups
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
[query, limit, after, sorts, properties, filter_groups].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::Crm::LineItems.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/crm/line_items/models/error_detail.rb | lib/hubspot/codegen/crm/line_items/models/error_detail.rb | =begin
#Line Items
#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 Crm
module LineItems
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::Crm::LineItems::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::Crm::LineItems::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::Crm::LineItems.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/crm/line_items/models/associated_id.rb | lib/hubspot/codegen/crm/line_items/models/associated_id.rb | =begin
#Line Items
#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 Crm
module LineItems
class AssociatedId
attr_accessor :id
attr_accessor :type
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'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
{
:'id' => :'String',
:'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::Crm::LineItems::AssociatedId` 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::Crm::LineItems::AssociatedId`. 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?(:'type')
self.type = attributes[:'type']
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 @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 @id.nil?
return false if @type.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 &&
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
[id, 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::Crm::LineItems.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/crm/line_items/models/simple_public_object_batch_input_for_create.rb | lib/hubspot/codegen/crm/line_items/models/simple_public_object_batch_input_for_create.rb | =begin
#Line Items
#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 Crm
module LineItems
class SimplePublicObjectBatchInputForCreate
attr_accessor :associations
attr_accessor :object_write_trace_id
attr_accessor :properties
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'associations' => :'associations',
:'object_write_trace_id' => :'objectWriteTraceId',
:'properties' => :'properties'
}
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
{
:'associations' => :'Array<PublicAssociationsForObject>',
:'object_write_trace_id' => :'String',
:'properties' => :'Hash<String, 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::Crm::LineItems::SimplePublicObjectBatchInputForCreate` 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::Crm::LineItems::SimplePublicObjectBatchInputForCreate`. 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?(:'associations')
if (value = attributes[:'associations']).is_a?(Array)
self.associations = value
end
end
if attributes.key?(:'object_write_trace_id')
self.object_write_trace_id = attributes[:'object_write_trace_id']
end
if attributes.key?(:'properties')
if (value = attributes[:'properties']).is_a?(Hash)
self.properties = 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 @properties.nil?
invalid_properties.push('invalid value for "properties", properties 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 @properties.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 &&
associations == o.associations &&
object_write_trace_id == o.object_write_trace_id &&
properties == o.properties
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
[associations, object_write_trace_id, properties].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::Crm::LineItems.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/crm/line_items/models/simple_public_object.rb | lib/hubspot/codegen/crm/line_items/models/simple_public_object.rb | =begin
#Line Items
#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 Crm
module LineItems
class SimplePublicObject
attr_accessor :created_at
attr_accessor :archived
attr_accessor :archived_at
attr_accessor :properties_with_history
attr_accessor :id
attr_accessor :object_write_trace_id
attr_accessor :properties
attr_accessor :updated_at
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'created_at' => :'createdAt',
:'archived' => :'archived',
:'archived_at' => :'archivedAt',
:'properties_with_history' => :'propertiesWithHistory',
:'id' => :'id',
:'object_write_trace_id' => :'objectWriteTraceId',
:'properties' => :'properties',
:'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
{
:'created_at' => :'Time',
:'archived' => :'Boolean',
:'archived_at' => :'Time',
:'properties_with_history' => :'Hash<String, Array<ValueWithTimestamp>>',
:'id' => :'String',
:'object_write_trace_id' => :'String',
:'properties' => :'Hash<String, 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::Crm::LineItems::SimplePublicObject` 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::Crm::LineItems::SimplePublicObject`. 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?(:'created_at')
self.created_at = attributes[:'created_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?(:'properties_with_history')
if (value = attributes[:'properties_with_history']).is_a?(Hash)
self.properties_with_history = value
end
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'object_write_trace_id')
self.object_write_trace_id = attributes[:'object_write_trace_id']
end
if attributes.key?(:'properties')
if (value = attributes[:'properties']).is_a?(Hash)
self.properties = value
end
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 @created_at.nil?
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @properties.nil?
invalid_properties.push('invalid value for "properties", properties 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 @created_at.nil?
return false if @id.nil?
return false if @properties.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 &&
created_at == o.created_at &&
archived == o.archived &&
archived_at == o.archived_at &&
properties_with_history == o.properties_with_history &&
id == o.id &&
object_write_trace_id == o.object_write_trace_id &&
properties == o.properties &&
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
[created_at, archived, archived_at, properties_with_history, id, object_write_trace_id, properties, 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::Crm::LineItems.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/crm/line_items/models/batch_response_simple_public_upsert_object.rb | lib/hubspot/codegen/crm/line_items/models/batch_response_simple_public_upsert_object.rb | =begin
#Line Items
#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 Crm
module LineItems
class BatchResponseSimplePublicUpsertObject
attr_accessor :completed_at
attr_accessor :requested_at
attr_accessor :started_at
attr_accessor :links
attr_accessor :results
attr_accessor :status
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
{
:'completed_at' => :'completedAt',
:'requested_at' => :'requestedAt',
:'started_at' => :'startedAt',
:'links' => :'links',
:'results' => :'results',
:'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
{
:'completed_at' => :'Time',
:'requested_at' => :'Time',
:'started_at' => :'Time',
:'links' => :'Hash<String, String>',
:'results' => :'Array<SimplePublicUpsertObject>',
:'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::Crm::LineItems::BatchResponseSimplePublicUpsertObject` 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::Crm::LineItems::BatchResponseSimplePublicUpsertObject`. 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?(:'completed_at')
self.completed_at = attributes[:'completed_at']
end
if attributes.key?(:'requested_at')
self.requested_at = attributes[:'requested_at']
end
if attributes.key?(:'started_at')
self.started_at = attributes[:'started_at']
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = 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 @completed_at.nil?
invalid_properties.push('invalid value for "completed_at", completed_at cannot be nil.')
end
if @started_at.nil?
invalid_properties.push('invalid value for "started_at", started_at cannot be nil.')
end
if @results.nil?
invalid_properties.push('invalid value for "results", results 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 @completed_at.nil?
return false if @started_at.nil?
return false if @results.nil?
return false if @status.nil?
status_validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
return false unless status_validator.valid?(@status)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] status Object to be assigned
def status=(status)
validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
unless validator.valid?(status)
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
end
@status = status
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 &&
completed_at == o.completed_at &&
requested_at == o.requested_at &&
started_at == o.started_at &&
links == o.links &&
results == o.results &&
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
[completed_at, requested_at, started_at, links, results, 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::Crm::LineItems.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/crm/line_items/models/batch_response_simple_public_upsert_object_with_errors.rb | lib/hubspot/codegen/crm/line_items/models/batch_response_simple_public_upsert_object_with_errors.rb | =begin
#Line Items
#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 Crm
module LineItems
class BatchResponseSimplePublicUpsertObjectWithErrors
attr_accessor :completed_at
attr_accessor :num_errors
attr_accessor :requested_at
attr_accessor :started_at
attr_accessor :links
attr_accessor :results
attr_accessor :errors
attr_accessor :status
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
{
:'completed_at' => :'completedAt',
:'num_errors' => :'numErrors',
:'requested_at' => :'requestedAt',
:'started_at' => :'startedAt',
:'links' => :'links',
:'results' => :'results',
:'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
{
:'completed_at' => :'Time',
:'num_errors' => :'Integer',
:'requested_at' => :'Time',
:'started_at' => :'Time',
:'links' => :'Hash<String, String>',
:'results' => :'Array<SimplePublicUpsertObject>',
:'errors' => :'Array<StandardError>',
:'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::Crm::LineItems::BatchResponseSimplePublicUpsertObjectWithErrors` 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::Crm::LineItems::BatchResponseSimplePublicUpsertObjectWithErrors`. 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?(:'completed_at')
self.completed_at = attributes[:'completed_at']
end
if attributes.key?(:'num_errors')
self.num_errors = attributes[:'num_errors']
end
if attributes.key?(:'requested_at')
self.requested_at = attributes[:'requested_at']
end
if attributes.key?(:'started_at')
self.started_at = attributes[:'started_at']
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
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 @completed_at.nil?
invalid_properties.push('invalid value for "completed_at", completed_at cannot be nil.')
end
if @started_at.nil?
invalid_properties.push('invalid value for "started_at", started_at cannot be nil.')
end
if @results.nil?
invalid_properties.push('invalid value for "results", results 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 @completed_at.nil?
return false if @started_at.nil?
return false if @results.nil?
return false if @status.nil?
status_validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
return false unless status_validator.valid?(@status)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] status Object to be assigned
def status=(status)
validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
unless validator.valid?(status)
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
end
@status = status
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 &&
completed_at == o.completed_at &&
num_errors == o.num_errors &&
requested_at == o.requested_at &&
started_at == o.started_at &&
links == o.links &&
results == o.results &&
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
[completed_at, num_errors, requested_at, started_at, links, results, 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::Crm::LineItems.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/crm/line_items/models/forward_paging.rb | lib/hubspot/codegen/crm/line_items/models/forward_paging.rb | =begin
#Line Items
#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 Crm
module LineItems
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::Crm::LineItems::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::Crm::LineItems::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::Crm::LineItems.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/crm/line_items/models/batch_input_simple_public_object_batch_input.rb | lib/hubspot/codegen/crm/line_items/models/batch_input_simple_public_object_batch_input.rb | =begin
#Line Items
#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 Crm
module LineItems
class BatchInputSimplePublicObjectBatchInput
attr_accessor :inputs
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'inputs' => :'inputs'
}
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
{
:'inputs' => :'Array<SimplePublicObjectBatchInput>'
}
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::Crm::LineItems::BatchInputSimplePublicObjectBatchInput` 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::Crm::LineItems::BatchInputSimplePublicObjectBatchInput`. 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?(:'inputs')
if (value = attributes[:'inputs']).is_a?(Array)
self.inputs = 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 @inputs.nil?
invalid_properties.push('invalid value for "inputs", inputs 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 @inputs.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 &&
inputs == o.inputs
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
[inputs].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::Crm::LineItems.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/crm/line_items/models/batch_input_simple_public_object_batch_input_for_create.rb | lib/hubspot/codegen/crm/line_items/models/batch_input_simple_public_object_batch_input_for_create.rb | =begin
#Line Items
#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 Crm
module LineItems
class BatchInputSimplePublicObjectBatchInputForCreate
attr_accessor :inputs
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'inputs' => :'inputs'
}
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
{
:'inputs' => :'Array<SimplePublicObjectBatchInputForCreate>'
}
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::Crm::LineItems::BatchInputSimplePublicObjectBatchInputForCreate` 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::Crm::LineItems::BatchInputSimplePublicObjectBatchInputForCreate`. 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?(:'inputs')
if (value = attributes[:'inputs']).is_a?(Array)
self.inputs = 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 @inputs.nil?
invalid_properties.push('invalid value for "inputs", inputs 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 @inputs.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 &&
inputs == o.inputs
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
[inputs].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::Crm::LineItems.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/crm/line_items/models/simple_public_object_batch_input.rb | lib/hubspot/codegen/crm/line_items/models/simple_public_object_batch_input.rb | =begin
#Line Items
#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 Crm
module LineItems
class SimplePublicObjectBatchInput
# The name of a property whose values are unique for this object
attr_accessor :id_property
attr_accessor :object_write_trace_id
# The id to be updated. This can be the object id, or the unique property value of the idProperty property
attr_accessor :id
attr_accessor :properties
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id_property' => :'idProperty',
:'object_write_trace_id' => :'objectWriteTraceId',
:'id' => :'id',
:'properties' => :'properties'
}
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_property' => :'String',
:'object_write_trace_id' => :'String',
:'id' => :'String',
:'properties' => :'Hash<String, 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::Crm::LineItems::SimplePublicObjectBatchInput` 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::Crm::LineItems::SimplePublicObjectBatchInput`. 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_property')
self.id_property = attributes[:'id_property']
end
if attributes.key?(:'object_write_trace_id')
self.object_write_trace_id = attributes[:'object_write_trace_id']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'properties')
if (value = attributes[:'properties']).is_a?(Hash)
self.properties = 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 @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @properties.nil?
invalid_properties.push('invalid value for "properties", properties 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 @properties.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_property == o.id_property &&
object_write_trace_id == o.object_write_trace_id &&
id == o.id &&
properties == o.properties
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_property, object_write_trace_id, id, properties].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::Crm::LineItems.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/crm/line_items/models/simple_public_object_input_for_create.rb | lib/hubspot/codegen/crm/line_items/models/simple_public_object_input_for_create.rb | =begin
#Line Items
#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 Crm
module LineItems
class SimplePublicObjectInputForCreate
attr_accessor :associations
attr_accessor :properties
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'associations' => :'associations',
:'properties' => :'properties'
}
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
{
:'associations' => :'Array<PublicAssociationsForObject>',
:'properties' => :'Hash<String, 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::Crm::LineItems::SimplePublicObjectInputForCreate` 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::Crm::LineItems::SimplePublicObjectInputForCreate`. 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?(:'associations')
if (value = attributes[:'associations']).is_a?(Array)
self.associations = value
end
end
if attributes.key?(:'properties')
if (value = attributes[:'properties']).is_a?(Hash)
self.properties = 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 @properties.nil?
invalid_properties.push('invalid value for "properties", properties 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 @properties.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 &&
associations == o.associations &&
properties == o.properties
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
[associations, properties].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::Crm::LineItems.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/crm/line_items/models/filter_group.rb | lib/hubspot/codegen/crm/line_items/models/filter_group.rb | =begin
#Line Items
#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 Crm
module LineItems
class FilterGroup
attr_accessor :filters
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'filters' => :'filters'
}
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
{
:'filters' => :'Array<Filter>'
}
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::Crm::LineItems::FilterGroup` 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::Crm::LineItems::FilterGroup`. 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?(:'filters')
if (value = attributes[:'filters']).is_a?(Array)
self.filters = 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 @filters.nil?
invalid_properties.push('invalid value for "filters", filters 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 @filters.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 &&
filters == o.filters
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
[filters].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::Crm::LineItems.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/crm/line_items/models/simple_public_upsert_object.rb | lib/hubspot/codegen/crm/line_items/models/simple_public_upsert_object.rb | =begin
#Line Items
#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 Crm
module LineItems
class SimplePublicUpsertObject
attr_accessor :created_at
attr_accessor :archived
attr_accessor :archived_at
attr_accessor :new
attr_accessor :properties_with_history
attr_accessor :id
attr_accessor :object_write_trace_id
attr_accessor :properties
attr_accessor :updated_at
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'created_at' => :'createdAt',
:'archived' => :'archived',
:'archived_at' => :'archivedAt',
:'new' => :'new',
:'properties_with_history' => :'propertiesWithHistory',
:'id' => :'id',
:'object_write_trace_id' => :'objectWriteTraceId',
:'properties' => :'properties',
:'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
{
:'created_at' => :'Time',
:'archived' => :'Boolean',
:'archived_at' => :'Time',
:'new' => :'Boolean',
:'properties_with_history' => :'Hash<String, Array<ValueWithTimestamp>>',
:'id' => :'String',
:'object_write_trace_id' => :'String',
:'properties' => :'Hash<String, 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::Crm::LineItems::SimplePublicUpsertObject` 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::Crm::LineItems::SimplePublicUpsertObject`. 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?(:'created_at')
self.created_at = attributes[:'created_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?(:'new')
self.new = attributes[:'new']
end
if attributes.key?(:'properties_with_history')
if (value = attributes[:'properties_with_history']).is_a?(Hash)
self.properties_with_history = value
end
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'object_write_trace_id')
self.object_write_trace_id = attributes[:'object_write_trace_id']
end
if attributes.key?(:'properties')
if (value = attributes[:'properties']).is_a?(Hash)
self.properties = value
end
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 @created_at.nil?
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
end
if @new.nil?
invalid_properties.push('invalid value for "new", new cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @properties.nil?
invalid_properties.push('invalid value for "properties", properties 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 @created_at.nil?
return false if @new.nil?
return false if @id.nil?
return false if @properties.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 &&
created_at == o.created_at &&
archived == o.archived &&
archived_at == o.archived_at &&
new == o.new &&
properties_with_history == o.properties_with_history &&
id == o.id &&
object_write_trace_id == o.object_write_trace_id &&
properties == o.properties &&
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
[created_at, archived, archived_at, new, properties_with_history, id, object_write_trace_id, properties, 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::Crm::LineItems.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/crm/line_items/models/public_object_id.rb | lib/hubspot/codegen/crm/line_items/models/public_object_id.rb | =begin
#Line Items
#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 Crm
module LineItems
class PublicObjectId
attr_accessor :id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'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
{
:'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::Crm::LineItems::PublicObjectId` 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::Crm::LineItems::PublicObjectId`. 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
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 &&
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
[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::Crm::LineItems.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/crm/line_items/models/simple_public_object_input.rb | lib/hubspot/codegen/crm/line_items/models/simple_public_object_input.rb | =begin
#Line Items
#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 Crm
module LineItems
class SimplePublicObjectInput
attr_accessor :properties
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'properties' => :'properties'
}
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
{
:'properties' => :'Hash<String, 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::Crm::LineItems::SimplePublicObjectInput` 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::Crm::LineItems::SimplePublicObjectInput`. 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?(:'properties')
if (value = attributes[:'properties']).is_a?(Hash)
self.properties = 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 @properties.nil?
invalid_properties.push('invalid value for "properties", properties 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 @properties.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 &&
properties == o.properties
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
[properties].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::Crm::LineItems.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/crm/line_items/models/error.rb | lib/hubspot/codegen/crm/line_items/models/error.rb | =begin
#Line Items
#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 Crm
module LineItems
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::Crm::LineItems::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::Crm::LineItems::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::Crm::LineItems.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/crm/line_items/api/batch_api.rb | lib/hubspot/codegen/crm/line_items/api/batch_api.rb | =begin
#Line Items
#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 Crm
module LineItems
class BatchApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Archive a batch of line items by ID
# @param batch_input_simple_public_object_id [BatchInputSimplePublicObjectId]
# @param [Hash] opts the optional parameters
# @return [nil]
def archive(batch_input_simple_public_object_id, opts = {})
archive_with_http_info(batch_input_simple_public_object_id, opts)
nil
end
# Archive a batch of line items by ID
# @param batch_input_simple_public_object_id [BatchInputSimplePublicObjectId]
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def archive_with_http_info(batch_input_simple_public_object_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: BatchApi.archive ...'
end
# verify the required parameter 'batch_input_simple_public_object_id' is set
if @api_client.config.client_side_validation && batch_input_simple_public_object_id.nil?
fail ArgumentError, "Missing the required parameter 'batch_input_simple_public_object_id' when calling BatchApi.archive"
end
# resource path
local_var_path = '/crm/v3/objects/line_items/batch/archive'
# 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(['*/*'])
# 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(batch_input_simple_public_object_id)
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"BatchApi.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(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: BatchApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Create a batch of line items
# @param batch_input_simple_public_object_batch_input_for_create [BatchInputSimplePublicObjectBatchInputForCreate]
# @param [Hash] opts the optional parameters
# @return [BatchResponseSimplePublicObject]
def create(batch_input_simple_public_object_batch_input_for_create, opts = {})
data, _status_code, _headers = create_with_http_info(batch_input_simple_public_object_batch_input_for_create, opts)
data
end
# Create a batch of line items
# @param batch_input_simple_public_object_batch_input_for_create [BatchInputSimplePublicObjectBatchInputForCreate]
# @param [Hash] opts the optional parameters
# @return [Array<(BatchResponseSimplePublicObject, Integer, Hash)>] BatchResponseSimplePublicObject data, response status code and response headers
def create_with_http_info(batch_input_simple_public_object_batch_input_for_create, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: BatchApi.create ...'
end
# verify the required parameter 'batch_input_simple_public_object_batch_input_for_create' is set
if @api_client.config.client_side_validation && batch_input_simple_public_object_batch_input_for_create.nil?
fail ArgumentError, "Missing the required parameter 'batch_input_simple_public_object_batch_input_for_create' when calling BatchApi.create"
end
# resource path
local_var_path = '/crm/v3/objects/line_items/batch/create'
# 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(batch_input_simple_public_object_batch_input_for_create)
# return_type
return_type = opts[:debug_return_type] || 'BatchResponseSimplePublicObject'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"BatchApi.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: BatchApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Read a batch of line items by internal ID, or unique property values
# Retrieve records by record ID or include the `idProperty` parameter to retrieve records by a custom unique value property.
# @param batch_read_input_simple_public_object_id [BatchReadInputSimplePublicObjectId]
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :archived Whether to return only results that have been archived. (default to false)
# @return [BatchResponseSimplePublicObject]
def read(batch_read_input_simple_public_object_id, opts = {})
data, _status_code, _headers = read_with_http_info(batch_read_input_simple_public_object_id, opts)
data
end
# Read a batch of line items by internal ID, or unique property values
# Retrieve records by record ID or include the `idProperty` parameter to retrieve records by a custom unique value property.
# @param batch_read_input_simple_public_object_id [BatchReadInputSimplePublicObjectId]
# @param [Hash] opts the optional parameters
# @option opts [Boolean] :archived Whether to return only results that have been archived. (default to false)
# @return [Array<(BatchResponseSimplePublicObject, Integer, Hash)>] BatchResponseSimplePublicObject data, response status code and response headers
def read_with_http_info(batch_read_input_simple_public_object_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: BatchApi.read ...'
end
# verify the required parameter 'batch_read_input_simple_public_object_id' is set
if @api_client.config.client_side_validation && batch_read_input_simple_public_object_id.nil?
fail ArgumentError, "Missing the required parameter 'batch_read_input_simple_public_object_id' when calling BatchApi.read"
end
# resource path
local_var_path = '/crm/v3/objects/line_items/batch/read'
# 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', '*/*'])
# 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(batch_read_input_simple_public_object_id)
# return_type
return_type = opts[:debug_return_type] || 'BatchResponseSimplePublicObject'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"BatchApi.read",
: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: BatchApi#read\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Update a batch of line items by internal ID, or unique property values
# @param batch_input_simple_public_object_batch_input [BatchInputSimplePublicObjectBatchInput]
# @param [Hash] opts the optional parameters
# @return [BatchResponseSimplePublicObject]
def update(batch_input_simple_public_object_batch_input, opts = {})
data, _status_code, _headers = update_with_http_info(batch_input_simple_public_object_batch_input, opts)
data
end
# Update a batch of line items by internal ID, or unique property values
# @param batch_input_simple_public_object_batch_input [BatchInputSimplePublicObjectBatchInput]
# @param [Hash] opts the optional parameters
# @return [Array<(BatchResponseSimplePublicObject, Integer, Hash)>] BatchResponseSimplePublicObject data, response status code and response headers
def update_with_http_info(batch_input_simple_public_object_batch_input, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: BatchApi.update ...'
end
# verify the required parameter 'batch_input_simple_public_object_batch_input' is set
if @api_client.config.client_side_validation && batch_input_simple_public_object_batch_input.nil?
fail ArgumentError, "Missing the required parameter 'batch_input_simple_public_object_batch_input' when calling BatchApi.update"
end
# resource path
local_var_path = '/crm/v3/objects/line_items/batch/update'
# 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(batch_input_simple_public_object_batch_input)
# return_type
return_type = opts[:debug_return_type] || 'BatchResponseSimplePublicObject'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"BatchApi.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(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: BatchApi#update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Create or update a batch of line items by unique property values
# Create or update records identified by a unique property value as specified by the `idProperty` query param. `idProperty` query param refers to a property whose values are unique for the object.
# @param batch_input_simple_public_object_batch_input_upsert [BatchInputSimplePublicObjectBatchInputUpsert]
# @param [Hash] opts the optional parameters
# @return [BatchResponseSimplePublicUpsertObject]
def upsert(batch_input_simple_public_object_batch_input_upsert, opts = {})
data, _status_code, _headers = upsert_with_http_info(batch_input_simple_public_object_batch_input_upsert, opts)
data
end
# Create or update a batch of line items by unique property values
# Create or update records identified by a unique property value as specified by the `idProperty` query param. `idProperty` query param refers to a property whose values are unique for the object.
# @param batch_input_simple_public_object_batch_input_upsert [BatchInputSimplePublicObjectBatchInputUpsert]
# @param [Hash] opts the optional parameters
# @return [Array<(BatchResponseSimplePublicUpsertObject, Integer, Hash)>] BatchResponseSimplePublicUpsertObject data, response status code and response headers
def upsert_with_http_info(batch_input_simple_public_object_batch_input_upsert, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: BatchApi.upsert ...'
end
# verify the required parameter 'batch_input_simple_public_object_batch_input_upsert' is set
if @api_client.config.client_side_validation && batch_input_simple_public_object_batch_input_upsert.nil?
fail ArgumentError, "Missing the required parameter 'batch_input_simple_public_object_batch_input_upsert' when calling BatchApi.upsert"
end
# resource path
local_var_path = '/crm/v3/objects/line_items/batch/upsert'
# 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(batch_input_simple_public_object_batch_input_upsert)
# return_type
return_type = opts[:debug_return_type] || 'BatchResponseSimplePublicUpsertObject'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"BatchApi.upsert",
: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: BatchApi#upsert\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/crm/line_items/api/basic_api.rb | lib/hubspot/codegen/crm/line_items/api/basic_api.rb | =begin
#Line Items
#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 Crm
module LineItems
class BasicApi
require 'hubspot/helpers/get_all_helper'
include Hubspot::Helpers::GetAllHelper
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Archive
# Move an Object identified by `{lineItemId}` to the recycling bin.
# @param line_item_id [String]
# @param [Hash] opts the optional parameters
# @return [nil]
def archive(line_item_id, opts = {})
archive_with_http_info(line_item_id, opts)
nil
end
# Archive
# Move an Object identified by `{lineItemId}` to the recycling bin.
# @param line_item_id [String]
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def archive_with_http_info(line_item_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: BasicApi.archive ...'
end
# verify the required parameter 'line_item_id' is set
if @api_client.config.client_side_validation && line_item_id.nil?
fail ArgumentError, "Missing the required parameter 'line_item_id' when calling BasicApi.archive"
end
# resource path
local_var_path = '/crm/v3/objects/line_items/{lineItemId}'.sub('{' + 'lineItemId' + '}', CGI.escape(line_item_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(['*/*'])
# 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 => :"BasicApi.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: BasicApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Create
# Create a line item with the given properties and return a copy of the object, including the ID. Documentation and examples for creating standard line items is provided.
# @param simple_public_object_input_for_create [SimplePublicObjectInputForCreate]
# @param [Hash] opts the optional parameters
# @return [SimplePublicObject]
def create(simple_public_object_input_for_create, opts = {})
data, _status_code, _headers = create_with_http_info(simple_public_object_input_for_create, opts)
data
end
# Create
# Create a line item with the given properties and return a copy of the object, including the ID. Documentation and examples for creating standard line items is provided.
# @param simple_public_object_input_for_create [SimplePublicObjectInputForCreate]
# @param [Hash] opts the optional parameters
# @return [Array<(SimplePublicObject, Integer, Hash)>] SimplePublicObject data, response status code and response headers
def create_with_http_info(simple_public_object_input_for_create, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: BasicApi.create ...'
end
# verify the required parameter 'simple_public_object_input_for_create' is set
if @api_client.config.client_side_validation && simple_public_object_input_for_create.nil?
fail ArgumentError, "Missing the required parameter 'simple_public_object_input_for_create' when calling BasicApi.create"
end
# resource path
local_var_path = '/crm/v3/objects/line_items'
# 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(simple_public_object_input_for_create)
# return_type
return_type = opts[:debug_return_type] || 'SimplePublicObject'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"BasicApi.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: BasicApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Read
# Read an Object identified by `{lineItemId}`. `{lineItemId}` refers to the internal object ID by default, or optionally any unique property value as specified by the `idProperty` query param. Control what is returned via the `properties` query param.
# @param line_item_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored.
# @option opts [Array<String>] :properties_with_history A comma separated list of the properties to be returned along with their history of previous values. If any of the specified properties are not present on the requested object(s), they will be ignored.
# @option opts [Array<String>] :associations A comma separated list of object types to retrieve associated IDs for. If any of the specified associations do not exist, they will be ignored.
# @option opts [Boolean] :archived Whether to return only results that have been archived. (default to false)
# @option opts [String] :id_property The name of a property whose values are unique for this object
# @return [SimplePublicObjectWithAssociations]
def get_by_id(line_item_id, opts = {})
data, _status_code, _headers = get_by_id_with_http_info(line_item_id, opts)
data
end
# Read
# Read an Object identified by `{lineItemId}`. `{lineItemId}` refers to the internal object ID by default, or optionally any unique property value as specified by the `idProperty` query param. Control what is returned via the `properties` query param.
# @param line_item_id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored.
# @option opts [Array<String>] :properties_with_history A comma separated list of the properties to be returned along with their history of previous values. If any of the specified properties are not present on the requested object(s), they will be ignored.
# @option opts [Array<String>] :associations A comma separated list of object types to retrieve associated IDs for. If any of the specified associations do not exist, they will be ignored.
# @option opts [Boolean] :archived Whether to return only results that have been archived. (default to false)
# @option opts [String] :id_property The name of a property whose values are unique for this object
# @return [Array<(SimplePublicObjectWithAssociations, Integer, Hash)>] SimplePublicObjectWithAssociations data, response status code and response headers
def get_by_id_with_http_info(line_item_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: BasicApi.get_by_id ...'
end
# verify the required parameter 'line_item_id' is set
if @api_client.config.client_side_validation && line_item_id.nil?
fail ArgumentError, "Missing the required parameter 'line_item_id' when calling BasicApi.get_by_id"
end
# resource path
local_var_path = '/crm/v3/objects/line_items/{lineItemId}'.sub('{' + 'lineItemId' + '}', CGI.escape(line_item_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?
query_params[:'propertiesWithHistory'] = @api_client.build_collection_param(opts[:'properties_with_history'], :multi) if !opts[:'properties_with_history'].nil?
query_params[:'associations'] = @api_client.build_collection_param(opts[:'associations'], :multi) if !opts[:'associations'].nil?
query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil?
query_params[:'idProperty'] = opts[:'id_property'] if !opts[:'id_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] || 'SimplePublicObjectWithAssociations'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"BasicApi.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: BasicApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# List
# Read a page of line items. Control what is returned via the `properties` query param.
# @param [Hash] opts the optional parameters
# @option opts [Integer] :limit The maximum number of results to display per page. (default to 10)
# @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 [Array<String>] :properties A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored.
# @option opts [Array<String>] :properties_with_history A comma separated list of the properties to be returned along with their history of previous values. If any of the specified properties are not present on the requested object(s), they will be ignored. Usage of this parameter will reduce the maximum number of objects that can be read by a single request.
# @option opts [Array<String>] :associations A comma separated list of object types to retrieve associated IDs for. If any of the specified associations do not exist, they will be ignored.
# @option opts [Boolean] :archived Whether to return only results that have been archived. (default to false)
# @return [CollectionResponseSimplePublicObjectWithAssociationsForwardPaging]
def get_page(opts = {})
data, _status_code, _headers = get_page_with_http_info(opts)
data
end
# List
# Read a page of line items. Control what is returned via the `properties` query param.
# @param [Hash] opts the optional parameters
# @option opts [Integer] :limit The maximum number of results to display per page. (default to 10)
# @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 [Array<String>] :properties A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored.
# @option opts [Array<String>] :properties_with_history A comma separated list of the properties to be returned along with their history of previous values. If any of the specified properties are not present on the requested object(s), they will be ignored. Usage of this parameter will reduce the maximum number of objects that can be read by a single request.
# @option opts [Array<String>] :associations A comma separated list of object types to retrieve associated IDs for. If any of the specified associations do not exist, they will be ignored.
# @option opts [Boolean] :archived Whether to return only results that have been archived. (default to false)
# @return [Array<(CollectionResponseSimplePublicObjectWithAssociationsForwardPaging, Integer, Hash)>] CollectionResponseSimplePublicObjectWithAssociationsForwardPaging 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: BasicApi.get_page ...'
end
# resource path
local_var_path = '/crm/v3/objects/line_items'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?
query_params[:'propertiesWithHistory'] = @api_client.build_collection_param(opts[:'properties_with_history'], :multi) if !opts[:'properties_with_history'].nil?
query_params[:'associations'] = @api_client.build_collection_param(opts[:'associations'], :multi) if !opts[:'associations'].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] || 'CollectionResponseSimplePublicObjectWithAssociationsForwardPaging'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"BasicApi.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: BasicApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Update
# Perform a partial update of an Object identified by `{lineItemId}`or optionally a unique property value as specified by the `idProperty` query param. `{lineItemId}` refers to the internal object ID by default, and the `idProperty` query param refers to a property whose values are unique for the object. Provided property values will be overwritten. Read-only and non-existent properties will result in an error. Properties values can be cleared by passing an empty string.
# @param line_item_id [String]
# @param simple_public_object_input [SimplePublicObjectInput]
# @param [Hash] opts the optional parameters
# @option opts [String] :id_property The name of a property whose values are unique for this object
# @return [SimplePublicObject]
def update(line_item_id, simple_public_object_input, opts = {})
data, _status_code, _headers = update_with_http_info(line_item_id, simple_public_object_input, opts)
data
end
# Update
# Perform a partial update of an Object identified by `{lineItemId}`or optionally a unique property value as specified by the `idProperty` query param. `{lineItemId}` refers to the internal object ID by default, and the `idProperty` query param refers to a property whose values are unique for the object. Provided property values will be overwritten. Read-only and non-existent properties will result in an error. Properties values can be cleared by passing an empty string.
# @param line_item_id [String]
# @param simple_public_object_input [SimplePublicObjectInput]
# @param [Hash] opts the optional parameters
# @option opts [String] :id_property The name of a property whose values are unique for this object
# @return [Array<(SimplePublicObject, Integer, Hash)>] SimplePublicObject data, response status code and response headers
def update_with_http_info(line_item_id, simple_public_object_input, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: BasicApi.update ...'
end
# verify the required parameter 'line_item_id' is set
if @api_client.config.client_side_validation && line_item_id.nil?
fail ArgumentError, "Missing the required parameter 'line_item_id' when calling BasicApi.update"
end
# verify the required parameter 'simple_public_object_input' is set
if @api_client.config.client_side_validation && simple_public_object_input.nil?
fail ArgumentError, "Missing the required parameter 'simple_public_object_input' when calling BasicApi.update"
end
# resource path
local_var_path = '/crm/v3/objects/line_items/{lineItemId}'.sub('{' + 'lineItemId' + '}', CGI.escape(line_item_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'idProperty'] = opts[:'id_property'] if !opts[:'id_property'].nil?
# 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(simple_public_object_input)
# return_type
return_type = opts[:debug_return_type] || 'SimplePublicObject'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"BasicApi.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: BasicApi#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/crm/line_items/api/search_api.rb | lib/hubspot/codegen/crm/line_items/api/search_api.rb | =begin
#Line Items
#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 Crm
module LineItems
class SearchApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Search for line items
# Search for line items by filtering on properties, searching through associations, and sorting results. Learn more about [CRM search](https://developers.hubspot.com/docs/guides/api/crm/search#make-a-search-request).
# @param public_object_search_request [PublicObjectSearchRequest]
# @param [Hash] opts the optional parameters
# @return [CollectionResponseWithTotalSimplePublicObjectForwardPaging]
def do_search(public_object_search_request, opts = {})
data, _status_code, _headers = do_search_with_http_info(public_object_search_request, opts)
data
end
# Search for line items
# Search for line items by filtering on properties, searching through associations, and sorting results. Learn more about [CRM search](https://developers.hubspot.com/docs/guides/api/crm/search#make-a-search-request).
# @param public_object_search_request [PublicObjectSearchRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(CollectionResponseWithTotalSimplePublicObjectForwardPaging, Integer, Hash)>] CollectionResponseWithTotalSimplePublicObjectForwardPaging data, response status code and response headers
def do_search_with_http_info(public_object_search_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: SearchApi.do_search ...'
end
# verify the required parameter 'public_object_search_request' is set
if @api_client.config.client_side_validation && public_object_search_request.nil?
fail ArgumentError, "Missing the required parameter 'public_object_search_request' when calling SearchApi.do_search"
end
# resource path
local_var_path = '/crm/v3/objects/line_items/search'
# 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_object_search_request)
# return_type
return_type = opts[:debug_return_type] || 'CollectionResponseWithTotalSimplePublicObjectForwardPaging'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"SearchApi.do_search",
: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: SearchApi#do_search\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/crm/extensions/videoconferencing/api_error.rb | lib/hubspot/codegen/crm/extensions/videoconferencing/api_error.rb | =begin
#Video Conferencing Extension
#These APIs allow you to specify URLs that can be used to interact with a video conferencing application, to allow HubSpot to add video conference links to meeting requests with contacts.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Crm
module Extensions
module Videoconferencing
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
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/crm/extensions/videoconferencing/configuration.rb | lib/hubspot/codegen/crm/extensions/videoconferencing/configuration.rb | =begin
#Video Conferencing Extension
#These APIs allow you to specify URLs that can be used to interact with a video conferencing application, to allow HubSpot to add video conference links to meeting requests with contacts.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Crm
module Extensions
module Videoconferencing
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')
},
}
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
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/crm/extensions/videoconferencing/api_client.rb | lib/hubspot/codegen/crm/extensions/videoconferencing/api_client.rb | =begin
#Video Conferencing Extension
#These APIs allow you to specify URLs that can be used to interact with a video conferencing application, to allow HubSpot to add video conference links to meeting requests with contacts.
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 Crm
module Extensions
module Videoconferencing
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::Crm::Extensions::Videoconferencing.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
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/crm/extensions/videoconferencing/models/external_settings.rb | lib/hubspot/codegen/crm/extensions/videoconferencing/models/external_settings.rb | =begin
#Video Conferencing Extension
#These APIs allow you to specify URLs that can be used to interact with a video conferencing application, to allow HubSpot to add video conference links to meeting requests with contacts.
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 Crm
module Extensions
module Videoconferencing
# The URLs of the various actions provided by the video conferencing application. All URLs must use the `https` protocol.
class ExternalSettings
# The URL that HubSpot will use to verify that a user exists in the video conference application.
attr_accessor :user_verify_url
attr_accessor :fetch_accounts_uri
# The URL that HubSpot will send requests to create a new video conference.
attr_accessor :create_meeting_url
# The URL that HubSpot will send updates to existing meetings. Typically called when the user changes the topic or times of a meeting.
attr_accessor :update_meeting_url
# The URL that HubSpot will send notifications of meetings that have been deleted in HubSpot.
attr_accessor :delete_meeting_url
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'user_verify_url' => :'userVerifyUrl',
:'fetch_accounts_uri' => :'fetchAccountsUri',
:'create_meeting_url' => :'createMeetingUrl',
:'update_meeting_url' => :'updateMeetingUrl',
:'delete_meeting_url' => :'deleteMeetingUrl'
}
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
{
:'user_verify_url' => :'String',
:'fetch_accounts_uri' => :'String',
:'create_meeting_url' => :'String',
:'update_meeting_url' => :'String',
:'delete_meeting_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::Crm::Extensions::Videoconferencing::ExternalSettings` 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::Crm::Extensions::Videoconferencing::ExternalSettings`. 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?(:'user_verify_url')
self.user_verify_url = attributes[:'user_verify_url']
end
if attributes.key?(:'fetch_accounts_uri')
self.fetch_accounts_uri = attributes[:'fetch_accounts_uri']
end
if attributes.key?(:'create_meeting_url')
self.create_meeting_url = attributes[:'create_meeting_url']
end
if attributes.key?(:'update_meeting_url')
self.update_meeting_url = attributes[:'update_meeting_url']
end
if attributes.key?(:'delete_meeting_url')
self.delete_meeting_url = attributes[:'delete_meeting_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
if @create_meeting_url.nil?
invalid_properties.push('invalid value for "create_meeting_url", create_meeting_url 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_meeting_url.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 &&
user_verify_url == o.user_verify_url &&
fetch_accounts_uri == o.fetch_accounts_uri &&
create_meeting_url == o.create_meeting_url &&
update_meeting_url == o.update_meeting_url &&
delete_meeting_url == o.delete_meeting_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
[user_verify_url, fetch_accounts_uri, create_meeting_url, update_meeting_url, delete_meeting_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::Crm::Extensions::Videoconferencing.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
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/crm/extensions/videoconferencing/models/error_detail.rb | lib/hubspot/codegen/crm/extensions/videoconferencing/models/error_detail.rb | =begin
#Video Conferencing Extension
#These APIs allow you to specify URLs that can be used to interact with a video conferencing application, to allow HubSpot to add video conference links to meeting requests with contacts.
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 Crm
module Extensions
module Videoconferencing
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::Crm::Extensions::Videoconferencing::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::Crm::Extensions::Videoconferencing::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::Crm::Extensions::Videoconferencing.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
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/crm/extensions/videoconferencing/models/error.rb | lib/hubspot/codegen/crm/extensions/videoconferencing/models/error.rb | =begin
#Video Conferencing Extension
#These APIs allow you to specify URLs that can be used to interact with a video conferencing application, to allow HubSpot to add video conference links to meeting requests with contacts.
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 Crm
module Extensions
module Videoconferencing
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::Crm::Extensions::Videoconferencing::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::Crm::Extensions::Videoconferencing::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::Crm::Extensions::Videoconferencing.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
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/crm/extensions/videoconferencing/api/settings_api.rb | lib/hubspot/codegen/crm/extensions/videoconferencing/api/settings_api.rb | =begin
#Video Conferencing Extension
#These APIs allow you to specify URLs that can be used to interact with a video conferencing application, to allow HubSpot to add video conference links to meeting requests with contacts.
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 Crm
module Extensions
module Videoconferencing
class SettingsApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Delete settings
# Deletes the settings for a video conference application with the specified ID.
# @param app_id [Integer] The ID of the video conference application. This is the identifier of the application created in your HubSpot developer portal.
# @param [Hash] opts the optional parameters
# @return [nil]
def archive(app_id, opts = {})
archive_with_http_info(app_id, opts)
nil
end
# Delete settings
# Deletes the settings for a video conference application with the specified ID.
# @param app_id [Integer] The ID of the video conference application. This is the identifier of the application created in your HubSpot developer portal.
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def archive_with_http_info(app_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: SettingsApi.archive ...'
end
# verify the required parameter 'app_id' is set
if @api_client.config.client_side_validation && app_id.nil?
fail ArgumentError, "Missing the required parameter 'app_id' when calling SettingsApi.archive"
end
# resource path
local_var_path = '/crm/v3/extensions/videoconferencing/settings/{appId}'.sub('{' + 'appId' + '}', CGI.escape(app_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(['*/*'])
# 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] || ['developer_hapikey']
new_options = opts.merge(
:operation => :"SettingsApi.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: SettingsApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get settings
# Return the settings for a video conference application with the specified ID.
# @param app_id [Integer] The ID of the video conference application. This is the identifier of the application created in your HubSpot developer portal.
# @param [Hash] opts the optional parameters
# @return [ExternalSettings]
def get_by_id(app_id, opts = {})
data, _status_code, _headers = get_by_id_with_http_info(app_id, opts)
data
end
# Get settings
# Return the settings for a video conference application with the specified ID.
# @param app_id [Integer] The ID of the video conference application. This is the identifier of the application created in your HubSpot developer portal.
# @param [Hash] opts the optional parameters
# @return [Array<(ExternalSettings, Integer, Hash)>] ExternalSettings data, response status code and response headers
def get_by_id_with_http_info(app_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: SettingsApi.get_by_id ...'
end
# verify the required parameter 'app_id' is set
if @api_client.config.client_side_validation && app_id.nil?
fail ArgumentError, "Missing the required parameter 'app_id' when calling SettingsApi.get_by_id"
end
# resource path
local_var_path = '/crm/v3/extensions/videoconferencing/settings/{appId}'.sub('{' + 'appId' + '}', CGI.escape(app_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] || 'ExternalSettings'
# auth_names
auth_names = opts[:debug_auth_names] || ['developer_hapikey']
new_options = opts.merge(
:operation => :"SettingsApi.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: SettingsApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Update settings
# Updates the settings for a video conference application with the specified ID.
# @param app_id [Integer] The ID of the video conference application. This is the identifier of the application created in your HubSpot developer portal.
# @param external_settings [ExternalSettings]
# @param [Hash] opts the optional parameters
# @return [ExternalSettings]
def replace(app_id, external_settings, opts = {})
data, _status_code, _headers = replace_with_http_info(app_id, external_settings, opts)
data
end
# Update settings
# Updates the settings for a video conference application with the specified ID.
# @param app_id [Integer] The ID of the video conference application. This is the identifier of the application created in your HubSpot developer portal.
# @param external_settings [ExternalSettings]
# @param [Hash] opts the optional parameters
# @return [Array<(ExternalSettings, Integer, Hash)>] ExternalSettings data, response status code and response headers
def replace_with_http_info(app_id, external_settings, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: SettingsApi.replace ...'
end
# verify the required parameter 'app_id' is set
if @api_client.config.client_side_validation && app_id.nil?
fail ArgumentError, "Missing the required parameter 'app_id' when calling SettingsApi.replace"
end
# verify the required parameter 'external_settings' is set
if @api_client.config.client_side_validation && external_settings.nil?
fail ArgumentError, "Missing the required parameter 'external_settings' when calling SettingsApi.replace"
end
# resource path
local_var_path = '/crm/v3/extensions/videoconferencing/settings/{appId}'.sub('{' + 'appId' + '}', CGI.escape(app_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(external_settings)
# return_type
return_type = opts[:debug_return_type] || 'ExternalSettings'
# auth_names
auth_names = opts[:debug_auth_names] || ['developer_hapikey']
new_options = opts.merge(
:operation => :"SettingsApi.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: SettingsApi#replace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
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/crm/extensions/cards/api_error.rb | lib/hubspot/codegen/crm/extensions/cards/api_error.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Crm
module Extensions
module Cards
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
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/crm/extensions/cards/configuration.rb | lib/hubspot/codegen/crm/extensions/cards/configuration.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Crm
module Extensions
module Cards
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')
},
}
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
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/crm/extensions/cards/api_client.rb | lib/hubspot/codegen/crm/extensions/cards/api_client.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/card_patch_request.rb | lib/hubspot/codegen/crm/extensions/cards/models/card_patch_request.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
# Body for a patch with optional fields
class CardPatchRequest
attr_accessor :fetch
attr_accessor :display
# The top-level title for this card. Displayed to users in the CRM UI.
attr_accessor :title
attr_accessor :actions
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'fetch' => :'fetch',
:'display' => :'display',
:'title' => :'title',
:'actions' => :'actions'
}
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
{
:'fetch' => :'CardFetchBodyPatch',
:'display' => :'CardDisplayBody',
:'title' => :'String',
:'actions' => :'CardActions'
}
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::Crm::Extensions::Cards::CardPatchRequest` 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::Crm::Extensions::Cards::CardPatchRequest`. 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?(:'fetch')
self.fetch = attributes[:'fetch']
end
if attributes.key?(:'display')
self.display = attributes[:'display']
end
if attributes.key?(:'title')
self.title = attributes[:'title']
end
if attributes.key?(:'actions')
self.actions = attributes[:'actions']
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 &&
fetch == o.fetch &&
display == o.display &&
title == o.title &&
actions == o.actions
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
[fetch, display, title, actions].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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/card_actions.rb | lib/hubspot/codegen/crm/extensions/cards/models/card_actions.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
# Configuration for custom user actions on cards.
class CardActions
# A list of URL prefixes that will be accepted for card action URLs. If your data fetch response includes an action URL that doesn't begin with one of these values, it will result in an error and the card will not be displayed.
attr_accessor :base_urls
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'base_urls' => :'baseUrls'
}
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
{
:'base_urls' => :'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::Crm::Extensions::Cards::CardActions` 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::Crm::Extensions::Cards::CardActions`. 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?(:'base_urls')
if (value = attributes[:'base_urls']).is_a?(Array)
self.base_urls = 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 @base_urls.nil?
invalid_properties.push('invalid value for "base_urls", base_urls 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 @base_urls.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 &&
base_urls == o.base_urls
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
[base_urls].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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/card_fetch_body.rb | lib/hubspot/codegen/crm/extensions/cards/models/card_fetch_body.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
# Configuration for this card's data fetch request.
class CardFetchBody
attr_accessor :serverless_function
attr_accessor :card_type
# An array of CRM object types where this card should be displayed. HubSpot will call your data fetch URL whenever a user visits a record page of the types defined here.
attr_accessor :object_types
# URL to a service endpoints that will respond with card details. HubSpot will call this endpoint each time a user visits a CRM record page where this card should be displayed.
attr_accessor :target_url
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
{
:'serverless_function' => :'serverlessFunction',
:'card_type' => :'cardType',
:'object_types' => :'objectTypes',
:'target_url' => :'targetUrl'
}
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
{
:'serverless_function' => :'String',
:'card_type' => :'String',
:'object_types' => :'Array<CardObjectTypeBody>',
:'target_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::Crm::Extensions::Cards::CardFetchBody` 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::Crm::Extensions::Cards::CardFetchBody`. 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?(:'serverless_function')
self.serverless_function = attributes[:'serverless_function']
end
if attributes.key?(:'card_type')
self.card_type = attributes[:'card_type']
end
if attributes.key?(:'object_types')
if (value = attributes[:'object_types']).is_a?(Array)
self.object_types = value
end
end
if attributes.key?(:'target_url')
self.target_url = attributes[:'target_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
if @object_types.nil?
invalid_properties.push('invalid value for "object_types", object_types cannot be nil.')
end
if @target_url.nil?
invalid_properties.push('invalid value for "target_url", target_url 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?
card_type_validator = EnumAttributeValidator.new('String', ["EXTERNAL", "SERVERLESS"])
return false unless card_type_validator.valid?(@card_type)
return false if @object_types.nil?
return false if @target_url.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] card_type Object to be assigned
def card_type=(card_type)
validator = EnumAttributeValidator.new('String', ["EXTERNAL", "SERVERLESS"])
unless validator.valid?(card_type)
fail ArgumentError, "invalid value for \"card_type\", must be one of #{validator.allowable_values}."
end
@card_type = card_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 &&
serverless_function == o.serverless_function &&
card_type == o.card_type &&
object_types == o.object_types &&
target_url == o.target_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
[serverless_function, card_type, object_types, target_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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/card_display_property.rb | lib/hubspot/codegen/crm/extensions/cards/models/card_display_property.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
# Definition for a card display property.
class CardDisplayProperty
# Type of data represented by this property.
attr_accessor :data_type
# An internal identifier for this property. This value must be unique TODO.
attr_accessor :name
# An array of available options that can be displayed. Only used in when `dataType` is `STATUS`.
attr_accessor :options
# The label for this property as you'd like it displayed to users.
attr_accessor :label
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
{
:'data_type' => :'dataType',
:'name' => :'name',
:'options' => :'options',
:'label' => :'label'
}
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
{
:'data_type' => :'String',
:'name' => :'String',
:'options' => :'Array<DisplayOption>',
:'label' => :'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::Crm::Extensions::Cards::CardDisplayProperty` 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::Crm::Extensions::Cards::CardDisplayProperty`. 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?(:'data_type')
self.data_type = attributes[:'data_type']
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?(:'label')
self.label = attributes[:'label']
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 @data_type.nil?
invalid_properties.push('invalid value for "data_type", data_type 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 @label.nil?
invalid_properties.push('invalid value for "label", label 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 @data_type.nil?
data_type_validator = EnumAttributeValidator.new('String', ["BOOLEAN", "CURRENCY", "DATE", "DATETIME", "EMAIL", "LINK", "NUMERIC", "STRING", "STATUS"])
return false unless data_type_validator.valid?(@data_type)
return false if @name.nil?
return false if @options.nil?
return false if @label.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] data_type Object to be assigned
def data_type=(data_type)
validator = EnumAttributeValidator.new('String', ["BOOLEAN", "CURRENCY", "DATE", "DATETIME", "EMAIL", "LINK", "NUMERIC", "STRING", "STATUS"])
unless validator.valid?(data_type)
fail ArgumentError, "invalid value for \"data_type\", must be one of #{validator.allowable_values}."
end
@data_type = data_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 &&
data_type == o.data_type &&
name == o.name &&
options == o.options &&
label == o.label
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
[data_type, name, options, label].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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/card_display_body.rb | lib/hubspot/codegen/crm/extensions/cards/models/card_display_body.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
# Configuration for displayed info on a card
class CardDisplayBody
# Card display properties. These will will be rendered as \"label : value\" pairs in the card UI. See the [example card](#) in the overview docs for more details.
attr_accessor :properties
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'properties' => :'properties'
}
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
{
:'properties' => :'Array<CardDisplayProperty>'
}
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::Crm::Extensions::Cards::CardDisplayBody` 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::Crm::Extensions::Cards::CardDisplayBody`. 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?(:'properties')
if (value = attributes[:'properties']).is_a?(Array)
self.properties = 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 @properties.nil?
invalid_properties.push('invalid value for "properties", properties 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 @properties.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 &&
properties == o.properties
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
[properties].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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/public_card_list_response.rb | lib/hubspot/codegen/crm/extensions/cards/models/public_card_list_response.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
class PublicCardListResponse
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'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
{
:'results' => :'Array<PublicCardResponse>'
}
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::Crm::Extensions::Cards::PublicCardListResponse` 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::Crm::Extensions::Cards::PublicCardListResponse`. 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?(:'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 &&
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
[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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/integrator_object_result_actions_inner.rb | lib/hubspot/codegen/crm/extensions/cards/models/integrator_object_result_actions_inner.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
module IntegratorObjectResultActionsInner
class << self
# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'ActionHookActionBody',
:'IFrameActionBody'
]
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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/card_object_type_body.rb | lib/hubspot/codegen/crm/extensions/cards/models/card_object_type_body.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
class CardObjectTypeBody
# A CRM object type where this card should be displayed.
attr_accessor :name
# An array of properties that should be sent to this card's target URL when the data fetch request is made. Must be valid properties for the corresponding CRM object type.
attr_accessor :properties_to_send
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
{
:'name' => :'name',
:'properties_to_send' => :'propertiesToSend'
}
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
{
:'name' => :'String',
:'properties_to_send' => :'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::Crm::Extensions::Cards::CardObjectTypeBody` 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::Crm::Extensions::Cards::CardObjectTypeBody`. 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?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'properties_to_send')
if (value = attributes[:'properties_to_send']).is_a?(Array)
self.properties_to_send = 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 @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @properties_to_send.nil?
invalid_properties.push('invalid value for "properties_to_send", properties_to_send 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 @name.nil?
name_validator = EnumAttributeValidator.new('String', ["contacts", "deals", "companies", "tickets", "marketing_events"])
return false unless name_validator.valid?(@name)
return false if @properties_to_send.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] name Object to be assigned
def name=(name)
validator = EnumAttributeValidator.new('String', ["contacts", "deals", "companies", "tickets", "marketing_events"])
unless validator.valid?(name)
fail ArgumentError, "invalid value for \"name\", must be one of #{validator.allowable_values}."
end
@name = name
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 &&
name == o.name &&
properties_to_send == o.properties_to_send
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
[name, properties_to_send].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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/error_detail.rb | lib/hubspot/codegen/crm/extensions/cards/models/error_detail.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
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::Crm::Extensions::Cards::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::Crm::Extensions::Cards::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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/card_audit_response.rb | lib/hubspot/codegen/crm/extensions/cards/models/card_audit_response.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
class CardAuditResponse
attr_accessor :action_type
attr_accessor :object_type_id
attr_accessor :auth_source
attr_accessor :changed_at
attr_accessor :application_id
attr_accessor :initiating_user_id
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
{
:'action_type' => :'actionType',
:'object_type_id' => :'objectTypeId',
:'auth_source' => :'authSource',
:'changed_at' => :'changedAt',
:'application_id' => :'applicationId',
:'initiating_user_id' => :'initiatingUserId'
}
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
{
:'action_type' => :'String',
:'object_type_id' => :'Integer',
:'auth_source' => :'String',
:'changed_at' => :'Integer',
:'application_id' => :'Integer',
:'initiating_user_id' => :'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::Crm::Extensions::Cards::CardAuditResponse` 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::Crm::Extensions::Cards::CardAuditResponse`. 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?(:'action_type')
self.action_type = attributes[:'action_type']
end
if attributes.key?(:'object_type_id')
self.object_type_id = attributes[:'object_type_id']
end
if attributes.key?(:'auth_source')
self.auth_source = attributes[:'auth_source']
end
if attributes.key?(:'changed_at')
self.changed_at = attributes[:'changed_at']
end
if attributes.key?(:'application_id')
self.application_id = attributes[:'application_id']
end
if attributes.key?(:'initiating_user_id')
self.initiating_user_id = attributes[:'initiating_user_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 @action_type.nil?
invalid_properties.push('invalid value for "action_type", action_type cannot be nil.')
end
if @object_type_id.nil?
invalid_properties.push('invalid value for "object_type_id", object_type_id cannot be nil.')
end
if @auth_source.nil?
invalid_properties.push('invalid value for "auth_source", auth_source cannot be nil.')
end
if @changed_at.nil?
invalid_properties.push('invalid value for "changed_at", changed_at cannot be nil.')
end
if @application_id.nil?
invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
end
if @initiating_user_id.nil?
invalid_properties.push('invalid value for "initiating_user_id", initiating_user_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 @action_type.nil?
action_type_validator = EnumAttributeValidator.new('String', ["CREATE", "UPDATE", "DELETE"])
return false unless action_type_validator.valid?(@action_type)
return false if @object_type_id.nil?
return false if @auth_source.nil?
auth_source_validator = EnumAttributeValidator.new('String', ["INTERNAL", "APP", "EXTERNAL"])
return false unless auth_source_validator.valid?(@auth_source)
return false if @changed_at.nil?
return false if @application_id.nil?
return false if @initiating_user_id.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] action_type Object to be assigned
def action_type=(action_type)
validator = EnumAttributeValidator.new('String', ["CREATE", "UPDATE", "DELETE"])
unless validator.valid?(action_type)
fail ArgumentError, "invalid value for \"action_type\", must be one of #{validator.allowable_values}."
end
@action_type = action_type
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] auth_source Object to be assigned
def auth_source=(auth_source)
validator = EnumAttributeValidator.new('String', ["INTERNAL", "APP", "EXTERNAL"])
unless validator.valid?(auth_source)
fail ArgumentError, "invalid value for \"auth_source\", must be one of #{validator.allowable_values}."
end
@auth_source = auth_source
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 &&
action_type == o.action_type &&
object_type_id == o.object_type_id &&
auth_source == o.auth_source &&
changed_at == o.changed_at &&
application_id == o.application_id &&
initiating_user_id == o.initiating_user_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
[action_type, object_type_id, auth_source, changed_at, application_id, initiating_user_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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/action_confirmation_body.rb | lib/hubspot/codegen/crm/extensions/cards/models/action_confirmation_body.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
class ActionConfirmationBody
attr_accessor :prompt
attr_accessor :confirm_button_label
attr_accessor :cancel_button_label
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'prompt' => :'prompt',
:'confirm_button_label' => :'confirmButtonLabel',
:'cancel_button_label' => :'cancelButtonLabel'
}
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
{
:'prompt' => :'String',
:'confirm_button_label' => :'String',
:'cancel_button_label' => :'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::Crm::Extensions::Cards::ActionConfirmationBody` 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::Crm::Extensions::Cards::ActionConfirmationBody`. 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?(:'prompt')
self.prompt = attributes[:'prompt']
end
if attributes.key?(:'confirm_button_label')
self.confirm_button_label = attributes[:'confirm_button_label']
end
if attributes.key?(:'cancel_button_label')
self.cancel_button_label = attributes[:'cancel_button_label']
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 @prompt.nil?
invalid_properties.push('invalid value for "prompt", prompt cannot be nil.')
end
if @confirm_button_label.nil?
invalid_properties.push('invalid value for "confirm_button_label", confirm_button_label cannot be nil.')
end
if @cancel_button_label.nil?
invalid_properties.push('invalid value for "cancel_button_label", cancel_button_label 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 @prompt.nil?
return false if @confirm_button_label.nil?
return false if @cancel_button_label.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 &&
prompt == o.prompt &&
confirm_button_label == o.confirm_button_label &&
cancel_button_label == o.cancel_button_label
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
[prompt, confirm_button_label, cancel_button_label].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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/card_fetch_body_patch.rb | lib/hubspot/codegen/crm/extensions/cards/models/card_fetch_body_patch.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
# Variant of CardFetchBody with fields as optional for patches
class CardFetchBodyPatch
attr_accessor :serverless_function
attr_accessor :card_type
# An array of CRM object types where this card should be displayed. HubSpot will call your target URL whenever a user visits a record page of the types defined here.
attr_accessor :object_types
# URL to a service endpoint that will respond with details for this card. HubSpot will call this endpoint each time a user visits a CRM record page where this card should be displayed.
attr_accessor :target_url
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
{
:'serverless_function' => :'serverlessFunction',
:'card_type' => :'cardType',
:'object_types' => :'objectTypes',
:'target_url' => :'targetUrl'
}
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
{
:'serverless_function' => :'String',
:'card_type' => :'String',
:'object_types' => :'Array<CardObjectTypeBody>',
:'target_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::Crm::Extensions::Cards::CardFetchBodyPatch` 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::Crm::Extensions::Cards::CardFetchBodyPatch`. 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?(:'serverless_function')
self.serverless_function = attributes[:'serverless_function']
end
if attributes.key?(:'card_type')
self.card_type = attributes[:'card_type']
end
if attributes.key?(:'object_types')
if (value = attributes[:'object_types']).is_a?(Array)
self.object_types = value
end
end
if attributes.key?(:'target_url')
self.target_url = attributes[:'target_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
if @object_types.nil?
invalid_properties.push('invalid value for "object_types", object_types 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?
card_type_validator = EnumAttributeValidator.new('String', ["EXTERNAL", "SERVERLESS"])
return false unless card_type_validator.valid?(@card_type)
return false if @object_types.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] card_type Object to be assigned
def card_type=(card_type)
validator = EnumAttributeValidator.new('String', ["EXTERNAL", "SERVERLESS"])
unless validator.valid?(card_type)
fail ArgumentError, "invalid value for \"card_type\", must be one of #{validator.allowable_values}."
end
@card_type = card_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 &&
serverless_function == o.serverless_function &&
card_type == o.card_type &&
object_types == o.object_types &&
target_url == o.target_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
[serverless_function, card_type, object_types, target_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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/integrator_object_result.rb | lib/hubspot/codegen/crm/extensions/cards/models/integrator_object_result.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
class IntegratorObjectResult
attr_accessor :link_url
attr_accessor :tokens
attr_accessor :id
attr_accessor :title
attr_accessor :actions
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'link_url' => :'linkUrl',
:'tokens' => :'tokens',
:'id' => :'id',
:'title' => :'title',
:'actions' => :'actions'
}
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_url' => :'String',
:'tokens' => :'Array<ObjectToken>',
:'id' => :'String',
:'title' => :'String',
:'actions' => :'Array<IntegratorObjectResultActionsInner>'
}
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::Crm::Extensions::Cards::IntegratorObjectResult` 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::Crm::Extensions::Cards::IntegratorObjectResult`. 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_url')
self.link_url = attributes[:'link_url']
end
if attributes.key?(:'tokens')
if (value = attributes[:'tokens']).is_a?(Array)
self.tokens = value
end
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'title')
self.title = attributes[:'title']
end
if attributes.key?(:'actions')
if (value = attributes[:'actions']).is_a?(Array)
self.actions = 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 @tokens.nil?
invalid_properties.push('invalid value for "tokens", tokens cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @title.nil?
invalid_properties.push('invalid value for "title", title cannot be nil.')
end
if @actions.nil?
invalid_properties.push('invalid value for "actions", actions 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 @tokens.nil?
return false if @id.nil?
return false if @title.nil?
return false if @actions.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_url == o.link_url &&
tokens == o.tokens &&
id == o.id &&
title == o.title &&
actions == o.actions
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_url, tokens, id, title, actions].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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/public_card_fetch_body.rb | lib/hubspot/codegen/crm/extensions/cards/models/public_card_fetch_body.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
class PublicCardFetchBody
attr_accessor :object_types
attr_accessor :target_url
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'object_types' => :'objectTypes',
:'target_url' => :'targetUrl'
}
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_types' => :'Array<CardObjectTypeBody>',
:'target_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::Crm::Extensions::Cards::PublicCardFetchBody` 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::Crm::Extensions::Cards::PublicCardFetchBody`. 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_types')
if (value = attributes[:'object_types']).is_a?(Array)
self.object_types = value
end
end
if attributes.key?(:'target_url')
self.target_url = attributes[:'target_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
if @object_types.nil?
invalid_properties.push('invalid value for "object_types", object_types cannot be nil.')
end
if @target_url.nil?
invalid_properties.push('invalid value for "target_url", target_url 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_types.nil?
return false if @target_url.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_types == o.object_types &&
target_url == o.target_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
[object_types, target_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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/card_create_request.rb | lib/hubspot/codegen/crm/extensions/cards/models/card_create_request.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
# State of card definition to be created
class CardCreateRequest
attr_accessor :fetch
attr_accessor :display
# The top-level title for this card. Displayed to users in the CRM UI.
attr_accessor :title
attr_accessor :actions
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'fetch' => :'fetch',
:'display' => :'display',
:'title' => :'title',
:'actions' => :'actions'
}
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
{
:'fetch' => :'CardFetchBody',
:'display' => :'CardDisplayBody',
:'title' => :'String',
:'actions' => :'CardActions'
}
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::Crm::Extensions::Cards::CardCreateRequest` 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::Crm::Extensions::Cards::CardCreateRequest`. 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?(:'fetch')
self.fetch = attributes[:'fetch']
end
if attributes.key?(:'display')
self.display = attributes[:'display']
end
if attributes.key?(:'title')
self.title = attributes[:'title']
end
if attributes.key?(:'actions')
self.actions = attributes[:'actions']
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 @fetch.nil?
invalid_properties.push('invalid value for "fetch", fetch cannot be nil.')
end
if @display.nil?
invalid_properties.push('invalid value for "display", display cannot be nil.')
end
if @title.nil?
invalid_properties.push('invalid value for "title", title cannot be nil.')
end
if @actions.nil?
invalid_properties.push('invalid value for "actions", actions 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 @fetch.nil?
return false if @display.nil?
return false if @title.nil?
return false if @actions.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 &&
fetch == o.fetch &&
display == o.display &&
title == o.title &&
actions == o.actions
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
[fetch, display, title, actions].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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/i_frame_action_body.rb | lib/hubspot/codegen/crm/extensions/cards/models/i_frame_action_body.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
class IFrameActionBody
attr_accessor :property_names_included
attr_accessor :width
attr_accessor :label
attr_accessor :type
attr_accessor :url
attr_accessor :height
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
{
:'property_names_included' => :'propertyNamesIncluded',
:'width' => :'width',
:'label' => :'label',
:'type' => :'type',
:'url' => :'url',
:'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
{
:'property_names_included' => :'Array<String>',
:'width' => :'Integer',
:'label' => :'String',
:'type' => :'String',
:'url' => :'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::Crm::Extensions::Cards::IFrameActionBody` 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::Crm::Extensions::Cards::IFrameActionBody`. 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?(:'property_names_included')
if (value = attributes[:'property_names_included']).is_a?(Array)
self.property_names_included = value
end
end
if attributes.key?(:'width')
self.width = attributes[:'width']
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'type')
self.type = attributes[:'type']
else
self.type = 'IFRAME'
end
if attributes.key?(:'url')
self.url = attributes[:'url']
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
if @property_names_included.nil?
invalid_properties.push('invalid value for "property_names_included", property_names_included cannot be nil.')
end
if @width.nil?
invalid_properties.push('invalid value for "width", width cannot be nil.')
end
if @type.nil?
invalid_properties.push('invalid value for "type", type cannot be nil.')
end
if @url.nil?
invalid_properties.push('invalid value for "url", url cannot be nil.')
end
if @height.nil?
invalid_properties.push('invalid value for "height", height 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 @property_names_included.nil?
return false if @width.nil?
return false if @type.nil?
type_validator = EnumAttributeValidator.new('String', ["IFRAME"])
return false unless type_validator.valid?(@type)
return false if @url.nil?
return false if @height.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', ["IFRAME"])
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 &&
property_names_included == o.property_names_included &&
width == o.width &&
label == o.label &&
type == o.type &&
url == o.url &&
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
[property_names_included, width, label, type, url, 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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/integrator_card_payload_response.rb | lib/hubspot/codegen/crm/extensions/cards/models/integrator_card_payload_response.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
# The card details payload, sent to HubSpot by an app in response to a data fetch request when a user visits a CRM record page.
class IntegratorCardPayloadResponse
attr_accessor :response_version
# The label to be used for the `allItemsLinkUrl` link (e.g. 'See more tickets'). If not provided, this falls back to the card's title.
attr_accessor :card_label
# URL to a page the integrator has built that displays all details for this card. This URL will be displayed to users under a `See more [x]` link if there are more than five items in your response, where `[x]` is the value of `itemLabel`.
attr_accessor :all_items_link_url
# The total number of card properties that will be sent in this response.
attr_accessor :total_count
attr_accessor :top_level_actions
# A list of up to five valid card sub categories.
attr_accessor :sections
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
{
:'response_version' => :'responseVersion',
:'card_label' => :'cardLabel',
:'all_items_link_url' => :'allItemsLinkUrl',
:'total_count' => :'totalCount',
:'top_level_actions' => :'topLevelActions',
:'sections' => :'sections'
}
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
{
:'response_version' => :'String',
:'card_label' => :'String',
:'all_items_link_url' => :'String',
:'total_count' => :'Integer',
:'top_level_actions' => :'TopLevelActions',
:'sections' => :'Array<IntegratorObjectResult>'
}
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::Crm::Extensions::Cards::IntegratorCardPayloadResponse` 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::Crm::Extensions::Cards::IntegratorCardPayloadResponse`. 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?(:'response_version')
self.response_version = attributes[:'response_version']
end
if attributes.key?(:'card_label')
self.card_label = attributes[:'card_label']
end
if attributes.key?(:'all_items_link_url')
self.all_items_link_url = attributes[:'all_items_link_url']
end
if attributes.key?(:'total_count')
self.total_count = attributes[:'total_count']
end
if attributes.key?(:'top_level_actions')
self.top_level_actions = attributes[:'top_level_actions']
end
if attributes.key?(:'sections')
if (value = attributes[:'sections']).is_a?(Array)
self.sections = 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_count.nil?
invalid_properties.push('invalid value for "total_count", total_count 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?
response_version_validator = EnumAttributeValidator.new('String', ["v1", "v3"])
return false unless response_version_validator.valid?(@response_version)
return false if @total_count.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] response_version Object to be assigned
def response_version=(response_version)
validator = EnumAttributeValidator.new('String', ["v1", "v3"])
unless validator.valid?(response_version)
fail ArgumentError, "invalid value for \"response_version\", must be one of #{validator.allowable_values}."
end
@response_version = response_version
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 &&
response_version == o.response_version &&
card_label == o.card_label &&
all_items_link_url == o.all_items_link_url &&
total_count == o.total_count &&
top_level_actions == o.top_level_actions &&
sections == o.sections
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
[response_version, card_label, all_items_link_url, total_count, top_level_actions, sections].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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/top_level_actions.rb | lib/hubspot/codegen/crm/extensions/cards/models/top_level_actions.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
class TopLevelActions
attr_accessor :secondary
attr_accessor :settings
attr_accessor :primary
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'secondary' => :'secondary',
:'settings' => :'settings',
:'primary' => :'primary'
}
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
{
:'secondary' => :'Array<IntegratorObjectResultActionsInner>',
:'settings' => :'IFrameActionBody',
:'primary' => :'IntegratorObjectResultActionsInner'
}
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::Crm::Extensions::Cards::TopLevelActions` 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::Crm::Extensions::Cards::TopLevelActions`. 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?(:'secondary')
if (value = attributes[:'secondary']).is_a?(Array)
self.secondary = value
end
end
if attributes.key?(:'settings')
self.settings = attributes[:'settings']
end
if attributes.key?(:'primary')
self.primary = attributes[:'primary']
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 @secondary.nil?
invalid_properties.push('invalid value for "secondary", secondary 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 @secondary.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 &&
secondary == o.secondary &&
settings == o.settings &&
primary == o.primary
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
[secondary, settings, primary].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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/display_option.rb | lib/hubspot/codegen/crm/extensions/cards/models/display_option.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
# Option definition for STATUS dataTypes.
class DisplayOption
# JSON-friendly unique name for option.
attr_accessor :name
# The text that will be displayed to users for this option.
attr_accessor :label
# The type of status.
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
{
:'name' => :'name',
:'label' => :'label',
:'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
{
:'name' => :'String',
:'label' => :'String',
:'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::Crm::Extensions::Cards::DisplayOption` 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::Crm::Extensions::Cards::DisplayOption`. 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?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'type')
self.type = attributes[:'type']
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
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
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 @name.nil?
return false if @label.nil?
return false if @type.nil?
type_validator = EnumAttributeValidator.new('String', ["DEFAULT", "SUCCESS", "WARNING", "DANGER", "INFO"])
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', ["DEFAULT", "SUCCESS", "WARNING", "DANGER", "INFO"])
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 &&
name == o.name &&
label == o.label &&
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
[name, label, 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::Crm::Extensions::Cards.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
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/crm/extensions/cards/models/object_token.rb | lib/hubspot/codegen/crm/extensions/cards/models/object_token.rb | =begin
#Public App Crm Cards
#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.
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 Crm
module Extensions
module Cards
class ObjectToken
attr_accessor :data_type
attr_accessor :name
attr_accessor :label
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
{
:'data_type' => :'dataType',
:'name' => :'name',
:'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
{
:'data_type' => :'String',
:'name' => :'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::Crm::Extensions::Cards::ObjectToken` 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::Crm::Extensions::Cards::ObjectToken`. 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?(:'data_type')
self.data_type = attributes[:'data_type']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
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 @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?
data_type_validator = EnumAttributeValidator.new('String', ["BOOLEAN", "CURRENCY", "DATE", "DATETIME", "EMAIL", "LINK", "NUMERIC", "STRING", "STATUS"])
return false unless data_type_validator.valid?(@data_type)
return false if @value.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] data_type Object to be assigned
def data_type=(data_type)
validator = EnumAttributeValidator.new('String', ["BOOLEAN", "CURRENCY", "DATE", "DATETIME", "EMAIL", "LINK", "NUMERIC", "STRING", "STATUS"])
unless validator.valid?(data_type)
fail ArgumentError, "invalid value for \"data_type\", must be one of #{validator.allowable_values}."
end
@data_type = data_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 &&
data_type == o.data_type &&
name == o.name &&
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
[data_type, name, 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::Crm::Extensions::Cards.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
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.