Class: Knockapi::Resources::Objects
- Inherits:
-
Object
- Object
- Knockapi::Resources::Objects
- Defined in:
- lib/knockapi/resources/objects.rb,
lib/knockapi/resources/objects/bulk.rb
Defined Under Namespace
Classes: Bulk
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#add_subscriptions(collection, object_id_, recipients:, properties: nil, request_options: {}) ⇒ Array<Knockapi::Models::Recipients::Subscription>
Some parameter documentations has been truncated, see Models::ObjectAddSubscriptionsParams for more details.
-
#delete(collection, id, request_options: {}) ⇒ nil
Permanently removes an object from the specified collection.
-
#delete_subscriptions(collection, object_id_, recipients:, request_options: {}) ⇒ Array<Knockapi::Models::Recipients::Subscription>
Some parameter documentations has been truncated, see Models::ObjectDeleteSubscriptionsParams for more details.
-
#get(collection, id, request_options: {}) ⇒ Knockapi::Models::Object
Retrieves a specific object by its ID from the specified collection.
-
#get_channel_data(collection, object_id_, channel_id, request_options: {}) ⇒ Knockapi::Models::Recipients::RecipientsChannelData
Returns the channel data for the specified object and channel.
-
#get_preferences(collection, object_id_, id, request_options: {}) ⇒ Knockapi::Models::Recipients::PreferenceSet
Returns the preference set for the specified object and preference set ‘id`.
-
#initialize(client:) ⇒ Objects
constructor
private
A new instance of Objects.
-
#list(collection, after: nil, before: nil, include: nil, page_size: nil, request_options: {}) ⇒ Knockapi::Internal::EntriesCursor<Knockapi::Models::Object>
Returns a paginated list of objects from the specified collection.
-
#list_messages(collection, id, after: nil, before: nil, channel_id: nil, engagement_status: nil, inserted_at: nil, message_ids: nil, page_size: nil, source: nil, status: nil, tenant: nil, trigger_data: nil, workflow_categories: nil, workflow_recipient_run_id: nil, workflow_run_id: nil, request_options: {}) ⇒ Knockapi::Internal::ItemsCursor<Knockapi::Models::Message>
Some parameter documentations has been truncated, see Models::ObjectListMessagesParams for more details.
-
#list_preferences(collection, object_id_, request_options: {}) ⇒ Array<Knockapi::Models::Recipients::PreferenceSet>
Returns a paginated list of preference sets for the specified object.
-
#list_schedules(collection, id, after: nil, before: nil, page_size: nil, tenant: nil, workflow: nil, request_options: {}) ⇒ Knockapi::Internal::EntriesCursor<Knockapi::Models::Schedule>
Returns a paginated list of schedules for an object.
-
#list_subscriptions(collection, object_id_, after: nil, before: nil, include: nil, mode: nil, objects: nil, page_size: nil, recipients: nil, request_options: {}) ⇒ Knockapi::Internal::EntriesCursor<Knockapi::Models::Recipients::Subscription>
Some parameter documentations has been truncated, see Models::ObjectListSubscriptionsParams for more details.
-
#set(collection, id, channel_data: nil, locale: nil, name: nil, preferences: nil, timezone: nil, request_options: {}) ⇒ Knockapi::Models::Object
Some parameter documentations has been truncated, see Models::ObjectSetParams for more details.
-
#set_channel_data(collection, object_id_, channel_id, data:, request_options: {}) ⇒ Knockapi::Models::Recipients::RecipientsChannelData
Sets the channel data for the specified object and channel.
-
#set_preferences(collection, object_id_, id, _persistence_strategy: nil, categories: nil, channel_types: nil, channels: nil, commercial_subscribed: nil, workflows: nil, request_options: {}) ⇒ Knockapi::Models::Recipients::PreferenceSet
Some parameter documentations has been truncated, see Models::ObjectSetPreferencesParams for more details.
-
#unset_channel_data(collection, object_id_, channel_id, request_options: {}) ⇒ nil
Unsets the channel data for the specified object and channel.
Constructor Details
#initialize(client:) ⇒ Objects
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.
Returns a new instance of Objects.
502 503 504 505 |
# File 'lib/knockapi/resources/objects.rb', line 502 def initialize(client:) @client = client @bulk = Knockapi::Resources::Objects::Bulk.new(client: client) end |
Instance Attribute Details
#bulk ⇒ Knockapi::Resources::Objects::Bulk (readonly)
7 8 9 |
# File 'lib/knockapi/resources/objects.rb', line 7 def bulk @bulk end |
Instance Method Details
#add_subscriptions(collection, object_id_, recipients:, properties: nil, request_options: {}) ⇒ Array<Knockapi::Models::Recipients::Subscription>
Some parameter documentations has been truncated, see Models::ObjectAddSubscriptionsParams for more details.
Add subscriptions for an object. If a subscription already exists, it will be updated. This endpoint also handles [inline identifications](/managing-recipients/identifying-recipients#inline-identifying-recipients) for the ‘recipient`.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/knockapi/resources/objects.rb', line 87 def add_subscriptions(collection, object_id_, params) parsed, = Knockapi::ObjectAddSubscriptionsParams.dump_request(params) @client.request( method: :post, path: ["v1/objects/%1$s/%2$s/subscriptions", collection, object_id_], body: parsed, model: Knockapi::Internal::Type::ArrayOf[Knockapi::Recipients::Subscription], options: ) end |
#delete(collection, id, request_options: {}) ⇒ nil
Permanently removes an object from the specified collection. This operation cannot be undone.
55 56 57 58 59 60 61 62 |
# File 'lib/knockapi/resources/objects.rb', line 55 def delete(collection, id, params = {}) @client.request( method: :delete, path: ["v1/objects/%1$s/%2$s", collection, id], model: NilClass, options: params[:request_options] ) end |
#delete_subscriptions(collection, object_id_, recipients:, request_options: {}) ⇒ Array<Knockapi::Models::Recipients::Subscription>
Some parameter documentations has been truncated, see Models::ObjectDeleteSubscriptionsParams for more details.
Delete subscriptions for the specified recipients from an object. Returns the list of deleted subscriptions.
117 118 119 120 121 122 123 124 125 126 |
# File 'lib/knockapi/resources/objects.rb', line 117 def delete_subscriptions(collection, object_id_, params) parsed, = Knockapi::ObjectDeleteSubscriptionsParams.dump_request(params) @client.request( method: :delete, path: ["v1/objects/%1$s/%2$s/subscriptions", collection, object_id_], body: parsed, model: Knockapi::Internal::Type::ArrayOf[Knockapi::Recipients::Subscription], options: ) end |
#get(collection, id, request_options: {}) ⇒ Knockapi::Models::Object
Retrieves a specific object by its ID from the specified collection. Returns the object with all its properties.
142 143 144 145 146 147 148 149 |
# File 'lib/knockapi/resources/objects.rb', line 142 def get(collection, id, params = {}) @client.request( method: :get, path: ["v1/objects/%1$s/%2$s", collection, id], model: Knockapi::Object, options: params[:request_options] ) end |
#get_channel_data(collection, object_id_, channel_id, request_options: {}) ⇒ Knockapi::Models::Recipients::RecipientsChannelData
Returns the channel data for the specified object and channel.
166 167 168 169 170 171 172 173 |
# File 'lib/knockapi/resources/objects.rb', line 166 def get_channel_data(collection, object_id_, channel_id, params = {}) @client.request( method: :get, path: ["v1/objects/%1$s/%2$s/channel_data/%3$s", collection, object_id_, channel_id], model: Knockapi::Recipients::RecipientsChannelData, options: params[:request_options] ) end |
#get_preferences(collection, object_id_, id, request_options: {}) ⇒ Knockapi::Models::Recipients::PreferenceSet
Returns the preference set for the specified object and preference set ‘id`.
190 191 192 193 194 195 196 197 |
# File 'lib/knockapi/resources/objects.rb', line 190 def get_preferences(collection, object_id_, id, params = {}) @client.request( method: :get, path: ["v1/objects/%1$s/%2$s/preferences/%3$s", collection, object_id_, id], model: Knockapi::Recipients::PreferenceSet, options: params[:request_options] ) end |
#list(collection, after: nil, before: nil, include: nil, page_size: nil, request_options: {}) ⇒ Knockapi::Internal::EntriesCursor<Knockapi::Models::Object>
Returns a paginated list of objects from the specified collection. Optionally includes preference data for the objects.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/knockapi/resources/objects.rb', line 29 def list(collection, params = {}) parsed, = Knockapi::ObjectListParams.dump_request(params) @client.request( method: :get, path: ["v1/objects/%1$s", collection], query: parsed, page: Knockapi::Internal::EntriesCursor, model: Knockapi::Object, options: ) end |
#list_messages(collection, id, after: nil, before: nil, channel_id: nil, engagement_status: nil, inserted_at: nil, message_ids: nil, page_size: nil, source: nil, status: nil, tenant: nil, trigger_data: nil, workflow_categories: nil, workflow_recipient_run_id: nil, workflow_run_id: nil, request_options: {}) ⇒ Knockapi::Internal::ItemsCursor<Knockapi::Models::Message>
Some parameter documentations has been truncated, see Models::ObjectListMessagesParams for more details.
Returns a paginated list of messages for a specific object in the given collection. Allows filtering by message status and provides various sorting options.
245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/knockapi/resources/objects.rb', line 245 def (collection, id, params = {}) parsed, = Knockapi::ObjectListMessagesParams.dump_request(params) @client.request( method: :get, path: ["v1/objects/%1$s/%2$s/messages", collection, id], query: parsed, page: Knockapi::Internal::ItemsCursor, model: Knockapi::Message, options: ) end |
#list_preferences(collection, object_id_, request_options: {}) ⇒ Array<Knockapi::Models::Recipients::PreferenceSet>
Returns a paginated list of preference sets for the specified object.
270 271 272 273 274 275 276 277 |
# File 'lib/knockapi/resources/objects.rb', line 270 def list_preferences(collection, object_id_, params = {}) @client.request( method: :get, path: ["v1/objects/%1$s/%2$s/preferences", collection, object_id_], model: Knockapi::Internal::Type::ArrayOf[Knockapi::Recipients::PreferenceSet], options: params[:request_options] ) end |
#list_schedules(collection, id, after: nil, before: nil, page_size: nil, tenant: nil, workflow: nil, request_options: {}) ⇒ Knockapi::Internal::EntriesCursor<Knockapi::Models::Schedule>
Returns a paginated list of schedules for an object.
302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/knockapi/resources/objects.rb', line 302 def list_schedules(collection, id, params = {}) parsed, = Knockapi::ObjectListSchedulesParams.dump_request(params) @client.request( method: :get, path: ["v1/objects/%1$s/%2$s/schedules", collection, id], query: parsed, page: Knockapi::Internal::EntriesCursor, model: Knockapi::Schedule, options: ) end |
#list_subscriptions(collection, object_id_, after: nil, before: nil, include: nil, mode: nil, objects: nil, page_size: nil, recipients: nil, request_options: {}) ⇒ Knockapi::Internal::EntriesCursor<Knockapi::Models::Recipients::Subscription>
Some parameter documentations has been truncated, see Models::ObjectListSubscriptionsParams for more details.
List subscriptions for an object. Either list the recipients that subscribe to the provided object, or list the objects that the provided object is subscribed to. Determined by the ‘mode` query parameter.
346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/knockapi/resources/objects.rb', line 346 def list_subscriptions(collection, object_id_, params = {}) parsed, = Knockapi::ObjectListSubscriptionsParams.dump_request(params) @client.request( method: :get, path: ["v1/objects/%1$s/%2$s/subscriptions", collection, object_id_], query: parsed, page: Knockapi::Internal::EntriesCursor, model: Knockapi::Recipients::Subscription, options: ) end |
#set(collection, id, channel_data: nil, locale: nil, name: nil, preferences: nil, timezone: nil, request_options: {}) ⇒ Knockapi::Models::Object
Some parameter documentations has been truncated, see Models::ObjectSetParams for more details.
Creates a new object or updates an existing one in the specified collection. This operation is used to identify objects with their properties, as well as optional preferences and channel data.
386 387 388 389 390 391 392 393 394 395 |
# File 'lib/knockapi/resources/objects.rb', line 386 def set(collection, id, params = {}) parsed, = Knockapi::ObjectSetParams.dump_request(params) @client.request( method: :put, path: ["v1/objects/%1$s/%2$s", collection, id], body: parsed, model: Knockapi::Object, options: ) end |
#set_channel_data(collection, object_id_, channel_id, data:, request_options: {}) ⇒ Knockapi::Models::Recipients::RecipientsChannelData
Sets the channel data for the specified object and channel. If no object exists in the current environment for the given ‘collection` and `object_id`, Knock will create the object as part of this request.
416 417 418 419 420 421 422 423 424 425 |
# File 'lib/knockapi/resources/objects.rb', line 416 def set_channel_data(collection, object_id_, channel_id, params) parsed, = Knockapi::ObjectSetChannelDataParams.dump_request(params) @client.request( method: :put, path: ["v1/objects/%1$s/%2$s/channel_data/%3$s", collection, object_id_, channel_id], body: parsed, model: Knockapi::Recipients::RecipientsChannelData, options: ) end |
#set_preferences(collection, object_id_, id, _persistence_strategy: nil, categories: nil, channel_types: nil, channels: nil, commercial_subscribed: nil, workflows: nil, request_options: {}) ⇒ Knockapi::Models::Recipients::PreferenceSet
Some parameter documentations has been truncated, see Models::ObjectSetPreferencesParams for more details.
Sets preferences within the given preference set. By default, this is a destructive operation and will replace any existing preferences with the preferences given. Use ‘__persistence_strategy’: ‘merge’ to merge with existing preferences instead. If no object exists in the current environment for the given ‘:collection` and `:object_id`, Knock will create the object as part of this request. The preference set `:id` can be either `default` or a `tenant.id`. Learn more about [per-tenant preferences](/preferences/tenant-preferences).
464 465 466 467 468 469 470 471 472 473 |
# File 'lib/knockapi/resources/objects.rb', line 464 def set_preferences(collection, object_id_, id, params = {}) parsed, = Knockapi::ObjectSetPreferencesParams.dump_request(params) @client.request( method: :put, path: ["v1/objects/%1$s/%2$s/preferences/%3$s", collection, object_id_, id], body: parsed, model: Knockapi::Recipients::PreferenceSet, options: ) end |
#unset_channel_data(collection, object_id_, channel_id, request_options: {}) ⇒ nil
Unsets the channel data for the specified object and channel.
490 491 492 493 494 495 496 497 |
# File 'lib/knockapi/resources/objects.rb', line 490 def unset_channel_data(collection, object_id_, channel_id, params = {}) @client.request( method: :delete, path: ["v1/objects/%1$s/%2$s/channel_data/%3$s", collection, object_id_, channel_id], model: NilClass, options: params[:request_options] ) end |