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/automation/actions/models/public_action_definition_input_field_dependencies_inner.rb
lib/hubspot/codegen/automation/actions/models/public_action_definition_input_field_dependencies_inner.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions module PublicActionDefinitionInputFieldDependenciesInner class << self # List of class defined in oneOf (OpenAPI v3) def openapi_one_of [ :'PublicConditionalSingleFieldDependency', :'PublicSingleFieldDependency' ] 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::Automation::Actions.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/automation/actions/models/public_action_revision.rb
lib/hubspot/codegen/automation/actions/models/public_action_revision.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class PublicActionRevision attr_accessor :revision_id attr_accessor :created_at attr_accessor :definition attr_accessor :id # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'revision_id' => :'revisionId', :'created_at' => :'createdAt', :'definition' => :'definition', :'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 { :'revision_id' => :'String', :'created_at' => :'Time', :'definition' => :'PublicActionDefinition', :'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::Automation::Actions::PublicActionRevision` 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::Automation::Actions::PublicActionRevision`. 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?(:'revision_id') self.revision_id = attributes[:'revision_id'] end if attributes.key?(:'created_at') self.created_at = attributes[:'created_at'] end if attributes.key?(:'definition') self.definition = attributes[:'definition'] end if attributes.key?(:'id') self.id = attributes[:'id'] end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new if @revision_id.nil? invalid_properties.push('invalid value for "revision_id", revision_id cannot be nil.') end if @created_at.nil? invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') end if @definition.nil? invalid_properties.push('invalid value for "definition", definition cannot be nil.') end 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 @revision_id.nil? return false if @created_at.nil? return false if @definition.nil? 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 && revision_id == o.revision_id && created_at == o.created_at && definition == o.definition && 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 [revision_id, created_at, definition, 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::Automation::Actions.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/automation/actions/models/public_object_request_options.rb
lib/hubspot/codegen/automation/actions/models/public_object_request_options.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class PublicObjectRequestOptions 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<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::Automation::Actions::PublicObjectRequestOptions` 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::Automation::Actions::PublicObjectRequestOptions`. 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::Automation::Actions.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/automation/actions/models/error_detail.rb
lib/hubspot/codegen/automation/actions/models/error_detail.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions 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::Automation::Actions::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::Automation::Actions::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::Automation::Actions.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/automation/actions/models/callback_completion_request.rb
lib/hubspot/codegen/automation/actions/models/callback_completion_request.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class CallbackCompletionRequest attr_accessor :output_fields # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'output_fields' => :'outputFields' } 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 { :'output_fields' => :'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::Automation::Actions::CallbackCompletionRequest` 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::Automation::Actions::CallbackCompletionRequest`. 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?(:'output_fields') if (value = attributes[:'output_fields']).is_a?(Hash) self.output_fields = value end end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new if @output_fields.nil? invalid_properties.push('invalid value for "output_fields", output_fields cannot be nil.') end invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? return false if @output_fields.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 && output_fields == o.output_fields end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash [output_fields].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) new.build_from_hash(attributes) end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end # Deserializes the data based on type # @param string type Data type # @param string value Value to be deserialized # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = Hubspot::Automation::Actions.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/automation/actions/models/collection_response_public_action_definition_forward_paging.rb
lib/hubspot/codegen/automation/actions/models/collection_response_public_action_definition_forward_paging.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class CollectionResponsePublicActionDefinitionForwardPaging 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<PublicActionDefinition>' } 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::Automation::Actions::CollectionResponsePublicActionDefinitionForwardPaging` 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::Automation::Actions::CollectionResponsePublicActionDefinitionForwardPaging`. 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::Automation::Actions.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/automation/actions/models/field_type_definition.rb
lib/hubspot/codegen/automation/actions/models/field_type_definition.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class FieldTypeDefinition attr_accessor :help_text attr_accessor :referenced_object_type attr_accessor :name attr_accessor :options attr_accessor :description attr_accessor :external_options_reference_type attr_accessor :label attr_accessor :type attr_accessor :field_type attr_accessor :options_url attr_accessor :external_options class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values def initialize(datatype, allowable_values) @allowable_values = allowable_values.map do |value| case datatype.to_s when /Integer/i value.to_i when /Float/i value.to_f else value end end end def valid?(value) !value || allowable_values.include?(value) end end # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'help_text' => :'helpText', :'referenced_object_type' => :'referencedObjectType', :'name' => :'name', :'options' => :'options', :'description' => :'description', :'external_options_reference_type' => :'externalOptionsReferenceType', :'label' => :'label', :'type' => :'type', :'field_type' => :'fieldType', :'options_url' => :'optionsUrl', :'external_options' => :'externalOptions' } 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 { :'help_text' => :'String', :'referenced_object_type' => :'String', :'name' => :'String', :'options' => :'Array<Option>', :'description' => :'String', :'external_options_reference_type' => :'String', :'label' => :'String', :'type' => :'String', :'field_type' => :'String', :'options_url' => :'String', :'external_options' => :'Boolean' } end # List of attributes with nullable: true def self.openapi_nullable Set.new([ ]) end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Automation::Actions::FieldTypeDefinition` 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::Automation::Actions::FieldTypeDefinition`. 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?(:'help_text') self.help_text = attributes[:'help_text'] end if attributes.key?(:'referenced_object_type') self.referenced_object_type = attributes[:'referenced_object_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?(:'description') self.description = attributes[:'description'] end if attributes.key?(:'external_options_reference_type') self.external_options_reference_type = attributes[:'external_options_reference_type'] end if attributes.key?(:'label') self.label = attributes[:'label'] end if attributes.key?(:'type') self.type = attributes[:'type'] end if attributes.key?(:'field_type') self.field_type = attributes[:'field_type'] end if attributes.key?(:'options_url') self.options_url = attributes[:'options_url'] end if attributes.key?(:'external_options') self.external_options = attributes[:'external_options'] end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new if @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 @type.nil? invalid_properties.push('invalid value for "type", type cannot be nil.') end if @external_options.nil? invalid_properties.push('invalid value for "external_options", external_options cannot be nil.') end invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? referenced_object_type_validator = EnumAttributeValidator.new('String', ["CONTACT", "COMPANY", "DEAL", "ENGAGEMENT", "TICKET", "OWNER", "PRODUCT", "LINE_ITEM", "BET_DELIVERABLE_SERVICE", "CONTENT", "CONVERSATION", "BET_ALERT", "PORTAL", "QUOTE", "FORM_SUBMISSION_INBOUNDDB", "QUOTA", "UNSUBSCRIBE", "COMMUNICATION", "FEEDBACK_SUBMISSION", "ATTRIBUTION", "SALESFORCE_SYNC_ERROR", "RESTORABLE_CRM_OBJECT", "HUB", "LANDING_PAGE", "PRODUCT_OR_FOLDER", "TASK", "FORM", "MARKETING_EMAIL", "AD_ACCOUNT", "AD_CAMPAIGN", "AD_GROUP", "AD", "KEYWORD", "CAMPAIGN", "SOCIAL_CHANNEL", "SOCIAL_POST", "SITE_PAGE", "BLOG_POST", "IMPORT", "EXPORT", "CTA", "TASK_TEMPLATE", "AUTOMATION_PLATFORM_FLOW", "OBJECT_LIST", "NOTE", "MEETING_EVENT", "CALL", "EMAIL", "PUBLISHING_TASK", "CONVERSATION_SESSION", "CONTACT_CREATE_ATTRIBUTION", "INVOICE", "MARKETING_EVENT", "CONVERSATION_INBOX", "CHATFLOW", "MEDIA_BRIDGE", "SEQUENCE", "SEQUENCE_STEP", "FORECAST", "SNIPPET", "TEMPLATE", "DEAL_CREATE_ATTRIBUTION", "QUOTE_TEMPLATE", "QUOTE_MODULE", "QUOTE_MODULE_FIELD", "QUOTE_FIELD", "SEQUENCE_ENROLLMENT", "SUBSCRIPTION", "ACCEPTANCE_TEST", "SOCIAL_BROADCAST", "DEAL_SPLIT", "DEAL_REGISTRATION", "GOAL_TARGET", "GOAL_TARGET_GROUP", "PORTAL_OBJECT_SYNC_MESSAGE", "FILE_MANAGER_FILE", "FILE_MANAGER_FOLDER", "SEQUENCE_STEP_ENROLLMENT", "APPROVAL", "APPROVAL_STEP", "CTA_VARIANT", "SALES_DOCUMENT", "DISCOUNT", "FEE", "TAX", "MARKETING_CALENDAR", "PERMISSIONS_TESTING", "PRIVACY_SCANNER_COOKIE", "DATA_SYNC_STATE", "WEB_INTERACTIVE", "PLAYBOOK", "FOLDER", "PLAYBOOK_QUESTION", "PLAYBOOK_SUBMISSION", "PLAYBOOK_SUBMISSION_ANSWER", "COMMERCE_PAYMENT", "GSC_PROPERTY", "SOX_PROTECTED_DUMMY_TYPE", "BLOG_LISTING_PAGE", "QUARANTINED_SUBMISSION", "PAYMENT_SCHEDULE", "PAYMENT_SCHEDULE_INSTALLMENT", "MARKETING_CAMPAIGN_UTM", "DISCOUNT_TEMPLATE", "DISCOUNT_CODE", "FEEDBACK_SURVEY", "CMS_URL", "SALES_TASK", "SALES_WORKLOAD", "USER", "POSTAL_MAIL", "SCHEMAS_BACKEND_TEST", "PAYMENT_LINK", "SUBMISSION_TAG", "CAMPAIGN_STEP", "SCHEDULING_PAGE", "SOX_PROTECTED_TEST_TYPE", "ORDER", "MARKETING_SMS", "PARTNER_ACCOUNT", "CAMPAIGN_TEMPLATE", "CAMPAIGN_TEMPLATE_STEP", "PLAYLIST", "CLIP", "CAMPAIGN_BUDGET_ITEM", "CAMPAIGN_SPEND_ITEM", "MIC", "CONTENT_AUDIT", "CONTENT_AUDIT_PAGE", "PLAYLIST_FOLDER", "LEAD", "ABANDONED_CART", "EXTERNAL_WEB_URL", "VIEW", "VIEW_BLOCK", "ROSTER", "CART", "AUTOMATION_PLATFORM_FLOW_ACTION", "SOCIAL_PROFILE", "PARTNER_CLIENT", "ROSTER_MEMBER", "MARKETING_EVENT_ATTENDANCE", "ALL_PAGES", "AI_FORECAST", "CRM_PIPELINES_DUMMY_TYPE", "KNOWLEDGE_ARTICLE", "PROPERTY_INFO", "DATA_PRIVACY_CONSENT", "GOAL_TEMPLATE", "SCORE_CONFIGURATION", "AUDIENCE", "PARTNER_CLIENT_REVENUE", "AUTOMATION_JOURNEY", "UNKNOWN"]) return false unless referenced_object_type_validator.valid?(@referenced_object_type) return false if @name.nil? return false if @options.nil? return false if @type.nil? type_validator = EnumAttributeValidator.new('String', ["string", "number", "bool", "datetime", "enumeration", "date", "phone_number", "currency_number", "json", "object_coordinates"]) return false unless type_validator.valid?(@type) field_type_validator = EnumAttributeValidator.new('String', ["booleancheckbox", "checkbox", "date", "file", "number", "phonenumber", "radio", "select", "text", "textarea", "calculation_equation", "calculation_rollup", "calculation_score", "calculation_read_time", "unknown", "html"]) return false unless field_type_validator.valid?(@field_type) return false if @external_options.nil? true end # Custom attribute writer method checking allowed values (enum). # @param [Object] referenced_object_type Object to be assigned def referenced_object_type=(referenced_object_type) validator = EnumAttributeValidator.new('String', ["CONTACT", "COMPANY", "DEAL", "ENGAGEMENT", "TICKET", "OWNER", "PRODUCT", "LINE_ITEM", "BET_DELIVERABLE_SERVICE", "CONTENT", "CONVERSATION", "BET_ALERT", "PORTAL", "QUOTE", "FORM_SUBMISSION_INBOUNDDB", "QUOTA", "UNSUBSCRIBE", "COMMUNICATION", "FEEDBACK_SUBMISSION", "ATTRIBUTION", "SALESFORCE_SYNC_ERROR", "RESTORABLE_CRM_OBJECT", "HUB", "LANDING_PAGE", "PRODUCT_OR_FOLDER", "TASK", "FORM", "MARKETING_EMAIL", "AD_ACCOUNT", "AD_CAMPAIGN", "AD_GROUP", "AD", "KEYWORD", "CAMPAIGN", "SOCIAL_CHANNEL", "SOCIAL_POST", "SITE_PAGE", "BLOG_POST", "IMPORT", "EXPORT", "CTA", "TASK_TEMPLATE", "AUTOMATION_PLATFORM_FLOW", "OBJECT_LIST", "NOTE", "MEETING_EVENT", "CALL", "EMAIL", "PUBLISHING_TASK", "CONVERSATION_SESSION", "CONTACT_CREATE_ATTRIBUTION", "INVOICE", "MARKETING_EVENT", "CONVERSATION_INBOX", "CHATFLOW", "MEDIA_BRIDGE", "SEQUENCE", "SEQUENCE_STEP", "FORECAST", "SNIPPET", "TEMPLATE", "DEAL_CREATE_ATTRIBUTION", "QUOTE_TEMPLATE", "QUOTE_MODULE", "QUOTE_MODULE_FIELD", "QUOTE_FIELD", "SEQUENCE_ENROLLMENT", "SUBSCRIPTION", "ACCEPTANCE_TEST", "SOCIAL_BROADCAST", "DEAL_SPLIT", "DEAL_REGISTRATION", "GOAL_TARGET", "GOAL_TARGET_GROUP", "PORTAL_OBJECT_SYNC_MESSAGE", "FILE_MANAGER_FILE", "FILE_MANAGER_FOLDER", "SEQUENCE_STEP_ENROLLMENT", "APPROVAL", "APPROVAL_STEP", "CTA_VARIANT", "SALES_DOCUMENT", "DISCOUNT", "FEE", "TAX", "MARKETING_CALENDAR", "PERMISSIONS_TESTING", "PRIVACY_SCANNER_COOKIE", "DATA_SYNC_STATE", "WEB_INTERACTIVE", "PLAYBOOK", "FOLDER", "PLAYBOOK_QUESTION", "PLAYBOOK_SUBMISSION", "PLAYBOOK_SUBMISSION_ANSWER", "COMMERCE_PAYMENT", "GSC_PROPERTY", "SOX_PROTECTED_DUMMY_TYPE", "BLOG_LISTING_PAGE", "QUARANTINED_SUBMISSION", "PAYMENT_SCHEDULE", "PAYMENT_SCHEDULE_INSTALLMENT", "MARKETING_CAMPAIGN_UTM", "DISCOUNT_TEMPLATE", "DISCOUNT_CODE", "FEEDBACK_SURVEY", "CMS_URL", "SALES_TASK", "SALES_WORKLOAD", "USER", "POSTAL_MAIL", "SCHEMAS_BACKEND_TEST", "PAYMENT_LINK", "SUBMISSION_TAG", "CAMPAIGN_STEP", "SCHEDULING_PAGE", "SOX_PROTECTED_TEST_TYPE", "ORDER", "MARKETING_SMS", "PARTNER_ACCOUNT", "CAMPAIGN_TEMPLATE", "CAMPAIGN_TEMPLATE_STEP", "PLAYLIST", "CLIP", "CAMPAIGN_BUDGET_ITEM", "CAMPAIGN_SPEND_ITEM", "MIC", "CONTENT_AUDIT", "CONTENT_AUDIT_PAGE", "PLAYLIST_FOLDER", "LEAD", "ABANDONED_CART", "EXTERNAL_WEB_URL", "VIEW", "VIEW_BLOCK", "ROSTER", "CART", "AUTOMATION_PLATFORM_FLOW_ACTION", "SOCIAL_PROFILE", "PARTNER_CLIENT", "ROSTER_MEMBER", "MARKETING_EVENT_ATTENDANCE", "ALL_PAGES", "AI_FORECAST", "CRM_PIPELINES_DUMMY_TYPE", "KNOWLEDGE_ARTICLE", "PROPERTY_INFO", "DATA_PRIVACY_CONSENT", "GOAL_TEMPLATE", "SCORE_CONFIGURATION", "AUDIENCE", "PARTNER_CLIENT_REVENUE", "AUTOMATION_JOURNEY", "UNKNOWN"]) unless validator.valid?(referenced_object_type) fail ArgumentError, "invalid value for \"referenced_object_type\", must be one of #{validator.allowable_values}." end @referenced_object_type = referenced_object_type end # Custom attribute writer method checking allowed values (enum). # @param [Object] type Object to be assigned def type=(type) validator = EnumAttributeValidator.new('String', ["string", "number", "bool", "datetime", "enumeration", "date", "phone_number", "currency_number", "json", "object_coordinates"]) unless validator.valid?(type) fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." end @type = type end # Custom attribute writer method checking allowed values (enum). # @param [Object] field_type Object to be assigned def field_type=(field_type) validator = EnumAttributeValidator.new('String', ["booleancheckbox", "checkbox", "date", "file", "number", "phonenumber", "radio", "select", "text", "textarea", "calculation_equation", "calculation_rollup", "calculation_score", "calculation_read_time", "unknown", "html"]) unless validator.valid?(field_type) fail ArgumentError, "invalid value for \"field_type\", must be one of #{validator.allowable_values}." end @field_type = field_type end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && help_text == o.help_text && referenced_object_type == o.referenced_object_type && name == o.name && options == o.options && description == o.description && external_options_reference_type == o.external_options_reference_type && label == o.label && type == o.type && field_type == o.field_type && options_url == o.options_url && external_options == o.external_options end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash [help_text, referenced_object_type, name, options, description, external_options_reference_type, label, type, field_type, options_url, external_options].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) new.build_from_hash(attributes) end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end # Deserializes the data based on type # @param string type Data type # @param string value Value to be deserialized # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = Hubspot::Automation::Actions.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/automation/actions/models/option.rb
lib/hubspot/codegen/automation/actions/models/option.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class Option attr_accessor :hidden attr_accessor :display_order attr_accessor :double_data attr_accessor :description attr_accessor :read_only attr_accessor :label attr_accessor :value # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'hidden' => :'hidden', :'display_order' => :'displayOrder', :'double_data' => :'doubleData', :'description' => :'description', :'read_only' => :'readOnly', :'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 { :'hidden' => :'Boolean', :'display_order' => :'Integer', :'double_data' => :'Float', :'description' => :'String', :'read_only' => :'Boolean', :'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::Automation::Actions::Option` 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::Automation::Actions::Option`. 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?(:'hidden') self.hidden = attributes[:'hidden'] end if attributes.key?(:'display_order') self.display_order = attributes[:'display_order'] end if attributes.key?(:'double_data') self.double_data = attributes[:'double_data'] end if attributes.key?(:'description') self.description = attributes[:'description'] end if attributes.key?(:'read_only') self.read_only = attributes[:'read_only'] 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 @hidden.nil? invalid_properties.push('invalid value for "hidden", hidden cannot be nil.') end if @display_order.nil? invalid_properties.push('invalid value for "display_order", display_order cannot be nil.') end if @double_data.nil? invalid_properties.push('invalid value for "double_data", double_data cannot be nil.') end if @description.nil? invalid_properties.push('invalid value for "description", description cannot be nil.') end if @read_only.nil? invalid_properties.push('invalid value for "read_only", read_only cannot be nil.') end if @label.nil? invalid_properties.push('invalid value for "label", label cannot be nil.') end if @value.nil? invalid_properties.push('invalid value for "value", value cannot be nil.') end invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? return false if @hidden.nil? return false if @display_order.nil? return false if @double_data.nil? return false if @description.nil? return false if @read_only.nil? return false if @label.nil? return false if @value.nil? true end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && hidden == o.hidden && display_order == o.display_order && double_data == o.double_data && description == o.description && read_only == o.read_only && 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 [hidden, display_order, double_data, description, read_only, 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::Automation::Actions.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/automation/actions/models/public_action_labels.rb
lib/hubspot/codegen/automation/actions/models/public_action_labels.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class PublicActionLabels attr_accessor :input_field_descriptions attr_accessor :app_display_name attr_accessor :output_field_labels attr_accessor :input_field_option_labels attr_accessor :action_description attr_accessor :execution_rules attr_accessor :input_field_labels attr_accessor :action_name attr_accessor :action_card_content # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'input_field_descriptions' => :'inputFieldDescriptions', :'app_display_name' => :'appDisplayName', :'output_field_labels' => :'outputFieldLabels', :'input_field_option_labels' => :'inputFieldOptionLabels', :'action_description' => :'actionDescription', :'execution_rules' => :'executionRules', :'input_field_labels' => :'inputFieldLabels', :'action_name' => :'actionName', :'action_card_content' => :'actionCardContent' } 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 { :'input_field_descriptions' => :'Hash<String, String>', :'app_display_name' => :'String', :'output_field_labels' => :'Hash<String, String>', :'input_field_option_labels' => :'Hash<String, Hash<String, String>>', :'action_description' => :'String', :'execution_rules' => :'Hash<String, String>', :'input_field_labels' => :'Hash<String, String>', :'action_name' => :'String', :'action_card_content' => :'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::Automation::Actions::PublicActionLabels` 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::Automation::Actions::PublicActionLabels`. 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?(:'input_field_descriptions') if (value = attributes[:'input_field_descriptions']).is_a?(Hash) self.input_field_descriptions = value end end if attributes.key?(:'app_display_name') self.app_display_name = attributes[:'app_display_name'] end if attributes.key?(:'output_field_labels') if (value = attributes[:'output_field_labels']).is_a?(Hash) self.output_field_labels = value end end if attributes.key?(:'input_field_option_labels') if (value = attributes[:'input_field_option_labels']).is_a?(Hash) self.input_field_option_labels = value end end if attributes.key?(:'action_description') self.action_description = attributes[:'action_description'] end if attributes.key?(:'execution_rules') if (value = attributes[:'execution_rules']).is_a?(Hash) self.execution_rules = value end end if attributes.key?(:'input_field_labels') if (value = attributes[:'input_field_labels']).is_a?(Hash) self.input_field_labels = value end end if attributes.key?(:'action_name') self.action_name = attributes[:'action_name'] end if attributes.key?(:'action_card_content') self.action_card_content = attributes[:'action_card_content'] 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_name.nil? invalid_properties.push('invalid value for "action_name", action_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 @action_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 && input_field_descriptions == o.input_field_descriptions && app_display_name == o.app_display_name && output_field_labels == o.output_field_labels && input_field_option_labels == o.input_field_option_labels && action_description == o.action_description && execution_rules == o.execution_rules && input_field_labels == o.input_field_labels && action_name == o.action_name && action_card_content == o.action_card_content 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 [input_field_descriptions, app_display_name, output_field_labels, input_field_option_labels, action_description, execution_rules, input_field_labels, action_name, action_card_content].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::Automation::Actions.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/automation/actions/models/forward_paging.rb
lib/hubspot/codegen/automation/actions/models/forward_paging.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions 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::Automation::Actions::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::Automation::Actions::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::Automation::Actions.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/automation/actions/models/output_field_definition.rb
lib/hubspot/codegen/automation/actions/models/output_field_definition.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class OutputFieldDefinition attr_accessor :type_definition # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'type_definition' => :'typeDefinition' } end # Returns all the JSON keys this model knows about def self.acceptable_attributes attribute_map.values end # Attribute type mapping. def self.openapi_types { :'type_definition' => :'FieldTypeDefinition' } 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::Automation::Actions::OutputFieldDefinition` 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::Automation::Actions::OutputFieldDefinition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'type_definition') self.type_definition = attributes[:'type_definition'] end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new if @type_definition.nil? invalid_properties.push('invalid value for "type_definition", type_definition cannot be nil.') end invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? return false if @type_definition.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 && type_definition == o.type_definition end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash [type_definition].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::Automation::Actions.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/automation/actions/models/batch_input_callback_completion_batch_request.rb
lib/hubspot/codegen/automation/actions/models/batch_input_callback_completion_batch_request.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class BatchInputCallbackCompletionBatchRequest 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<CallbackCompletionBatchRequest>' } 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::Automation::Actions::BatchInputCallbackCompletionBatchRequest` 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::Automation::Actions::BatchInputCallbackCompletionBatchRequest`. 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::Automation::Actions.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/automation/actions/models/public_single_field_dependency.rb
lib/hubspot/codegen/automation/actions/models/public_single_field_dependency.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class PublicSingleFieldDependency attr_accessor :dependency_type attr_accessor :dependent_field_names attr_accessor :controlling_field_name 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 { :'dependency_type' => :'dependencyType', :'dependent_field_names' => :'dependentFieldNames', :'controlling_field_name' => :'controllingFieldName' } 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 { :'dependency_type' => :'String', :'dependent_field_names' => :'Array<String>', :'controlling_field_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::Automation::Actions::PublicSingleFieldDependency` 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::Automation::Actions::PublicSingleFieldDependency`. 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?(:'dependency_type') self.dependency_type = attributes[:'dependency_type'] else self.dependency_type = 'SINGLE_FIELD' end if attributes.key?(:'dependent_field_names') if (value = attributes[:'dependent_field_names']).is_a?(Array) self.dependent_field_names = value end end if attributes.key?(:'controlling_field_name') self.controlling_field_name = attributes[:'controlling_field_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 @dependency_type.nil? invalid_properties.push('invalid value for "dependency_type", dependency_type cannot be nil.') end if @dependent_field_names.nil? invalid_properties.push('invalid value for "dependent_field_names", dependent_field_names cannot be nil.') end if @controlling_field_name.nil? invalid_properties.push('invalid value for "controlling_field_name", controlling_field_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 @dependency_type.nil? dependency_type_validator = EnumAttributeValidator.new('String', ["SINGLE_FIELD"]) return false unless dependency_type_validator.valid?(@dependency_type) return false if @dependent_field_names.nil? return false if @controlling_field_name.nil? true end # Custom attribute writer method checking allowed values (enum). # @param [Object] dependency_type Object to be assigned def dependency_type=(dependency_type) validator = EnumAttributeValidator.new('String', ["SINGLE_FIELD"]) unless validator.valid?(dependency_type) fail ArgumentError, "invalid value for \"dependency_type\", must be one of #{validator.allowable_values}." end @dependency_type = dependency_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 && dependency_type == o.dependency_type && dependent_field_names == o.dependent_field_names && controlling_field_name == o.controlling_field_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 [dependency_type, dependent_field_names, controlling_field_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::Automation::Actions.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/automation/actions/models/callback_completion_batch_request.rb
lib/hubspot/codegen/automation/actions/models/callback_completion_batch_request.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class CallbackCompletionBatchRequest attr_accessor :output_fields attr_accessor :callback_id # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'output_fields' => :'outputFields', :'callback_id' => :'callbackId' } 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 { :'output_fields' => :'Hash<String, String>', :'callback_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::Automation::Actions::CallbackCompletionBatchRequest` 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::Automation::Actions::CallbackCompletionBatchRequest`. 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?(:'output_fields') if (value = attributes[:'output_fields']).is_a?(Hash) self.output_fields = value end end if attributes.key?(:'callback_id') self.callback_id = attributes[:'callback_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 @output_fields.nil? invalid_properties.push('invalid value for "output_fields", output_fields cannot be nil.') end if @callback_id.nil? invalid_properties.push('invalid value for "callback_id", callback_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 @output_fields.nil? return false if @callback_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 && output_fields == o.output_fields && callback_id == o.callback_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 [output_fields, callback_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::Automation::Actions.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/automation/actions/models/public_execution_translation_rule.rb
lib/hubspot/codegen/automation/actions/models/public_execution_translation_rule.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class PublicExecutionTranslationRule attr_accessor :label_name attr_accessor :conditions # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'label_name' => :'labelName', :'conditions' => :'conditions' } end # Returns all the JSON keys this model knows about def self.acceptable_attributes attribute_map.values end # Attribute type mapping. def self.openapi_types { :'label_name' => :'String', :'conditions' => :'Hash<String, Object>' } 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::Automation::Actions::PublicExecutionTranslationRule` 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::Automation::Actions::PublicExecutionTranslationRule`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'label_name') self.label_name = attributes[:'label_name'] end if attributes.key?(:'conditions') if (value = attributes[:'conditions']).is_a?(Hash) self.conditions = 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 @label_name.nil? invalid_properties.push('invalid value for "label_name", label_name cannot be nil.') end if @conditions.nil? invalid_properties.push('invalid value for "conditions", conditions cannot be nil.') end invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? return false if @label_name.nil? return false if @conditions.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 && label_name == o.label_name && conditions == o.conditions end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash [label_name, conditions].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::Automation::Actions.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/automation/actions/models/input_field_definition.rb
lib/hubspot/codegen/automation/actions/models/input_field_definition.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class InputFieldDefinition attr_accessor :is_required attr_accessor :automation_field_type attr_accessor :type_definition attr_accessor :supported_value_types 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 { :'is_required' => :'isRequired', :'automation_field_type' => :'automationFieldType', :'type_definition' => :'typeDefinition', :'supported_value_types' => :'supportedValueTypes' } 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 { :'is_required' => :'Boolean', :'automation_field_type' => :'String', :'type_definition' => :'FieldTypeDefinition', :'supported_value_types' => :'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::Automation::Actions::InputFieldDefinition` 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::Automation::Actions::InputFieldDefinition`. 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?(:'is_required') self.is_required = attributes[:'is_required'] end if attributes.key?(:'automation_field_type') self.automation_field_type = attributes[:'automation_field_type'] end if attributes.key?(:'type_definition') self.type_definition = attributes[:'type_definition'] end if attributes.key?(:'supported_value_types') if (value = attributes[:'supported_value_types']).is_a?(Array) self.supported_value_types = 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 @is_required.nil? invalid_properties.push('invalid value for "is_required", is_required cannot be nil.') end if @type_definition.nil? invalid_properties.push('invalid value for "type_definition", type_definition 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 @is_required.nil? return false if @type_definition.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 && is_required == o.is_required && automation_field_type == o.automation_field_type && type_definition == o.type_definition && supported_value_types == o.supported_value_types 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 [is_required, automation_field_type, type_definition, supported_value_types].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::Automation::Actions.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/automation/actions/models/collection_response_public_action_revision_forward_paging.rb
lib/hubspot/codegen/automation/actions/models/collection_response_public_action_revision_forward_paging.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class CollectionResponsePublicActionRevisionForwardPaging 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<PublicActionRevision>' } 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::Automation::Actions::CollectionResponsePublicActionRevisionForwardPaging` 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::Automation::Actions::CollectionResponsePublicActionRevisionForwardPaging`. 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::Automation::Actions.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/automation/actions/models/public_action_function.rb
lib/hubspot/codegen/automation/actions/models/public_action_function.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class PublicActionFunction attr_accessor :function_source attr_accessor :function_type attr_accessor :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 { :'function_source' => :'functionSource', :'function_type' => :'functionType', :'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 { :'function_source' => :'String', :'function_type' => :'String', :'id' => :'String' } end # List of attributes with nullable: true def self.openapi_nullable Set.new([ ]) end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Automation::Actions::PublicActionFunction` 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::Automation::Actions::PublicActionFunction`. 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?(:'function_source') self.function_source = attributes[:'function_source'] end if attributes.key?(:'function_type') self.function_type = attributes[:'function_type'] end if attributes.key?(:'id') self.id = attributes[:'id'] end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new if @function_source.nil? invalid_properties.push('invalid value for "function_source", function_source cannot be nil.') end if @function_type.nil? invalid_properties.push('invalid value for "function_type", function_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 @function_source.nil? return false if @function_type.nil? function_type_validator = EnumAttributeValidator.new('String', ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS", "POST_ACTION_EXECUTION"]) return false unless function_type_validator.valid?(@function_type) true end # Custom attribute writer method checking allowed values (enum). # @param [Object] function_type Object to be assigned def function_type=(function_type) validator = EnumAttributeValidator.new('String', ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS", "POST_ACTION_EXECUTION"]) unless validator.valid?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{validator.allowable_values}." end @function_type = function_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 && function_source == o.function_source && function_type == o.function_type && 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 [function_source, function_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::Automation::Actions.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/automation/actions/models/error.rb
lib/hubspot/codegen/automation/actions/models/error.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions 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::Automation::Actions::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::Automation::Actions::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::Automation::Actions.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/automation/actions/models/public_action_definition_egg.rb
lib/hubspot/codegen/automation/actions/models/public_action_definition_egg.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'date' require 'time' module Hubspot module Automation module Actions class PublicActionDefinitionEgg attr_accessor :input_fields attr_accessor :output_fields attr_accessor :archived_at attr_accessor :functions attr_accessor :action_url attr_accessor :input_field_dependencies attr_accessor :published attr_accessor :execution_rules attr_accessor :object_types attr_accessor :object_request_options attr_accessor :labels # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'input_fields' => :'inputFields', :'output_fields' => :'outputFields', :'archived_at' => :'archivedAt', :'functions' => :'functions', :'action_url' => :'actionUrl', :'input_field_dependencies' => :'inputFieldDependencies', :'published' => :'published', :'execution_rules' => :'executionRules', :'object_types' => :'objectTypes', :'object_request_options' => :'objectRequestOptions', :'labels' => :'labels' } 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 { :'input_fields' => :'Array<InputFieldDefinition>', :'output_fields' => :'Array<OutputFieldDefinition>', :'archived_at' => :'Integer', :'functions' => :'Array<PublicActionFunction>', :'action_url' => :'String', :'input_field_dependencies' => :'Array<PublicActionDefinitionInputFieldDependenciesInner>', :'published' => :'Boolean', :'execution_rules' => :'Array<PublicExecutionTranslationRule>', :'object_types' => :'Array<String>', :'object_request_options' => :'PublicObjectRequestOptions', :'labels' => :'Hash<String, PublicActionLabels>' } 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::Automation::Actions::PublicActionDefinitionEgg` 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::Automation::Actions::PublicActionDefinitionEgg`. 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?(:'input_fields') if (value = attributes[:'input_fields']).is_a?(Array) self.input_fields = value end end if attributes.key?(:'output_fields') if (value = attributes[:'output_fields']).is_a?(Array) self.output_fields = value end end if attributes.key?(:'archived_at') self.archived_at = attributes[:'archived_at'] end if attributes.key?(:'functions') if (value = attributes[:'functions']).is_a?(Array) self.functions = value end end if attributes.key?(:'action_url') self.action_url = attributes[:'action_url'] end if attributes.key?(:'input_field_dependencies') if (value = attributes[:'input_field_dependencies']).is_a?(Array) self.input_field_dependencies = value end end if attributes.key?(:'published') self.published = attributes[:'published'] end if attributes.key?(:'execution_rules') if (value = attributes[:'execution_rules']).is_a?(Array) self.execution_rules = value end end if attributes.key?(:'object_types') if (value = attributes[:'object_types']).is_a?(Array) self.object_types = value end end if attributes.key?(:'object_request_options') self.object_request_options = attributes[:'object_request_options'] end if attributes.key?(:'labels') if (value = attributes[:'labels']).is_a?(Hash) self.labels = 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 @input_fields.nil? invalid_properties.push('invalid value for "input_fields", input_fields cannot be nil.') end if @functions.nil? invalid_properties.push('invalid value for "functions", functions cannot be nil.') end if @action_url.nil? invalid_properties.push('invalid value for "action_url", action_url cannot be nil.') end if @published.nil? invalid_properties.push('invalid value for "published", published cannot be nil.') end if @object_types.nil? invalid_properties.push('invalid value for "object_types", object_types cannot be nil.') end if @labels.nil? invalid_properties.push('invalid value for "labels", labels 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 @input_fields.nil? return false if @functions.nil? return false if @action_url.nil? return false if @published.nil? return false if @object_types.nil? return false if @labels.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 && input_fields == o.input_fields && output_fields == o.output_fields && archived_at == o.archived_at && functions == o.functions && action_url == o.action_url && input_field_dependencies == o.input_field_dependencies && published == o.published && execution_rules == o.execution_rules && object_types == o.object_types && object_request_options == o.object_request_options && labels == o.labels 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 [input_fields, output_fields, archived_at, functions, action_url, input_field_dependencies, published, execution_rules, object_types, object_request_options, labels].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::Automation::Actions.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/automation/actions/api/definitions_api.rb
lib/hubspot/codegen/automation/actions/api/definitions_api.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'cgi' module Hubspot module Automation module Actions class DefinitionsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Archive an extension definition # @param definition_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [nil] def archive(definition_id, app_id, opts = {}) archive_with_http_info(definition_id, app_id, opts) nil end # Archive an extension definition # @param definition_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def archive_with_http_info(definition_id, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DefinitionsApi.archive ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling DefinitionsApi.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 DefinitionsApi.archive" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).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 => :"DefinitionsApi.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: DefinitionsApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create a new extension definition # @param app_id [Integer] # @param public_action_definition_egg [PublicActionDefinitionEgg] # @param [Hash] opts the optional parameters # @return [PublicActionDefinition] def create(app_id, public_action_definition_egg, opts = {}) data, _status_code, _headers = create_with_http_info(app_id, public_action_definition_egg, opts) data end # Create a new extension definition # @param app_id [Integer] # @param public_action_definition_egg [PublicActionDefinitionEgg] # @param [Hash] opts the optional parameters # @return [Array<(PublicActionDefinition, Integer, Hash)>] PublicActionDefinition data, response status code and response headers def create_with_http_info(app_id, public_action_definition_egg, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DefinitionsApi.create ...' 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 DefinitionsApi.create" end # verify the required parameter 'public_action_definition_egg' is set if @api_client.config.client_side_validation && public_action_definition_egg.nil? fail ArgumentError, "Missing the required parameter 'public_action_definition_egg' when calling DefinitionsApi.create" end # resource path local_var_path = '/automation/v4/actions/{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(public_action_definition_egg) # return_type return_type = opts[:debug_return_type] || 'PublicActionDefinition' # auth_names auth_names = opts[:debug_auth_names] || ['developer_hapikey'] new_options = opts.merge( :operation => :"DefinitionsApi.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: DefinitionsApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get extension definition by Id # @param definition_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @option opts [Boolean] :archived Whether to return only results that have been archived. (default to false) # @return [PublicActionDefinition] def get_by_id(definition_id, app_id, opts = {}) data, _status_code, _headers = get_by_id_with_http_info(definition_id, app_id, opts) data end # Get extension definition by Id # @param definition_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @option opts [Boolean] :archived Whether to return only results that have been archived. (default to false) # @return [Array<(PublicActionDefinition, Integer, Hash)>] PublicActionDefinition data, response status code and response headers def get_by_id_with_http_info(definition_id, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DefinitionsApi.get_by_id ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling DefinitionsApi.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 DefinitionsApi.get_by_id" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'appId' + '}', CGI.escape(app_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'PublicActionDefinition' # auth_names auth_names = opts[:debug_auth_names] || ['developer_hapikey'] new_options = opts.merge( :operation => :"DefinitionsApi.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: DefinitionsApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get paged extension definitions # @param app_id [Integer] # @param [Hash] opts the optional parameters # @option opts [Integer] :limit The maximum number of results to display per page. # @option opts [String] :after The paging cursor token of the last successfully read resource will be returned as the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results. # @option opts [Boolean] :archived Whether to return only results that have been archived. (default to false) # @return [CollectionResponsePublicActionDefinitionForwardPaging] def get_page(app_id, opts = {}) data, _status_code, _headers = get_page_with_http_info(app_id, opts) data end # Get paged extension definitions # @param app_id [Integer] # @param [Hash] opts the optional parameters # @option opts [Integer] :limit The maximum number of results to display per page. # @option opts [String] :after The paging cursor token of the last successfully read resource will be returned as the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results. # @option opts [Boolean] :archived Whether to return only results that have been archived. (default to false) # @return [Array<(CollectionResponsePublicActionDefinitionForwardPaging, Integer, Hash)>] CollectionResponsePublicActionDefinitionForwardPaging data, response status code and response headers def get_page_with_http_info(app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DefinitionsApi.get_page ...' 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 DefinitionsApi.get_page" end # resource path local_var_path = '/automation/v4/actions/{appId}'.sub('{' + 'appId' + '}', CGI.escape(app_id.to_s)) # 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[:'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] || 'CollectionResponsePublicActionDefinitionForwardPaging' # auth_names auth_names = opts[:debug_auth_names] || ['developer_hapikey'] new_options = opts.merge( :operation => :"DefinitionsApi.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: DefinitionsApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Patch an existing extension definition # @param definition_id [String] # @param app_id [Integer] # @param public_action_definition_patch [PublicActionDefinitionPatch] # @param [Hash] opts the optional parameters # @return [PublicActionDefinition] def update(definition_id, app_id, public_action_definition_patch, opts = {}) data, _status_code, _headers = update_with_http_info(definition_id, app_id, public_action_definition_patch, opts) data end # Patch an existing extension definition # @param definition_id [String] # @param app_id [Integer] # @param public_action_definition_patch [PublicActionDefinitionPatch] # @param [Hash] opts the optional parameters # @return [Array<(PublicActionDefinition, Integer, Hash)>] PublicActionDefinition data, response status code and response headers def update_with_http_info(definition_id, app_id, public_action_definition_patch, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DefinitionsApi.update ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling DefinitionsApi.update" 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 DefinitionsApi.update" end # verify the required parameter 'public_action_definition_patch' is set if @api_client.config.client_side_validation && public_action_definition_patch.nil? fail ArgumentError, "Missing the required parameter 'public_action_definition_patch' when calling DefinitionsApi.update" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).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(public_action_definition_patch) # return_type return_type = opts[:debug_return_type] || 'PublicActionDefinition' # auth_names auth_names = opts[:debug_auth_names] || ['developer_hapikey'] new_options = opts.merge( :operation => :"DefinitionsApi.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: DefinitionsApi#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/automation/actions/api/functions_api.rb
lib/hubspot/codegen/automation/actions/api/functions_api.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'cgi' module Hubspot module Automation module Actions class FunctionsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Archive a function for a definition # @param definition_id [String] # @param function_type [String] # @param function_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [nil] def archive(definition_id, function_type, function_id, app_id, opts = {}) archive_with_http_info(definition_id, function_type, function_id, app_id, opts) nil end # Archive a function for a definition # @param definition_id [String] # @param function_type [String] # @param function_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def archive_with_http_info(definition_id, function_type, function_id, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.archive ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.archive" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.archive" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS", "POST_ACTION_EXECUTION"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" end # verify the required parameter 'function_id' is set if @api_client.config.client_side_validation && function_id.nil? fail ArgumentError, "Missing the required parameter 'function_id' when calling FunctionsApi.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 FunctionsApi.archive" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}/{functionId}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).sub('{' + 'functionId' + '}', CGI.escape(function_id.to_s)).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 => :"FunctionsApi.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: FunctionsApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete a function for a definition # @param definition_id [String] # @param function_type [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [nil] def archive_by_function_type(definition_id, function_type, app_id, opts = {}) archive_by_function_type_with_http_info(definition_id, function_type, app_id, opts) nil end # Delete a function for a definition # @param definition_id [String] # @param function_type [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def archive_by_function_type_with_http_info(definition_id, function_type, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.archive_by_function_type ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.archive_by_function_type" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.archive_by_function_type" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS", "POST_ACTION_EXECUTION"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" 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 FunctionsApi.archive_by_function_type" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).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 => :"FunctionsApi.archive_by_function_type", :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: FunctionsApi#archive_by_function_type\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Insert a function for a definition # @param definition_id [String] # @param function_type [String] # @param function_id [String] # @param app_id [Integer] # @param body [String] # @param [Hash] opts the optional parameters # @return [PublicActionFunctionIdentifier] def create_or_replace(definition_id, function_type, function_id, app_id, body, opts = {}) data, _status_code, _headers = create_or_replace_with_http_info(definition_id, function_type, function_id, app_id, body, opts) data end # Insert a function for a definition # @param definition_id [String] # @param function_type [String] # @param function_id [String] # @param app_id [Integer] # @param body [String] # @param [Hash] opts the optional parameters # @return [Array<(PublicActionFunctionIdentifier, Integer, Hash)>] PublicActionFunctionIdentifier data, response status code and response headers def create_or_replace_with_http_info(definition_id, function_type, function_id, app_id, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.create_or_replace ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.create_or_replace" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.create_or_replace" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS", "POST_ACTION_EXECUTION"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" end # verify the required parameter 'function_id' is set if @api_client.config.client_side_validation && function_id.nil? fail ArgumentError, "Missing the required parameter 'function_id' when calling FunctionsApi.create_or_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 FunctionsApi.create_or_replace" end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling FunctionsApi.create_or_replace" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}/{functionId}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).sub('{' + 'functionId' + '}', CGI.escape(function_id.to_s)).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(['text/plain']) 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(body) # return_type return_type = opts[:debug_return_type] || 'PublicActionFunctionIdentifier' # auth_names auth_names = opts[:debug_auth_names] || ['developer_hapikey'] new_options = opts.merge( :operation => :"FunctionsApi.create_or_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: FunctionsApi#create_or_replace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Insert a function for a definition # @param definition_id [String] # @param function_type [String] # @param app_id [Integer] # @param body [String] # @param [Hash] opts the optional parameters # @return [PublicActionFunctionIdentifier] def create_or_replace_by_function_type(definition_id, function_type, app_id, body, opts = {}) data, _status_code, _headers = create_or_replace_by_function_type_with_http_info(definition_id, function_type, app_id, body, opts) data end # Insert a function for a definition # @param definition_id [String] # @param function_type [String] # @param app_id [Integer] # @param body [String] # @param [Hash] opts the optional parameters # @return [Array<(PublicActionFunctionIdentifier, Integer, Hash)>] PublicActionFunctionIdentifier data, response status code and response headers def create_or_replace_by_function_type_with_http_info(definition_id, function_type, app_id, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.create_or_replace_by_function_type ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.create_or_replace_by_function_type" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.create_or_replace_by_function_type" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS", "POST_ACTION_EXECUTION"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" 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 FunctionsApi.create_or_replace_by_function_type" end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling FunctionsApi.create_or_replace_by_function_type" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).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(['text/plain']) 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(body) # return_type return_type = opts[:debug_return_type] || 'PublicActionFunctionIdentifier' # auth_names auth_names = opts[:debug_auth_names] || ['developer_hapikey'] new_options = opts.merge( :operation => :"FunctionsApi.create_or_replace_by_function_type", :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: FunctionsApi#create_or_replace_by_function_type\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all functions by a type for a given definition # @param definition_id [String] # @param function_type [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [PublicActionFunction] def get_by_function_type(definition_id, function_type, app_id, opts = {}) data, _status_code, _headers = get_by_function_type_with_http_info(definition_id, function_type, app_id, opts) data end # Get all functions by a type for a given definition # @param definition_id [String] # @param function_type [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(PublicActionFunction, Integer, Hash)>] PublicActionFunction data, response status code and response headers def get_by_function_type_with_http_info(definition_id, function_type, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.get_by_function_type ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.get_by_function_type" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.get_by_function_type" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS", "POST_ACTION_EXECUTION"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" 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 FunctionsApi.get_by_function_type" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).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] || 'PublicActionFunction' # auth_names auth_names = opts[:debug_auth_names] || ['developer_hapikey'] new_options = opts.merge( :operation => :"FunctionsApi.get_by_function_type", :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: FunctionsApi#get_by_function_type\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a function for a given definition # @param definition_id [String] # @param function_type [String] # @param function_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [PublicActionFunction] def get_by_id(definition_id, function_type, function_id, app_id, opts = {}) data, _status_code, _headers = get_by_id_with_http_info(definition_id, function_type, function_id, app_id, opts) data end # Get a function for a given definition # @param definition_id [String] # @param function_type [String] # @param function_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(PublicActionFunction, Integer, Hash)>] PublicActionFunction data, response status code and response headers def get_by_id_with_http_info(definition_id, function_type, function_id, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.get_by_id ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.get_by_id" end # verify the required parameter 'function_type' is set if @api_client.config.client_side_validation && function_type.nil? fail ArgumentError, "Missing the required parameter 'function_type' when calling FunctionsApi.get_by_id" end # verify enum value allowable_values = ["PRE_ACTION_EXECUTION", "PRE_FETCH_OPTIONS", "POST_FETCH_OPTIONS", "POST_ACTION_EXECUTION"] if @api_client.config.client_side_validation && !allowable_values.include?(function_type) fail ArgumentError, "invalid value for \"function_type\", must be one of #{allowable_values}" end # verify the required parameter 'function_id' is set if @api_client.config.client_side_validation && function_id.nil? fail ArgumentError, "Missing the required parameter 'function_id' when calling FunctionsApi.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 FunctionsApi.get_by_id" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions/{functionType}/{functionId}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'functionType' + '}', CGI.escape(function_type.to_s)).sub('{' + 'functionId' + '}', CGI.escape(function_id.to_s)).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] || 'PublicActionFunction' # auth_names auth_names = opts[:debug_auth_names] || ['developer_hapikey'] new_options = opts.merge( :operation => :"FunctionsApi.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: FunctionsApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all functions for a given definition # @param definition_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [CollectionResponsePublicActionFunctionIdentifierNoPaging] def get_page(definition_id, app_id, opts = {}) data, _status_code, _headers = get_page_with_http_info(definition_id, app_id, opts) data end # Get all functions for a given definition # @param definition_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(CollectionResponsePublicActionFunctionIdentifierNoPaging, Integer, Hash)>] CollectionResponsePublicActionFunctionIdentifierNoPaging data, response status code and response headers def get_page_with_http_info(definition_id, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FunctionsApi.get_page ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling FunctionsApi.get_page" 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 FunctionsApi.get_page" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/functions'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).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] || 'CollectionResponsePublicActionFunctionIdentifierNoPaging' # auth_names auth_names = opts[:debug_auth_names] || ['developer_hapikey'] new_options = opts.merge( :operation => :"FunctionsApi.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: FunctionsApi#get_page\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/automation/actions/api/revisions_api.rb
lib/hubspot/codegen/automation/actions/api/revisions_api.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'cgi' module Hubspot module Automation module Actions class RevisionsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Gets a revision for a given definition by revision id # @param definition_id [String] # @param revision_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [PublicActionRevision] def get_by_id(definition_id, revision_id, app_id, opts = {}) data, _status_code, _headers = get_by_id_with_http_info(definition_id, revision_id, app_id, opts) data end # Gets a revision for a given definition by revision id # @param definition_id [String] # @param revision_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @return [Array<(PublicActionRevision, Integer, Hash)>] PublicActionRevision data, response status code and response headers def get_by_id_with_http_info(definition_id, revision_id, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: RevisionsApi.get_by_id ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling RevisionsApi.get_by_id" end # verify the required parameter 'revision_id' is set if @api_client.config.client_side_validation && revision_id.nil? fail ArgumentError, "Missing the required parameter 'revision_id' when calling RevisionsApi.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 RevisionsApi.get_by_id" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/revisions/{revisionId}'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'revisionId' + '}', CGI.escape(revision_id.to_s)).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] || 'PublicActionRevision' # auth_names auth_names = opts[:debug_auth_names] || ['developer_hapikey'] new_options = opts.merge( :operation => :"RevisionsApi.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: RevisionsApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all revisions for a given definition # @param definition_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @option opts [Integer] :limit The maximum number of results to display per page. # @option opts [String] :after The paging cursor token of the last successfully read resource will be returned as the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results. # @return [CollectionResponsePublicActionRevisionForwardPaging] def get_page(definition_id, app_id, opts = {}) data, _status_code, _headers = get_page_with_http_info(definition_id, app_id, opts) data end # Get all revisions for a given definition # @param definition_id [String] # @param app_id [Integer] # @param [Hash] opts the optional parameters # @option opts [Integer] :limit The maximum number of results to display per page. # @option opts [String] :after The paging cursor token of the last successfully read resource will be returned as the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results. # @return [Array<(CollectionResponsePublicActionRevisionForwardPaging, Integer, Hash)>] CollectionResponsePublicActionRevisionForwardPaging data, response status code and response headers def get_page_with_http_info(definition_id, app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: RevisionsApi.get_page ...' end # verify the required parameter 'definition_id' is set if @api_client.config.client_side_validation && definition_id.nil? fail ArgumentError, "Missing the required parameter 'definition_id' when calling RevisionsApi.get_page" 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 RevisionsApi.get_page" end # resource path local_var_path = '/automation/v4/actions/{appId}/{definitionId}/revisions'.sub('{' + 'definitionId' + '}', CGI.escape(definition_id.to_s)).sub('{' + 'appId' + '}', CGI.escape(app_id.to_s)) # 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? # 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] || 'CollectionResponsePublicActionRevisionForwardPaging' # auth_names auth_names = opts[:debug_auth_names] || ['developer_hapikey'] new_options = opts.merge( :operation => :"RevisionsApi.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: RevisionsApi#get_page\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/automation/actions/api/callbacks_api.rb
lib/hubspot/codegen/automation/actions/api/callbacks_api.rb
=begin #Automation Actions V4 #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: v4 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'cgi' module Hubspot module Automation module Actions class CallbacksApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Completes a single callback # @param callback_id [String] # @param callback_completion_request [CallbackCompletionRequest] # @param [Hash] opts the optional parameters # @return [nil] def complete(callback_id, callback_completion_request, opts = {}) complete_with_http_info(callback_id, callback_completion_request, opts) nil end # Completes a single callback # @param callback_id [String] # @param callback_completion_request [CallbackCompletionRequest] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def complete_with_http_info(callback_id, callback_completion_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CallbacksApi.complete ...' end # verify the required parameter 'callback_id' is set if @api_client.config.client_side_validation && callback_id.nil? fail ArgumentError, "Missing the required parameter 'callback_id' when calling CallbacksApi.complete" end # verify the required parameter 'callback_completion_request' is set if @api_client.config.client_side_validation && callback_completion_request.nil? fail ArgumentError, "Missing the required parameter 'callback_completion_request' when calling CallbacksApi.complete" end # resource path local_var_path = '/automation/v4/actions/callbacks/{callbackId}/complete'.sub('{' + 'callbackId' + '}', CGI.escape(callback_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(['*/*']) # 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(callback_completion_request) # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['oauth2'] new_options = opts.merge( :operation => :"CallbacksApi.complete", :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: CallbacksApi#complete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Completes a batch of callbacks # @param batch_input_callback_completion_batch_request [BatchInputCallbackCompletionBatchRequest] # @param [Hash] opts the optional parameters # @return [nil] def complete_batch(batch_input_callback_completion_batch_request, opts = {}) complete_batch_with_http_info(batch_input_callback_completion_batch_request, opts) nil end # Completes a batch of callbacks # @param batch_input_callback_completion_batch_request [BatchInputCallbackCompletionBatchRequest] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def complete_batch_with_http_info(batch_input_callback_completion_batch_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CallbacksApi.complete_batch ...' end # verify the required parameter 'batch_input_callback_completion_batch_request' is set if @api_client.config.client_side_validation && batch_input_callback_completion_batch_request.nil? fail ArgumentError, "Missing the required parameter 'batch_input_callback_completion_batch_request' when calling CallbacksApi.complete_batch" end # resource path local_var_path = '/automation/v4/actions/callbacks/complete' # 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_callback_completion_batch_request) # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['oauth2'] new_options = opts.merge( :operation => :"CallbacksApi.complete_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: CallbacksApi#complete_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/helpers/path.rb
lib/hubspot/helpers/path.rb
require_relative 'snake_case' module Hubspot module Helpers class Path def format(module_name) Hubspot::Helpers::SnakeCase.new.format(module_name.to_s) end def require_with_mapping(path) require path end def require_with_codegen_mapping(path) require path 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/helpers/get_all_helper.rb
lib/hubspot/helpers/get_all_helper.rb
module Hubspot module Helpers module GetAllHelper MAX_PAGE_SIZE = 100 # List # Read all contacts. Control what is returned via the `properties` query param. # @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>] :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 def get_all(opts = {}) after = nil objects = [] opts[:limit] ||= MAX_PAGE_SIZE loop do page_opts = opts.merge(after: after) page = get_page(page_opts) objects.concat(page.results) break objects if page.paging.nil? after = page.paging._next.after 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/helpers/camel_case.rb
lib/hubspot/helpers/camel_case.rb
module Hubspot module Helpers class CamelCase def format(string) case string when 'public_smtp_tokens_api' 'PublicSMTPTokensApi' else string.split('_').collect(&:capitalize).join 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/helpers/signature.rb
lib/hubspot/helpers/signature.rb
require 'date' require 'openssl' module Hubspot module Helpers class Signature MAX_ALLOWED_TIMESTAMP = 300_000 def timestamp_valid?(timestamp) return false if timestamp.nil? begin get_current_timestamp_microseconds - timestamp.to_i < MAX_ALLOWED_TIMESTAMP rescue StandardError false end end def is_valid( signature:, client_secret:, request_body:, http_uri: nil, http_method: 'POST', signature_version: 'v2', timestamp: nil ) if signature_version == "v3" unless timestamp_valid?(timestamp) raise InvalidSignatureTimestampError, "Invalid timestamp: #{timestamp}" end end normalized_request_body = normalize_to_utf8(request_body) hashed_signature = get_signature( client_secret: client_secret, request_body: normalized_request_body, signature_version: signature_version, http_uri: http_uri, http_method: http_method, timestamp: timestamp ) secure_compare(signature, hashed_signature) end def get_current_timestamp_microseconds (Time.now.to_f * 1000).to_i end def get_signature( client_secret:, request_body:, signature_version:, http_uri: nil, http_method: "POST", timestamp: nil ) case signature_version when "v1" source_string = "#{client_secret}#{request_body}" Digest::SHA2.hexdigest(normalize_to_utf8(source_string)) when "v2" source_string = "#{client_secret}#{http_method}#{http_uri}#{request_body}" Digest::SHA2.hexdigest(normalize_to_utf8(source_string)) when "v3" source_string = "#{http_method}#{http_uri}#{request_body}#{timestamp}" OpenSSL::HMAC.base64digest('SHA256', client_secret, normalize_to_utf8(source_string)) else raise InvalidSignatureVersionError, "Invalid signature version: #{signature_version}" end end def normalize_to_utf8(str) return "" if str.nil? str = str.force_encoding("UTF-8") str.valid_encoding? ? str : str.encode("UTF-8", invalid: :replace, undef: :replace, replace: "?") end def secure_compare(a, b) return false unless a.is_a?(String) && b.is_a?(String) && a.bytesize == b.bytesize result = 0 a.bytes.zip(b.bytes) { |x, y| result |= x ^ y } result.zero? 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/helpers/snake_case.rb
lib/hubspot/helpers/snake_case.rb
module Hubspot module Helpers class SnakeCase def format(string) string.gsub('OAuth', 'Oauth'). gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase 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/helpers/association_type.rb
lib/hubspot/helpers/association_type.rb
module Hubspot module Helpers class AssociationType PRIMARY_CONTACT_TO_COMPANY = 1 PRIMARY_COMPANY_TO_CONTACT = 2 DEAL_TO_CONTACT = 3 CONTACT_TO_DEAL = 4 PRIMARY_DEAL_TO_COMPANY = 5 PRIMARY_COMPANY_TO_DEAL = 6 PARENT_TO_CHILD_COMPANY = 13 CHILD_TO_PARENT_COMPANY = 14 CONTACT_TO_TICKET = 15 TICKET_TO_CONTACT = 16 DEAL_TO_LINE_ITEM = 19 LINE_ITEM_TO_DEAL = 20 PRIMARY_COMPANY_TO_TICKET = 25 PRIMARY_TICKET_TO_COMPANY = 26 DEAL_TO_TICKET = 27 TICKET_TO_DEAL = 28 TICKET_TO_THREAD = 32 DEAL_TO_QUOTE = 63 QUOTE_TO_DEAL = 64 QUOTE_TO_LINE_ITEM = 67 LINE_ITEM_TO_QUOTE = 68 QUOTE_TO_CONTACT = 69 CONTACT_TO_QUOTE = 70 QUOTE_TO_COMPANY = 71 COMPANY_TO_QUOTE = 72 COMMUNICATION_TO_CONTACT = 81 CONTACT_TO_COMMUNICATION = 82 COMMUNICATION_TO_TICKET = 83 TICKET_TO_COMMUNICATION = 84 COMMUNICATION_TO_DEAL = 85 DEAL_TO_COMMUNICATION = 86 COMMUNICATION_TO_COMPANY = 87 COMPANY_TO_COMMUNICATION = 88 CONTACT_TO_FEEDBACK_SUBMISSION = 97 FEEDBACK_SUBMISSION_TO_CONTACT = 98 TICKET_TO_FEEDBACK_SUBMISSION = 99 FEEDBACK_SUBMISSION_TO_TICKET = 100 INVOICE_TO_DEAL = 175 DEAL_TO_INVOICE = 176 INVOICE_TO_CONTACT = 177 CONTACT_TO_INVOICE = 178 INVOICE_TO_COMPANY = 179 COMPANY_TO_INVOICE = 180 COMPANY_TO_CALL = 181 CALL_TO_COMPANY = 182 COMPANY_TO_EMAIL = 185 EMAIL_TO_COMPANY = 186 COMPANY_TO_MEETING = 187 MEETING_TO_COMPANY = 188 COMPANY_TO_NOTE = 189 NOTE_TO_COMPANY = 190 COMPANY_TO_TASK = 191 TASK_TO_COMPANY = 192 CONTACT_TO_CALL = 193 CALL_TO_CONTACT = 194 CONTACT_TO_EMAIL = 197 EMAIL_TO_CONTACT = 198 CONTACT_TO_MEETING = 199 MEETING_TO_CONTACT = 200 CONTACT_TO_NOTE = 201 NOTE_TO_CONTACT = 202 CONTACT_TO_TASK = 203 TASK_TO_CONTACT = 204 DEAL_TO_CALL = 205 CALL_TO_DEAL = 206 DEAL_TO_EMAIL = 209 EMAIL_TO_DEAL = 210 DEAL_TO_MEETING = 211 MEETING_TO_DEAL = 212 DEAL_TO_NOTE = 213 NOTE_TO_DEAL = 214 DEAL_TO_TASK = 215 TASK_TO_DEAL = 216 QUOTE_TO_TASK = 217 TASK_TO_QUOTE = 218 TICKET_TO_CALL = 219 CALL_TO_TICKET = 220 TICKET_TO_EMAIL = 223 EMAIL_TO_TICKET = 224 TICKET_TO_MEETING = 225 MEETING_TO_TICKET = 226 TICKET_TO_NOTE = 227 NOTE_TO_TICKET = 228 TICKET_TO_TASK = 229 TASK_TO_TICKET = 230 TICKET_TO_CONVERSATION = 278 CONTACT_TO_COMPANY = 279 COMPANY_TO_CONTACT = 280 QUOTE_TO_QUOTE_TEMPLATE = 286 SUBSCRIPTION_TO_CONTACT = 295 CONTACT_TO_SUBSCRIPTION = 296 SUBSCRIPTION_TO_COMPANY = 297 COMPANY_TO_SUBSCRIPTION = 298 SUBSCRIPTION_TO_DEAL = 299 DEAL_TO_SUBSCRIPTION = 300 SUBSCRIPTION_TO_LINE_ITEM = 301 LINE_ITEM_TO_SUBSCRIPTION = 302 SUBSCRIPTION_TO_QUOTE = 303 QUOTE_TO_SUBSCRIPTION = 304 DEAL_TO_DEAL_SPLIT = 313 TICKET_TO_COMPANY = 339 COMPANY_TO_TICKET = 340 DEAL_TO_COMPANY = 341 COMPANY_TO_DEAL = 342 DISCOUNT_TO_QUOTE = 361 QUOTE_TO_DISCOUNT = 362 FEE_TO_QUOTE = 363 QUOTE_TO_FEE = 364 TAX_TO_QUOTE = 365 QUOTE_TO_TAX = 366 DISCOUNT_TO_LINE_ITEM = 367 LINE_ITEM_TO_DISCOUNT = 368 DISCOUNT_TO_DEAL = 369 PAYMENT_TO_CONTACT = 387 CONTACT_TO_PAYMENT = 388 PAYMENT_TO_COMPANY = 389 COMPANY_TO_PAYMENT = 390 PAYMENT_TO_DEAL = 391 DEAL_TO_PAYMENT = 392 PAYMENT_TO_SUBSCRIPTION = 393 PAYMENT_TO_LINE_ITEM = 395 LINE_ITEM_TO_PAYMENT = 396 PAYMENT_TO_QUOTE = 397 QUOTE_TO_PAYMENT = 398 CALL_TO_MEETING = 399 MEETING_TO_CALL = 400 INVOICE_TO_QUOTE = 407 QUOTE_TO_INVOICE = 408 INVOICE_TO_LINE_ITEM = 409 LINE_ITEM_TO_INVOICE = 410 INVOICE_TO_DISCOUNT = 411 DISCOUNT_TO_INVOICE = 412 INVOICE_TO_FEE = 413 FEE_TO_INVOICE = 414 INVOICE_TO_TAX = 415 TAX_TO_INVOICE = 416 PAYMENT_TO_DISCOUNT = 428 CONTACT_TO_CONTACT = 449 COMPANY_TO_COMPANY = 450 DEAL_TO_DEAL = 451 TICKET_TO_TICKET = 452 POSTAL_MAIL_TO_CONTACT = 453 CONTACT_TO_POSTAL_MAIL = 454 POSTAL_MAIL_TO_TICKET = 455 TICKET_TO_POSTAL_MAIL = 456 POSTAL_MAIL_TO_DEAL = 457 DEAL_TO_POSTAL_MAIL = 458 POSTAL_MAIL_TO_COMPANY = 459 COMPANY_TO_POSTAL_MAIL = 460 PAYMENT_LINK_TO_CONTACT = 469 CONTACT_TO_PAYMENT_LINK = 470 PAYMENT_LINK_TO_COMPANY = 471 COMPANY_TO_PAYMENT_LINK = 472 PAYMENT_LINK_TO_DEAL = 473 DEAL_TO_PAYMENT_LINK = 474 PAYMENT_LINK_TO_PAYMENT = 475 PAYMENT_TO_PAYMENT_LINK = 476 PAYMENT_LINK_TO_SUBSCRIPTION = 477 SUBSCRIPTION_TO_PAYMENT_LINK = 478 ORDER_TO_CONTACT = 507 CONTACT_TO_ORDER = 508 ORDER_TO_COMPANY = 509 COMPANY_TO_ORDER = 510 DEAL_TO_ORDER = 511 ORDER_TO_DEAL = 512 ORDER_TO_LINE_ITEM = 513 LINE_ITEM_TO_ORDER = 514 SUBSCRIPTION_TO_ORDER = 515 ORDER_TO_SUBSCRIPTION = 516 INVOICE_TO_ORDER = 517 ORDER_TO_INVOICE = 518 ORDER_TO_DISCOUNT = 519 DISCOUNT_TO_ORDER = 520 ORDER_TO_DISCOUNT_CODE = 521 ORDER_TO_PAYMENT = 523 PAYMENT_TO_ORDER = 524 ORDER_TO_TICKET = 525 TICKET_TO_ORDER = 526 INVOICE_TO_PAYMENT = 541 PAYMENT_TO_INVOICE = 542 UPCOMING_LINE_ITEM_TO_SUBSCRIPTION = 565 LINE_ITEM_TO_ABANDONED_CART = 571 LEAD_TO_PRIMARY_CONTACT = 578 CART_TO_CONTACT = 586 CONTACT_TO_CART = 587 CART_TO_DISCOUNT = 588 DISCOUNT_TO_CART = 589 CART_TO_LINE_ITEM = 590 LINE_ITEM_TO_CART = 591 CART_TO_ORDER = 592 ORDER_TO_CART = 593 CART_TO_TICKET = 594 CART_TO_FEEDBACK_SUBMISSION = 594 LEAD_TO_CALL = 596 LEAD_TO_EMAIL = 598 LEAD_TO_MEETING = 600 LEAD_TO_COMMUNICATION = 602 LEAD_TO_CONTACT = 608 LEAD_TO_COMPANY = 610 INVOICE_TO_SUBSCRIPTION = 622 SUBSCRIPTION_TO_INVOICE = 623 LEAD_TO_TASK = 646 INVOICE_TO_DATA_SYNC_STATE = 679 PAYMENT_LINK_TO_DISCOUNT = 682 DISCOUNT_TO_PAYMENT_LINK = 683 PAYMENT_LINK_TO_TAX = 684 TAX_TO_PAYMENT_LINK = 685 PAYMENT_LINK_TO_FEE = 686 FEE_TO_PAYMENT_LINK = 687 INVOICE_TO_PAYMENT_SCHEDULE_INSTALLMENT = 691 CONTACT_SIGNER = 702 ORDER_TO_TASK = 726 CART_TO_TASK = 728 ORDER_TO_QUOTE = 730 QUOTE_TO_ORDER = 731 CART_TO_QUOTE = 732 QUOTE_TO_CART = 733 PAYMENT_LINK_TO_LINE_ITEM = 758 LINE_ITEM_TO_PAYMENT_LINK = 759 SERVICE_TO_COMPANY = 792 COMPANY_TO_SERVICE = 793 SERVICE_TO_DEAL = 794 DEAL_TO_SERVICE = 795 SERVICE_TO_TICKET = 796 TICKET_TO_SERVICE = 797 SERVICE_TO_CONTACT = 798 CONTACT_TO_SERVICE = 799 PAYMENT_LINK_TO_INVOICE = 814 INVOICE_TO_PAYMENT_LINK = 815 SERVICE_TO_NOTE = 836 NOTE_TO_SERVICE = 837 SERVICE_TO_MEETING = 838 MEETING_TO_SERVICE = 839 SERVICE_TO_CALL = 840 CALL_TO_SERVICE = 841 SERVICE_TO_EMAIL = 842 EMAIL_TO_SERVICE = 843 SERVICE_TO_COMMUNICATION = 846 COMMUNICATION_TO_SERVICE = 847 SERVICE_TO_POSTAL_MAIL = 848 POSTAL_MAIL_TO_SERVICE = 849 SERVICE_TO_TASK = 852 TASK_TO_SERVICE = 853 LEAD_TO_NOTE = 854 COURSE_TO_CONTACT = 860 CONTACT_TO_COURSE = 861 COURSE_TO_DEAL = 862 DEAL_TO_COURSE = 863 COURSE_TO_CALL = 866 CALL_TO_COURSE = 867 COURSE_TO_EMAIL = 870 EMAIL_TO_COURSE = 871 COURSE_TO_MEETING = 872 MEETING_TO_COURSE = 873 COURSE_TO_NOTE = 874 NOTE_TO_COURSE = 875 COURSE_TO_TASK = 876 TASK_TO_COURSE = 877 COURSE_TO_COMMUNICATION = 878 COMMUNICATION_TO_COURSE = 879 COURSE_TO_POSTAL_MAIL = 880 POSTAL_MAIL_TO_COURSE = 881 LISTING_TO_CONTACT = 882 CONTACT_TO_LISTING = 883 LISTING_TO_COMPANY = 884 COMPANY_TO_LISTING = 885 LISTING_TO_DEAL = 886 DEAL_TO_LISTING = 887 LISTING_TO_CALL = 890 CALL_TO_LISTING = 891 LISTING_TO_EMAIL = 894 EMAIL_TO_LISTING = 895 LISTING_TO_MEETING = 896 MEETING_TO_LISTING = 897 LISTING_TO_NOTE = 898 NOTE_TO_LISTING = 899 LISTING_TO_TASK = 900 TASK_TO_LISTING = 901 LISTING_TO_COMMUNICATION = 902 COMMUNICATION_TO_LISTING = 903 LISTING_TO_POSTAL_MAIL = 904 POSTAL_MAIL_TO_LISTING = 905 APPOINTMENT_TO_CONTACT = 906 CONTACT_TO_APPOINTMENT = 907 APPOINTMENT_TO_COMPANY = 908 COMPANY_TO_APPOINTMENT = 909 APPOINTMENT_TO_CALL = 912 CALL_TO_APPOINTMENT = 913 APPOINTMENT_TO_EMAIL = 916 EMAIL_TO_APPOINTMENT = 917 APPOINTMENT_TO_MEETING = 918 MEETING_TO_APPOINTMENT = 919 APPOINTMENT_TO_NOTE = 920 NOTE_TO_APPOINTMENT = 921 APPOINTMENT_TO_TASK = 922 TASK_TO_APPOINTMENT = 923 APPOINTMENT_TO_COMMUNICATION = 924 COMMUNICATION_TO_APPOINTMENT = 925 APPOINTMENT_TO_POSTAL_MAIL = 926 POSTAL_MAIL_TO_APPOINTMENT = 927 FEEDBACK_SUBMISSION_TO_COMPANY = 928 COMPANY_TO_FEEDBACK_SUBMISSION = 929 COURSE_TO_COMPANY = 938 COMPANY_TO_COURSE = 939 COURSE_TO_TICKET = 940 TICKET_TO_COURSE = 941 LISTING_TO_TICKET = 942 TICKET_TO_LISTING = 943 APPOINTMENT_TO_DEAL = 944 DEAL_TO_APPOINTMENT = 945 APPOINTMENT_TO_TICKET = 946 TICKET_TO_APPOINTMENT = 947 FEEDBACK_SUBMISSION_TO_DEAL = 984 DEAL_TO_FEEDBACK_SUBMISSION = 985 INVOICE_TO_TICKET = 986 SUBSCRIPTION_TO_TICKET = 1121 TICKET_TO_SUBSCRIPTION = 1122 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/helpers/requests/http_auth.rb
lib/hubspot/helpers/requests/http_auth.rb
module Hubspot module Helpers class Auth def self.get_auth_types [:access_token, :api_key] end def self.has_auth_value?(source, key) !source[key].nil? && !source[key].to_s.empty? end def self.choose_auth(config, options) auth_types = get_auth_types auth_type = options[:auth_type] || nil if auth_type.nil? auth_types.each do |key| if has_auth_value?(config, key) auth_type = key break end end end if auth_type && auth_types.include?(auth_type) return { auth_type: auth_type } else raise "Unsupported auth_type: #{auth_type}" 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/helpers/requests/http_request_builder.rb
lib/hubspot/helpers/requests/http_request_builder.rb
require 'net/http' require 'uri' require 'json' require 'openssl' require_relative 'http_auth' module Hubspot module Helpers class Request attr_reader :url, :method, :headers, :body def initialize(config, options = {}) @config = config || {} @options = options || {} @base_url = config.fetch("base_url", "https://api.hubapi.com") @headers = {} @body = nil @default_json = options.fetch("default_json", true) @method = (@options[:method] || "GET").upcase init_headers apply_auth @url = generate_url set_body end def apply_auth auth = Hubspot::Helpers::Auth.choose_auth(@config, @options) case auth[:auth_type] when :api_key @options[:qs] ||= {} @options[:qs][:hapikey] ||= @options[:auth_value] when :access_token @headers["Authorization"] = "Bearer #{@config[:access_token]}" end end def init_headers @headers["Content-Type"] = "application/json" if @default_json @headers.merge!(get_default_headers) @headers.merge!(@options[:headers] || {}) end def get_default_headers headers = { "User-Agent" => @config.fetch("user_agent", "custom-ruby-client/1.0") } headers["Accept"] = "application/json, */*;q=0.8" if @default_json headers end def get_query_string qs = @options[:qs] return nil unless qs URI.encode_www_form(qs) rescue => e puts "Error processing query string: #{e.message}" nil end def generate_url path = @options.fetch(:path, "") url = URI.join(@base_url, path).to_s query_string = get_query_string if query_string delimiter = url.include?('?') ? '&' : '?' url += "#{delimiter}#{query_string}" end validate_url(url) url end def validate_url(url) URI.parse(url) rescue URI::InvalidURIError => e raise "Invalid URL generated: #{url} - #{e.message}" end def set_body if @options.key?(:body) @body = @options[:body] @body = @body.to_json if @default_json && (@body.is_a?(Hash) || @body.is_a?(Array)) end end def send uri = URI.parse(@url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == "https" http_methods = { "GET" => Net::HTTP::Get, "POST" => Net::HTTP::Post, "PUT" => Net::HTTP::Put, "DELETE" => Net::HTTP::Delete, "PATCH" => Net::HTTP::Patch } request_class = http_methods[@method] raise "Unsupported HTTP method: #{@method}" unless request_class request = request_class.new(uri.request_uri, @headers) request.body = @body if @body begin response = http.request(request) response rescue StandardError => e puts "HTTP error occurred: #{e.message}" raise end end end end end
ruby
Apache-2.0
75a9afa65e9789fbe6ff711066d798ca0c10f432
2026-01-04T17:55:03.682567Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/app/helpers/users_helper.rb
app/helpers/users_helper.rb
module UsersHelper end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/app/helpers/application_helper.rb
app/helpers/application_helper.rb
module ApplicationHelper end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/app/helpers/home_helper.rb
app/helpers/home_helper.rb
module HomeHelper end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/app/controllers/home_controller.rb
app/controllers/home_controller.rb
class HomeController < ApplicationController respond_to :html layout "angular" def index end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/app/controllers/application_controller.rb
app/controllers/application_controller.rb
class ApplicationController < ActionController::Base protect_from_forgery end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/app/controllers/api/v1/record_controller.rb
app/controllers/api/v1/record_controller.rb
class Api::V1::RecordController < Api::V1::BaseController before_filter :authenticate_user! def index respond_with(Record.all) end def show @data = Record.find(params[:id]).to_json() respond_with(@data) end def update @data = Record.find(params[:id]) respond_to do |format| if @data.update_attributes(record_params) format.json { head :no_content } else format.json { render json: @data.errors, status: :unprocessable_entity } end end end def create @data = Record.create(record_params) @data.save respond_with(@data) end def destroy @data = Record.find(params[:id]) @data.destroy respond_to do |format| format.json { head :ok } end end private def record_params params.require(:record).permit(:secure) end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/app/controllers/api/v1/users_controller.rb
app/controllers/api/v1/users_controller.rb
class Api::V1::UsersController < Api::V1::BaseController before_filter :authenticate_user!, :except => [:create, :show] def show render :json => {:info => "Current User", :user => current_user}, :status => 200 end def create @user = User.create(user_params) if @user.valid? sign_in(@user) respond_with @user, :location => api_users_path else respond_with @user.errors, :location => api_users_path end end def update respond_with :api, User.update(current_user.id, user_params) end def destroy respond_with :api, User.find(current_user.id).destroy end private def user_params params.require(:user).permit(:email, :password, :password_confirmation) end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/app/controllers/api/v1/base_controller.rb
app/controllers/api/v1/base_controller.rb
class Api::V1::BaseController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :null_session, :if => Proc.new { |c| c.request.format == 'application/vnd.radd.v1' } respond_to :json rescue_from Exception, with: :generic_exception rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found private def record_not_found(error) respond_to do |format| format.json { render :json => {:error => error.message}, :status => 404 } end end def generic_exception(error) respond_to do |format| format.json { render :json => {:error => error.message}, :status => 500 } end end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/app/controllers/api/v1/sessions_controller.rb
app/controllers/api/v1/sessions_controller.rb
class Api::V1::SessionsController < Devise::SessionsController protect_from_forgery with: :null_session, :if => Proc.new { |c| c.request.format == 'application/vnd.radd.v1' } def create warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure") render :status => 200, :json => { :success => true, :info => "Logged in", :user => current_user } end def destroy warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure") sign_out render :status => 200, :json => { :success => true, :info => "Logged out", :csrfParam => request_forgery_protection_token, :csrfToken => form_authenticity_token } end def failure render :status => 401, :json => { :success => false, :info => "Login Credentials Failed" } end def show_current_user warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure") render :status => 200, :json => { :success => true, :info => "Current User", :user => current_user } end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/app/models/record.rb
app/models/record.rb
class Record < ActiveRecord::Base end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/app/models/user.rb
app/models/user.rb
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/db/seeds.rb
db/seeds.rb
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) Record.create(data: 'Some secure data...')
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/db/schema.rb
db/schema.rb
# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20131108124450) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "records", force: true do |t| t.string "data" t.datetime "created_at" t.datetime "updated_at" end create_table "users", force: true do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" end add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/db/migrate/20131108124450_create_records.rb
db/migrate/20131108124450_create_records.rb
class CreateRecords < ActiveRecord::Migration def change create_table :records do |t| t.string :data t.timestamps end end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/db/migrate/20120920193543_devise_create_users.rb
db/migrate/20120920193543_devise_create_users.rb
class DeviseCreateUsers < ActiveRecord::Migration def change create_table(:users) do |t| ## Database authenticatable t.string :email, :null => false, :default => "" t.string :encrypted_password, :null => false, :default => "" ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at ## Rememberable t.datetime :remember_created_at ## Trackable t.integer :sign_in_count, :default => 0 t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token # t.datetime :confirmed_at # t.datetime :confirmation_sent_at # t.string :unconfirmed_email # Only if using reconfirmable ## Lockable # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts # t.string :unlock_token # Only if unlock strategy is :email or :both # t.datetime :locked_at ## Token authenticatable # t.string :authentication_token t.timestamps end add_index :users, :email, :unique => true add_index :users, :reset_password_token, :unique => true # add_index :users, :confirmation_token, :unique => true # add_index :users, :unlock_token, :unique => true # add_index :users, :authentication_token, :unique => true end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/spec/spec_helper.rb
spec/spec_helper.rb
# This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } # Checks for pending migrations before tests are run. # If you are not using ActiveRecord, you can remove this line. ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) RSpec.configure do |config| # ## Mock Framework # # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: # # config.mock_with :mocha # config.mock_with :flexmock # config.mock_with :rr # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures config.fixture_path = "#{::Rails.root}/spec/fixtures" # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. config.use_transactional_fixtures = true # If true, the base class of anonymous controllers will be inferred # automatically. This will be the default behavior in future versions of # rspec-rails. config.infer_base_class_for_anonymous_controllers = false # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 config.order = "random" config.include FactoryGirl::Syntax::Methods config.include JsonSpec::Helpers RspecApiDocumentation.configure do |config| config.format = :json config.docs_dir = Rails.root.join("docs", "") end Faker::Config.locale = 'en-us' config.before(:each) { ActionMailer::Base.deliveries.clear } config.include Rails.application.routes.url_helpers end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/spec/support/api_helper.rb
spec/support/api_helper.rb
module ApiHelper include Rack::Test::Methods def app Rails.application end end RSpec.configure do |c| c.include ApiHelper, :type => :api end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/spec/support/request_helper.rb
spec/support/request_helper.rb
module Requests module JsonHelpers def json @json ||= JSON.parse(response.body) end end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/spec/factories/users.rb
spec/factories/users.rb
require 'faker' FactoryGirl.define do factory :user do |u| sequence(:email) { |n| "user#{n}_#{Time.now.to_i}@example.com" } password "password" password_confirmation "password" end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/spec/models/user_spec.rb
spec/models/user_spec.rb
require 'spec_helper' describe User do it "has a valid factory" do expect(build(:user)).to be_valid end let(:user) { create(:user) } describe "ActiveModel validations" do context "Basic validations" do it { should validate_presence_of :email } it { should validate_uniqueness_of :email } it { should validate_presence_of :password } end end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/spec/acceptance/api/v1/users_spec.rb
spec/acceptance/api/v1/users_spec.rb
require 'spec_helper' require 'rspec_api_documentation/dsl' resource 'User' do header "Accept", "application/vnd.radd.v1" let(:user) { create(:user) } get "/api/users" do include Warden::Test::Helpers before (:each) do login_as user, scope: :user end example_request "Show current user" do expect(response_body).to be_json_eql({:info => "Current User", :user => user }.to_json) expect(status).to eq 200 end end post "/api/users" do parameter :email, "Email", :required => true, :scope => :user parameter :password, "Password", :required => true, :scope => :user parameter :password_confirmation, "Password Confirmation", :required => true, :scope => :user example "Registering a user" do user = attributes_for(:user).except(:id) do_request(user: user) hash = JSON.parse(response_body) hash.to_json.should be_json_eql(user.except(:password, :password_confirmation).to_json) expect(status).to eq 201 #expect(ActionMailer::Base.deliveries.count).to eq 1 end end put "/api/users" do include Warden::Test::Helpers before do login_as user, scope: :user end parameter :email, "Email", :required => true, :scope => :user parameter :password, "Password", :required => true, :scope => :user parameter :password_confirmation, "Password Confirmation", :required => true, :scope => :user example "Updating a user" do user_attrs = attributes_for(:user).except(:id) do_request(user: user_attrs) expect(status).to eq 204 end end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/spec/acceptance/api/v1/sessions_spec.rb
spec/acceptance/api/v1/sessions_spec.rb
require 'spec_helper' require 'rspec_api_documentation/dsl' resource 'Session' do header "Accept", "application/vnd.radd.v1" let!(:user) { create(:user) } post "/api/sessions" do parameter :email, "Email", :required => true, :scope => :user parameter :password, "Password", :required => true, :scope => :user let(:email) { user.email } let(:password) { user.password } example_request "Logging in" do expect(response_body).to be_json_eql({:info => "Logged in", :success => true, :user => user }.to_json) expect(status).to eq 200 end end delete "/api/sessions" do include Warden::Test::Helpers before (:each) do login_as user, scope: :user end example_request "Logging out" do hash = JSON.parse(response_body) hash.delete('csrfParam') hash.delete('csrfToken') expect(hash.to_json).to be_json_eql({:info => "Logged out", :success => true }.to_json) expect(status).to eq 200 end end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/lib/api_constraints.rb
lib/api_constraints.rb
class ApiConstraints def initialize(options) @version = options[:version] @default = options[:default] end def matches?(req) @default || req.headers['Accept'].include?("application/vnd.radd.v#{@version}") end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/application.rb
config/application.rb
require File.expand_path('../boot', __FILE__) require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, :assets, Rails.env) module Radd class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de config.autoload_paths += Dir["#{config.root}/lib/**/"] # Enable escaping HTML in JSON. config.active_support.escape_html_entities_in_json = true config.to_prepare do DeviseController.respond_to :html, :json end config.active_record.schema_format = :ruby I18n.config.enforce_available_locales = false end end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/environment.rb
config/environment.rb
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Radd::Application.initialize!
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/routes.rb
config/routes.rb
Radd::Application.routes.draw do # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase # This route can be invoked with purchase_url(:id => product.id) # Sample resource route (maps HTTP verbs to controller actions automatically): # resources :products # Sample resource route with options: # resources :products do # member do # get 'short' # post 'toggle' # end # # collection do # get 'sold' # end # end # Sample resource route with sub-resources: # resources :products do # resources :comments, :sales # resource :seller # end # Sample resource route with more complex sub-resources # resources :products do # resources :comments # resources :sales do # get 'recent', :on => :collection # end # end # Sample resource route within a namespace: # namespace :admin do # # Directs /admin/products/* to Admin::ProductsController # # (app/controllers/admin/products_controller.rb) # resources :products # end # You can have the root of your site routed with "root" # just remember to delete public/index.html. # root :to => 'welcome#index' resources :home, only: [:index] root :to => "home#index" devise_for :users namespace :api, defaults: {format: :json} do scope module: :v1, constraints: ApiConstraints.new(version: 1, default: :true) do devise_scope :user do match '/sessions' => 'sessions#create', :via => :post match '/sessions' => 'sessions#destroy', :via => :delete end resources :record resources :users, only: [:create] match '/users' => 'users#show', :via => :get match '/users' => 'users#update', :via => :put match '/users' => 'users#destroy', :via => :delete end end # See how all your routes lay out with "rake routes" # This is a legacy wild controller route that's not recommended for RESTful applications. # Note: This route will make all actions in every controller accessible via GET requests. # match ':controller(/:action(/:id))(.:format)' end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/boot.rb
config/boot.rb
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/initializers/session_store.rb
config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. Radd::Application.config.session_store :cookie_store, key: '_radd_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rails generate session_migration") # Radd::Application.config.session_store :active_record_store
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/initializers/devise.rb
config/initializers/devise.rb
# Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| # The secret key used by Devise. Devise uses this key to generate # random tokens. Changing this key will render invalid all existing # confirmation, reset password and unlock tokens in the database. config.secret_key = '81ecd7571d2fa1aee44f55f11c1c152a6e81e5d552954a423399eba78a4eaee027027a0811d59f6569169f46e811c2931c518cda3f0c9aa4a7c189bfbb80971b' # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class with default "from" parameter. config.mailer_sender = "no-reply@travelizer.io" # Configure the class responsible to send e-mails. # config.mailer = "Devise::Mailer" # ==> ORM configuration # Load and configure the ORM. Supports :active_record (default) and # :mongoid (bson_ext recommended) by default. Other ORMs may be # available as additional gems. require 'devise/orm/active_record' # ==> Configuration for any authentication mechanism # Configure which keys are used when authenticating a user. The default is # just :email. You can configure it to use [:username, :subdomain], so for # authenticating a user, both parameters are required. Remember that those # parameters are used only when authenticating and not when retrieving from # session. If you need permissions, you should implement that in a before filter. # You can also supply a hash where the value is a boolean determining whether # or not authentication should be aborted when the value is not present. # config.authentication_keys = [ :email ] # Configure parameters from the request object used for authentication. Each entry # given should be a request method and it will automatically be passed to the # find_for_authentication method and considered in your model lookup. For instance, # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. # The same considerations mentioned for authentication_keys also apply to request_keys. # config.request_keys = [] # Configure which authentication keys should be case-insensitive. # These keys will be downcased upon creating or modifying a user and when used # to authenticate or find a user. Default is :email. config.case_insensitive_keys = [ :email ] # Configure which authentication keys should have whitespace stripped. # These keys will have whitespace before and after removed upon creating or # modifying a user and when used to authenticate or find a user. Default is :email. config.strip_whitespace_keys = [ :email ] # Tell if authentication through request.params is enabled. True by default. # It can be set to an array that will enable params authentication only for the # given strategies, for example, `config.params_authenticatable = [:database]` will # enable it only for database (email + password) authentication. # config.params_authenticatable = true # Tell if authentication through HTTP Basic Auth is enabled. False by default. # It can be set to an array that will enable http authentication only for the # given strategies, for example, `config.http_authenticatable = [:token]` will # enable it only for token authentication. # config.http_authenticatable = false # If http headers should be returned for AJAX requests. True by default. # config.http_authenticatable_on_xhr = true # The realm used in Http Basic Authentication. "Application" by default. # config.http_authentication_realm = "Application" # It will change confirmation, password recovery and other workflows # to behave the same regardless if the e-mail provided was right or wrong. # Does not affect registerable. # config.paranoid = true # By default Devise will store the user in session. You can skip storage for # :http_auth and :token_auth by adding those symbols to the array below. # Notice that if you are skipping storage for all authentication paths, you # may want to disable generating routes to Devise's sessions controller by # passing :skip => :sessions to `devise_for` in your config/routes.rb config.skip_session_storage = [:http_auth] # ==> Configuration for :database_authenticatable # For bcrypt, this is the cost for hashing the password and defaults to 10. If # using other encryptors, it sets how many times you want the password re-encrypted. # # Limiting the stretches to just one in testing will increase the performance of # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use # a value less than 10 in other environments. config.stretches = Rails.env.test? ? 1 : 10 # Setup a pepper to generate the encrypted password. # config.pepper = "ad495051247836771b266446087ca3232f75c1d4f0f20b9c9ff1e1fb34ee29f015998d50d4778d6c2984c682007aaaf78f4b679a318dd2cd1fd17f6d06f34e5b" # ==> Configuration for :confirmable # A period that the user is allowed to access the website even without # confirming his account. For instance, if set to 2.days, the user will be # able to access the website for two days without confirming his account, # access will be blocked just in the third day. Default is 0.days, meaning # the user cannot access the website without confirming his account. # config.allow_unconfirmed_access_for = 2.days # If true, requires any email changes to be confirmed (exactly the same way as # initial account confirmation) to be applied. Requires additional unconfirmed_email # db field (see migrations). Until confirmed new email is stored in # unconfirmed email column, and copied to email column on successful confirmation. config.reconfirmable = true # Defines which key will be used when confirming an account # config.confirmation_keys = [ :email ] # ==> Configuration for :rememberable # The time the user will be remembered without asking for credentials again. # config.remember_for = 2.weeks # If true, extends the user's remember period when remembered via cookie. # config.extend_remember_period = false # Options to be passed to the created cookie. For instance, you can set # :secure => true in order to force SSL only cookies. # config.rememberable_options = {} # ==> Configuration for :validatable # Range for password length. Default is 6..128. # config.password_length = 6..128 # Email regex used to validate email formats. It simply asserts that # an one (and only one) @ exists in the given string. This is mainly # to give user feedback and not to assert the e-mail validity. # config.email_regexp = /\A[^@]+@[^@]+\z/ # ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this # time the user will be asked for credentials again. Default is 30 minutes. # config.timeout_in = 30.minutes # If true, expires auth token on session timeout. # config.expire_auth_token_on_timeout = false # ==> Configuration for :lockable # Defines which strategy will be used to lock an account. # :failed_attempts = Locks an account after a number of failed attempts to sign in. # :none = No lock strategy. You should handle locking by yourself. # config.lock_strategy = :failed_attempts # Defines which key will be used when locking and unlocking an account # config.unlock_keys = [ :email ] # Defines which strategy will be used to unlock an account. # :email = Sends an unlock link to the user email # :time = Re-enables login after a certain amount of time (see :unlock_in below) # :both = Enables both strategies # :none = No unlock strategy. You should handle unlocking by yourself. # config.unlock_strategy = :both # Number of authentication tries before locking an account if lock_strategy # is failed attempts. # config.maximum_attempts = 20 # Time interval to unlock the account if :time is enabled as unlock_strategy. # config.unlock_in = 1.hour # ==> Configuration for :recoverable # # Defines which key will be used when recovering the password for an account # config.reset_password_keys = [ :email ] # Time interval you can reset your password with a reset password key. # Don't put a too small interval or your users won't have the time to # change their passwords. config.reset_password_within = 6.hours # ==> Configuration for :encryptable # Allow you to use another encryption algorithm besides bcrypt (default). You can use # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) # and :restful_authentication_sha1 (then you should set stretches to 10, and copy # REST_AUTH_SITE_KEY to pepper) # config.encryptor = :sha512 # ==> Configuration for :token_authenticatable # Defines name of the authentication token params key # config.token_authentication_key = :auth_token # ==> Scopes configuration # Turn scoped views on. Before rendering "sessions/new", it will first check for # "users/sessions/new". It's turned off by default because it's slower if you # are using only default views. config.scoped_views = true # Configure the default scope given to Warden. By default it's the first # devise role declared in your routes (usually :user). # config.default_scope = :user # Set this configuration to false if you want /users/sign_out to sign out # only the current scope. By default, Devise signs out all scopes. # config.sign_out_all_scopes = true # ==> Navigation configuration # Lists the formats that should be treated as navigational. Formats like # :html, should redirect to the sign in page when the user does not have # access, but formats like :xml or :json, should return 401. # # If you have any extra navigational formats, like :iphone or :mobile, you # should add them to the navigational formats lists. # # The "*/*" below is required to match Internet Explorer requests. # config.navigational_formats = ["*/*", :html] # The default HTTP method used to sign out a resource. Default is :delete. config.sign_out_via = :delete # ==> OmniAuth # Add a new OmniAuth provider. Check the wiki for more information on setting # up on your models and hooks. # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' # ==> Warden configuration # If you want to use other strategies, that are not supported by Devise, or # change the failure app, you can configure them inside the config.warden block. # # config.warden do |manager| # manager.intercept_401 = false # manager.default_strategies(:scope => :user).unshift :some_external_strategy # end # ==> Mountable engine configurations # When using Devise inside an engine, let's call it `MyEngine`, and this engine # is mountable, there are some extra configurations to be taken into account. # The following options are available, assuming the engine is mounted as: # # mount MyEngine, at: "/my_engine" # # The router that invoked `devise_for`, in the example above, would be: # config.router_name = :my_engine # # When using omniauth, Devise cannot automatically set Omniauth path, # so you need to do it manually. For the users scope, it would be: # config.omniauth_path_prefix = "/my_engine/users/auth" end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/initializers/wrap_parameters.rb
config/initializers/wrap_parameters.rb
# Be sure to restart your server when you modify this file. # # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] end # Disable root element in JSON by default. ActiveSupport.on_load(:active_record) do self.include_root_in_json = false end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/initializers/inflections.rb
config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections do |inflect| # inflect.acronym 'RESTful' # end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/initializers/backtrace_silencers.rb
config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # Rails.backtrace_cleaner.remove_silencers!
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/initializers/mime_types.rb
config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/initializers/secret_token.rb
config/initializers/secret_token.rb
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. Radd::Application.config.secret_token = '6feb73a38a88fc668d05b34ab6ca3fc4d1d45157172d7e056e8cebedccb35eb7988a5f4a7c3f1ef611c88d0a809e041f6333cce29621a1717012529394a28558' Radd::Application.config.secret_key_base = '6fb54cf90827377f6c3fd4c376e7b6841cd26d295511db5d877a0e145d5fdba769be5957f68eca09360ced98b135aa29f56b9fece16be44c14099266ead5cb50'
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/environments/test.rb
config/environments/test.rb
Radd::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. config.eager_load = false # Configure static asset server for tests with Cache-Control for performance. config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test config.action_mailer.default_url_options = { host: "localhost:3000" } # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/environments/development.rb
config/environments/development.rb
Radd::Application.configure do # Settings specified here will take precedence over those in config/application.rb. $stdout.sync = true # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false config.action_mailer.default_url_options = { host: "localhost:3000" } # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
jesalg/RADD
https://github.com/jesalg/RADD/blob/97a382ef33b8518b0990e14d0c44300bd0b51af2/config/environments/production.rb
config/environments/production.rb
Radd::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both thread web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Enable Rack::Cache to put a simple HTTP cache in front of your application # Add `rack-cache` to your Gemfile before enabling this. # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. # config.action_dispatch.rack_cache = true # Disable Rails's static asset server (Apache or nginx will already do this). config.serve_static_assets = true # Compress JavaScripts and CSS. config.assets.js_compressor = Uglifier.new(mangle: false) # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = true # Generate digests for assets URLs. config.assets.digest = true # Version of your assets, change this if you want to expire all your assets. config.assets.version = '1.0' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Set to :debug to see everything in the log. config.log_level = :info # Prepend all log lines with the following tags. # config.log_tags = [ :subdomain, :uuid ] # Use a different logger for distributed setups. # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production. # config.cache_store = :mem_cache_store # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # config.assets.precompile += %w( search.js ) # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation can not be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify # Disable automatic flushing of the log to improve performance. # config.autoflush_log = false # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new config.action_mailer.default_url_options = { host: "radd.herokuapp.com" } end
ruby
MIT
97a382ef33b8518b0990e14d0c44300bd0b51af2
2026-01-04T17:55:25.451414Z
false
calderalabs/rspec_api_blueprint
https://github.com/calderalabs/rspec_api_blueprint/blob/16d6e69bd65fcc4fe3b856c50962e24d0fb0ea85/lib/rspec_api_blueprint.rb
lib/rspec_api_blueprint.rb
require "rspec_api_blueprint/version" require "rspec_api_blueprint/string_extensions" RSpec.configure do |config| config.before(:suite) do if defined? Rails api_docs_folder_path = File.join(Rails.root, '/api_docs/') else api_docs_folder_path = File.join(File.expand_path('.'), '/api_docs/') end Dir.mkdir(api_docs_folder_path) unless Dir.exists?(api_docs_folder_path) Dir.glob(File.join(api_docs_folder_path, '*')).each do |f| File.delete(f) end end config.after(:each, type: :request) do response ||= last_response request ||= last_request if response example_group = example.metadata[:example_group] example_groups = [] while example_group example_groups << example_group example_group = example_group[:example_group] end action = example_groups[-2][:description_args].first if example_groups[-2] example_groups[-1][:description_args].first.match(/(\w+)\sRequests/) file_name = $1.underscore if defined? Rails file = File.join(Rails.root, "/api_docs/#{file_name}.txt") else file = File.join(File.expand_path('.'), "/api_docs/#{file_name}.txt") end File.open(file, 'a') do |f| # Resource & Action f.write "# #{action}\n\n" # Request request_body = request.body.read authorization_header = request.env ? request.env['Authorization'] : request.headers['Authorization'] if request_body.present? || authorization_header.present? f.write "+ Request #{request.content_type}\n\n" # Request Headers if authorization_header.present? f.write "+ Headers\n\n".indent(4) f.write "Authorization: #{authorization_header}\n\n".indent(12) end # Request Body if request_body.present? && request.content_type == 'application/json' f.write "+ Body\n\n".indent(4) if authorization_header f.write "#{JSON.pretty_generate(JSON.parse(request_body))}\n\n".indent(authorization_header ? 12 : 8) end end # Response f.write "+ Response #{response.status} #{response.content_type}\n\n" if response.body.present? && response.content_type =~ /application\/json/ f.write "#{JSON.pretty_generate(JSON.parse(response.body))}\n\n".indent(8) end end unless response.status == 401 || response.status == 403 || response.status == 301 end end end
ruby
MIT
16d6e69bd65fcc4fe3b856c50962e24d0fb0ea85
2026-01-04T17:55:28.474567Z
false
calderalabs/rspec_api_blueprint
https://github.com/calderalabs/rspec_api_blueprint/blob/16d6e69bd65fcc4fe3b856c50962e24d0fb0ea85/lib/rspec_api_blueprint/version.rb
lib/rspec_api_blueprint/version.rb
module RspecApiBlueprint VERSION = "0.0.8" end
ruby
MIT
16d6e69bd65fcc4fe3b856c50962e24d0fb0ea85
2026-01-04T17:55:28.474567Z
false
calderalabs/rspec_api_blueprint
https://github.com/calderalabs/rspec_api_blueprint/blob/16d6e69bd65fcc4fe3b856c50962e24d0fb0ea85/lib/rspec_api_blueprint/string_extensions.rb
lib/rspec_api_blueprint/string_extensions.rb
unless "".respond_to?(:indent) class String def indent(count, char = ' ') gsub(/([^\n]*)(\n|$)/) do |match| last_iteration = ($1 == "" && $2 == "") line = "" line << (char * count) unless last_iteration line << $1 line << $2 line end end end end
ruby
MIT
16d6e69bd65fcc4fe3b856c50962e24d0fb0ea85
2026-01-04T17:55:28.474567Z
false
amatsuda/string_template
https://github.com/amatsuda/string_template/blob/ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3/benchmark.rb
benchmark.rb
# frozen_string_literal: true require 'benchmark_driver' Benchmark.driver do |x| x.prelude %{ require 'rails' require 'action_view' require 'string_template' StringTemplate::Railtie.run_initializers require 'action_view/base' (view = Class.new(ActionView::Base).new(ActionView::LookupContext.new(''))).instance_variable_set(:@world, 'world!') } x.report 'erb', %{ view.render(template: 'hello', handlers: 'erb') } x.report 'string', %{ view.render(template: 'hello', handlers: 'string') } end
ruby
MIT
ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3
2026-01-04T17:55:25.805409Z
false
amatsuda/string_template
https://github.com/amatsuda/string_template/blob/ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3/test/string_template_test.rb
test/string_template_test.rb
# frozen_string_literal: true require 'test_helper' class StringTemplateTest < Minitest::Test def setup @view = if ActionView::VERSION::MAJOR >= 6 Class.new(ActionView::Base.with_empty_template_cache).with_view_paths([__dir__]) else Class.new(ActionView::Base).new(ActionView::LookupContext.new(__dir__)) end super end def assert_render(expected, template, options = {}) result = @view.render(options.merge(inline: template, type: 'string')) assert_equal expected, result end def test_no_interpolation assert_render 'hello', 'hello' end def test_basic_interpolation assert_render 'hello', '#{"hello"}' end def test_ivar @view.instance_variable_set :@foo, 'hello' assert_render 'hello', '#{@foo}' end def test_if assert_render 'hello', '#{if true;"hello";end}' assert_render 'hello', '#{"hello" if true}' end def test_each_as_map_and_join assert_render "hello\nhello\nhello", '#{[*1..3].map do "hello" end.join("\n")}' end def test_each_with_object assert_render "hello\nhello\nhello\n", '#{[*1..3].each_with_object("".dup) do |i, s| s << "hello\n" end}' end def test_locals assert_render 'hello', '#{foo}', locals: {foo: 'hello'} end def test_render_partial result = @view.render(template: 'main', handlers: :string) assert_equal 'hello, world!', result.strip end end
ruby
MIT
ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3
2026-01-04T17:55:25.805409Z
false
amatsuda/string_template
https://github.com/amatsuda/string_template/blob/ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3/test/test_helper.rb
test/test_helper.rb
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) # require logger before requiring rails, or Rails 6 fails to boot require 'logger' require 'rails' require 'action_view' require "string_template" StringTemplate::Railtie.run_initializers require 'action_view/base' require "minitest/autorun"
ruby
MIT
ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3
2026-01-04T17:55:25.805409Z
false
amatsuda/string_template
https://github.com/amatsuda/string_template/blob/ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3/lib/string_template.rb
lib/string_template.rb
# frozen_string_literal: true require_relative 'string_template/handler' require_relative 'string_template/railtie'
ruby
MIT
ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3
2026-01-04T17:55:25.805409Z
false
amatsuda/string_template
https://github.com/amatsuda/string_template/blob/ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3/lib/string_template/railtie.rb
lib/string_template/railtie.rb
# frozen_string_literal: true module StringTemplate class Railtie < ::Rails::Railtie initializer 'string_template' do ActiveSupport.on_load :action_view do ActionView::Template.register_template_handler :string, StringTemplate::Handler end end end end
ruby
MIT
ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3
2026-01-04T17:55:25.805409Z
false
amatsuda/string_template
https://github.com/amatsuda/string_template/blob/ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3/lib/string_template/handler.rb
lib/string_template/handler.rb
# frozen_string_literal: true module StringTemplate class Handler def self.call(template, source = nil) "%Q\0#{source || template.source}\0" end def self.handles_encoding? true end end end
ruby
MIT
ce8fff3b6d3679d9362c6c6f83410f5a9a5455a3
2026-01-04T17:55:25.805409Z
false
shlima/translate_enum
https://github.com/shlima/translate_enum/blob/1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0/spec/spec_helper.rb
spec/spec_helper.rb
require 'pry' require 'active_model' require 'action_view' require 'translate_enum' RSpec.configure do |config| config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true end config.shared_context_metadata_behavior = :apply_to_host_groups config.filter_run_when_matching :focus config.disable_monkey_patching! config.warnings = true config.profile_examples = 0 config.order = :random Kernel.srand config.seed end
ruby
MIT
1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0
2026-01-04T17:55:30.719325Z
false
shlima/translate_enum
https://github.com/shlima/translate_enum/blob/1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0/spec/translate_enum/action_view_spec.rb
spec/translate_enum/action_view_spec.rb
RSpec.describe ActionView do let(:view) do Class.new do include ActionView::Helpers include ActionView::Context end.new end let(:model) do Class.new do include ActiveModel::Model include TranslateEnum translate_enum :status def self.model_name ActiveModel::Name.new(nil, nil, 'model') end def self.statuses { published: 1, removed: 0 } end end end describe 'select_tag' do subject do options_for_select = model.translated_statuses.map { |translation, k, _v| [translation, k] } view.select_tag :statuses, view.options_for_select(options_for_select, selected: :published) end let(:expectation) do <<-HTML.chomp <select name="statuses" id="statuses"><option selected="selected" value="published">translation missing: en.activemodel.attributes.model.status_list.published</option> <option value="removed">translation missing: en.activemodel.attributes.model.status_list.removed</option></select> HTML end it 'puts value inside hidden option and translation inside visible tag' do expect(subject).to eq(expectation) end end end
ruby
MIT
1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0
2026-01-04T17:55:30.719325Z
false
shlima/translate_enum
https://github.com/shlima/translate_enum/blob/1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0/spec/translate_enum/translate_enum_spec.rb
spec/translate_enum/translate_enum_spec.rb
RSpec.describe TranslateEnum do let(:model_base) do Class.new do include ActiveModel::Model include TranslateEnum def self.model_name ActiveModel::Name.new(nil, nil, 'model') end def self.genders { male: 0, female: 1 } end def gender @gender ||= :male end def gender=(value) @gender = value end end end subject do model.new end context 'default' do let(:model) do Class.new(model_base) do translate_enum :gender end end let(:translations) do { male: 'I am a default of the male', female: 'Female (not default)' } end before do I18n.backend.store_translations(:en, attributes: { gender_list: { male: translations.fetch(:male) } }) I18n.backend.store_translations(:en, activemodel: { attributes: { model: { gender_list: { female: translations.fetch(:female) } } } }) end after do I18n.reload! end it 'uses default path as a fallback' do expect(model.translated_gender(:male)).to eq(translations.fetch(:male)) expect(model.translated_gender(:female)).to eq(translations.fetch(:female)) end end context 'default options' do let(:model) do Class.new(model_base) do translate_enum :gender end end let(:translations) do { male: 'translation missing: en.activemodel.attributes.model.gender_list.male', female: 'translation missing: en.activemodel.attributes.model.gender_list.female' } end it '#translated_gender' do expect(subject.gender).to eq(:male) expect { subject.gender = :female }.to change { subject.translated_gender }.from(translations.fetch(:male)).to(translations.fetch(:female)) expect(subject.gender).to eq(:female) end it '.translated_gender' do expect(model.translated_gender(:male)).to eq(translations.fetch(:male)) expect(model.translated_gender(:female)).to eq(translations.fetch(:female)) end it '.translated_genders' do expectation = [ [translations.fetch(:male), :male, 0], [translations.fetch(:female), :female, 1] ] expect(model.translated_genders).to match_array(expectation) end end context 'redefined options' do let(:model) do Class.new(model_base) do translate_enum :gender do |config| config.i18n_scope = 'scope' config.i18n_key = 'key' config.enum_klass_method_name = 'my_genders_method' config.enum_instance_method_name = 'my_gender_method' config.method_name_singular = 'russian_gender' config.method_name_plural = 'russian_genders' end class << self undef :genders end undef :gender undef :gender= def self.my_genders_method { male: 0, female: 1 } end def my_gender_method @my_gender_method ||= :male end def my_gender_method=(value) @my_gender_method = value end end end let(:translations) do { male: 'translation missing: en.scope.model.key.male', female: 'translation missing: en.scope.model.key.female' } end it '.russian_gender' do expect(model.russian_gender(:male)).to eq(translations.fetch(:male)) expect(model.russian_gender(:female)).to eq(translations.fetch(:female)) end it '.russian_genders' do expectation = [ [translations.fetch(:male), :male, 0], [translations.fetch(:female), :female, 1] ] expect(model.russian_genders).to match_array(expectation) end it '#russian_gender' do expect(subject.russian_gender).to eq(translations.fetch(:male)) end end context 'redefined methods' do let(:model) do Class.new(model_base) do translate_enum :gender def self.translated_gender(key, **options) "foo_bar_#{key}" end end end it 'returns redefined value' do expect(subject.translated_gender).to eq('foo_bar_male') end end context 'count' do let(:model) do Class.new(model_base) do translate_enum :gender end end let(:translations) do { male: { zero: 'no males', one: 'one male', other: '%{count} males' } } end before do I18n.backend.store_translations(:en, activemodel: { attributes: { model: { gender_list: translations } } } ) end after do I18n.reload! end it 'uses count' do expect(model.translated_gender(:male, count: 0)).to eq('no males') expect(model.translated_gender(:male, count: 1)).to eq('one male') expect(model.translated_gender(:male, count: 3)).to eq('3 males') expect(subject.translated_gender(count: 0)).to eq('no males') expect(subject.translated_gender(count: 1)).to eq('one male') expect(subject.translated_gender(count: 3)).to eq('3 males') expect(subject.translated_gender).to eq('one male') expect(subject.translated_gender).to eq('one male') expect(model.translated_genders.to_s).to include('one male') end end context 'trow' do let(:model) do Class.new(model_base) do translate_enum :gender end end it 'it works' do expect { model.translated_gender(:male, raise: true) }.to raise_error(I18n::MissingTranslationData) expect { model.translated_genders(raise: true) }.to raise_error(I18n::MissingTranslationData) expect { subject.translated_gender(raise: true) }.to raise_error(I18n::MissingTranslationData) end end end
ruby
MIT
1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0
2026-01-04T17:55:30.719325Z
false
shlima/translate_enum
https://github.com/shlima/translate_enum/blob/1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0/spec/translate_enum/active_record_spec.rb
spec/translate_enum/active_record_spec.rb
RSpec.describe 'ActiveRecord::Base', order: :defined do subject do require 'translate_enum/active_record' end context 'ActiveRecord is undefined' do it 'raises an error' do expect { subject }.to raise_error(NameError) end end context 'ActiveRecord defined' do let(:active_record_class) do Class.new end before do stub_const('ActiveRecord::Base', active_record_class) end it 'extends ActiveRecord' do expect { subject }.to change { ActiveRecord::Base.respond_to?(:translate_enum) }.to true end end end
ruby
MIT
1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0
2026-01-04T17:55:30.719325Z
false
shlima/translate_enum
https://github.com/shlima/translate_enum/blob/1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0/lib/translate_enum.rb
lib/translate_enum.rb
# frozen_string_literal: true require 'active_support/concern' require 'active_support/core_ext/string' require 'translate_enum/version' require 'translate_enum/builder' module TranslateEnum extend ActiveSupport::Concern # include TranslateEnum in ActiveModel or ActiveRecord module ClassMethods # @example # class User < ActiveRecord::Base # include TranslateEnum # enum status: %i(active archived) # translate_enum :status # end # # User.translated_status(:active) #=> "Active translation" def translate_enum(attribute, &block) builder = Builder.new(self, attribute, &block) # User.translated_status(:active) define_singleton_method(builder.method_name_singular) do |key, throw: false, raise: false, locale: nil, **options| opts = { default: builder.i18n_default_location(key) }.merge(options) I18n.translate("#{builder.i18n_scope}.#{builder.i18n_location(key)}", throw: throw, raise: raise, locale: locale, **opts) end # @return [Array] # @example # f.select_field :gender, f.object.class.translated_genders define_singleton_method(builder.method_name_plural) do |throw: false, raise: false, locale: nil, **options| options = { count: 1 }.merge(options) public_send(builder.enum_klass_method_name).map do |key, value| translation = public_send(builder.method_name_singular, key, throw: throw, raise: raise, locale: locale, **options) [translation, key, value] end end # @return [String] # @example # @user.translated_gender define_method(builder.method_name_singular) do |throw: false, raise: false, locale: nil, **options| if (key = public_send(builder.enum_instance_method_name)).present? options = { count: 1 }.merge(options) self.class.public_send(builder.method_name_singular, key, throw: throw, raise: raise, locale: locale, **options) end end end end end
ruby
MIT
1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0
2026-01-04T17:55:30.719325Z
false
shlima/translate_enum
https://github.com/shlima/translate_enum/blob/1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0/lib/translate_enum/active_record.rb
lib/translate_enum/active_record.rb
# frozen_string_literal: true # Require this fle in order to be +TranslateEnum+ included in +ActiveRecord::Base+ # @example # require 'translate_enum/active_record' require_relative '../translate_enum' unless defined?(ActiveRecord::Base) raise NameError, 'TranslateEnum requires ActiveRecord be defined but it is not' end ActiveRecord::Base.include(TranslateEnum)
ruby
MIT
1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0
2026-01-04T17:55:30.719325Z
false
shlima/translate_enum
https://github.com/shlima/translate_enum/blob/1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0/lib/translate_enum/version.rb
lib/translate_enum/version.rb
# frozen_string_literal: true module TranslateEnum VERSION = '0.2.0' end
ruby
MIT
1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0
2026-01-04T17:55:30.719325Z
false
shlima/translate_enum
https://github.com/shlima/translate_enum/blob/1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0/lib/translate_enum/builder.rb
lib/translate_enum/builder.rb
# frozen_string_literal: true module TranslateEnum class Builder attr_accessor :i18n_scope attr_accessor :i18n_key attr_accessor :enum_instance_method_name attr_accessor :enum_klass_method_name attr_accessor :method_name_singular attr_accessor :method_name_plural attr_reader :model, :attribute # @param model [ActiveModel::Model, ActiveRecord::Base] # @param attribute [String] def initialize(model, attribute) @model = model @attribute = attribute yield(self) if block_given? end # like "activerecord.attributes" or "activemodel.attributes" def i18n_scope @i18n_scope ||= "#{model.i18n_scope}.attributes" end def i18n_key @i18n_key ||= "#{attribute}_list" end def i18n_location(key) "#{model.model_name.i18n_key}.#{i18n_key}.#{key}" end def i18n_default_location(key) :"attributes.#{i18n_key}.#{key}" end # @param [String] # like "translated_genders" def method_name_plural @method_name_plural ||= "translated_#{attribute.to_s.pluralize}" end # @param [String] # like "translated_gender" def method_name_singular @method_name_singular ||= "translated_#{attribute.to_s.singularize}" end def enum_klass_method_name @enum_klass_method_name ||= attribute.to_s.pluralize end def enum_instance_method_name @enum_instance_method_name ||= attribute end end end
ruby
MIT
1c24f623b8476dc6eb26bb05f5cbd1266d10c4f0
2026-01-04T17:55:30.719325Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/spec/spec_helper.rb
spec/spec_helper.rb
require 'bundler' Bundler.require(:default, :development) # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} RSpec.configure do |config| config.mock_with :rspec end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/spec/lib/slurper/client_spec.rb
spec/lib/slurper/client_spec.rb
require 'spec_helper' describe Slurper::Client do subject { Slurper::Client } it 'uses the project id in the url' do expect(described_class::CREATE_STORY_URL).to eq "https://www.pivotaltracker.com/services/v5/projects/12345/stories" end describe '#create' do let(:story) { Slurper::Story.new } before { allow(story).to receive(:requested_by_id).and_return(11) } it 'posts the story to pivotal' do expect(RestClient).to receive(:post).with( Slurper::Client::CREATE_STORY_URL, story.to_json, { "Content-Type" => "application/json", "X-TrackerToken" => Slurper::Config.token } ) Slurper::Client.create(story) end end describe '#users' do it 'retrieves the users from pivotal' do expect(RestClient).to receive(:get).with( Slurper::Client::USERS_URL, { "X-TrackerToken" => Slurper::Config.token } ) Slurper::Client.users end end end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/spec/lib/slurper/story_spec.rb
spec/lib/slurper/story_spec.rb
require 'spec_helper' describe Slurper::Story do before do allow(Slurper::User).to receive(:collection).and_return( [Slurper::User.new(name: 'Johnny Hashrocket', id: 9)] ) end describe '#to_json' do subject { story.to_json } context 'fully populated' do let(:story) do described_class.new( name: 'one', description: 'two', story_type: 'bug', labels: 'three,four', estimate: 5 ) end it do should == { name: 'one', description: 'two', story_type: 'bug', labels: [{name:'three'},{name:'four'}], estimate: 5, requested_by_id: 9 }.to_json end end context 'with just a name' do let(:story) { described_class.new(name: 'one') } it { should == { name: 'one', requested_by_id: 9 }.to_json } end end describe "#description" do subject { story.description } let(:story) { described_class.new(description: description) } context "when the description is blank" do let(:description) { '' } it { should be_nil } end context "when there is no description given" do let(:story) { described_class.new } it { should be_nil } end context "when it contains quotes" do let(:description) do <<-STRING I have a "quote" STRING end it { should == "I have a \"quote\"" } end context "when it is full of whitespace" do let(:description) do <<-STRING In order to do something As a role I want to click a thingy STRING end it { should == "In order to do something\nAs a role\nI want to click a thingy" } end context "when it contains acceptance criteria" do let(:description) do <<-STRING In order to do something As a role I want to click a thingy Acceptance: - do the thing - don't forget the other thing STRING end it { should == "In order to do something\nAs a role\nI want to click a thingy\n\nAcceptance:\n- do the thing\n- don't forget the other thing" } end end describe '#labels' do let(:story) { described_class.new(labels: labels) } subject { story.labels } context 'when blank' do let(:labels) { nil } it { should == [] } end context 'with one' do let(:labels) { 'tag' } it { should == [{name:'tag'}] } end context 'with multiple' do let(:labels) { 'one,two' } it { should == [{name:'one'},{name:'two'}] } end end describe "#requested_by" do subject { story.requested_by } let(:story) { described_class.new(requested_by: requested_by) } context "uses the default if not provided" do let(:requested_by) { nil } it { should == 'Johnny Hashrocket' } end context "uses the default if given a blank" do let(:requested_by) { '' } it { should == 'Johnny Hashrocket' } end context "uses the name given in the story file if there is one" do let(:requested_by) { 'Mr. Stakeholder' } it { should == 'Mr. Stakeholder' } end end describe '#requested_by_id' do subject { story.requested_by_id } let(:story) { described_class.new(requested_by: requested_by) } before do allow(Slurper::User).to receive(:collection).and_return([Slurper::User.new(name: 'George Washington', id: 5)]) end context 'with a matching user' do let(:requested_by) { 'George Washington' } it { should == 5 } end context 'without a matching user' do let(:requested_by) { 'Peter Pan' } it { should be_nil } end end end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/spec/lib/slurper/config_spec.rb
spec/lib/slurper/config_spec.rb
require 'spec_helper' describe Slurper::Config do subject { Slurper::Config } it { expect(subject.project_id).to eq 12345 } it { expect(subject.requested_by).to eq 'Johnny Hashrocket' } it { expect(subject.token).to eq '123abc123abc123abc123abc' } end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/spec/lib/slurper/engine_spec.rb
spec/lib/slurper/engine_spec.rb
require 'spec_helper' describe Slurper::Engine do subject { engine.stories.first } let(:engine) { described_class.new(File.join(File.dirname(__FILE__), "..", "..", "fixtures", filename)) } context "deals with leading/trailing whitespace" do let(:filename) { 'whitespacey_story.slurper' } it{ expect(subject.name).to eq('Profit') } it{ expect(subject.description).to eq("In order to do something\nAs a role\nI want to click a thingy") } it{ expect(subject.story_type).to be_nil } it{ expect(subject.labels).to eq [] } it{ expect(subject.estimate).to be_nil } it{ expect(subject.requested_by).to eq 'Johnny Hashrocket' } end context "given values for all attributes" do let(:filename) { 'full_story.slurper' } it { expect(subject.name).to eq 'Profit' } it { expect(subject.description).to eq "In order to do something\nAs a role\nI want to click a thingy\n\nAcceptance:\n- do the thing\n- don't forget the other thing" } it { expect(subject.story_type).to eq 'feature' } it { expect(subject.labels).to eq [{name:'money'},{name:'power'},{name:'fame'}] } it { expect(subject.estimate).to be_nil } it { expect(subject.requested_by).to eq 'Johnny Hashrocket' } end context "given only a name" do let(:filename) { 'name_only.slurper' } it { expect(subject.name).to eq 'Profit' } it { expect(subject.description).to be_blank } it { expect(subject.story_type).to be_nil } it { expect(subject.labels).to eq [] } it { expect(subject.estimate).to be_nil } it { expect(subject.requested_by).to eq 'Johnny Hashrocket' } end context "given empty attributes" do let(:filename) { 'empty_attributes.slurper' } it { expect(subject.name).to be_blank } it { expect(subject.description).to be_blank } it { expect(subject.story_type).to be_nil } it { expect(subject.labels).to eq [] } it { expect(subject.estimate).to be_nil } it { expect(subject.requested_by).to eq 'Johnny Hashrocket' } end context "given advanced attributes" do let(:filename) { 'advanced_stories.slurper' } it { expect(subject.name).to eq "Make the cart accept coupons on checkout" } it { expect(subject.description).to eq "When I get to the checkout phase, I want the ability to add an optional coupon code. Use TESTCOUPON to test with." } it { expect(subject.story_type).to eq 'feature' } it { expect(subject.labels).to eq [{name:'cart'},{name:'coupon system'},{name:'checkout'}] } it { expect(subject.estimate).to eq 3 } it { expect(subject.requested_by).to eq 'Joe Developer' } end context "given bad identation" do let(:filename) { 'windows_google_doc_bad_indentation.slurper' } it { expect(subject.name).to eq "Attorney Signs up through Attorney Portal" } it { expect(subject.description).to eq <<~HEREDOC.strip } Given I’m an Attorney When I arrive at the attorney portal signup page And I fill in the name field with my name And I fill in the firm name field with my firm name And I fill in the bar number with my state bar id number And I click Submit Then I am on the Attorney Portal Dashboard HEREDOC it { expect(subject.story_type).to eq 'feature' } it { expect(subject.labels).to eq [{name:'attorney-portal'}] } it { expect(subject.requested_by).to eq 'Johnny Hashrocket' } end end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/spec/lib/slurper/user_spec.rb
spec/lib/slurper/user_spec.rb
require 'spec_helper' describe Slurper::User do describe '.collection' do before do allow(Slurper::Client).to receive(:users).and_return( [ { "person" => { "id" => 100, "name" => "Emperor Palpatine" } }, { "person" => { "id" => 101, "name" => "Darth Vader" } } ] ) end it 'turns the json response into User objects' do user1 = described_class.collection.first expect(user1.id).to eq 100 expect(user1.name).to eq 'Emperor Palpatine' user2 = described_class.collection.last expect(user2.id).to eq 101 expect(user2.name).to eq 'Darth Vader' end end describe '.find_by_name' do let(:user) { described_class.new(name: 'Awesome Guy', id: 9) } before do allow(Slurper::User).to receive(:collection).and_return([user, described_class.new(name: 'Super Girl', id: 7)]) end subject { described_class.find_by_name(name) } context 'with a found user' do let(:name) { 'Awesome Guy' } it { should == user } end context 'no user found' do let(:name) { 'Nu Exista' } it { should be_nil } end end end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/lib/slurper.rb
lib/slurper.rb
require 'active_support' require 'active_support/core_ext/object' require 'yaml' module Slurper autoload :Client, 'slurper/client' autoload :Config, 'slurper/config' autoload :Engine, 'slurper/engine' autoload :Story, 'slurper/story' autoload :User, 'slurper/user' def self.slurp(story_file, reverse) slurper = Engine.new(story_file) slurper.stories.reverse! unless reverse slurper.process end end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/lib/slurper/story.rb
lib/slurper/story.rb
require 'json' module Slurper class Story attr_accessor :attributes def initialize(attrs={}) self.attributes = (attrs || {}).symbolize_keys if attributes[:owned_by].present? puts "DEPRECATION WARNING: `owned_by` is no longer a supported attribute. Please change to `requested_by`." attributes[:requested_by] = attributes[:owned_by] end end def to_json { name: name, description: description, story_type: story_type, labels: labels, estimate: estimate, requested_by_id: requested_by_id }.reject { |k,v| v.blank? }.to_json end def save (@response = Slurper::Client.create(self)).success? end def error_message; @response.body end def name; attributes[:name] end def estimate; attributes[:estimate] end def story_type; attributes[:story_type] end def description return nil unless attributes[:description].present? attributes[:description].split("\n").map(&:strip).join("\n") end def labels return [] unless attributes[:labels].present? attributes[:labels].split(',').map do |tag| {name: tag} end end def requested_by attributes[:requested_by].presence || Slurper::Config.requested_by end def requested_by_id Slurper::User.find_by_name(requested_by).try(:id) if requested_by.present? end def valid? if name.blank? raise "Name is blank for story:\n#{to_json}" elsif !requested_by_id raise "Could not find requester \"#{requested_by}\" in project" end end end end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/lib/slurper/client.rb
lib/slurper/client.rb
require 'rest-client' module Slurper class Client CREATE_STORY_URL = "https://www.pivotaltracker.com/services/v5/projects/#{Slurper::Config.project_id}/stories" USERS_URL = "https://www.pivotaltracker.com/services/v5/projects/#{Slurper::Config.project_id}/memberships" def self.create(story) RestClient.post( CREATE_STORY_URL, story.to_json, { "Content-Type" => "application/json", "X-TrackerToken" => Slurper::Config.token } ) end def self.users JSON.parse(RestClient.get( USERS_URL, { "X-TrackerToken" => Slurper::Config.token } ).try(:body) || '[]') end end end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/lib/slurper/config.rb
lib/slurper/config.rb
module Slurper class Config def self.project_id; @project_id ||= yaml['project_id'] end def self.requested_by; @requested_by ||= yaml['requested_by'] end def self.token; @token ||= yaml['token'] end private def self.yaml YAML.load_file('slurper_config.yml') end end end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/lib/slurper/engine.rb
lib/slurper/engine.rb
module Slurper class Engine < Struct.new(:story_file) def stories @stories ||= YAML.load(yamlize_story_file).map { |attrs| Slurper::Story.new(attrs) } end def process puts "Validating story content" stories.each(&:valid?) puts "Preparing to slurp #{stories.size} stories into Tracker..." stories.each_with_index do |story, index| if story.save puts "#{index+1}. #{story.name}" else puts "Slurp failed. #{story.error_message}" end end end protected def yamlize_story_file IO.read(story_file) .yield_self {|x| x.strip} .yield_self {|x| x.gsub(/^ \b/, " ") } .yield_self {|x| x.gsub(/^/, " ") } .yield_self {|x| x.gsub(/ $/, "") } .yield_self {|x| x.gsub(/ ==.*/, "-") } .yield_self {|x| x.gsub(/ description:$/, " description: |") } end end end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
hashrocket/slurper
https://github.com/hashrocket/slurper/blob/4e31454411387ca638c4667b13614969a3bdc18e/lib/slurper/user.rb
lib/slurper/user.rb
module Slurper class User attr_accessor :attributes def initialize(attrs={}) self.attributes = (attrs || {}).symbolize_keys end def self.collection @collection ||= Slurper::Client.users.map do |attrs| Slurper::User.new(attrs['person']) end end def self.find_by_name(name) collection.detect { |user| user.name == name } end def name; attributes[:name] end def id; attributes[:id] end end end
ruby
MIT
4e31454411387ca638c4667b13614969a3bdc18e
2026-01-04T17:55:36.755248Z
false
phatworx/easy_captcha
https://github.com/phatworx/easy_captcha/blob/d3a0281b00bd8fc67caf15a0380e185809f12252/init.rb
init.rb
require 'easy_captcha'
ruby
MIT
d3a0281b00bd8fc67caf15a0380e185809f12252
2026-01-04T17:55:31.126454Z
false
phatworx/easy_captcha
https://github.com/phatworx/easy_captcha/blob/d3a0281b00bd8fc67caf15a0380e185809f12252/spec/espeak_spec.rb
spec/espeak_spec.rb
# encoding: utf-8 require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe EasyCaptcha::Espeak do context 'check default values' do subject { EasyCaptcha::Espeak.new } its(:amplitude) { (80..120).should include(subject.amplitude) } its(:pitch) { (30..70).should include(subject.pitch) } its(:gap) { should eq 80 } its(:voice) { should be_nil } end context 'check config: voices' do let(:voices) { ['german', 'german+m1'] } subject do EasyCaptcha::Espeak.new do |config| config.voice = voices end end it { voices.should include(subject.voice) } end end
ruby
MIT
d3a0281b00bd8fc67caf15a0380e185809f12252
2026-01-04T17:55:31.126454Z
false