Class: HubSpotSDK::Resources::Crm::ObjectSchemas

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot_sdk/resources/crm/object_schemas.rb,
lib/hubspot_sdk/resources/crm/object_schemas/batch.rb

Defined Under Namespace

Classes: Batch

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ObjectSchemas

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ObjectSchemas.

Parameters:



234
235
236
237
# File 'lib/hubspot_sdk/resources/crm/object_schemas.rb', line 234

def initialize(client:)
  @client = client
  @batch = HubSpotSDK::Resources::Crm::ObjectSchemas::Batch.new(client: client)
end

Instance Attribute Details

#batchHubSpotSDK::Resources::Crm::ObjectSchemas::Batch (readonly)



8
9
10
# File 'lib/hubspot_sdk/resources/crm/object_schemas.rb', line 8

def batch
  @batch
end

Instance Method Details

#create(allows_sensitive_properties:, associated_objects:, labels:, name:, properties:, required_properties:, searchable_properties:, secondary_display_properties:, description: nil, primary_display_property: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::ObjectSchema

Some parameter documentations has been truncated, see Models::Crm::ObjectSchemaCreateParams for more details.

Create a new custom object schema by defining its properties and associations.

Parameters:

  • allows_sensitive_properties (Boolean)

    Determines if the object type can include properties that are marked as sensitiv

  • associated_objects (Array<String>)

    Associations defined for this object type.

  • labels (HubSpotSDK::Models::ObjectTypeDefinitionLabels)
  • name (String)

    A unique name for this object. For internal use only.

  • properties (Array<HubSpotSDK::Models::Crm::ObjectTypePropertyCreate>)

    Properties defined for this object type.

  • required_properties (Array<String>)

    The names of properties that should be required when creating an object of t

  • searchable_properties (Array<String>)

    Names of properties that will be indexed for this object type in by HubSpot’s pr

  • secondary_display_properties (Array<String>)

    The names of secondary properties for this object. These will be displayed as se

  • description (String)

    A brief explanation of the object type.

  • primary_display_property (String)

    The name of the primary property for this object. This will be displayed as prim

  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



42
43
44
45
46
47
48
49
50
51
# File 'lib/hubspot_sdk/resources/crm/object_schemas.rb', line 42

def create(params)
  parsed, options = HubSpotSDK::Crm::ObjectSchemaCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "crm-object-schemas/2026-03/schemas",
    body: parsed,
    model: HubSpotSDK::Crm::ObjectSchema,
    options: options
  )
end

#create_association(object_type, from_object_type_id:, to_object_type_id:, name: nil, request_options: {}) ⇒ HubSpotSDK::Models::AssociationDefinition

Create a new association between the specified object type and another object type. This operation requires the definition of the association attributes, such as the primary and target object type IDs.

Parameters:

  • object_type (String)
  • from_object_type_id (String)
  • to_object_type_id (String)
  • name (String)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



159
160
161
162
163
164
165
166
167
168
# File 'lib/hubspot_sdk/resources/crm/object_schemas.rb', line 159

def create_association(object_type, params)
  parsed, options = HubSpotSDK::Crm::ObjectSchemaCreateAssociationParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["crm-object-schemas/2026-03/schemas/%1$s/associations", object_type],
    body: parsed,
    model: HubSpotSDK::AssociationDefinition,
    options: options
  )
end

#delete(object_type, archived: nil, request_options: {}) ⇒ nil

Remove a custom object schema from the account using its object type ID or fully qualified name.

Parameters:

  • object_type (String)
  • archived (Boolean)

    Whether to return only results that have been archived.

  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/hubspot_sdk/resources/crm/object_schemas.rb', line 132

def delete(object_type, params = {})
  parsed, options = HubSpotSDK::Crm::ObjectSchemaDeleteParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :delete,
    path: ["crm-object-schemas/2026-03/schemas/%1$s", object_type],
    query: query,
    model: NilClass,
    options: options
  )
