Class: RingCentralSdk::REST::Request::Simple

Inherits:
Base
  • Object
show all
Defined in:
lib/ringcentral_sdk/rest/request/simple.rb

Overview

Simple is a generic simple request class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Simple

Returns a new instance of Simple.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ringcentral_sdk/rest/request/simple.rb', line 12

def initialize(opts = {})
  @method = opts[:method]
  @url = opts[:url]
  @params = opts[:params]
  @headers = opts[:headers]
  @body = opts[:body].nil? ? {} : opts[:body]
  if @body.is_a? Hash
    @headers = {} unless @headers.is_a? Hash
    @headers['Content-Type'] = 'application/json'
  end
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



10
11
12
# File 'lib/ringcentral_sdk/rest/request/simple.rb', line 10

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



9
10
11
# File 'lib/ringcentral_sdk/rest/request/simple.rb', line 9

def headers
  @headers
end

#methodObject (readonly)

Returns the value of attribute method.



6
7
8
# File 'lib/ringcentral_sdk/rest/request/simple.rb', line 6

def method
  @method
end

#paramsObject (readonly)

Returns the value of attribute params.



8
9
10
# File 'lib/ringcentral_sdk/rest/request/simple.rb', line 8

def params
  @params
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/ringcentral_sdk/rest/request/simple.rb', line 7

def url
  @url
end

Instance Method Details

#content_typeObject



24
25
26
# File 'lib/ringcentral_sdk/rest/request/simple.rb', line 24

def content_type
  @headers.is_a?(Hash) ? @headers['Content-Type'] || '' : 'application/json'
end