Sha256: 0c4b45661aea3098e4f9dddf81f07c667a1dfb36b4e912925b2309e15ace10e9
Contents?: true
Size: 1.31 KB
Versions: 5
Compression:
Stored size: 1.31 KB
Contents
class K2Transaction attr_reader :id, :type, :metadata, :links_self, :callback_url def initialize(payload) @id = payload.dig('data', 'id') @type = payload.dig('data', 'type') @metadata = payload.dig('data', 'attributes', 'metadata') @links_self = payload.dig('data', 'attributes', '_links', 'self') @callback_url = payload.dig('data', 'attributes', '_links', 'callback_url') end end class CommonPayment < K2Transaction include ActiveModel::Validations attr_reader :status, :initiation_time validate :valid_payment_type def initialize(payload) super @status = payload.dig('data', 'attributes', 'status') @initiation_time = payload.dig('data', 'attributes', 'initiation_time') if @type.eql?('incoming_payment') end private def valid_payment_type; end end class OutgoingTransaction < CommonPayment attr_reader :created_at, :transfer_batches, :total_value def initialize(payload) super @created_at = payload.dig('data', 'attributes', 'created_at') @currency = payload.dig('data', 'attributes', 'amount', 'currency') @total_value = payload.dig('data', 'attributes', 'amount', 'value') @transfer_batches = payload.dig('data', 'attributes', 'transfer_batches') end end
Version data entries
5 entries across 5 versions & 1 rubygems