Class: Knockapi::Resources::Messages::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/knockapi/resources/messages/batch.rb,
sig/knockapi/resources/messages/batch.rbs

Overview

A message sent to a single recipient on a channel.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Batch

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

Parameters:



204
205
206
# File 'lib/knockapi/resources/messages/batch.rb', line 204

def initialize(client:)
  @client = client
end

Instance Method Details

#archive(message_ids:, request_options: {}) ⇒ Array<Knockapi::Models::Message>

Marks the given messages as archived. Archived messages are hidden from the default message list in the feed but can still be accessed and unarchived later.

Parameters:

Returns:

See Also:



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

def archive(params)
  parsed, options = Knockapi::Messages::BatchArchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/messages/batch/archived",
    body: parsed,
    model: Knockapi::Internal::Type::ArrayOf[Knockapi::Message],
    options: options
  )
end

#get_content(message_ids:, request_options: {}) ⇒ Array<Knockapi::Models::Messages::BatchGetContentResponseItem>

Get the contents of multiple messages in a single request.

Parameters:

Returns:

See Also:



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/knockapi/resources/messages/batch.rb', line 42

def get_content(params)
  parsed, options = Knockapi::Messages::BatchGetContentParams.dump_request(params)
  query = Knockapi::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/messages/batch/content",
    query: query,
    model: Knockapi::Internal::Type::ArrayOf[Knockapi::Models::Messages::BatchGetContentResponseItem],
    options: options
  )
end

#mark_as_interacted(message_ids:, metadata: nil, request_options: {}) ⇒ Array<Knockapi::Models::Message>

Marks the given messages as interacted with by the user. This can include any user action on the message, with optional metadata about the specific interaction. Cannot include more than 5 key-value pairs, must not contain nested data. Read more about message engagement statuses here.

Parameters:

  • message_ids (Array<String>)

    The message IDs to batch mark as interacted with.

  • metadata (Hash{Symbol=>Object}, nil)

    Metadata about the interaction.

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

Returns:

See Also:



71
72
73
74
75
76
77
78
79
80
# File 'lib/knockapi/resources/messages/batch.rb', line 71

def mark_as_interacted(params)
  parsed, options = Knockapi::Messages::BatchMarkAsInteractedParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/messages/batch/interacted",
    body: parsed,
    model: Knockapi::Internal::Type::ArrayOf[Knockapi::Message],
    options: options
  )
end

#mark_as_read(message_ids:, request_options: {}) ⇒ Array<Knockapi::Models::Message>

Marks the given messages as read. Read more about message engagement statuses here.

Parameters:

Returns:

See Also:



94
95
96
97
98
99
100
101
102
103
# File 'lib/knockapi/resources/messages/batch.rb', line 94

def mark_as_read(params)
  parsed, options = Knockapi::Messages::BatchMarkAsReadParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/messages/batch/read",
    body: parsed,
    model: Knockapi::Internal::Type::ArrayOf[Knockapi::Message],
    options: options
  )
end

#mark_as_seen(message_ids:, request_options: {}) ⇒ Array<Knockapi::Models::Message>

Marks the given messages as seen. This indicates that the user has viewed the message in their feed or inbox. Read more about message engagement statuses here.

Parameters:

Returns:

See Also:



118
119
120
121
122
123
124
125
126
127
# File 'lib/knockapi/resources/messages/batch.rb', line 118

def mark_as_seen(params)
  parsed, options = Knockapi::Messages::BatchMarkAsSeenParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/messages/batch/seen",
    body: parsed,
    model: Knockapi::Internal::Type::ArrayOf[Knockapi::Message],
    options: options
  )
end

#mark_as_unread(message_ids:, request_options: {}) ⇒ Array<Knockapi::Models::Message>

Marks the given messages as unread. This reverses the read state. Read more about message engagement statuses here.

Parameters:

Returns:

See Also:



142
143
144
145
146
147
148
149
150
151
# File 'lib/knockapi/resources/messages/batch.rb', line 142

def mark_as_unread(params)
  parsed, options = Knockapi::Messages::BatchMarkAsUnreadParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/messages/batch/unread",
    body: parsed,
    model: Knockapi::Internal::Type::ArrayOf[Knockapi::Message],
    options: options
  )
end

#mark_as_unseen(message_ids:, request_options: {}) ⇒ Array<Knockapi::Models::Message>

Marks the given messages as unseen. This reverses the seen state. Read more about message engagement statuses here.

Parameters:

Returns:

See Also:



166
167
168
169
170
171
172
173
174
175
# File 'lib/knockapi/resources/messages/batch.rb', line 166

def mark_as_unseen(params)
  parsed, options = Knockapi::Messages::BatchMarkAsUnseenParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/messages/batch/unseen",
    body: parsed,
    model: Knockapi::Internal::Type::ArrayOf[Knockapi::Message],
    options: options
  )
end

#unarchive(message_ids:, request_options: {}) ⇒ Array<Knockapi::Models::Message>

Marks the given messages as unarchived. This reverses the archived state. Archived messages are hidden from the default message list in the feed but can still be accessed and unarchived later.

Parameters:

Returns:

See Also:



190
191
192
193
194
195
196
197
198
199
# File 'lib/knockapi/resources/messages/batch.rb', line 190

def unarchive(params)
  parsed, options = Knockapi::Messages::BatchUnarchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/messages/batch/unarchived",
    body: parsed,
    model: Knockapi::Internal::Type::ArrayOf[Knockapi::Message],
    options: options
  )
end