Class: Webhookdb::Replicator::StripeRefundV1
- Inherits:
-
Base
- Object
- Base
- Webhookdb::Replicator::StripeRefundV1
show all
- Includes:
- Appydays::Loggable, StripeV1Mixin
- Defined in:
- lib/webhookdb/replicator/stripe_refund_v1.rb
Constant Summary
Constants inherited
from Base
Base::MAX_INDEX_NAME_LENGTH
DBAdapter::ColumnTypes::BIGINT, DBAdapter::ColumnTypes::BIGINT_ARRAY, DBAdapter::ColumnTypes::BOOLEAN, DBAdapter::ColumnTypes::COLUMN_TYPES, DBAdapter::ColumnTypes::DATE, DBAdapter::ColumnTypes::DECIMAL, DBAdapter::ColumnTypes::DOUBLE, DBAdapter::ColumnTypes::FLOAT, DBAdapter::ColumnTypes::INTEGER, DBAdapter::ColumnTypes::INTEGER_ARRAY, DBAdapter::ColumnTypes::OBJECT, DBAdapter::ColumnTypes::TEXT, DBAdapter::ColumnTypes::TEXT_ARRAY, DBAdapter::ColumnTypes::TIMESTAMP, DBAdapter::ColumnTypes::UUID
Instance Attribute Summary
Attributes inherited from Base
#service_integration
Class Method Summary
collapse
Instance Method Summary
collapse
#_fetch_backfill_page, #_resource_and_event, #_timestamp_column_name, #_verify_backfill_401_err_msg, #_verify_backfill_403_err_msg, #_verify_backfill_err_msg, #_webhook_response, #calculate_backfill_state_machine, #calculate_webhook_state_machine
Methods inherited from Base
#_any_subscriptions_to_notify?, #_backfill_state_change_fields, #_backfillers, #_clear_backfill_information, #_clear_webook_information, #_coalesce_excluded_on_update, #_enqueue_backfill_jobs, #_extra_index_specs, #_fetch_enrichment, #_find_dependency_candidate, #_notify_dependents, #_parallel_backfill, #_prepare_for_insert, #_publish_rowupsert, #_resource_and_event, #_resource_to_data, #_store_enrichment_body?, #_timestamp_column_name, #_to_json, #_upsert_update_expr, #_verify_backfill_err_msg, #_webhook_response, #_webhook_state_change_fields, #admin_dataset, #backfill, #backfill_not_supported_message, #calculate_and_backfill_state_machine, #calculate_backfill_state_machine, #calculate_dependency_state_machine_step, #calculate_preferred_create_state_machine, #calculate_webhook_state_machine, chunked_row_update_bounds, #clear_backfill_information, #clear_webhook_information, #create_table, #create_table_modification, #data_column, #dbadapter_table, #denormalized_columns, #descriptor, #dispatch_request_to, #documentation_url, #enqueue_sync_targets, #enrichment_column, #ensure_all_columns, #ensure_all_columns_modification, #find_dependent, #find_dependent!, #indices, #initialize, #on_backfill_error, #on_dependency_webhook_upsert, #preferred_create_state_machine_method, #preprocess_headers_for_logging, #primary_key_column, #process_state_change, #process_webhooks_synchronously?, #qualified_table_sequel_identifier, #readonly_dataset, #remote_key_column, #requires_sequence?, #resource_name_plural, #resource_name_singular, #schema_and_table_symbols, #storable_columns, #synchronous_processing_response_body, #timestamp_column, #upsert_has_deps?, #upsert_webhook, #upsert_webhook_body, #verify_backfill_credentials, #webhook_endpoint, #webhook_response
Class Method Details
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/webhookdb/replicator/stripe_refund_v1.rb', line 11
def self.descriptor
return Webhookdb::Replicator::Descriptor.new(
name: "stripe_refund_v1",
ctor: ->(sint) { Webhookdb::Replicator::StripeRefundV1.new(sint) },
feature_roles: [],
resource_name_singular: "Stripe Refund",
supports_webhooks: true,
supports_backfill: true,
api_docs_url: "https://stripe.com/docs/api/refunds",
)
end
|
Instance Method Details
#_denormalized_columns ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/webhookdb/replicator/stripe_refund_v1.rb', line 27
def _denormalized_columns
return [
Webhookdb::Replicator::Column.new(:amount, INTEGER, index: true),
Webhookdb::Replicator::Column.new(:balance_transaction, TEXT, index: true),
Webhookdb::Replicator::Column.new(:charge, TEXT, index: true),
Webhookdb::Replicator::Column.new(:created, TIMESTAMP, index: true, converter: :tsat),
Webhookdb::Replicator::Column.new(:payment_intent, TEXT, index: true),
Webhookdb::Replicator::Column.new(:receipt_number, TEXT, index: true),
Webhookdb::Replicator::Column.new(:source_transfer_reversal, TEXT, index: true),
Webhookdb::Replicator::Column.new(:status, TEXT),
Webhookdb::Replicator::Column.new(:transfer_reversal, TEXT, index: true),
Webhookdb::Replicator::Column.new(
:updated,
TIMESTAMP,
index: true,
data_key: "created",
event_key: "created",
converter: :tsat,
),
]
end
|
#_mixin_backfill_url ⇒ Object
53
54
55
|
# File 'lib/webhookdb/replicator/stripe_refund_v1.rb', line 53
def _mixin_backfill_url
return "https://api.stripe.com/v1/refunds"
end
|
#_mixin_event_type_names ⇒ Object
57
58
59
|
# File 'lib/webhookdb/replicator/stripe_refund_v1.rb', line 57
def _mixin_event_type_names
return ["charge.refund.updated"]
end
|
#_remote_key_column ⇒ Object
23
24
25
|
# File 'lib/webhookdb/replicator/stripe_refund_v1.rb', line 23
def _remote_key_column
return Webhookdb::Replicator::Column.new(:stripe_id, TEXT, data_key: "id")
end
|
#_update_where_expr ⇒ Object
49
50
51
|
# File 'lib/webhookdb/replicator/stripe_refund_v1.rb', line 49
def _update_where_expr
return self.qualified_table_sequel_identifier[:updated] < Sequel[:excluded][:updated]
end
|
#_upsert_webhook(request, upsert: true) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/webhookdb/replicator/stripe_refund_v1.rb', line 63
def _upsert_webhook(request, upsert: true)
resource, _event = self._resource_and_event(request)
object_type = resource.fetch("object")
return super if object_type == "refund"
refunds_obj = request.body.dig("data", "object", "refunds")
if refunds_obj.fetch("has_more") == true
Webhookdb::DeveloperAlert.new(
subsystem: "Stripe Refunds Webhook Error",
emoji: ":hook:",
fallback: "Full backfill required for integration #{self.service_integration.opaque_id}",
fields: [],
).emit
end
refunds_obj.fetch("data").each do |b|
new_request = request.dup
new_request.body = b
super(new_request, upsert:)
end
end
|
#restricted_key_resource_name ⇒ Object
61
|
# File 'lib/webhookdb/replicator/stripe_refund_v1.rb', line 61
def restricted_key_resource_name = "Charges"
|