Sha256: a8fcaa788577f6f88d5efb97a3a8923008c1a2c90ac79b7c91eeb4ab5a91bfcd

Contents?: true

Size: 1.92 KB

Versions: 15

Compression:

Stored size: 1.92 KB

Contents

module RockRMS
  class Client
    module SavedPaymentMethod
      def list_saved_payment_methods(options = {})
        res = get(saved_payment_method_path, options)
        Response::SavedPaymentMethod.format(res)
      end

      def create_saved_payment_method(
        gateway_id:,
        gateway_person_id: nil,
        payment_detail_id:,
        person_alias_id:,
        name:,
        reference_number:
      )
        options = {
          'FinancialGatewayId'       => gateway_id,
          'FinancialPaymentDetailId' => payment_detail_id,
          'Name'                     => name,
          'PersonAliasId'            => person_alias_id,
          'ReferenceNumber'          => reference_number
        }

        if gateway_person_id
          options['GatewayPersonIdentifier'] = gateway_person_id
        end

        post(saved_payment_method_path, options)
      end

      def update_saved_payment_method(
        id,
        gateway_id: nil,
        gateway_person_id: nil,
        payment_detail_id: nil,
        person_alias_id: nil,
        name: nil,
        reference_number: nil
      )
        options = {}

        options['FinancialGatewayId']       = gateway_id        if gateway_id
        options['GatewayPersonIdentifier']  = gateway_person_id if gateway_person_id
        options['FinancialPaymentDetailId'] = payment_detail_id if payment_detail_id
        options['Name']                     = name              if name
        options['PersonAliasId']            = person_alias_id   if person_alias_id
        options['ReferenceNumber']          = reference_number  if reference_number

        patch(saved_payment_method_path(id), options)
      end

      def delete_saved_payment_method(id)
        delete(saved_payment_method_path(id))
      end

      private

      def saved_payment_method_path(id = nil)
        id ? "FinancialPersonSavedAccounts/#{id}" : 'FinancialPersonSavedAccounts'
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rock_rms-6.0.6 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-6.0.5 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-6.0.4 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-6.0.3 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-6.0.1 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-6.0.0 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-5.18.0 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-5.17.0 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-5.16.0 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-5.15.0 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-5.14.0 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-5.13.0 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-5.12.0 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-5.11.0 lib/rock_rms/resources/saved_payment_method.rb
rock_rms-5.10.0 lib/rock_rms/resources/saved_payment_method.rb