Class: Moonbase::Resources::InboxMessages::Attachments

Inherits:
Object
  • Object
show all
Defined in:
lib/moonbase/resources/inbox_messages/attachments.rb

Overview

Manage your inboxes, conversations, and messages

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Attachments

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

Parameters:



66
67
68
# File 'lib/moonbase/resources/inbox_messages/attachments.rb', line 66

def initialize(client:)
  @client = client
end

Instance Method Details

#create(inbox_message_id, file: nil, file_id: nil, request_options: {}) ⇒ Moonbase::Models::MessageAttachment

Add an attachment to a draft message. You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.

Parameters:

Returns:

See Also:



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/moonbase/resources/inbox_messages/attachments.rb', line 24

def create(inbox_message_id, params = {})
  parsed, options = Moonbase::InboxMessages::AttachmentCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["inbox_messages/%1$s/attachments", inbox_message_id],
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: Moonbase::MessageAttachment,
    options: options
  )
end

#delete(id, inbox_message_id:, request_options: {}) ⇒ nil

Removes an attachment from a draft message.

Parameters:

  • id (String)

    The ID of the attachment to remove.

  • inbox_message_id (String)

    The ID of the Message.

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

Returns:

  • (nil)

See Also:



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/moonbase/resources/inbox_messages/attachments.rb', line 49

def delete(id, params)
  parsed, options = Moonbase::InboxMessages::AttachmentDeleteParams.dump_request(params)
  inbox_message_id =
    parsed.delete(:inbox_message_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["inbox_messages/%1$s/attachments/%2$s", inbox_message_id, id],
    model: NilClass,
    options: options
  )
end