Class: Lithic::Resources::Events::Subscriptions

Inherits:
Object
  • Object
show all
Defined in:
lib/lithic/resources/events/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.



305
306
307
# File 'lib/lithic/resources/events/subscriptions.rb', line 305

def initialize(client:)
  @client = client
end

Instance Method Details

#create(url:, description: nil, disabled: nil, event_types: nil, request_options: {}) ⇒ Lithic::Models::EventSubscription

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

Create a new event subscription.



27
28
29
30
31
32
33
34
35
36
# File 'lib/lithic/resources/events/subscriptions.rb', line 27

def create(params)
  parsed, options = Lithic::Events::SubscriptionCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/event_subscriptions",
    body: parsed,
    model: Lithic::EventSubscription,
    options: options
  )
end

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

Delete an event subscription.



130
131
132
133
134
135
136
137
# File 'lib/lithic/resources/events/subscriptions.rb', line 130

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

#list(ending_before: nil, page_size: nil, starting_after: nil, request_options: {}) ⇒ Lithic::Internal::CursorPage<Lithic::Models::EventSubscription>

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

List all the event subscriptions.



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/lithic/resources/events/subscriptions.rb', line 108

def list(params = {})
  parsed, options = Lithic::Events::SubscriptionListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "v1/event_subscriptions",
    query: parsed,
    page: Lithic::Internal::CursorPage,
    model: Lithic::EventSubscription,
    options: options
  )
end

#list_attempts(event_subscription_token, begin_: nil, end_: nil, ending_before: nil, page_size: nil, starting_after: nil, status: nil, request_options: {}) ⇒ Lithic::Internal::CursorPage<Lithic::Models::MessageAttempt>

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

List all the message attempts for a given event subscription.



165
166
167
168
169
170
171
172
173
174
175
# File 'lib/lithic/resources/events/subscriptions.rb', line 165

def list_attempts(event_subscription_token, params = {})
  parsed, options = Lithic::Events::SubscriptionListAttemptsParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v1/event_subscriptions/%1$s/attempts", event_subscription_token],
    query: parsed.transform_keys(begin_: "begin", end_: "end"),
    page: Lithic::Internal::CursorPage,
    model: Lithic::MessageAttempt,
    options: options
  )
end

#recover(event_subscription_token, begin_: nil, end_: nil, request_options: {}) ⇒ nil

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

Resend all failed messages since a given time.



195
196
197
198
199
200
201
202
203
204
# File 'lib/lithic/resources/events/subscriptions.rb', line 195

def recover(event_subscription_token, params = {})
  parsed, options = Lithic::Events::SubscriptionRecoverParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/event_subscriptions/%1$s/recover", event_subscription_token],
    query: parsed.transform_keys(begin_: "begin", end_: "end"),
    model: NilClass,
    options: options
  )
end

#replay_missing(event_subscription_token, begin_: nil, end_: nil, request_options: {}) ⇒ nil

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

Replays messages to the endpoint. Only messages that were created after ‘begin` will be sent. Messages that were previously sent to the endpoint are not resent. Message will be retried if endpoint responds with a non-2xx status code. See [Retry Schedule](docs.lithic.com/docs/events-api#retry-schedule) for details.



228
229
230
231
232
233
234
235
236
237
# File 'lib/lithic/resources/events/subscriptions.rb', line 228

def replay_missing(event_subscription_token, params = {})
  parsed, options = Lithic::Events::SubscriptionReplayMissingParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/event_subscriptions/%1$s/replay_missing", event_subscription_token],
    query: parsed.transform_keys(begin_: "begin", end_: "end"),
    model: NilClass,
    options: options
  )
end

#retrieve(event_subscription_token, request_options: {}) ⇒ Lithic::Models::EventSubscription

Get an event subscription.



48
49
50
51
52
53
54
55
# File 'lib/lithic/resources/events/subscriptions.rb', line 48

def retrieve(event_subscription_token, params = {})
  @client.request(
    method: :get,
    path: ["v1/event_subscriptions/%1$s", event_subscription_token],
    model: Lithic::EventSubscription,
    options: params[:request_options]
  )
end

#retrieve_secret(event_subscription_token, request_options: {}) ⇒ Lithic::Models::Events::SubscriptionRetrieveSecretResponse

Get the secret for an event subscription.



249
250
251
252
253
254
255
256
# File 'lib/lithic/resources/events/subscriptions.rb', line 249

def retrieve_secret(event_subscription_token, params = {})
  @client.request(
    method: :get,
    path: ["v1/event_subscriptions/%1$s/secret", event_subscription_token],
    model: Lithic::Models::Events::SubscriptionRetrieveSecretResponse,
    options: params[:request_options]
  )
end

#rotate_secret(event_subscription_token, request_options: {}) ⇒ nil

Rotate the secret for an event subscription. The previous secret will be valid for the next 24 hours.



269
270
271
272
273
274
275
276
# File 'lib/lithic/resources/events/subscriptions.rb', line 269

def rotate_secret(event_subscription_token, params = {})
  @client.request(
    method: :post,
    path: ["v1/event_subscriptions/%1$s/secret/rotate", event_subscription_token],
    model: NilClass,
    options: params[:request_options]
  )
end

#send_simulated_example(event_subscription_token, event_type: nil, request_options: {}) ⇒ nil

Send an example message for event.



291
292
293
294
295
296
297
298
299
300
# File 'lib/lithic/resources/events/subscriptions.rb', line 291

def send_simulated_example(event_subscription_token, params = {})
  parsed, options = Lithic::Events::SubscriptionSendSimulatedExampleParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/simulate/event_subscriptions/%1$s/send_example", event_subscription_token],
    body: parsed,
    model: NilClass,
    options: options
  )
end

#update(event_subscription_token, url:, description: nil, disabled: nil, event_types: nil, request_options: {}) ⇒ Lithic::Models::EventSubscription

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

Update an event subscription.



79
80
81
82
83
84
85
86
87
88
# File 'lib/lithic/resources/events/subscriptions.rb', line 79

def update(event_subscription_token, params)
  parsed, options = Lithic::Events::SubscriptionUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["v1/event_subscriptions/%1$s", event_subscription_token],
    body: parsed,
    model: Lithic::EventSubscription,
    options: options
  )
end