Class: Knockapi::Resources::Objects::Bulk

Inherits:
Object
  • Object
show all
Defined in:
lib/knockapi/resources/objects/bulk.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Bulk

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 Bulk.

Parameters:



111
112
113
# File 'lib/knockapi/resources/objects/bulk.rb', line 111

def initialize(client:)
  @client = client
end

Instance Method Details

#add_subscriptions(collection, subscriptions:, request_options: {}) ⇒ Knockapi::Models::BulkOperation

Add subscriptions for all objects in a single collection. If a subscription for an object in the collection already exists, it will be updated. This endpoint also handles [inline identifications](/managing-recipients/identifying-recipients#inline-identifying-recipients) for the ‘recipient` field.

Parameters:

Returns:

See Also:



48
49
50
51
52
53
54
55
56
57
# File 'lib/knockapi/resources/objects/bulk.rb', line 48

def add_subscriptions(collection, params)
  parsed, options = Knockapi::Objects::BulkAddSubscriptionsParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/objects/%1$s/bulk/subscriptions/add", collection],
    body: parsed,
    model: Knockapi::BulkOperation,
    options: options
  )
end

#delete(collection, object_ids:, request_options: {}) ⇒ Knockapi::Models::BulkOperation

Bulk deletes objects from the specified collection.

Parameters:

  • collection (String)

    The collection this object belongs to.

  • object_ids (Array<String>)

    List of object IDs to delete.

  • request_options (Knockapi::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



20
21
22
23
24
25
26
27
28
29
# File 'lib/knockapi/resources/objects/bulk.rb', line 20

def delete(collection, params)
  parsed, options = Knockapi::Objects::BulkDeleteParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/objects/%1$s/bulk/delete", collection],
    body: parsed,
    model: Knockapi::BulkOperation,
    options: options
  )
end

#delete_subscriptions(collection, subscriptions:, request_options: {}) ⇒ Knockapi::Models::BulkOperation

Delete subscriptions for many objects in a single collection type. If a subscription for an object in the collection doesn’t exist, it will be skipped.

Parameters:

Returns:

See Also:



73
74
75
76
77
78
79
80
81
82
# File 'lib/knockapi/resources/objects/bulk.rb', line 73

def delete_subscriptions(collection, params)
  parsed, options = Knockapi::Objects::BulkDeleteSubscriptionsParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/objects/%1$s/bulk/subscriptions/delete", collection],
    body: parsed,
    model: Knockapi::BulkOperation,
    options: options
  )
end

#set(collection, objects:, request_options: {}) ⇒ Knockapi::Models::BulkOperation

Bulk sets up to 1,000 objects at a time in the specified collection.

Parameters:

Returns:

See Also:



97
98
99
100
101
102
103
104
105
106
# File 'lib/knockapi/resources/objects/bulk.rb', line 97

def set(collection, params)
  parsed, options = Knockapi::Objects::BulkSetParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/objects/%1$s/bulk/set", collection],
    body: parsed,
    model: Knockapi::BulkOperation,
    options: options
  )
end