Sha256: 16623b53690a7b577f5065ede7668862f3642bef4a5988e59c585395b1f8dc31

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'xeroizer')

client = Xeroizer::PrivateApplication.new(ARGV[0], ARGV[1], ARGV[2])

base_path = File.expand_path(File.dirname(__FILE__))

if ARGV[3]
  models = [ARGV[3]]
else
  models = %w(Account BankTransaction BrandingTheme Contact CreditNote Currency Employee Invoice Item ManualJournal Organisation Payment TaxRate TrackingCategory)
end

models.each do | model_name |
  model = client.send(model_name.to_sym)
  
  # List
  records = model.all
  File.open("#{base_path}/#{model_name.underscore.pluralize}.xml", "w") { | fp | fp.write model.response.response_xml }
  
  if %w(BankTransaction Contact CreditNote Invoice ManualJournal).include?(model_name)
    records.each do | summary_record |
      record = model.find(summary_record.id)
      File.open("#{base_path}/records/#{model_name.underscore}-#{record.id}.xml", "w") { | fp | fp.write model.response.response_xml }
    end    
    
    record = model.find(records.first.id)
    File.open("#{base_path}/#{model_name.underscore.singularize}.xml", "w") { | fp | fp.write model.response.response_xml }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
xeroizer-float-2.15.5.2 test/stub_responses/refresh_responses.rb
xeroizer-float-2.15.5.1 test/stub_responses/refresh_responses.rb
xeroizer-float-2.15.3.16 test/stub_responses/refresh_responses.rb
xeroizer-float-2.15.3.15 test/stub_responses/refresh_responses.rb
xeroizer-float-2.15.3.14 test/stub_responses/refresh_responses.rb