Class: Onlyfans::Resources::Chats

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

Defined Under Namespace

Classes: MarkAllAsRead, Messages

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Chats

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

Parameters:



283
284
285
286
287
# File 'lib/onlyfans/resources/chats.rb', line 283

def initialize(client:)
  @client = client
  @messages = Onlyfans::Resources::Chats::Messages.new(client: client)
  @mark_all_as_read = Onlyfans::Resources::Chats::MarkAllAsRead.new(client: client)
end

Instance Attribute Details

#mark_all_as_readOnlyfans::Resources::Chats::MarkAllAsRead (readonly)



10
11
12
# File 'lib/onlyfans/resources/chats.rb', line 10

def mark_all_as_read
  @mark_all_as_read
end

#messagesOnlyfans::Resources::Chats::Messages (readonly)



7
8
9
# File 'lib/onlyfans/resources/chats.rb', line 7

def messages
  @messages
end

Instance Method Details

#delete(chat_id, account:, request_options: {}) ⇒ Onlyfans::Models::ChatDeleteResponse

Delete a specific chat.

Parameters:

  • chat_id (String)

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

  • account (String)

    The Account ID

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

Returns:

See Also:



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/onlyfans/resources/chats.rb', line 60

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

#hide(chat_id, account:, request_options: {}) ⇒ Onlyfans::Models::ChatHideResponse

Hide a specific chat from the chat list. To unhide this chat, send a new message to the user.

Parameters:

  • chat_id (String)

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

  • account (String)

    The Account ID

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

Returns:

See Also:



88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/onlyfans/resources/chats.rb', line 88

def hide(chat_id, params)
  parsed, options = Onlyfans::ChatHideParams.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/hide", , chat_id],
    model: Onlyfans::Models::ChatHideResponse,
    options: options
  )
end

#list(account, filter: nil, limit: nil, offset: nil, order: nil, query: nil, skip_users: nil, request_options: {}) ⇒ Onlyfans::Models::ChatListResponse

Get the list of chats for an Account.

Parameters:

Returns:

See Also:



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/onlyfans/resources/chats.rb', line 35

def list(, params = {})
  parsed, options = Onlyfans::ChatListParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/%1$s/chats", ],
    query: query,
    model: Onlyfans::Models::ChatListResponse,
    options: options
  )
end

#list_media(chat_id, account:, limit: nil, offset: nil, skip_users: nil, type: nil, request_options: {}) ⇒ Onlyfans::Models::ChatListMediaResponse

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

List media files shared in a specific chat.

Parameters:

  • chat_id (String)

    Path param: The ID of the chat to get media from, usually a fan’s OnlyFans User

  • account (String)

    Path param: The Account ID

  • limit (String)

    Query param: Number of medias to return. Default = 20

  • offset (String)

    Query param: Number of medias to skip for pagination

  • skip_users (String)

    Query param: Whether to skip user details in response (all or none). Default = a

  • type (Symbol, Onlyfans::Models::ChatListMediaParams::Type, nil)

    Query param: Filter by specific media types. Keep empty to return all.

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

Returns:

See Also:



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/onlyfans/resources/chats.rb', line 126

def list_media(chat_id, params)
  parsed, options = Onlyfans::ChatListMediaParams.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/media", , chat_id],
    query: query,
    model: Onlyfans::Models::ChatListMediaResponse,
    options: options
  )
end

#mark_as_read(chat_id, account:, request_options: {}) ⇒ Onlyfans::Models::ChatMarkAsReadResponse

Mark a specific chat as read. Alternative to List Chat Messages endpoint, if you just want to mark the chat as read without fetching messages.

Parameters:

  • chat_id (String)

    The ID of the chat to mark as read, usually a fan’s OnlyFans User ID

  • account (String)

    The Account ID

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

Returns:

See Also:



156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/onlyfans/resources/chats.rb', line 156

def mark_as_read(chat_id, params)
  parsed, options = Onlyfans::ChatMarkAsReadParams.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/mark-as-read", , chat_id],
    model: Onlyfans::Models::ChatMarkAsReadResponse,
    options: options
  )
end

#mark_as_unread(chat_id, account:, request_options: {}) ⇒ Onlyfans::Models::ChatMarkAsUnreadResponse

Mark a specific chat as unread.

Parameters:

  • chat_id (String)

    The ID of the chat to mark as read, usually a fan’s OnlyFans User ID

  • account (String)

    The Account ID

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

Returns:

See Also:



183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/onlyfans/resources/chats.rb', line 183

def mark_as_unread(chat_id, params)
  parsed, options = Onlyfans::ChatMarkAsUnreadParams.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/mark-as-unread", , chat_id],
    model: Onlyfans::Models::ChatMarkAsUnreadResponse,
    options: options
  )
end

#mute(chat_id, account:, request_options: {}) ⇒ Onlyfans::Models::ChatMuteResponse

Mute notifications for a specific chat.

Parameters:

  • chat_id (String)

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

  • account (String)

    The Account ID

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

Returns:

See Also:



210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/onlyfans/resources/chats.rb', line 210

def mute(chat_id, params)
  parsed, options = Onlyfans::ChatMuteParams.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/mute", , chat_id],
    model: Onlyfans::Models::ChatMuteResponse,
    options: options
  )
end

#start_typing(chat_id, account:, request_options: {}) ⇒ Onlyfans::Models::ChatStartTypingResponse

Calling this endpoint will show the target fan a “Model is typing…” note in the chat for ~4 seconds. If you want to continue showing the indicator call this endpoint multiple times. Free - no credits charged.

Parameters:

  • chat_id (String)

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

  • account (String)

    The Account ID

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

Returns:

See Also:



239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/onlyfans/resources/chats.rb', line 239

def start_typing(chat_id, params)
  parsed, options = Onlyfans::ChatStartTypingParams.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/typing", , chat_id],
    model: Onlyfans::Models::ChatStartTypingResponse,
    options: options
  )
end

#unmute(chat_id, account:, request_options: {}) ⇒ Onlyfans::Models::ChatUnmuteResponse

Unmute notifications for a specific chat.

Parameters:

  • chat_id (String)

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

  • account (String)

    The Account ID

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

Returns:

See Also:



266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/onlyfans/resources/chats.rb', line 266

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