Sha256: 2cd36ca925d854c7c3292f01b24eece0d28e0144bcacedd5d5d884764f058034

Contents?: true

Size: 1.47 KB

Versions: 9

Compression:

Stored size: 1.47 KB

Contents

module XeroGateway
  class Response
    attr_accessor :response_id, :status, :errors, :provider, :date_time, :response_item, :request_params, :request_xml, :response_xml
    
    def array_wrapped_response_item
      Array(response_item)
    end
    
    alias_method :invoice,              :response_item
    alias_method :credit_note,          :response_item
    alias_method :bank_transaction,     :response_item
    alias_method :manual_journal,       :response_item
    alias_method :contact,              :response_item
    alias_method :organisation,         :response_item
    alias_method :invoices,             :array_wrapped_response_item
    alias_method :credit_notes,         :array_wrapped_response_item
    alias_method :bank_transactions,    :array_wrapped_response_item
    alias_method :manual_journals,      :array_wrapped_response_item
    alias_method :contacts,             :array_wrapped_response_item
    alias_method :accounts,             :array_wrapped_response_item
    alias_method :tracking_categories,  :array_wrapped_response_item
    alias_method :tax_rates,            :array_wrapped_response_item
    alias_method :currencies,           :array_wrapped_response_item
    
    def initialize(params = {})
      params.each do |k,v|
        self.send("#{k}=", v)
      end
      
      @errors ||= []
      @response_item ||= []
    end
    
    
    def success?
      status == "OK"
    end
    
    def error
      errors.blank? ? nil : errors[0]
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
xero_gateway-float-2.1.3 lib/xero_gateway/response.rb
xero_gateway-float-2.1.1 lib/xero_gateway/response.rb
xero_gateway-2.1.0 lib/xero_gateway/response.rb
xero_gateway-n8vision-2.0.20 lib/xero_gateway/response.rb
xero_gateway-2.0.19 lib/xero_gateway/response.rb
xero_gateway-2.0.18 lib/xero_gateway/response.rb
xero_gateway-2.0.17 lib/xero_gateway/response.rb
xero_gateway-2.0.16 lib/xero_gateway/response.rb
xero_gateway-2.0.15 lib/xero_gateway/response.rb