lib/telphin_api/api.rb in telphin_api-1.0.2 vs lib/telphin_api/api.rb in telphin_api-1.0.3
- old
+ new
@@ -22,11 +22,11 @@
id = args.delete(:id)
url = [namespace, user_id, extension_number, action].join('/')
url = url + '/' + id unless id.nil?
flat_arguments = Utils.flatten_arguments(args)
- flat_arguments = flat_arguments.to_json.to_s if http_method == :post
+ flat_arguments = flat_arguments.to_json.to_s if [:post, :put].include? http_method
connection(url: TelphinApi.site, token: token, method: http_method).send(http_method, url, flat_arguments).body
end
# Faraday connection.
@@ -39,12 +39,10 @@
token = options.delete(:token)
method = options.delete(:method)
Faraday.new(url, TelphinApi.faraday_options) do |builder|
builder.headers['Authorization'] = "Bearer #{token}"
- if method == :post
- builder.headers['Content-Type'] = 'application/json'
- end
+ builder.headers['Content-Type'] = 'application/json' if [:post, :put].include? method
builder.request :multipart
builder.request :url_encoded
builder.request :retry, TelphinApi.max_retries