hookbridge 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/hookbridge/client.rb +114 -0
- data/lib/hookbridge/types.rb +86 -0
- data/lib/hookbridge/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a3ef380402beb61c7cbbca77fd98b1797aa086d052b6a9461300329bf7f26f9
|
|
4
|
+
data.tar.gz: 2932a270e9649ce1f26117122867c1c473566fdf6e6ebec04d2edcb630233fff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e2262aa8ce2ac43a6d468f9a1158ade14ea7667c201225b8e1b462876a7d9d85c105501f50252726f4f40285290260493593d446b86d14be406cfe0e87c1f4a1
|
|
7
|
+
data.tar.gz: 62effea4fc77737a93a938a918d307dde0ce1a553c25fc4627cb6857f25c2e68865c8fec4e1eac011aa02ab3c2b8e337a5ddb7fcb93f5625a7478662ced184f0
|
data/lib/hookbridge/client.rb
CHANGED
|
@@ -224,6 +224,120 @@ module HookBridge
|
|
|
224
224
|
create_endpoint_signing_key(endpoint_id)
|
|
225
225
|
end
|
|
226
226
|
|
|
227
|
+
def create_pull_endpoint(name: nil, description: nil, retention_days: nil, event_type_source: nil, event_type_path: nil,
|
|
228
|
+
verify_static_token: nil, token_header_name: nil, token_query_param: nil, token_value: nil,
|
|
229
|
+
verify_hmac: nil, hmac_header_name: nil, hmac_secret: nil, timestamp_header_name: nil,
|
|
230
|
+
timestamp_ttl_seconds: nil, verify_ip_allowlist: nil, allowed_cidrs: nil,
|
|
231
|
+
idempotency_header_names: nil, ingest_response_code: nil)
|
|
232
|
+
body = compact_hash(
|
|
233
|
+
name: name,
|
|
234
|
+
description: description,
|
|
235
|
+
retention_days: retention_days,
|
|
236
|
+
event_type_source: event_type_source,
|
|
237
|
+
event_type_path: event_type_path,
|
|
238
|
+
verify_static_token: verify_static_token,
|
|
239
|
+
token_header_name: token_header_name,
|
|
240
|
+
token_query_param: token_query_param,
|
|
241
|
+
token_value: token_value,
|
|
242
|
+
verify_hmac: verify_hmac,
|
|
243
|
+
hmac_header_name: hmac_header_name,
|
|
244
|
+
hmac_secret: hmac_secret,
|
|
245
|
+
timestamp_header_name: timestamp_header_name,
|
|
246
|
+
timestamp_ttl_seconds: timestamp_ttl_seconds,
|
|
247
|
+
verify_ip_allowlist: verify_ip_allowlist,
|
|
248
|
+
allowed_cidrs: allowed_cidrs,
|
|
249
|
+
idempotency_header_names: idempotency_header_names,
|
|
250
|
+
ingest_response_code: ingest_response_code
|
|
251
|
+
)
|
|
252
|
+
CreatePullEndpointResponse.new(extract_data(request(:post, "/v1/pull-endpoints", body)))
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def list_pull_endpoints(limit: nil, cursor: nil)
|
|
256
|
+
params = {}
|
|
257
|
+
params[:limit] = limit if limit
|
|
258
|
+
params[:cursor] = cursor if cursor
|
|
259
|
+
response = request(:get, "/v1/pull-endpoints", nil, params)
|
|
260
|
+
ListPullEndpointsResponse.new(
|
|
261
|
+
"data" => extract_data(response),
|
|
262
|
+
"next_cursor" => extract_meta(response)["next_cursor"] || response["next_cursor"]
|
|
263
|
+
)
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def get_pull_endpoint(endpoint_id)
|
|
267
|
+
PullEndpoint.new(extract_data(request(:get, "/v1/pull-endpoints/#{endpoint_id}")))
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def update_pull_endpoint(endpoint_id, **attributes)
|
|
271
|
+
PullEndpoint.new(extract_data(request(:patch, "/v1/pull-endpoints/#{endpoint_id}", compact_hash(attributes))))
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def delete_pull_endpoint(endpoint_id)
|
|
275
|
+
DeleteResult.new(extract_data(request(:delete, "/v1/pull-endpoints/#{endpoint_id}")))
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def pause_pull_endpoint(endpoint_id)
|
|
279
|
+
PauseState.new(extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/pause")))
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def resume_pull_endpoint(endpoint_id)
|
|
283
|
+
PauseState.new(extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/resume")))
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def list_pull_events(endpoint_id, status: nil, event_type: nil, since: nil, before: nil, limit: nil, cursor: nil)
|
|
287
|
+
params = {}
|
|
288
|
+
params[:status] = status if status
|
|
289
|
+
params[:event_type] = event_type if event_type
|
|
290
|
+
params[:since] = format_time(since) if since
|
|
291
|
+
params[:before] = format_time(before) if before
|
|
292
|
+
params[:limit] = limit if limit
|
|
293
|
+
params[:cursor] = cursor if cursor
|
|
294
|
+
response = request(:get, "/v1/pull-endpoints/#{endpoint_id}/events", nil, params)
|
|
295
|
+
ListPullEventsResponse.new(
|
|
296
|
+
"data" => extract_data(response),
|
|
297
|
+
"has_more" => extract_meta(response)["has_more"] || response["has_more"],
|
|
298
|
+
"next_cursor" => extract_meta(response)["next_cursor"] || response["next_cursor"]
|
|
299
|
+
)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def get_pull_event(endpoint_id, event_id)
|
|
303
|
+
PullEventDetail.new(extract_data(request(:get, "/v1/pull-endpoints/#{endpoint_id}/events/#{event_id}")))
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def ack_pull_events(endpoint_id, event_ids)
|
|
307
|
+
AckPullEventsResponse.new(
|
|
308
|
+
extract_data(request(:post, "/v1/pull-endpoints/#{endpoint_id}/events/ack", { event_ids: event_ids }))
|
|
309
|
+
)
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def get_pull_logs(pull_endpoint_id: nil, status: nil, event_type: nil, start_time: nil, end_time: nil, limit: nil, cursor: nil)
|
|
313
|
+
params = {}
|
|
314
|
+
params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id
|
|
315
|
+
params[:status] = status if status
|
|
316
|
+
params[:event_type] = event_type if event_type
|
|
317
|
+
params[:start_time] = format_time(start_time) if start_time
|
|
318
|
+
params[:end_time] = format_time(end_time) if end_time
|
|
319
|
+
params[:limit] = limit if limit
|
|
320
|
+
params[:cursor] = cursor if cursor
|
|
321
|
+
response = request(:get, "/v1/pull-logs", nil, params)
|
|
322
|
+
PullLogsResponse.new(
|
|
323
|
+
"data" => extract_data(response),
|
|
324
|
+
"has_more" => extract_meta(response)["has_more"] || response["has_more"],
|
|
325
|
+
"next_cursor" => extract_meta(response)["next_cursor"] || response["next_cursor"]
|
|
326
|
+
)
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
def get_pull_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil)
|
|
330
|
+
params = { window: window }
|
|
331
|
+
params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id
|
|
332
|
+
Metrics.new(extract_data(request(:get, "/v1/pull-metrics", nil, params)))
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def get_pull_timeseries_metrics(window: MetricsWindow::TWENTY_FOUR_HOURS, pull_endpoint_id: nil)
|
|
336
|
+
params = { window: window }
|
|
337
|
+
params[:pull_endpoint_id] = pull_endpoint_id if pull_endpoint_id
|
|
338
|
+
PullTimeSeriesMetrics.new(extract_data(request(:get, "/v1/pull-metrics/timeseries", nil, params)))
|
|
339
|
+
end
|
|
340
|
+
|
|
227
341
|
def create_checkout(plan:, interval:)
|
|
228
342
|
CheckoutSession.new(extract_data(request(:post, "/v1/billing/checkout", { plan: plan, interval: interval })))
|
|
229
343
|
end
|
data/lib/hookbridge/types.rb
CHANGED
|
@@ -283,6 +283,21 @@ module HookBridge
|
|
|
283
283
|
end
|
|
284
284
|
end
|
|
285
285
|
|
|
286
|
+
class PullTimeSeriesBucket < BaseModel
|
|
287
|
+
def initialize(data)
|
|
288
|
+
super(data, time_fields: %w[timestamp])
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
class PullTimeSeriesMetrics
|
|
293
|
+
attr_reader :window, :buckets
|
|
294
|
+
|
|
295
|
+
def initialize(data)
|
|
296
|
+
@window = data["window"]
|
|
297
|
+
@buckets = (data["buckets"] || []).map { |entry| PullTimeSeriesBucket.new(entry) }
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
|
|
286
301
|
class SubscriptionLimits < BaseModel
|
|
287
302
|
end
|
|
288
303
|
|
|
@@ -357,6 +372,77 @@ module HookBridge
|
|
|
357
372
|
class PauseState < BaseModel
|
|
358
373
|
end
|
|
359
374
|
|
|
375
|
+
class PullEndpointCounts < BaseModel
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
class PullEndpoint < BaseModel
|
|
379
|
+
def initialize(data)
|
|
380
|
+
attributes = (data || {}).dup
|
|
381
|
+
attributes["counts"] = PullEndpointCounts.new(attributes["counts"]) if attributes["counts"].is_a?(Hash)
|
|
382
|
+
super(attributes, time_fields: %w[created_at updated_at])
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
class CreatePullEndpointResponse < PullEndpoint
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
class PullEndpointSummary < BaseModel
|
|
390
|
+
def initialize(data)
|
|
391
|
+
super(data, time_fields: %w[created_at])
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
class ListPullEndpointsResponse
|
|
396
|
+
attr_reader :endpoints, :has_more, :next_cursor
|
|
397
|
+
|
|
398
|
+
def initialize(data)
|
|
399
|
+
@endpoints = (data["data"] || data || []).map { |entry| PullEndpointSummary.new(entry) }
|
|
400
|
+
@has_more = !data["next_cursor"].nil? && data["next_cursor"] != ""
|
|
401
|
+
@next_cursor = data["next_cursor"]
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
class PullEventSummary < BaseModel
|
|
406
|
+
def initialize(data)
|
|
407
|
+
super(data, time_fields: %w[received_at fetched_at delivered_at])
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
class PullEventDetail < BaseModel
|
|
412
|
+
def initialize(data)
|
|
413
|
+
super(data, time_fields: %w[received_at fetched_at delivered_at])
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
class ListPullEventsResponse
|
|
418
|
+
attr_reader :events, :has_more, :next_cursor
|
|
419
|
+
|
|
420
|
+
def initialize(data)
|
|
421
|
+
@events = (data["data"] || data || []).map { |entry| PullEventSummary.new(entry) }
|
|
422
|
+
@has_more = data["has_more"] || false
|
|
423
|
+
@next_cursor = data["next_cursor"]
|
|
424
|
+
end
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
class AckPullEventsResponse < BaseModel
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
class PullLogEntry < BaseModel
|
|
431
|
+
def initialize(data)
|
|
432
|
+
super(data, time_fields: %w[received_at fetched_at delivered_at])
|
|
433
|
+
end
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
class PullLogsResponse
|
|
437
|
+
attr_reader :entries, :has_more, :next_cursor
|
|
438
|
+
|
|
439
|
+
def initialize(data)
|
|
440
|
+
@entries = (data["data"] || data || []).map { |entry| PullLogEntry.new(entry) }
|
|
441
|
+
@has_more = data["has_more"] || false
|
|
442
|
+
@next_cursor = data["next_cursor"]
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
|
|
360
446
|
class InboundLogEntry < BaseModel
|
|
361
447
|
def initialize(data)
|
|
362
448
|
super(data, time_fields: %w[received_at delivered_at])
|
data/lib/hookbridge/version.rb
CHANGED