Sha256: 9ca61c7f7406fc6aba2744d6e82fabe6f737defc7819ffb76512671651aec09c
Contents?: true
Size: 990 Bytes
Versions: 2
Compression:
Stored size: 990 Bytes
Contents
require 'faraday' require 'json' module AvaTax module Request def get(path, options={}) request(:get, path, nil, options) end def post(path, model, options={}) request(:post, path, model, options) end def put(path, model, options={}) request(:put, path, model, options) end def delete(path, options={}) request(:delete, path, nil, options) end def request(method, path, model, options={}) response = connection.send(method) do |request| case method when :get, :delete request.url("#{URI.encode(path)}?#{URI.encode_www_form(options)}") when :post, :put request.path = ("#{URI.encode(path)}?#{URI.encode_www_form(options)}") request.headers['Content-Type'] = 'application/json' request.body = model.to_json unless model.empty? end end if faraday_response response else response.body end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
avatax-18.12.0 | lib/avatax/request.rb |
avatax-18.10.4 | lib/avatax/request.rb |