Sha256: 8a5c181bfc780192fe820ed3e7c345b08219faed88d1474c5e46d79867652936

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

module Braintree
  class MerchantAccount
    include BaseModule

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

    module FundingDestinations
      Bank = "bank"
      MobilePhone = "mobile_phone"
      Email = "email"
    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.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

1 entries across 1 versions & 1 rubygems

Version Path
braintree-2.27.0 lib/braintree/merchant_account.rb