Skip to content

Instantly share code, notes, and snippets.

@theinventor
Created August 10, 2014 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theinventor/a2607b163bafa84076a3 to your computer and use it in GitHub Desktop.
Save theinventor/a2607b163bafa84076a3 to your computer and use it in GitHub Desktop.
@subdomain = 'subdomain'
@api_key = 'api_key'
@api_version = "/api/v1"
base_url = "https://#{@subdomain}.repairshopr.com"
subtotal = 150.00
number = "12345"
invoice = {}
invoice[:date] = Time.now
invoice[:paid] = true
invoice[:date_received] = Time.now
invoice[:number] = number
invoice[:phone] = '4255551212'
invoice[:line_items] = [
{item: 'Labor', name: 'Field Service Labor', cost: 12.0, price: 100, quantity: 1},
{item: 'Labor', name: 'Field Service Labor Visit 2', cost: 12.0, price: 100, quantity: 0.5}
]
@conn = Faraday.new(:url => "#{@base_url}" ) do |faraday|
faraday.request :url_encoded # form-encode POST params
faraday.response :logger # log requests to STDOUT
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
end
response = @conn.post "#{@api_version}/invoices.json?api_key=#{@api_key}", invoice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment