Class: Attio::Resources::Objects Private

Inherits:
Base
  • Object
show all
Defined in:
lib/attio/resources/objects.rb

Overview

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

API resource for managing Attio objects

Objects define the schema and structure for different types of records in your Attio workspace (e.g., people, companies).

Examples:

Listing all objects

client.objects.list

Creating a custom object

client.objects.create(
  api_slug: "projects",
  singular_noun: "Project",
  plural_noun: "Projects"
)

Updating a custom object

client.objects.update(
  id_or_slug: "projects",
  plural_noun: "Active Projects"
)

Since:

  • 1.0.0

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Attio::Resources::Base

Instance Method Details

#create(api_slug:, singular_noun:, plural_noun:) ⇒ Hash

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.

Create a new custom object

Examples:

object = client.objects.create(
  api_slug: "projects",
  singular_noun: "Project",
  plural_noun: "Projects"
)

Parameters:

  • api_slug (String)

    Unique slug for the object (snake_case)

  • singular_noun (String)

    Singular name of the object

  • plural_noun (String)

    Plural name of the object

Returns:

  • (Hash)

    The created object with ID and timestamps

Raises:

  • (ArgumentError)

    if required parameters are missing

Since:

  • 1.0.0



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/attio/resources/objects.rb', line 56

def create(api_slug:, singular_noun:, plural_noun:)
  validate_required_string!(api_slug, "API slug")
  validate_required_string!(singular_noun, "Singular noun")
  validate_required_string!(plural_noun, "Plural noun")

  data = {
    api_slug: api_slug,
    singular_noun: singular_noun,
    plural_noun: plural_noun,
  }

  request(:post, "objects", { data: data })
end

#delete(id_or_slug:) ⇒ Object Also known as: destroy

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.

Delete a custom object

NOTE: The Attio API v2.0.0 does not currently support deleting custom objects. To delete a custom object, please visit your Attio settings at: Settings > Data Model > Objects

Examples:

client.objects.delete(id_or_slug: "projects")
# => NotImplementedError: The Attio API does not currently support deleting custom objects.
#    Please delete objects through the Attio UI at: Settings > Data Model > Objects

Parameters:

  • id_or_slug (String)

    The object ID or slug to delete

Raises:

  • (NotImplementedError)

    Always raised as the API doesn't support this operation

Since:

  • 1.0.0



115
116
117
118
119
120
# File 'lib/attio/resources/objects.rb', line 115

def delete(id_or_slug:)
  validate_id_or_slug!(id_or_slug)
  raise NotImplementedError,
        "The Attio API does not currently support deleting custom objects. " \
        "Please delete objects through the Attio UI at: Settings > Data Model > Objects"
end

#get(id_or_slug:) ⇒ Hash

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.

Get a single object by ID or slug

Parameters:

  • id_or_slug (String)

    The object ID or slug

Returns:

  • (Hash)

    The object details

Since:

  • 1.0.0



38
39
40
41
# File 'lib/attio/resources/objects.rb', line 38

def get(id_or_slug:)
  validate_id_or_slug!(id_or_slug)
  request(:get, "objects/#{id_or_slug}")
end

#list(**params) ⇒ Hash

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.

List all objects in the workspace

Parameters:

  • params (Hash)

    Optional query parameters

Returns:

  • (Hash)

    List of objects

Since:

  • 1.0.0



30
31
32
# File 'lib/attio/resources/objects.rb', line 30

def list(**params)
  request(:get, "objects", params)
end

#update(id_or_slug:, api_slug: nil, singular_noun: nil, plural_noun: nil) ⇒ Hash

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.

Update an existing custom object

Examples:

Update just the plural noun

client.objects.update(
  id_or_slug: "projects",
  plural_noun: "Active Projects"
)

Update multiple fields

client.objects.update(
  id_or_slug: "old_slug",
  api_slug: "new_slug",
  singular_noun: "New Name",
  plural_noun: "New Names"
)

Parameters:

  • id_or_slug (String)

    The object ID or slug to update

  • api_slug (String, nil) (defaults to: nil)

    New API slug (optional)

  • singular_noun (String, nil) (defaults to: nil)

    New singular noun (optional)

  • plural_noun (String, nil) (defaults to: nil)

    New plural noun (optional)

Returns:

  • (Hash)

    The updated object

Raises:

  • (ArgumentError)

    if no update fields are provided

Since:

  • 1.0.0



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/attio/resources/objects.rb', line 90

def update(id_or_slug:, api_slug: nil, singular_noun: nil, plural_noun: nil)
  validate_id_or_slug!(id_or_slug)

  data = {}
  data[:api_slug] = api_slug if api_slug
  data[:singular_noun] = singular_noun if singular_noun
  data[:plural_noun] = plural_noun if plural_noun

  raise ArgumentError, "At least one field to update is required" if data.empty?

  request(:patch, "objects/#{id_or_slug}", { data: data })
end

#validate_id_or_slug!(id_or_slug) ⇒ Object (private)

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.

Raises:

  • (ArgumentError)

Since:

  • 1.0.0



126
127
128
# File 'lib/attio/resources/objects.rb', line 126

private def validate_id_or_slug!(id_or_slug)
  raise ArgumentError, "Object ID or slug is required" if id_or_slug.nil? || id_or_slug.to_s.strip.empty?
end