Class: Notiflows::Resources::Topics::Subscriptions

Inherits:
Object
  • Object
show all
Defined in:
lib/notiflows/resources/topics/subscriptions.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Subscriptions

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

Parameters:



100
101
102
# File 'lib/notiflows/resources/topics/subscriptions.rb', line 100

def initialize(client:)
  @client = client
end

Instance Method Details

#list(topic_id, after: nil, before: nil, created_after: nil, created_before: nil, limit: nil, request_options: {}) ⇒ Notiflows::Internal::CursorPage<Notiflows::Models::Users::Subscription>

Retrieve all users subscribed to a specific topic.

Parameters:

  • topic_id (String) —

    Topic name

  • after (String) —

    Cursor for fetching the next page

  • before (String) —

    Cursor for fetching the previous page

  • created_after (String) —

    Filter by created after (ISO 8601 datetime)

  • created_before (String) —

    Filter by created before (ISO 8601 datetime)

  • limit (Integer) —

    Number of items per page (default: 25, max: 1000)

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

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/notiflows/resources/topics/subscriptions.rb', line 28

def list(topic_id, params = {})
  parsed, options = ::Notiflows::Topics::SubscriptionListParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["topics/%1$s/subscriptions", topic_id],
    query: parsed,
    page: ::Notiflows::Internal::CursorPage,
    model: ::Notiflows::Users::Subscription,
    options: options
  )
end

#subscribe_bulk(topic_id, user_external_ids:, request_options: {}) ⇒ Notiflows::Models::Topics::BulkOperationResponse

Subscribe multiple users to a topic in a single request.

  • Topics are created automatically if they don't exist.
  • If a user is already subscribed, they are included in the successful response.
  • Returns 207 Multi-Status if some subscriptions failed.

Parameters:

  • topic_id (String) —

    Topic name

  • user_external_ids (Array<String>) —

    List of user external IDs to subscribe/unsubscribe

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

Returns:

See Also:



58
59
60
61
62
63
64
65
66
67
# File 'lib/notiflows/resources/topics/subscriptions.rb', line 58

def subscribe_bulk(topic_id, params)
  parsed, options = ::Notiflows::Topics::SubscriptionSubscribeBulkParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["topics/%1$s/subscriptions", topic_id],
    body: parsed,
    model: ::Notiflows::Topics::BulkOperationResponse,
    options: options
  )
end

#unsubscribe_bulk(topic_id, user_external_ids:, request_options: {}) ⇒ Notiflows::Models::Topics::BulkOperationResponse

Unsubscribe multiple users from a topic in a single request.

  • Returns 207 Multi-Status if some unsubscriptions failed (e.g., user not found).
  • Users not subscribed to the topic are included in the failed response.

Parameters:

  • topic_id (String) —

    Topic name

  • user_external_ids (Array<String>) —

    List of user external IDs to subscribe/unsubscribe

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

Returns:

See Also:



86
87
88
89
90
91
92
93
94
95
# File 'lib/notiflows/resources/topics/subscriptions.rb', line 86

def unsubscribe_bulk(topic_id, params)
  parsed, options = ::Notiflows::Topics::SubscriptionUnsubscribeBulkParams.dump_request(params)
  @client.request(
    method: :delete,
    path: ["topics/%1$s/subscriptions", topic_id],
    body: parsed,
    model: ::Notiflows::Topics::BulkOperationResponse,
    options: options
  )
end