class DeskApi::Request::EncodeJson

{DeskApi::Request::EncodeJson} is the Faraday middleware that dumps a json string from whatever is specified in the request body. It also sets the “Content-Type” header.

@author Thomas Stachl <tstachl@salesforce.com> @copyright Copyright © 2013-2016 Salesforce.com @license BSD 3-Clause License

Public Instance Methods

call(env) click to toggle source

Changes the request before it gets sent

@param env [Hash] the request hash

# File lib/desk_api/request/encode_json.rb, line 44
def call(env)
  env[:request_headers]['Content-Type'] = 'application/json'
  if env[:body] && !env[:body].to_s.empty?
    env[:body] = ::JSON.dump(env[:body])
  end
  @app.call env
end