Sha256: 681e8204f8a61ae8874b117b1da7ce71d64210c93481e24f73e52488d109fa1a
Contents?: true
Size: 986 Bytes
Versions: 22
Compression:
Stored size: 986 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.url("#{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
22 entries across 22 versions & 1 rubygems