Class: FileApiClient
Defined Under Namespace
Classes: Edit, Move
Constant Summary
BaseApiClient::ApiErrors
Instance Method Summary
collapse
#check_response!, #initialize
Constructor Details
This class inherits a constructor from BaseApiClient
Instance Method Details
#get_file ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/dynalist/file_api_client.rb', line 5
def get_file
response = @conn.post "#{@base}file/list", {token: @token}.to_json
check_response!(response)
json = JSON.parse(response.body, symbolize_names: true)
FileTree.instance.root_id = json[:root_file_id]
json[:files].map do |file|
instance = if file[:type] == 'folder'
Folder.new(file)
else
Document.new(file)
end
FileTree.add(instance)
instance
end
end
|
#move_file(queries) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/dynalist/file_api_client.rb', line 23
def move_file(queries)
changes = queries.map(&:to_query)
response = @conn.post "#{@base}file/edit", {token: @token, changes: changes}.to_json
check_response!(response)
JSON.parse(response.body, symbolize_names: true)[:results]
end
|