Created
August 10, 2014 15:09
-
-
Save theinventor/a2607b163bafa84076a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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