Module: AvaTax::Request
- Included in:
- API
- Defined in:
- lib/avatax/request.rb
Instance Method Summary collapse
- #delete(path, options = {}, apiversion = "") ⇒ Object
- #get(path, options = {}, apiversion = "") ⇒ Object
- #post(path, model, options = {}, apiversion = "") ⇒ Object
- #put(path, model, options = {}, apiversion = "") ⇒ Object
- #request(method, path, model, options = {}, apiversion = "") ⇒ Object
Instance Method Details
#delete(path, options = {}, apiversion = "") ⇒ Object
21 22 23 |
# File 'lib/avatax/request.rb', line 21 def delete(path, ={}, apiversion="") request(:delete, path, nil, , apiversion) end |
#get(path, options = {}, apiversion = "") ⇒ Object
9 10 11 |
# File 'lib/avatax/request.rb', line 9 def get(path, ={}, apiversion="") request(:get, path, nil, , apiversion) end |
#post(path, model, options = {}, apiversion = "") ⇒ Object
13 14 15 |
# File 'lib/avatax/request.rb', line 13 def post(path, model, ={}, apiversion="") request(:post, path, model, , apiversion) end |
#put(path, model, options = {}, apiversion = "") ⇒ Object
17 18 19 |
# File 'lib/avatax/request.rb', line 17 def put(path, model, ={}, apiversion="") request(:put, path, model, , apiversion) end |
#request(method, path, model, options = {}, apiversion = "") ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/avatax/request.rb', line 25 def request(method, path, model, ={}, apiversion="") response = connection.send(method) do |request| request.headers['X-Avalara-Client'] = request.headers['X-Avalara-Client'].gsub("API_VERSION", apiversion) case method when :get, :delete request.url("#{encode_path(path)}?#{URI.encode_www_form()}") when :post, :put request.url("#{encode_path(path)}?#{URI.encode_www_form()}") 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 |