pcloud_api 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45e0e46ad9b58dd65f1ce2674c247fd72377fcb376bec9bdc29b3cb285216519
4
- data.tar.gz: 25a81544a107633c7c3c4459a1ab0f3e7c1a4c6092d5231b59a22ccbce55bb9b
3
+ metadata.gz: d8ed06d335251156478a9586f19c12ecb73cd3dd11a2ad2383cafdb3383210ad
4
+ data.tar.gz: 24e8bd133fb1f66e01293d06bc9eb1aa074849f7b51fbd16b6fe834437e52964
5
5
  SHA512:
6
- metadata.gz: dd0a131f94f7aec6ec700ad46ade522d37248d5475a23290d46b20f51025a5fd4043ccaf642fecdaeb387ef3cc85811282d0a52436dca6bdab1d8cbf23927211
7
- data.tar.gz: 7597d199d6795c480d0b346ed021845993ad3f0bdd01fa9e6df1b129324c12c61dc181fa36f8990d85916016330d389413e6b6bdbeabb373c455e1ff4f3a1dfb
6
+ metadata.gz: e9b4602cd3f54dd51914921c821c6c6fb916b7db2b64c76f88252b788ebd77f446d16e3bbc59f7ec6903f51267e38cdd0ca3418304f7064449cea923c00d914e
7
+ data.tar.gz: b752ef69113418aa2e2480f858173fb24e2721d75721a0518e44eb5cc548e970ebfb732f2095339acc361955be8d32d6af620280e4b8d4e4d03d71a9c9b4199b
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
- ## 0.2.3 2021-12-14
1
+ ## 0.2.5 2023-05-05
2
+
3
+ **Bugfix**
4
+ 1. When passing the optipnal `recursive: true` on `Pcloud::Folder#find` or `Pcloud::Folder#find_by` methods to load all the folders contents recursively in v0.2.4, recursive contents were not correctly parsed into objects. This release fixes that bug so that the recursive file tree is all `Pcloud::File` and `Pcloud::Folder` objects.
5
+
6
+ ## 0.2.4 2023-05-05
2
7
 
3
8
  **Changes**
4
9
  1. You can now specify `recursive: true` on `Pcloud::Folder#find` and `Pcloud::Folder#find_by` methods to load all the folders contents recursively. Note that this may result in long request times for folders with many items in them.
data/README.md CHANGED
@@ -40,7 +40,7 @@ The `Pcloud::Client` can be configured by directly calling the `Pcloud::Client.c
40
40
  ```ruby
41
41
  Pcloud::Client.configure(
42
42
  access_token: "your-pcloud-app-access-token",
43
- data_region: "EU"
43
+ data_region: "EU",
44
44
  timeout_seconds: 8 # optional integer, defaults to 8 seconds if not specified
45
45
  )
46
46
  ```
@@ -23,7 +23,7 @@ module Pcloud
23
23
  path: content_item["path"], # no path comes back from this api
24
24
  name: content_item["name"],
25
25
  parent_folder_id: content_item["parentfolderid"],
26
- contents: content_item["contents"], # no content comes back from this api
26
+ contents: recursively_parse_contents(content_item["contents"]), # this can be `nil` if recursive is false
27
27
  is_deleted: content_item["isdeleted"],
28
28
  created_at: content_item["created"],
29
29
  modified_at: content_item["modified"]
@@ -45,6 +45,39 @@ module Pcloud
45
45
  end
46
46
  )
47
47
  end
48
+
49
+ private
50
+
51
+ def recursively_parse_contents(contents)
52
+ return nil if contents.nil?
53
+ contents.map do |content_item|
54
+ if content_item["isfolder"]
55
+ Pcloud::Folder.new(
56
+ id: content_item["folderid"],
57
+ path: content_item["path"], # no path comes back from this api
58
+ name: content_item["name"],
59
+ parent_folder_id: content_item["parentfolderid"],
60
+ contents: recursively_parse_contents(content_item["contents"]),
61
+ is_deleted: content_item["isdeleted"],
62
+ created_at: content_item["created"],
63
+ modified_at: content_item["modified"]
64
+ )
65
+ else
66
+ Pcloud::File.new(
67
+ id: content_item["fileid"],
68
+ path: content_item["path"],
69
+ name: content_item["name"],
70
+ content_type: content_item["contenttype"],
71
+ category_id: content_item["category"],
72
+ size: content_item["size"],
73
+ parent_folder_id: content_item["parentfolderid"],
74
+ is_deleted: content_item["isdeleted"],
75
+ created_at: content_item["created"],
76
+ modified_at: content_item["modified"]
77
+ )
78
+ end
79
+ end
80
+ end
48
81
  end
49
82
  end
50
83
  end
@@ -1,3 +1,3 @@
1
1
  module Pcloud
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pcloud_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Hunsche Jones