end

#delete_association(association_identifier, object_type:, request_options: {}) ⇒ nil

Remove an association between two object types identified by the association identifier and object type. This operation is irreversible and will permanently delete the specified association.

Parameters:

Returns:

  • (nil)

See Also:



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/hubspot_sdk/resources/crm/object_schemas.rb', line 183

def delete_association(association_identifier, params)
  parsed, options = HubSpotSDK::Crm::ObjectSchemaDeleteAssociationParams.dump_request(params)
  object_type =
    parsed.delete(:object_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: [
      "crm-object-schemas/2026-03/schemas/%1$s/associations/%2$s",
      object_type,
      association_identifier
    ],
    model: NilClass,
    options: options
  )
end

#get(object_type, include_association_definitions: nil, include_audit_metadata: nil, include_property_definitions: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::ObjectSchema

Retrieve details of a custom object schema, including its properties and associations, using the object type ID or fully qualified name.

Parameters:

  • object_type (String)
  • include_association_definitions (Boolean)
  • include_audit_metadata (Boolean)
  • include_property_definitions (Boolean)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/hubspot_sdk/resources/crm/object_schemas.rb', line 215

def get(object_type, params = {})
  parsed, options = HubSpotSDK::Crm::ObjectSchemaGetParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["crm-object-schemas/2026-03/schemas/%1$s", object_type],
    query: query.transform_keys(
      include_association_definitions: "includeAssociationDefinitions",
      include_audit_metadata: "includeAuditMetadata",
      include_property_definitions: "includePropertyDefinitions"
    ),
    model: HubSpotSDK::Crm::ObjectSchema,
    options: options
  )
end

#list(archived: nil, include_association_definitions: nil, include_audit_metadata: nil, include_property_definitions: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::CollectionResponseObjectSchemaNoPaging

Retrieve all custom object schemas, with options to include property definitions, association definitions, and audit metadata.

Parameters:

  • archived (Boolean)

    Whether to return only results that have been archived.

  • include_association_definitions (Boolean)
  • include_audit_metadata (Boolean)
  • include_property_definitions (Boolean)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/hubspot_sdk/resources/crm/object_schemas.rb', line 102

def list(params = {})
  parsed, options = HubSpotSDK::Crm::ObjectSchemaListParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "crm-object-schemas/2026-03/schemas",
    query: query.transform_keys(
      include_association_definitions: "includeAssociationDefinitions",
      include_audit_metadata: "includeAuditMetadata",
      include_property_definitions: "includePropertyDefinitions"
    ),
    model: HubSpotSDK::Crm::CollectionResponseObjectSchemaNoPaging,
    options: options
  )
end

#update(object_type, clear_description:, allows_sensitive_properties: nil, description: nil, labels: nil, primary_display_property: nil, required_properties: nil, restorable: nil, searchable_properties: nil, secondary_display_properties: nil, request_options: {}) ⇒ HubSpotSDK::Models::ObjectTypeDefinition

Update attributes of a custom object schema, such as properties and labels, using the object type ID or fully qualified name.

Parameters:

  • object_type (String)
  • clear_description (Boolean)
  • allows_sensitive_properties (Boolean)
  • description (String)
  • labels (HubSpotSDK::Models::ObjectTypeDefinitionLabels)
  • primary_display_property (String)
  • required_properties (Array<String>)
  • restorable (Boolean)
  • searchable_properties (Array<String>)
  • secondary_display_properties (Array<String>)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



73
74
75
76
77
78
79
80
81
82
# File 'lib/hubspot_sdk/resources/crm/object_schemas.rb', line 73

def update(object_type, params)
  parsed, options = HubSpotSDK::Crm::ObjectSchemaUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["crm-object-schemas/2026-03/schemas/%1$s", object_type],
    body: parsed,
    model: HubSpotSDK::ObjectTypeDefinition,
    options: options
  )
end