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.

Parameters:



309
310
311
# File 'lib/lithic/resources/events/subscriptions.rb', line 309

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.

Parameters:

  • url (String)

    URL to which event webhooks will be sent. URL must be a valid HTTPS address.

  • description (String)

    Event subscription description.

  • disabled (Boolean)

    Whether the event subscription is active (false) or inactive (true).

  • event_types (Array<Symbol, Lithic::Models::Events::SubscriptionCreateParams::EventType>)

    Indicates types of events that will be sent to this subscription. If left blank,

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

Returns:

See Also:



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.

Parameters:

Returns:

  • (nil)

See Also:



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

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.

Parameters:

  • ending_before (String)

    A cursor representing an item’s token before which a page of results should end.

  • page_size (Integer)

    Page size (for pagination).

  • starting_after (String)

    A cursor representing an item’s token after which a page of results should begin

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

Returns:

See Also:



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

def list(params = {})
  parsed, options = Lithic::Events::SubscriptionListParams.dump_request(params)
  query = Lithic::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/event_subscriptions",
    query: query,
    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.

Parameters:

  • event_subscription_token (String)
  • begin_ (Time)

    Date string in RFC 3339 format. Only entries created after the specified time wi

  • end_ (Time)

    Date string in RFC 3339 format. Only entries created before the specified time w

  • ending_before (String)

    A cursor representing an item’s token before which a page of results should end.

  • page_size (Integer)

    Page size (for pagination).

  • starting_after (String)

    A cursor representing an item’s token after which a page of results should begin

  • status (Symbol, Lithic::Models::Events::SubscriptionListAttemptsParams::Status)
  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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

def list_attempts(event_subscription_token, params = {})
  parsed, options = Lithic::Events::SubscriptionListAttemptsParams.dump_request(params)
  query = Lithic::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["v1/event_subscriptions/%1$s/attempts", event_subscription_token],
    query: query.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.

Parameters:

  • event_subscription_token (String)
  • begin_ (Time)

    Date string in RFC 3339 format. Only entries created after the specified time wi

  • end_ (Time)

    Date string in RFC 3339 format. Only entries created before the specified time w

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

Returns:

  • (nil)

See Also:



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

def recover(event_subscription_token, params = {})
  parsed, options = Lithic::Events::SubscriptionRecoverParams.dump_request(params)
  query = Lithic::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :post,
    path: ["v1/event_subscriptions/%1$s/recover", event_subscription_token],
    query: query.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.

Parameters:

  • event_subscription_token (String)
  • begin_ (Time)

    Date string in RFC 3339 format. Only entries created after the specified time wi

  • end_ (Time)

    Date string in RFC 3339 format. Only entries created before the specified time w

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

Returns:

  • (nil)

See Also:



231
232
233
234
235
236
237
238
239
240
241
# File 'lib/lithic/resources/events/subscriptions.rb', line 231

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

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

Get an event subscription.

Parameters:

Returns:

See Also:



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.

Parameters:

Returns:

See Also:



253
254
255
256
257
258
259
260
# File 'lib/lithic/resources/events/subscriptions.rb', line 253

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.

Parameters:

Returns:

  • (nil)

See Also:



273
274
275
276
277
278
279
280
# File 'lib/lithic/resources/events/subscriptions.rb', line 273

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.

Parameters:

Returns:

  • (nil)

See Also:



295
296
297
298
299
300
301
302
303
304
# File 'lib/lithic/resources/events/subscriptions.rb', line 295

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.

Parameters:

  • event_subscription_token (String)
  • url (String)

    URL to which event webhooks will be sent. URL must be a valid HTTPS address.

  • description (String)

    Event subscription description.

  • disabled (Boolean)

    Whether the event subscription is active (false) or inactive (true).

  • event_types (Array<Symbol, Lithic::Models::Events::SubscriptionUpdateParams::EventType>)

    Indicates types of events that will be sent to this subscription. If left blank,

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

Returns:

See Also:



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