Module: Knock::Objects
Overview
Provides convienience methods for working with bulk operations
Instance Attribute Summary
Attributes included from Base
Class Method Summary collapse
-
.bulk_delete(collection:, object_ids: []) ⇒ Hash
Bulk deletes Objects in a collection.
-
.bulk_set(collection:, objects: []) ⇒ Hash
Bulk upserts Objects in a collection.
-
.delete(collection:, id:) ⇒ nil
Deletes an Object in a collection.
-
.get(collection:, id:) ⇒ Hash
Retrieves an Object in a collection.
-
.get_channel_data(collection:, id:, channel_id:) ⇒ Hash
Get object channel data for the given channel id.
-
.get_messages(collection:, id:, options: {}) ⇒ Hash
Get object's messages.
-
.set(collection:, id:, properties: {}) ⇒ Hash
Upserts an Object in a collection.
-
.set_channel_data(id:, channel_id:, channel_data:) ⇒ Hash
Upserts object channel data for the given channel id.
Methods included from Client
client, delete_request, execute_request, get_request, handle_error_response, post_request, put_request, user_agent
Class Method Details
.bulk_delete(collection:, object_ids: []) ⇒ Hash
Bulk deletes Objects in a collection
80 81 82 83 84 85 86 87 88 |
# File 'lib/knock/objects.rb', line 80 def bulk_delete(collection:, object_ids: []) request = post_request( auth: true, path: "/v1/objects/#{collection}/bulk/delete", body: {object_ids: object_ids} ) execute_request(request: request) end |
.bulk_set(collection:, objects: []) ⇒ Hash
Bulk upserts Objects in a collection
49 50 51 52 53 54 55 56 57 |
# File 'lib/knock/objects.rb', line 49 def bulk_set(collection:, objects: []) request = post_request( auth: true, path: "/v1/objects/#{collection}/bulk/set", body: {objects: objects} ) execute_request(request: request) end |
.delete(collection:, id:) ⇒ nil
Deletes an Object in a collection
65 66 67 68 69 70 71 72 |
# File 'lib/knock/objects.rb', line 65 def delete(collection:, id:) request = delete_request( auth: true, path: "/v1/objects/#{collection}/#{id}" ) execute_request(request: request) end |
.get(collection:, id:) ⇒ Hash
Retrieves an Object in a collection
17 18 19 20 21 22 23 24 |
# File 'lib/knock/objects.rb', line 17 def get(collection:, id:) request = get_request( auth: true, path: "/v1/objects/#{collection}/#{id}" ) execute_request(request: request) end |
.get_channel_data(collection:, id:, channel_id:) ⇒ Hash
Get object channel data for the given channel id
97 98 99 100 101 102 103 104 |
# File 'lib/knock/objects.rb', line 97 def get_channel_data(collection:, id:, channel_id:) request = get_request( auth: true, path: "/v1/objects/#{collection}/#{id}/channel_data/#{channel_id}" ) execute_request(request: request) end |
.get_messages(collection:, id:, options: {}) ⇒ Hash
Get object's messages
131 132 133 134 135 136 137 138 139 |
# File 'lib/knock/objects.rb', line 131 def (collection:, id:, options: {}) request = get_request( auth: true, path: "/v1/objects/#{collection}/#{id}/messages", params: ) execute_request(request: request) end |
.set(collection:, id:, properties: {}) ⇒ Hash
Upserts an Object in a collection
33 34 35 36 37 38 39 40 41 |
# File 'lib/knock/objects.rb', line 33 def set(collection:, id:, properties: {}) request = put_request( auth: true, path: "/v1/objects/#{collection}/#{id}", body: properties ) execute_request(request: request) end |
.set_channel_data(id:, channel_id:, channel_data:) ⇒ Hash
Upserts object channel data for the given channel id
114 115 116 117 118 119 120 121 122 |
# File 'lib/knock/objects.rb', line 114 def set_channel_data(id:, channel_id:, channel_data:) request = put_request( auth: true, path: "/v1/objects/#{collection}/#{id}/channel_data/#{channel_id}", body: {data: channel_data} ) execute_request(request: request) end |