Module: Pcloud::File::Parser::ClassMethods

Defined in:
lib/pcloud/file/parser.rb

Instance Method Summary collapse

Instance Method Details

#parse_many(response) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pcloud/file/parser.rb', line 25

def parse_many(response)
  response["metadata"].map do ||
    Pcloud::File.new(
      id: ["fileid"],
      path: ["path"],
      name: ["name"],
      content_type: ["contenttype"],
      category_id: ["category"],
      size: ["size"],
      parent_folder_id: ["parentfolderid"],
      is_deleted: ["isdeleted"],
      created_at: ["created"],
      modified_at: ["modified"]
    )
  end
end

#parse_one(response) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pcloud/file/parser.rb', line 10

def parse_one(response)
  Pcloud::File.new(
    id: response.dig("metadata", "fileid"),
    path: response.dig("metadata", "path"),
    name: response.dig("metadata", "name"),
    content_type: response.dig("metadata", "contenttype"),
    category_id: response.dig("metadata", "category"),
    size: response.dig("metadata", "size"),
    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")
  )
end