Class: Notiflows::Resources::Topics

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

Defined Under Namespace

Classes: Subscriptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Topics

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

Parameters:



85
86
87
88
# File 'lib/notiflows/resources/topics.rb', line 85

def initialize(client:)
  @client = client
  @subscriptions = Subscriptions.new(client: client)
end

Instance Attribute Details

#subscriptions ⇒ Notiflows::Resources::Topics::Subscriptions (readonly)



7
8
9
# File 'lib/notiflows/resources/topics.rb', line 7

def subscriptions
  @subscriptions
end

Instance Method Details

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

Delete a topic and all its subscriptions.

Warning: This removes all user subscriptions to this topic. Users will need to re-subscribe if the topic is recreated.

Parameters:

Returns:

  • (nil)

See Also:



73
74
75
76
77
78
79
80
# File 'lib/notiflows/resources/topics.rb', line 73

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["topics/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(after: nil, before: nil, limit: nil, request_options: {}) ⇒ Notiflows::Internal::CursorPage<Notiflows::Models::Topic>

Retrieve a paginated list of all topics in your project.

Topics are used for pub/sub notification patterns. Users subscribe to topics, and you can run notiflows for all subscribers of a topic.

Parameters:

  • after (String) —

    Cursor for fetching the next page

  • before (String) —

    Cursor for fetching the previous page

  • limit (Integer) —

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

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

Returns:

See Also:



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/notiflows/resources/topics.rb', line 47

def list(params = {})
  parsed, options = ::Notiflows::TopicListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "topics",
    query: parsed,
    page: ::Notiflows::Internal::CursorPage,
    model: ::Notiflows::Topic,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ Notiflows::Models::Topic

Retrieve a topic by name.

Parameters:

Returns:

See Also:



20
21
22
23
24
25
26
27
# File 'lib/notiflows/resources/topics.rb', line 20

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["topics/%1$s", id],
    model: ::Notiflows::Topic,
    options: params[:request_options]
  )
end