Class: Onlyfans::Resources::Chats::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyfans/resources/chats/messages.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Messages

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

Parameters:



337
338
339
# File 'lib/onlyfans/resources/chats/messages.rb', line 337

def initialize(client:)
  @client = client
end

Instance Method Details

#delete(message_id, account:, chat_id:, request_options: {}) ⇒ Onlyfans::Models::Chats::MessageDeleteResponse

Delete a message from a chat. Please note that ONLY messages sent less than 24 hours ago can be deleted.

Parameters:

  • message_id (String)

    The ID of the message to retrieve

  • account (String)

    The Account ID

  • chat_id (String)

    The ID of the chat (usually a fan’s OnlyFans User ID)

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

Returns:

See Also:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/onlyfans/resources/chats/messages.rb', line 101

def delete(message_id, params)
  parsed, options = Onlyfans::Chats::MessageDeleteParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  chat_id =
    parsed.delete(:chat_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["api/%1$s/chats/%2$s/messages/%3$s", , chat_id, message_id],
    model: Onlyfans::Models::Chats::MessageDeleteResponse,
    options: options
  )
end

#like(message_id, account:, chat_id:, request_options: {}) ⇒ Onlyfans::Models::Chats::MessageLikeResponse

Like a chat message.

Parameters:

  • message_id (String)

    The ID of the message to like

  • account (String)

    The Account ID

  • chat_id (String)

    The ID of the chat, usually a fan’s OnlyFans User ID

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

Returns:

See Also:



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/onlyfans/resources/chats/messages.rb', line 134

def like(message_id, params)
  parsed, options = Onlyfans::Chats::MessageLikeParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  chat_id =
    parsed.delete(:chat_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["api/%1$s/chats/%2$s/messages/%3$s/like", , chat_id, message_id],
    model: Onlyfans::Models::Chats::MessageLikeResponse,
    options: options
  )
end

#list(chat_id, account:, filter: nil, first_id: nil, last_id: nil, limit: nil, order: nil, skip_users: nil, request_options: {}) ⇒ Onlyfans::Models::Chats::MessageListResponse

Some parameter documentations has been truncated, see Models::Chats::MessageListParams for more details.

Get messages from a specific chat.

Parameters:

  • chat_id (String)

    Path param: The ID of the chat (usually a fan’s OnlyFans User ID)

  • account (String)

    Path param: The Account ID

  • filter (Symbol, Onlyfans::Models::Chats::MessageListParams::Filter)

    Query param: Filter by certain messages. Currently, only pins are filterable.

  • first_id (String, nil)

    Query param: Use for pagination when ‘order=desc` (newest to oldest). Include th

  • last_id (String, nil)

    Query param: Use for pagination when ‘order=asc` (oldest to newest). Include thi

  • limit (String)

    Query param: The number of messages to return (default = 10, max = 100)

  • order (String)

    Query param: Sort order for messages (desc or asc)

  • skip_users (String)

    Query param: Whether to skip user details (all or none)

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

Returns:

See Also:



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/onlyfans/resources/chats/messages.rb', line 69

def list(chat_id, params)
  parsed, options = Onlyfans::Chats::MessageListParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/%1$s/chats/%2$s/messages", , chat_id],
    query: query,
    model: Onlyfans::Models::Chats::MessageListResponse,
    options: options
  )
end

#pin(message_id, account:, chat_id:, request_options: {}) ⇒ Onlyfans::Models::Chats::MessagePinResponse

Pin a message from a chat.

Parameters:

  • message_id (String)

    The ID of the message to pin

  • account (String)

    The Account ID

  • chat_id (String)

    The ID of the chat, usually a fan’s OnlyFans User ID

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

Returns:

See Also:



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/onlyfans/resources/chats/messages.rb', line 167

def pin(message_id, params)
  parsed, options = Onlyfans::Chats::MessagePinParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  chat_id =
    parsed.delete(:chat_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["api/%1$s/chats/%2$s/messages/%3$s/pin", , chat_id, message_id],
    model: Onlyfans::Models::Chats::MessagePinResponse,
    options: options
  )
end

#retrieve(message_id, account:, chat_id:, request_options: {}) ⇒ Onlyfans::Models::Chats::MessageRetrieveResponse

Get a single chat message by its ID. Returns a 404 if the message does not exist in the chat.

Parameters:

  • message_id (String)

    The ID of the message to retrieve

  • account (String)

    The Account ID

  • chat_id (String)

    The ID of the chat (usually a fan’s OnlyFans User ID)

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

Returns:

See Also:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/onlyfans/resources/chats/messages.rb', line 23

