Class: Attio::Resources::Objects Private
- 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).
Instance Method Summary collapse
-
#create(api_slug:, singular_noun:, plural_noun:) ⇒ Hash
private
Create a new custom object.
-
#delete(id_or_slug:) ⇒ Object
(also: #destroy)
private
Delete a custom object.
-
#get(id_or_slug:) ⇒ Hash
private
Get a single object by ID or slug.
-
#list(**params) ⇒ Hash
private
List all objects in the workspace.
-
#update(id_or_slug:, api_slug: nil, singular_noun: nil, plural_noun: nil) ⇒ Hash
private
Update an existing custom object.
- #validate_id_or_slug!(id_or_slug) ⇒ Object private private
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
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
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
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
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
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.
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 |