Class: LedgerSync::Ledgers::TestLedger::WebhookNotification
- Inherits:
-
Object
- Object
- LedgerSync::Ledgers::TestLedger::WebhookNotification
- Defined in:
- lib/ledger_sync/test/support/test_ledger/webhook_notification.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#original_payload ⇒ Object
readonly
Returns the value of attribute original_payload.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#realm_id ⇒ Object
readonly
Returns the value of attribute realm_id.
-
#webhook ⇒ Object
readonly
Returns the value of attribute webhook.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ WebhookNotification
constructor
A new instance of WebhookNotification.
- #resources ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ WebhookNotification
Returns a new instance of WebhookNotification.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ledger_sync/test/support/test_ledger/webhook_notification.rb', line 16 def initialize(args = {}) @original_payload = args.fetch(:payload) @webhook = args.fetch(:webhook, nil) @payload = original_payload.is_a?(String) ? JSON.parse(original_payload) : original_payload @realm_id = @payload['realmId'] raise 'Invalid payload: Could not find realmId' if @realm_id.blank? events_payload = @payload.dig('dataChangeEvent', 'entities') raise 'Invalid payload: Could not find dataChangeEvent -> entities' unless events_payload.is_a?(Array) @events = [] events_payload.each do |event_payload| @events << WebhookEvent.new( payload: event_payload, webhook_notification: self ) end end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
10 11 12 |
# File 'lib/ledger_sync/test/support/test_ledger/webhook_notification.rb', line 10 def events @events end |
#original_payload ⇒ Object (readonly)
Returns the value of attribute original_payload.
10 11 12 |
# File 'lib/ledger_sync/test/support/test_ledger/webhook_notification.rb', line 10 def original_payload @original_payload end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
10 11 12 |
# File 'lib/ledger_sync/test/support/test_ledger/webhook_notification.rb', line 10 def payload @payload end |
#realm_id ⇒ Object (readonly)
Returns the value of attribute realm_id.
10 11 12 |
# File 'lib/ledger_sync/test/support/test_ledger/webhook_notification.rb', line 10 def realm_id @realm_id end |
#webhook ⇒ Object (readonly)
Returns the value of attribute webhook.
10 11 12 |
# File 'lib/ledger_sync/test/support/test_ledger/webhook_notification.rb', line 10 def webhook @webhook end |
Instance Method Details
#resources ⇒ Object
37 38 39 |
# File 'lib/ledger_sync/test/support/test_ledger/webhook_notification.rb', line 37 def resources @resources ||= events.map(&:resource).compact end |