Sha256: e2bc17e06d87e39cd06312822c186a1cba630d1cfc7385fae963985dd5d93927

Contents?: true

Size: 1.6 KB

Versions: 28

Compression:

Stored size: 1.6 KB

Contents

module Braintree
  class MerchantAccount
    include BaseModule

    module Status
      Pending = "pending"
      Active = "active"
      Suspended = "suspended"
    end

    module FundingDestination
      Bank = "bank"
      MobilePhone = "mobile_phone"
      Email = "email"
    end

    module FundingDestinations
      include Braintree::MerchantAccount::FundingDestination
    end

    attr_reader :status, :id, :master_merchant_account,
      :individual_details, :business_details, :funding_details

    def self.create(attributes)
      Configuration.gateway.merchant_account.create(attributes)
    end

    def self.find(attributes)
      Configuration.gateway.merchant_account.find(attributes)
    end

    def self.update(id, attributes)
      Configuration.gateway.merchant_account.update(id, attributes)
    end

    def initialize(gateway, attributes) # :nodoc
      @gateway = gateway
      set_instance_variables_from_hash(attributes)
      @individual_details = IndividualDetails.new(@individual)
      @business_details = BusinessDetails.new(@business)
      @funding_details = FundingDetails.new(@funding)
      @master_merchant_account = MerchantAccount._new(@gateway, attributes.delete(:master_merchant_account)) if attributes[:master_merchant_account]
    end

    class << self
      protected :new
      def _new(*args) # :nodoc:
        self.new *args
      end
    end

    def inspect
      order = [:id, :status, :master_merchant_account]
      nice_attributes = order.map do |attr|
        "#{attr}: #{send(attr).inspect}"
      end
      "#<#{self.class}: #{nice_attributes.join(', ')}>"
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
braintree-2.54.0 lib/braintree/merchant_account.rb
braintree-2.50.0 lib/braintree/merchant_account.rb
braintree-2.49.0 lib/braintree/merchant_account.rb
braintree-2.48.1 lib/braintree/merchant_account.rb
braintree-2.48.0 lib/braintree/merchant_account.rb
braintree-2.47.0 lib/braintree/merchant_account.rb
braintree-2.46.0 lib/braintree/merchant_account.rb
braintree-2.45.0 lib/braintree/merchant_account.rb
braintree-2.44.0 lib/braintree/merchant_account.rb
braintree-2.43.0 lib/braintree/merchant_account.rb
braintree-2.42.0 lib/braintree/merchant_account.rb
braintree-2.41.0 lib/braintree/merchant_account.rb
braintree-2.40.0 lib/braintree/merchant_account.rb
braintree-2.39.0 lib/braintree/merchant_account.rb
braintree-2.38.0 lib/braintree/merchant_account.rb
braintree-2.37.0 lib/braintree/merchant_account.rb
braintree-2.36.0 lib/braintree/merchant_account.rb
braintree-2.35.0 lib/braintree/merchant_account.rb
braintree-2.34.1 lib/braintree/merchant_account.rb
braintree-2.34.0 lib/braintree/merchant_account.rb