Class: FusionAuth::JSONBodyHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/fusionauth/rest_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body_object) ⇒ JSONBodyHandler

Returns a new instance of JSONBodyHandler.



331
332
333
# File 'lib/fusionauth/rest_client.rb', line 331

def initialize(body_object)
  @body = JSON.generate(body_object)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



329
330
331
# File 'lib/fusionauth/rest_client.rb', line 329

def body
  @body
end

#lengthObject

Returns the value of attribute length.



329
330
331
# File 'lib/fusionauth/rest_client.rb', line 329

def length
  @length
end

Instance Method Details

#body_objectString

Returns the body String for the request

Returns:

  • (String)

    The body as a String



339
340
341
# File 'lib/fusionauth/rest_client.rb', line 339

def body_object
  @body
end

#set_headers(headers) ⇒ Object

Sets any headers necessary for the body to be processed.

Parameters:

  • headers (Hash)

    The headers hash to add any headers needed by this BodyHandler

Returns:

  • (Object)

    The object



352
353
354
355
356
# File 'lib/fusionauth/rest_client.rb', line 352

def set_headers(headers)
  headers['Length'] = body.bytesize.to_s
  headers['Content-Type'] = 'application/json'
  nil
end

#typeObject



343
344
345
# File 'lib/fusionauth/rest_client.rb', line 343

def type
  "JSON"
end