brick_ftp 0.8.4 → 1.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +0 -5
  3. data/.rubocop.yml +2 -1
  4. data/.yardopts +1 -0
  5. data/CHANGELOG.md +16 -12
  6. data/Gemfile +2 -0
  7. data/README.md +24 -43
  8. data/Rakefile +2 -0
  9. data/bin/console +1 -0
  10. data/brick_ftp.gemspec +10 -9
  11. data/exe/brick_ftp +1 -0
  12. data/lib/brick_ftp.rb +5 -78
  13. data/lib/brick_ftp/client.rb +35 -411
  14. data/lib/brick_ftp/core_ext.rb +8 -0
  15. data/lib/brick_ftp/core_ext/hash.rb +13 -0
  16. data/lib/brick_ftp/core_ext/hash/compact.rb +13 -0
  17. data/lib/brick_ftp/core_ext/struct.rb +13 -0
  18. data/lib/brick_ftp/core_ext/struct/new.rb +16 -0
  19. data/lib/brick_ftp/restful_api.rb +82 -0
  20. data/lib/brick_ftp/restful_api/add_group_member.rb +44 -0
  21. data/lib/brick_ftp/restful_api/client.rb +179 -0
  22. data/lib/brick_ftp/restful_api/command.rb +21 -0
  23. data/lib/brick_ftp/restful_api/complete_upload.rb +46 -0
  24. data/lib/brick_ftp/restful_api/continue_upload.rb +50 -0
  25. data/lib/brick_ftp/restful_api/copy_folder.rb +46 -0
  26. data/lib/brick_ftp/restful_api/count_folder_contents.rb +36 -0
  27. data/lib/brick_ftp/restful_api/count_users.rb +22 -0
  28. data/lib/brick_ftp/restful_api/create_api_key.rb +46 -0
  29. data/lib/brick_ftp/restful_api/create_behavior.rb +42 -0
  30. data/lib/brick_ftp/restful_api/create_bundle.rb +40 -0
  31. data/lib/brick_ftp/restful_api/create_folder.rb +25 -0
  32. data/lib/brick_ftp/restful_api/create_group.rb +42 -0
  33. data/lib/brick_ftp/restful_api/create_notification.rb +44 -0
  34. data/lib/brick_ftp/restful_api/create_permission.rb +48 -0
  35. data/lib/brick_ftp/restful_api/create_public_key.rb +42 -0
  36. data/lib/brick_ftp/restful_api/create_user.rb +90 -0
  37. data/lib/brick_ftp/restful_api/create_user_in_group.rb +60 -0
  38. data/lib/brick_ftp/restful_api/delete_api_key.rb +23 -0
  39. data/lib/brick_ftp/restful_api/delete_behavior.rb +22 -0
  40. data/lib/brick_ftp/restful_api/delete_bundle.rb +22 -0
  41. data/lib/brick_ftp/restful_api/delete_folder.rb +32 -0
  42. data/lib/brick_ftp/restful_api/delete_group.rb +23 -0
  43. data/lib/brick_ftp/restful_api/delete_notification.rb +23 -0
  44. data/lib/brick_ftp/restful_api/delete_permission.rb +23 -0
  45. data/lib/brick_ftp/restful_api/delete_public_key.rb +23 -0
  46. data/lib/brick_ftp/restful_api/delete_user.rb +25 -0
  47. data/lib/brick_ftp/restful_api/download_file.rb +44 -0
  48. data/lib/brick_ftp/restful_api/get_api_key.rb +25 -0
  49. data/lib/brick_ftp/restful_api/get_behavior.rb +25 -0
  50. data/lib/brick_ftp/restful_api/get_bundle.rb +25 -0
  51. data/lib/brick_ftp/restful_api/get_bundle_zip.rb +48 -0
  52. data/lib/brick_ftp/restful_api/get_file_in_bundle.rb +49 -0
  53. data/lib/brick_ftp/restful_api/get_folder_size.rb +25 -0
  54. data/lib/brick_ftp/restful_api/get_group.rb +26 -0
  55. data/lib/brick_ftp/restful_api/get_public_key.rb +25 -0
  56. data/lib/brick_ftp/restful_api/get_site_usage.rb +19 -0
  57. data/lib/brick_ftp/restful_api/get_user.rb +26 -0
  58. data/lib/brick_ftp/restful_api/list_api_keys.rb +25 -0
  59. data/lib/brick_ftp/restful_api/list_behaviors.rb +23 -0
  60. data/lib/brick_ftp/restful_api/list_bundle_contents.rb +58 -0
  61. data/lib/brick_ftp/restful_api/list_bundles.rb +23 -0
  62. data/lib/brick_ftp/restful_api/list_folder_behaviors.rb +39 -0
  63. data/lib/brick_ftp/restful_api/list_folders.rb +108 -0
  64. data/lib/brick_ftp/restful_api/list_groups.rb +23 -0
  65. data/lib/brick_ftp/restful_api/list_notifications.rb +23 -0
  66. data/lib/brick_ftp/restful_api/list_permissions.rb +41 -0
  67. data/lib/brick_ftp/restful_api/list_public_keys.rb +25 -0
  68. data/lib/brick_ftp/restful_api/list_users.rb +60 -0
  69. data/lib/brick_ftp/restful_api/move_folder.rb +41 -0
  70. data/lib/brick_ftp/restful_api/remove_group_member.rb +23 -0
  71. data/lib/brick_ftp/restful_api/retrieve_file_history.rb +41 -0
  72. data/lib/brick_ftp/restful_api/retrieve_folder_history.rb +41 -0
  73. data/lib/brick_ftp/restful_api/retrieve_history.rb +54 -0
  74. data/lib/brick_ftp/restful_api/retrieve_login_history.rb +38 -0
  75. data/lib/brick_ftp/restful_api/retrieve_site_history.rb +38 -0
  76. data/lib/brick_ftp/restful_api/retrieve_user_history.rb +40 -0
  77. data/lib/brick_ftp/restful_api/search_user.rb +28 -0
  78. data/lib/brick_ftp/restful_api/start_upload.rb +27 -0
  79. data/lib/brick_ftp/restful_api/unlock_user.rb +25 -0
  80. data/lib/brick_ftp/restful_api/update_behavior.rb +39 -0
  81. data/lib/brick_ftp/restful_api/update_group.rb +44 -0
  82. data/lib/brick_ftp/restful_api/update_group_member.rb +40 -0
  83. data/lib/brick_ftp/restful_api/update_user.rb +101 -0
  84. data/lib/brick_ftp/restful_api/upload_file.rb +65 -0
  85. data/lib/brick_ftp/types.rb +23 -0
  86. data/lib/brick_ftp/types/behavior.rb +27 -0
  87. data/lib/brick_ftp/types/bundle.rb +34 -0
  88. data/lib/brick_ftp/types/bundle_content.rb +25 -0
  89. data/lib/brick_ftp/types/bundle_zip.rb +19 -0
  90. data/lib/brick_ftp/types/file.rb +45 -0
  91. data/lib/brick_ftp/types/file_in_bundle.rb +25 -0
  92. data/lib/brick_ftp/types/folder_contents_count.rb +24 -0
  93. data/lib/brick_ftp/types/group.rb +31 -0
  94. data/lib/brick_ftp/types/group_membership.rb +27 -0
  95. data/lib/brick_ftp/types/history.rb +43 -0
  96. data/lib/brick_ftp/types/notification.rb +31 -0
  97. data/lib/brick_ftp/types/permission.rb +35 -0
  98. data/lib/brick_ftp/types/site_usage.rb +23 -0
  99. data/lib/brick_ftp/types/upload.rb +45 -0
  100. data/lib/brick_ftp/types/user.rb +79 -0
  101. data/lib/brick_ftp/types/user_api_key.rb +33 -0
  102. data/lib/brick_ftp/types/user_public_key.rb +28 -0
  103. data/lib/brick_ftp/utils.rb +2 -0
  104. data/lib/brick_ftp/utils/chunk_io.rb +5 -4
  105. data/lib/brick_ftp/version.rb +3 -1
  106. metadata +123 -86
  107. data/lib/brick_ftp/api.rb +0 -9
  108. data/lib/brick_ftp/api/authentication.rb +0 -28
  109. data/lib/brick_ftp/api/authentication/session.rb +0 -25
  110. data/lib/brick_ftp/api/base.rb +0 -119
  111. data/lib/brick_ftp/api/behavior.rb +0 -19
  112. data/lib/brick_ftp/api/bundle.rb +0 -17
  113. data/lib/brick_ftp/api/bundle_content.rb +0 -18
  114. data/lib/brick_ftp/api/bundle_download.rb +0 -18
  115. data/lib/brick_ftp/api/file.rb +0 -20
  116. data/lib/brick_ftp/api/file_operation.rb +0 -6
  117. data/lib/brick_ftp/api/file_operation/copy.rb +0 -10
  118. data/lib/brick_ftp/api/file_operation/move.rb +0 -10
  119. data/lib/brick_ftp/api/file_operation/upload.rb +0 -66
  120. data/lib/brick_ftp/api/file_operation/uploading_result.rb +0 -22
  121. data/lib/brick_ftp/api/file_operation/uploading_session.rb +0 -95
  122. data/lib/brick_ftp/api/folder.rb +0 -22
  123. data/lib/brick_ftp/api/folder_behavior.rb +0 -12
  124. data/lib/brick_ftp/api/group.rb +0 -16
  125. data/lib/brick_ftp/api/history.rb +0 -6
  126. data/lib/brick_ftp/api/history/file.rb +0 -23
  127. data/lib/brick_ftp/api/history/folder.rb +0 -23
  128. data/lib/brick_ftp/api/history/login.rb +0 -23
  129. data/lib/brick_ftp/api/history/site.rb +0 -23
  130. data/lib/brick_ftp/api/history/user.rb +0 -23
  131. data/lib/brick_ftp/api/notification.rb +0 -14
  132. data/lib/brick_ftp/api/permission.rb +0 -17
  133. data/lib/brick_ftp/api/public_key.rb +0 -15
  134. data/lib/brick_ftp/api/site_usage.rb +0 -21
  135. data/lib/brick_ftp/api/user.rb +0 -36
  136. data/lib/brick_ftp/api_component.rb +0 -81
  137. data/lib/brick_ftp/api_definition.rb +0 -65
  138. data/lib/brick_ftp/cli.rb +0 -7
  139. data/lib/brick_ftp/cli/config.rb +0 -20
  140. data/lib/brick_ftp/cli/main.rb +0 -26
  141. data/lib/brick_ftp/cli/site.rb +0 -10
  142. data/lib/brick_ftp/configuration.rb +0 -121
  143. data/lib/brick_ftp/http_client.rb +0 -130
  144. data/lib/brick_ftp/log_formatter.rb +0 -15
  145. data/lib/brick_ftp/webhook.rb +0 -4
  146. data/lib/brick_ftp/webhook/request.rb +0 -28
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # Show an API key
6
+ #
7
+ # @see https://developers.brickftp.com/#show-an-api-key Show an API key
8
+ #
9
+ class GetAPIKey
10
+ include Command
11
+
12
+ # Returns a single API key.
13
+ #
14
+ # @param [Integer] id Globally unique identifier of each user API key.
15
+ # Each user API key is given an ID automatically upon creation.
16
+ # @return [BrickFTP::Types::UserAPIKey] User's API key
17
+ #
18
+ def call(id)
19
+ res = client.get("/api/rest/v1/api_keys/#{id}.json")
20
+
21
+ BrickFTP::Types::UserAPIKey.new(res.symbolize_keys)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # Show a behavior
6
+ #
7
+ # @see https://developers.brickftp.com/#show-a-behavior Show a behavior
8
+ #
9
+ class GetBehavior
10
+ include Command
11
+
12
+ # Returns a single behavior.
13
+ #
14
+ # @param [Integer] id Globally unique identifier of each behavior.
15
+ # @return [BrickFTP::Types::Behavior, nil] found Behavior or nil
16
+ #
17
+ def call(id)
18
+ res = client.get("/api/rest/v1/behaviors/#{id}.json")
19
+ return nil if !res || res.empty?
20
+
21
+ BrickFTP::Types::Behavior.new(res.symbolize_keys)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # Show a bundle
6
+ #
7
+ # @see https://developers.brickftp.com/#show-a-bundle Show a bundle
8
+ #
9
+ class GetBundle
10
+ include Command
11
+
12
+ # Returns a single bundle.
13
+ #
14
+ # @param [Integer] id Globally unique identifier of each bundle.
15
+ # @return [BrickFTP::Types::Bundle] Bundle
16
+ #
17
+ def call(id)
18
+ res = client.get("/api/rest/v1/bundles/#{id}.json")
19
+ return nil if !res || res.empty?
20
+
21
+ BrickFTP::Types::Bundle.new(res.symbolize_keys)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # Download entire bundle as ZIP
6
+ #
7
+ # @see https://developers.brickftp.com/#download-entire-bundle-as-zip Download entire bundle as ZIP
8
+ #
9
+ # ### Params
10
+ #
11
+ # PARAMETER | TYPE | DESCRIPTION
12
+ # --------- | ------ | -----------
13
+ # code, | string | Unique code string identifier for the bundle.
14
+ # password | string | Optional password to password-protect the bundle. This property is write-only. It cannot be retrieved via the API.
15
+ #
16
+ class GetBundleZip
17
+ include Command
18
+ using BrickFTP::CoreExt::Struct
19
+ using BrickFTP::CoreExt::Hash
20
+
21
+ Params = Struct.new(
22
+ 'GetBundleZipParams',
23
+ :code,
24
+ :password,
25
+ keyword_init: true
26
+ )
27
+
28
+ # Provides a download URL that will enable you to download all the files in a bundle as a single ZIP.
29
+ #
30
+ # The download URLs can be downloaded using an HTTP GET to the same hostname providing the download_uri
31
+ # as the URL path. This will be routed by our frontend proxies to our ZIP server that will stream the ZIP.
32
+ # The ZIP download link is valid for 3 minutes.
33
+ #
34
+ # The password parameter is required only for bundles that are password-protected.
35
+ # If a bundle is password-protected and the password is missing or incorrect, an error message will
36
+ # specify that the correct password is required.
37
+ #
38
+ # @param [BrickFTP::RESTfulAPI::GetFileInBundle::Params] params parameters
39
+ # @return [BrickFTP::Types::BundleZip] BundleZip
40
+ #
41
+ def call(params)
42
+ res = client.post('/api/rest/v1/bundles/zip.json', params.to_h.compact)
43
+
44
+ BrickFTP::Types::BundleZip.new(res.symbolize_keys)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # Download one file in a bundle
6
+ #
7
+ # @see https://developers.brickftp.com/#download-one-file-in-a-bundle Download one file in a bundle
8
+ #
9
+ # ### Params
10
+ #
11
+ # PARAMETER | TYPE | DESCRIPTION
12
+ # --------- | ------ | -----------
13
+ # code | string | Unique code string identifier for the bundle.
14
+ # path | string |
15
+ # password | string | Optional password to password-protect the bundle. This property is write-only. It cannot be retrieved via the API.
16
+ #
17
+ class GetFileInBundle
18
+ include Command
19
+ using BrickFTP::CoreExt::Struct
20
+ using BrickFTP::CoreExt::Hash
21
+
22
+ Params = Struct.new(
23
+ 'GetFileInBundleParams',
24
+ :code,
25
+ :path,
26
+ :password,
27
+ keyword_init: true
28
+ )
29
+
30
+ # Provides a download URL to download a single file in the bundle.
31
+ #
32
+ # The download URL is a direct URL to Amazon S3 that has been signed by BrickFTP to provide temporary access to the
33
+ # file. The download links are valid for 3 minutes. For details on the attributes in the response body from this
34
+ # endpoint, please see The file object.
35
+ #
36
+ # The password parameter is required only for bundles that are password-protected. If a bundle is password-protected
37
+ # and the password is missing or incorrect, an error message will specify that the correct password is required.
38
+ #
39
+ # @param [BrickFTP::RESTfulAPI::GetFileInBundle::Params] params parameters
40
+ # @return [BrickFTP::Types::FileInBundle] FileInBundle
41
+ #
42
+ def call(params)
43
+ res = client.post('/api/rest/v1/bundles/download.json', params.to_h.compact)
44
+
45
+ BrickFTP::Types::FileInBundle.new(res.symbolize_keys)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ module BrickFTP
6
+ module RESTfulAPI
7
+ # Get folder size
8
+ #
9
+ # @see https://developers.brickftp.com/#get-folder-size Get folder size
10
+ #
11
+ class GetFolderSize
12
+ include Command
13
+
14
+ # Returns the size (in bytes) of the specified folder, recursively.
15
+ #
16
+ # @param [String] path
17
+ # @return [Integer]
18
+ #
19
+ def call(path)
20
+ res = client.get("/api/rest/v1/folders/#{ERB::Util.url_encode(path)}?action=size")
21
+ res['data']['size']
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # Show a group
6
+ #
7
+ # @see https://developers.brickftp.com/#show-a-group Show a group
8
+ #
9
+ class GetGroup
10
+ include Command
11
+
12
+ # Returns a single group.
13
+ #
14
+ # @param [Integer] id Globally unique identifier of each group.
15
+ # Each group is given an ID automatically upon creation.
16
+ # @return [BrickFTP::Types::Group, nil] found Group or nil
17
+ #
18
+ def call(id)
19
+ res = client.get("/api/rest/v1/groups/#{id}.json")
20
+ return nil if !res || res.empty?
21
+
22
+ BrickFTP::Types::Group.new(res.symbolize_keys)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # Show a public key
6
+ #
7
+ # @see https://developers.brickftp.com/#show-a-public-key Show a public key
8
+ #
9
+ class GetPublicKey
10
+ include Command
11
+
12
+ # Returns a single public key.
13
+ #
14
+ # @param [Integer] id Globally unique identifier of each public key.
15
+ # Each public key is given an ID automatically upon creation.
16
+ # @return [BrickFTP::Types::UserPublicKey] User's Public key
17
+ #
18
+ def call(id)
19
+ res = client.get("/api/rest/v1/public_keys/#{id}.json")
20
+
21
+ BrickFTP::Types::UserPublicKey.new(res.symbolize_keys)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ class GetSiteUsage
6
+ include Command
7
+
8
+ # Returns site usage
9
+ #
10
+ # @return [BrickFTP::Types::SiteUsage] site usage
11
+ #
12
+ def call
13
+ res = client.get('/api/rest/v1/site/usage.json')
14
+
15
+ BrickFTP::Types::SiteUsage.new(res.symbolize_keys)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # Show a user
6
+ #
7
+ # @see https://developers.brickftp.com/#show-a-user Show a user
8
+ #
9
+ class GetUser
10
+ include Command
11
+
12
+ # Returns a single user.
13
+ #
14
+ # @param [Integer] id Globally unique identifier of each user.
15
+ # Each user is given an ID automatically upon creation.
16
+ # @return [BrickFTP::Types::User, nil] found User or nil
17
+ #
18
+ def call(id)
19
+ res = client.get("/api/rest/v1/users/#{id}.json")
20
+ return nil if !res || res.empty?
21
+
22
+ BrickFTP::Types::User.new(res.symbolize_keys)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # List API keys
6
+ #
7
+ # @see https://developers.brickftp.com/#list-api-keys List API keys
8
+ #
9
+ class ListAPIKeys
10
+ include Command
11
+
12
+ # Returns a list of all API keys for a user on the current site.
13
+ #
14
+ # @param [Integer] id Globally unique identifier of each user.
15
+ # Each user is given an ID automatically upon creation.
16
+ # @return [Array<BrickFTP::Types::UserAPIKey>] User's API keys
17
+ #
18
+ def call(id)
19
+ res = client.get("/api/rest/v1/users/#{id}/api_keys.json")
20
+
21
+ res.map { |i| BrickFTP::Types::UserAPIKey.new(i.symbolize_keys) }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # List all behaviors
6
+ #
7
+ # @see https://developers.brickftp.com/#list-all-behaviors List all behaviors
8
+ #
9
+ class ListBehaviors
10
+ include Command
11
+
12
+ # Returns a list of all behaviors on the current site.
13
+ #
14
+ # @return [Array<BrickFTP::Types::Behavior>] Behaviors
15
+ #
16
+ def call
17
+ res = client.get('/api/rest/v1/behaviors.json')
18
+
19
+ res.map { |i| BrickFTP::Types::Behavior.new(i.symbolize_keys) }
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ module BrickFTP
6
+ module RESTfulAPI
7
+ # List bundle contents
8
+ #
9
+ # @see https://developers.brickftp.com/#list-bundle-contents List bundle contents
10
+ #
11
+ # ### Params
12
+ #
13
+ # PARAMETER | TYPE | DESCRIPTION
14
+ # --------- | ------ | -----------
15
+ # code | string | Unique code string identifier for the bundle.
16
+ # password | string | Optional password to password-protect the bundle. This property is write-only. It cannot be retrieved via the API.
17
+ #
18
+ class ListBundleContents
19
+ include Command
20
+ using BrickFTP::CoreExt::Struct
21
+ using BrickFTP::CoreExt::Hash
22
+
23
+ Params = Struct.new(
24
+ 'ListBundleContentsParams',
25
+ :code,
26
+ :password,
27
+ keyword_init: true
28
+ )
29
+
30
+ # This unauthenticated (public) endpoint lists the contents of a bundle.
31
+ #
32
+ # When no path is specified, the contents of the root of the bundle will be listed. The contents of a subfolder
33
+ # can be listed by providing its path in the URL after /contents, for example: /bundles/contents/cloud/images.
34
+ # Alternatively, you can provide path as a parameter in the request body instead of in the URL.
35
+ #
36
+ # This endpoint only reveals the public part of the file paths (i.e. relative to the root of the bundle).
37
+ # To view the full path of included files, use the authenticated Show Bundle endpoint above.
38
+ #
39
+ # The password parameter is required only for bundles that are password-protected. If a bundle is password-protected
40
+ # and the password is missing or incorrect, an error message will specify that the correct password is required.
41
+ #
42
+ # @param [String, nil] path
43
+ # @param [BrickFTP::RESTfulAPI::ListBundleContents::Params] params parameters
44
+ # @return [Array<BrickFTP::Types::BundleContent>] BundleContent
45
+ #
46
+ def call(params, path: nil)
47
+ endpoint = if path
48
+ "/api/rest/v1/bundles/contents/#{ERB::Util.url_encode(path)}"
49
+ else
50
+ '/api/rest/v1/bundles/contents.json'
51
+ end
52
+ res = client.post(endpoint, params.to_h.compact)
53
+
54
+ res.map { |i| BrickFTP::Types::BundleContent.new(i.symbolize_keys) }
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # List all bundles
6
+ #
7
+ # @see https://developers.brickftp.com/#list-all-bundles List all bundles
8
+ #
9
+ class ListBundles
10
+ include Command
11
+
12
+ # Returns a list of all bundles on the current site.
13
+ #
14
+ # @return [Array<BrickFTP::Types::Bundle>] Bundle
15
+ #
16
+ def call
17
+ res = client.get('/api/rest/v1/bundles.json')
18
+
19
+ res.map { |i| BrickFTP::Types::Bundle.new(i.symbolize_keys) }
20
+ end
21
+ end
22
+ end
23
+ end