Sha256: 886c2fef16df65b4a01ffd36bfc6bc1229df4c7a26f7bf0aec14056896ba79ec

Contents?: true

Size: 1.92 KB

Versions: 17

Compression:

Stored size: 1.92 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 :business_details
    attr_reader :currency_iso_code
    attr_reader :default
    attr_reader :funding_details
    attr_reader :id
    attr_reader :individual_details
    attr_reader :master_merchant_account
    attr_reader :status

    alias_method :default?, :default

    def self.create(*args)
      Configuration.gateway.merchant_account.create(*args)
    end

    def self.create!(*args)
      Configuration.gateway.merchant_account.create!(*args)
    end

    def self.find(*args)
      Configuration.gateway.merchant_account.find(*args)
    end

    def self.update(*args)
      Configuration.gateway.merchant_account.update(*args)
    end

    def self.update!(*args)
      Configuration.gateway.merchant_account.update!(*args)
    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

17 entries across 17 versions & 1 rubygems

Version Path
braintree-4.15.0 lib/braintree/merchant_account.rb
braintree-4.14.0 lib/braintree/merchant_account.rb
braintree-4.13.0 lib/braintree/merchant_account.rb
braintree-4.12.0 lib/braintree/merchant_account.rb
braintree-4.11.0 lib/braintree/merchant_account.rb
braintree-4.10.0 lib/braintree/merchant_account.rb
braintree-4.9.0 lib/braintree/merchant_account.rb
braintree-4.8.0 lib/braintree/merchant_account.rb
braintree-4.7.0 lib/braintree/merchant_account.rb
braintree-4.6.0 lib/braintree/merchant_account.rb
braintree-4.5.0 lib/braintree/merchant_account.rb
braintree-4.4.0 lib/braintree/merchant_account.rb
braintree-4.3.0 lib/braintree/merchant_account.rb
braintree-4.2.0 lib/braintree/merchant_account.rb
braintree-4.1.0 lib/braintree/merchant_account.rb
braintree-4.0.0 lib/braintree/merchant_account.rb
braintree-3.4.0 lib/braintree/merchant_account.rb