Class: Attio::Resources::Records Private
- Defined in:
- lib/attio/resources/records.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.
Instance Method Summary collapse
-
#assert(object:, matching_attribute:, data:) ⇒ Hash
private
Assert (upsert) a record based on a matching attribute.
-
#create(object:, data:) ⇒ Hash
private
Create a new record.
-
#delete(object:, id:) ⇒ Hash
private
Delete a record.
-
#get(object:, id:) ⇒ Hash
private
Retrieve a specific record by ID.
-
#list(object:, filter: nil, sort: nil, limit: nil, offset: nil, **params) ⇒ Hash
private
Query and list records for a specific object type.
-
#list_all(object:, filter: nil, sort: nil, page_size: 50) ⇒ Enumerator
private
List all records with automatic pagination.
-
#update(object:, id:, data:) ⇒ Hash
private
Update an existing record.
-
#update_with_put(object:, id:, data:) ⇒ Hash
private
Update a record using PUT (replace operation).
-
#validate_record_data!(data) ⇒ Object
private
private
Validates that the data parameter is present and is a hash.
Constructor Details
This class inherits a constructor from Attio::Resources::Base
Instance Method Details
#assert(object:, matching_attribute:, 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.
Assert (upsert) a record based on a matching attribute.
This method creates or updates a record based on a matching attribute, providing upsert functionality. If a record with the matching attribute value exists, it will be updated; otherwise, a new record will be created.
179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/attio/resources/records.rb', line 179 def assert(object:, matching_attribute:, data:) validate_required_string!(object, "Object type") validate_required_string!(matching_attribute, "Matching attribute") validate_record_data!(data) request_body = { data: data, matching_attribute: matching_attribute, } request(:put, "objects/#{object}/records", request_body) end |
#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 new record.
112 113 114 115 116 |
# File 'lib/attio/resources/records.rb', line 112 def create(object:, data:) validate_required_string!(object, "Object type") validate_record_data!(data) request(:post, "objects/#{object}/records", data) end |
#delete(object:, id:) ⇒ 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.
Delete a record.
150 151 152 153 154 |
# File 'lib/attio/resources/records.rb', line 150 def delete(object:, id:) validate_required_string!(object, "Object type") validate_id!(id, "Record") request(:delete, "objects/#{object}/records/#{id}") end |
#get(object:, id:) ⇒ 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.
Retrieve a specific record by ID.
89 90 91 92 93 |
# File 'lib/attio/resources/records.rb', line 89 def get(object:, id:) validate_required_string!(object, "Object type") validate_id!(id, "Record") request(:get, "objects/#{object}/records/#{id}") end |
#list(object:, filter: nil, sort: nil, limit: nil, offset: nil, **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.
Query and list records for a specific object type.
This method allows you to retrieve records with optional filtering, sorting, and pagination parameters.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/attio/resources/records.rb', line 47 def list(object:, filter: nil, sort: nil, limit: nil, offset: nil, **params) validate_required_string!(object, "Object type") # Build query parameters with filtering and sorting support query_params = build_query_params({ filter: filter, sort: sort, limit: limit, offset: offset, **params, }) request(:post, "objects/#{object}/records/query", query_params) end |
#list_all(object:, filter: nil, sort: nil, page_size: 50) ⇒ Enumerator
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 records with automatic pagination
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/attio/resources/records.rb', line 68 def list_all(object:, filter: nil, sort: nil, page_size: 50) validate_required_string!(object, "Object type") query_params = build_query_params({ filter: filter, sort: sort, }) paginate("objects/#{object}/records/query", query_params, page_size: page_size) end |
#update(object:, id:, 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 record.
133 134 135 136 137 138 |
# File 'lib/attio/resources/records.rb', line 133 def update(object:, id:, data:) validate_required_string!(object, "Object type") validate_id!(id, "Record") validate_record_data!(data) request(:patch, "objects/#{object}/records/#{id}", data) end |
#update_with_put(object:, id:, 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 record using PUT (replace operation).
This method performs a complete replacement of the record, unlike the regular update method which uses PATCH. For multiselect fields, this overwrites the values instead of appending to them.
215 216 217 218 219 220 221 222 |
# File 'lib/attio/resources/records.rb', line 215 def update_with_put(object:, id:, data:) validate_required_string!(object, "Object type") validate_id!(id, "Record") validate_record_data!(data) request_body = { data: data } request(:put, "objects/#{object}/records/#{id}", request_body) end |
#validate_record_data!(data) ⇒ 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.
Validates that the data parameter is present and is a hash.
229 230 231 232 |
# File 'lib/attio/resources/records.rb', line 229 private def validate_record_data!(data) raise ArgumentError, "Data is required" if data.nil? raise ArgumentError, "Data must be a hash" unless data.is_a?(Hash) end |