10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/pcloud/folder/parser.rb', line 10
def parse_one(response)
Pcloud::Folder.new(
id: response.dig("metadata", "folderid"),
path: response.dig("metadata", "path"),
name: response.dig("metadata", "name"),
parent_folder_id: response.dig("metadata", "parentfolderid"),
is_deleted: response.dig("metadata", "isdeleted"),
created_at: response.dig("metadata", "created"),
modified_at: response.dig("metadata", "modified"),
contents: (response.dig("metadata", "contents") || []).map do |content_item|
if content_item["isfolder"]
Pcloud::Folder.new(
id: content_item["folderid"],
path: content_item["path"], name: content_item["name"],
parent_folder_id: content_item["parentfolderid"],
contents: recursively_parse_contents(content_item["contents"]), is_deleted: content_item["isdeleted"],
created_at: content_item["created"],
modified_at: content_item["modified"]
)
else
Pcloud::File.new(
id: content_item["fileid"],
path: content_item["path"],
name: content_item["name"],
content_type: content_item["contenttype"],
category_id: content_item["category"],
size: content_item["size"],
parent_folder_id: content_item["parentfolderid"],
is_deleted: content_item["isdeleted"],
created_at: content_item["created"],
modified_at: content_item["modified"]
)
end
end
)
end
|