Class: DropboxApi::Endpoints::Rpc

Inherits:
Base
  • Object
show all
Defined in:
lib/dropbox_api/endpoints/rpc.rb

Instance Method Summary collapse

Methods inherited from Base

add_endpoint

Constructor Details

#initialize(builder) ⇒ Rpc

Returns a new instance of Rpc.



3
4
5
6
7
# File 'lib/dropbox_api/endpoints/rpc.rb', line 3

def initialize(builder)
  @connection = builder.build("https://api.dropboxapi.com") do |c|
    c.response :decode_result
  end
end

Instance Method Details

#build_request(params) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/dropbox_api/endpoints/rpc.rb', line 9

def build_request(params)
  request_headers = {
    'content-type' => 'application/json'
  }

  return request_body(params), request_headers
end

#request_body(params) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/dropbox_api/endpoints/rpc.rb', line 17

def request_body(params)
  # This check is only required for compatibility with old JSON serializers
  if params.nil?
    'null'
  else
    JSON.dump(params)
  end
end