Skip to content

Instantly share code, notes, and snippets.

@coreycollins
Created April 15, 2013 18:53
Show Gist options
  • Select an option

  • Save coreycollins/5390401 to your computer and use it in GitHub Desktop.

Select an option

Save coreycollins/5390401 to your computer and use it in GitHub Desktop.

Revisions

  1. Corey Collins created this gist Apr 15, 2013.
    31 changes: 31 additions & 0 deletions add_job.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    oauth_client = OAuth::AccessToken.new($qb_oauth_consumer, qb[:token], qb[:secret])

    #Create New Job/Customer
    job_service = Quickeebooks::Windows::Service::Job.new
    job_service.access_token = oauth_client
    job_service.realm_id = qb[:realm_id]
    qb_job = Quickeebooks::Windows::Model::Job.new

    qb_job.name = job.id
    qb_job.type_of = 'Organization'

    qb_job.customer_name = job.account.name
    qb_job.job_parent_name = job.account.name
    qb_job.customer_type_name = "#{job.account_type.value}:#{job.list.name}"

    email = Quickeebooks::Windows::Model::Email.new(job.account.email)
    email.tag = 'Business'
    qb_job.email = email
    #qb_job.phones = customer.phones
    #qb_job.addresses = customer.addresses

    begin
    response = job_service.create(qb_job)
    if response.success?
    puts "Saved Job - ID: #{job.id}, QBID: #{job.qbid}"
    else
    puts response
    end
    rescue Exception => exp
    puts "Error: #{exp.message}"
    end