Class: Attio::Resources::Attributes Private
- Defined in:
- lib/attio/resources/attributes.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 attributes
Attributes define custom fields that can be added to objects and records in your Attio workspace.
Instance Method Summary collapse
-
#create(object:, data:) ⇒ Hash
private
Create a custom attribute for an object.
-
#create_option(object:, id_or_slug:, data:) ⇒ Hash
private
Create a new option for a select attribute.
-
#create_status(object:, id_or_slug:, data:) ⇒ Hash
private
Create a new status for a status attribute.
- #get(object:, id_or_slug:) ⇒ Object private
- #list(object:, **params) ⇒ Object private
-
#list_options(object:, id_or_slug:, **params) ⇒ Hash
private
List options for a select attribute.
-
#list_statuses(object:, id_or_slug:, **params) ⇒ Hash
private
List statuses for a status attribute.
-
#update(object:, id_or_slug:, data:) ⇒ Hash
private
Update an existing attribute.
-
#update_option(object:, id_or_slug:, option:, data:) ⇒ Hash
private
Update an option for a select attribute.
-
#update_status(object:, id_or_slug:, status:, data:) ⇒ Hash
private
Update a status for a status attribute.
- #validate_id_or_slug!(id_or_slug) ⇒ Object private private
- #validate_object!(object) ⇒ Object private private
- #validate_option_id!(option) ⇒ Object private private
- #validate_status_id!(status) ⇒ Object private private
Constructor Details
This class inherits a constructor from Attio::Resources::Base
Instance Method Details
#create(object:, data:) ⇒ 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 custom attribute for an object
64 65 66 67 68 69 70 71 72 |
# File 'lib/attio/resources/attributes.rb', line 64 def create(object:, data:) validate_object!(object) validate_required_hash!(data, "Attribute data") # Wrap data in the expected format payload = { data: data } request(:post, "objects/#{object}/attributes", payload) end |
#create_option(object:, id_or_slug:, data:) ⇒ 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 option for a select attribute
145 146 147 148 149 150 151 |
# File 'lib/attio/resources/attributes.rb', line 145 def create_option(object:, id_or_slug:, data:) validate_object!(object) validate_id_or_slug!(id_or_slug) validate_required_hash!(data, "Option data") request(:post, "objects/#{object}/attributes/#{id_or_slug}/options", data) end |
#create_status(object:, id_or_slug:, data:) ⇒ 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 status for a status attribute
222 223 224 225 226 227 228 |
# File 'lib/attio/resources/attributes.rb', line 222 def create_status(object:, id_or_slug:, data:) validate_object!(object) validate_id_or_slug!(id_or_slug) validate_required_hash!(data, "Status data") request(:post, "objects/#{object}/attributes/#{id_or_slug}/statuses", data) end |
#get(object:, id_or_slug:) ⇒ Object
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.
32 33 34 35 36 |
# File 'lib/attio/resources/attributes.rb', line 32 def get(object:, id_or_slug:) validate_object!(object) validate_id_or_slug!(id_or_slug) request(:get, "objects/#{object}/attributes/#{id_or_slug}") end |
#list(object:, **params) ⇒ Object
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.
27 28 29 30 |
# File 'lib/attio/resources/attributes.rb', line 27 def list(object:, **params) validate_object!(object) request(:get, "objects/#{object}/attributes", params) end |
#list_options(object:, id_or_slug:, **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 options for a select attribute
119 120 121 122 123 |
# File 'lib/attio/resources/attributes.rb', line 119 def (object:, id_or_slug:, **params) validate_object!(object) validate_id_or_slug!(id_or_slug) request(:get, "objects/#{object}/attributes/#{id_or_slug}/options", params) end |
#list_statuses(object:, id_or_slug:, **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 statuses for a status attribute
196 197 198 199 200 |
# File 'lib/attio/resources/attributes.rb', line 196 def list_statuses(object:, id_or_slug:, **params) validate_object!(object) validate_id_or_slug!(id_or_slug) request(:get, "objects/#{object}/attributes/#{id_or_slug}/statuses", params) end |
#update(object:, id_or_slug:, data:) ⇒ 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 attribute
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/attio/resources/attributes.rb', line 95 def update(object:, id_or_slug:, data:) validate_object!(object) validate_id_or_slug!(id_or_slug) validate_required_hash!(data, "Attribute data") # Wrap data in the expected format payload = { data: data } request(:patch, "objects/#{object}/attributes/#{id_or_slug}", payload) end |
#update_option(object:, id_or_slug:, option:, data:) ⇒ 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 option for a select attribute
174 175 176 177 178 179 180 181 |
# File 'lib/attio/resources/attributes.rb', line 174 def update_option(object:, id_or_slug:, option:, data:) validate_object!(object) validate_id_or_slug!(id_or_slug) validate_option_id!(option) validate_required_hash!(data, "Option data") request(:patch, "objects/#{object}/attributes/#{id_or_slug}/options/#{option}", data) end |
#update_status(object:, id_or_slug:, status:, data:) ⇒ 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 a status for a status attribute
251 252 253 254 255 256 257 258 |
# File 'lib/attio/resources/attributes.rb', line 251 def update_status(object:, id_or_slug:, status:, data:) validate_object!(object) validate_id_or_slug!(id_or_slug) validate_status_id!(status) validate_required_hash!(data, "Status data") request(:patch, "objects/#{object}/attributes/#{id_or_slug}/statuses/#{status}", 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.
264 265 266 |
# File 'lib/attio/resources/attributes.rb', line 264 private def validate_id_or_slug!(id_or_slug) raise ArgumentError, "Attribute ID or slug is required" if id_or_slug.nil? || id_or_slug.to_s.strip.empty? end |
#validate_object!(object) ⇒ 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.
260 261 262 |
# File 'lib/attio/resources/attributes.rb', line 260 private def validate_object!(object) raise ArgumentError, "Object type is required" if object.nil? || object.to_s.strip.empty? end |
#validate_option_id!(option) ⇒ 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.
268 269 270 |
# File 'lib/attio/resources/attributes.rb', line 268 private def validate_option_id!(option) raise ArgumentError, "Option ID is required" if option.nil? || option.to_s.strip.empty? end |
#validate_status_id!(status) ⇒ 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.
272 273 274 |
# File 'lib/attio/resources/attributes.rb', line 272 private def validate_status_id!(status) raise ArgumentError, "Status ID is required" if status.nil? || status.to_s.strip.empty? end |