Sha256: da7e693bfbea2d5f61f2e8fd2e5bf6b5ec455f94f66727799f90112a25575bac

Contents?: true

Size: 859 Bytes

Versions: 1

Compression:

Stored size: 859 Bytes

Contents

module XeroGateway
  class Response
    attr_accessor :response_id, :status, :errors, :provider, :date_time, :response_item, :request_params, :request_xml, :response_xml
    
    alias_method :invoice, :response_item
    alias_method :invoices, :response_item
    alias_method :contact, :response_item
    alias_method :contacts, :response_item
    alias_method :accounts, :response_item
    alias_method :tracking_categories, :response_item


    
    def initialize(params = {})
      params.each do |k,v|
        self.instance_variable_set("@#{k}", v)  ## create and initialize an instance variable for this key/value pair
        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

1 entries across 1 versions & 1 rubygems

Version Path
tlconnor-xero_gateway-1.0.3 lib/xero_gateway/response.rb