Sha256: 102a6ebf7f08a15ed32acb934ac725f6c67642c6488bb1a6e93edd33cb3d3865

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

module Zoop
  class Seller < Zoop::CustomerCommon

    def create
      @custom_url = self.class.url(mount_url)
      super
    end

    def update(params={})
      raise RequestError.new('Invalid ID') unless id.present?
      @custom_url = self.class.url(mount_url, CGI.escape(id.to_s))
      super
    end

    def save
      raise RequestError.new('Invalid ID') unless id.present?
      @custom_url = self.class.url(mount_url, CGI.escape(id.to_s))
      super
    end

    def receiving_policy
      Zoop::Request.get(url 'receiving_policy').call
    end

    def update_receiving_policy(params={})
      Zoop::Request.post(url('receiving_policy'), params: params).call
    end

    def documents
      Zoop::Request.get( url 'documents' ).call
    end

    def upload_documents(params={})
      Zoop::Request.post(url('documents'), params: params).call
    end

    def bank_accounts
      Zoop::Request.get( url 'bank_accounts' ).call
    end

    def bank_account
      return if self.default_credit.blank?
      Zoop::BankAccount.find(self.default_credit)
    end

    def transactions
      Zoop::Request.get(url('transactions'), headers: { 'Content-Type' => '' }).call
    end

    def balances
      Zoop::Request.get( url 'balances' ).call
    end

    private

    def mount_url
      self.type == 'business' ? 'businesses' : 'individuals'
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zoop-0.3.5 lib/zoop/resources/seller.rb
zoop-0.3.4 lib/zoop/resources/seller.rb