Sha256: f2f8c9898891aa3d00ab3f19a01f7096b9f75ce0699aed18b1e29f524353b63a
Contents?: true
Size: 703 Bytes
Versions: 1
Compression:
Stored size: 703 Bytes
Contents
# frozen_string_literal: true require "tikkie/notifications/bundle_notification" require "tikkie/notifications/payment_notification" require "tikkie/notifications/refund_notification" module Tikkie # Parses the payload for a Notification. module Notification module_function def parse(body) notification = JSON.parse(body, symbolize_names: true) notification_type = notification[:notificationType]&.capitalize return nil if notification_type.nil? || notification_type !~ /[a-z]+/i klass = Object.const_get("Tikkie::Notifications::#{notification_type}Notification") klass.new(notification) rescue JSON::ParserError, NameError nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tikkie-api-2.0.0 | lib/tikkie/notification.rb |