def retrieve(message_id, params)
  parsed, options = Onlyfans::Chats::MessageRetrieveParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  chat_id =
    parsed.delete(:chat_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/%1$s/chats/%2$s/messages/%3$s", , chat_id, message_id],
    model: Onlyfans::Models::Chats::MessageRetrieveResponse,
    options: options
  )
end

#search(chat_id, account:, query:, request_options: {}) ⇒ Onlyfans::Models::Chats::MessageSearchResponse

Search messages in a specific chat. Returns a list of message IDs matching the search query.

Parameters:

  • chat_id (String)

    Path param: The ID of the chat (usually a fan’s OnlyFans User ID)

  • account (String)

    Path param: The Account ID

  • query (String)

    Query param: The query search in messages.

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

Returns:

See Also:



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/onlyfans/resources/chats/messages.rb', line 201

def search(chat_id, params)
  parsed, options = Onlyfans::Chats::MessageSearchParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/%1$s/chats/%2$s/messages/search", , chat_id],
    query: query,
    model: Onlyfans::Models::Chats::MessageSearchResponse,
    options: options
  )
end

#send_(chat_id, account:, giphy_id: nil, locked_text: nil, media_files: nil, previews: nil, price: nil, reply_to_message_id: nil, rf_guest: nil, rf_partner: nil, rf_tag: nil, text: nil, request_options: {}) ⇒ Onlyfans::Models::Chats::MessageSendResponse

Some parameter documentations has been truncated, see Models::Chats::MessageSendParams for more details.

Send a new message to a chat.

Parameters:

  • chat_id (String)

    Path param: The ID of the chat (usually a fan’s OnlyFans User ID)

  • account (String)

    Path param: The Account ID

  • giphy_id (String)

    Body param: The ID of the Giphy GIF to attach to the message. Get IDs from the G

  • locked_text (Boolean)

    Body param: Whether the text should be shown or hidden

  • media_files (Array<Object>)

    Body param: Direct file uploads, OFAPI ‘ofapi_media_` IDs, or OF vault IDs. Will

  • previews (Array<Object>)

    Body param: Direct file uploads, OFAPI ‘ofapi_media_` IDs, OF vault IDs, or inte

  • price (Integer)

    Body param: Price for paid content (0 or between 3-200). In case this is not zer

  • reply_to_message_id (Integer)

    Body param: Mark this message as a reply to another (can be either your own, or

  • rf_guest (String)

    Body param: Array of OnlyFans Release Form Guest IDs to tag in your message

  • rf_partner (String)

    Body param: Array of OnlyFans Release Form Partners IDs to tag in your message

  • rf_tag (String)

    Body param: Array of OnlyFans Creator User IDs to tag in your message

  • text (String)

    Body param: The message text content. Required unless a media file is present.

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

Returns:

See Also:



253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/onlyfans/resources/chats/messages.rb', line 253

def send_(chat_id, params)
  parsed, options = Onlyfans::Chats::MessageSendParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["api/%1$s/chats/%2$s/messages", , chat_id],
    body: parsed,
    model: Onlyfans::Models::Chats::MessageSendResponse,
    options: options
  )
end

#unlike(message_id, account:, chat_id:, request_options: {}) ⇒ Onlyfans::Models::Chats::MessageUnlikeResponse

Unlike a chat message.

Parameters:

  • message_id (String)

    The ID of the message to unlike

  • account (String)

    The Account ID

  • chat_id (String)

    The ID of the chat, usually a fan’s OnlyFans User ID

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

Returns:

See Also:



283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/onlyfans/resources/chats/messages.rb', line 283

def unlike(message_id, params)
  parsed, options = Onlyfans::Chats::MessageUnlikeParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  chat_id =
    parsed.delete(:chat_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["api/%1$s/chats/%2$s/messages/%3$s/unlike", , chat_id, message_id],
    model: Onlyfans::Models::Chats::MessageUnlikeResponse,
    options: options
  )
end

#unpin(message_id, account:, chat_id:, request_options: {}) ⇒ Onlyfans::Models::Chats::MessageUnpinResponse

Unpin a message from a chat.

Parameters:

  • message_id (String)

    The ID of the message to unpin

  • account (String)

    The Account ID

  • chat_id (String)

    The ID of the chat, usually a fan’s OnlyFans User ID

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

Returns:

See Also:



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/onlyfans/resources/chats/messages.rb', line 316

def unpin(message_id, params)
  parsed, options = Onlyfans::Chats::MessageUnpinParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  chat_id =
    parsed.delete(:chat_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["api/%1$s/chats/%2$s/messages/%3$s/unpin", , chat_id, message_id],
    model: Onlyfans::Models::Chats::MessageUnpinResponse,
    options: options
  )
end