Class: Notiflows::Resources::Users::Subscriptions
- Inherits:
-
Object
- Object
- Notiflows::Resources::Users::Subscriptions
- Defined in:
- lib/notiflows/resources/users/subscriptions.rb
Instance Method Summary collapse
-
#initialize(client:) ⇒ Subscriptions
constructor
private
A new instance of Subscriptions.
-
#list(user_external_id, after: nil, before: nil, created_after: nil, created_before: nil, limit: nil, request_options: {}) ⇒ Notiflows::Internal::CursorPage<Notiflows::Models::Users::Subscription>
Retrieve all topic subscriptions for a user.
-
#retrieve(topic_name, user_external_id:, request_options: {}) ⇒ Notiflows::Models::Users::Subscription
Check if a user is subscribed to a specific topic.
-
#subscribe(user_external_id, topic_name:, request_options: {}) ⇒ Notiflows::Models::Users::Subscription
Some parameter documentations has been truncated, see Models::Users::SubscriptionSubscribeParams for more details.
-
#unsubscribe(topic_name, user_external_id:, request_options: {}) ⇒ nil
Remove a user's subscription from a topic.
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.
129 130 131 |
# File 'lib/notiflows/resources/users/subscriptions.rb', line 129 def initialize(client:) @client = client end |
Instance Method Details
#list(user_external_id, after: nil, before: nil, created_after: nil, created_before: nil, limit: nil, request_options: {}) ⇒ Notiflows::Internal::CursorPage<Notiflows::Models::Users::Subscription>
Retrieve all topic subscriptions for a user.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/notiflows/resources/users/subscriptions.rb', line 55 def list(user_external_id, params = {}) parsed, = ::Notiflows::Users::SubscriptionListParams.dump_request(params) @client.request( method: :get, path: ["users/%1$s/subscriptions", user_external_id], query: parsed, page: ::Notiflows::Internal::CursorPage, model: ::Notiflows::Users::Subscription, options: ) end |
#retrieve(topic_name, user_external_id:, request_options: {}) ⇒ Notiflows::Models::Users::Subscription
Check if a user is subscribed to a specific topic.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/notiflows/resources/users/subscriptions.rb', line 20 def retrieve(topic_name, params) parsed, = ::Notiflows::Users::SubscriptionRetrieveParams.dump_request(params) user_external_id = parsed.delete(:user_external_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["users/%1$s/subscriptions/%2$s", user_external_id, topic_name], model: ::Notiflows::Users::Subscription, options: ) end |
#subscribe(user_external_id, topic_name:, request_options: {}) ⇒ Notiflows::Models::Users::Subscription
Some parameter documentations has been truncated, see Models::Users::SubscriptionSubscribeParams for more details.
Subscribe a user to a topic. Topics are created automatically if they don't exist.
Idempotent: If the user is already subscribed, returns the existing
subscription with 200 OK.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/notiflows/resources/users/subscriptions.rb', line 87 def subscribe(user_external_id, params) parsed, = ::Notiflows::Users::SubscriptionSubscribeParams.dump_request(params) @client.request( method: :post, path: ["users/%1$s/subscriptions", user_external_id], body: parsed, model: ::Notiflows::Users::Subscription, options: ) end |
#unsubscribe(topic_name, user_external_id:, request_options: {}) ⇒ nil
Remove a user's subscription from a topic. The user will no longer receive notifications triggered for this topic.
112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/notiflows/resources/users/subscriptions.rb', line 112 def unsubscribe(topic_name, params) parsed, = ::Notiflows::Users::SubscriptionUnsubscribeParams.dump_request(params) user_external_id = parsed.delete(:user_external_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["users/%1$s/subscriptions/%2$s", user_external_id, topic_name], model: NilClass, options: ) end |