Class: DeskApi::Request::EncodeDates

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/desk_api/request/encode_dates.rb

Overview

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:

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object

Changes the request before it gets sent

Parameters:

  • env (Hash)

    the request hash



42
43
44
45
46
47
# File 'lib/desk_api/request/encode_dates.rb', line 42

def call(env)
  if env[:body] && !env[:body].to_s.empty?
    env[:body] = encode_dates(env[:body])
  end
  @app.call env
end