Sha256: cb0ef16ff9b16167c7e3d1ef77eefdd06bfb48f084fa5e8540eab37c141dbe2f

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module Laundry
  module PaymentsGateway

    class MerchantAuthenticatableDriver
      extend Laundry::SOAPModel

      attr_accessor :merchant

      def initialize(merchant)
        # Save the merchant.
        self.merchant = merchant
        setup_client!
      end

      def setup_client!
        self.class.client.wsdl.document = self.class.wsdl if self.class.respond_to?(:wsdl)
      end

      def default_body
        # Log in via the merchant's login credentials.
        self.merchant.login_credentials.merge("MerchantID" => self.merchant.id)
      end

      def self.prettifiable_fields
        []
      end

      def self.uglify_hash(hash)
        translation = {}
        self.prettifiable_fields.each do |f|
          translation[f.snakecase.to_sym] = f
        end
        ugly_hash = {}
        hash.each do |k, v|
          if translation.has_key?(k)
            ugly_hash[translation[k]] = v
          else
            ugly_hash[k] = v
          end
        end
        ugly_hash
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
laundry-0.0.8 lib/laundry/payments_gateway/drivers/merchant_authenticatable_driver.rb
laundry-0.0.7 lib/laundry/payments_gateway/drivers/merchant_authenticatable_driver.rb
laundry-0.0.6 lib/laundry/payments_gateway/drivers/merchant_authenticatable_driver.rb