Class: Nextcloud::Ocs::FileSharingApi::FederatedCloudShares
- Inherits:
-
Object
- Object
- Nextcloud::Ocs::FileSharingApi::FederatedCloudShares
- Includes:
- Helpers
- Defined in:
- lib/nextcloud/ocs/file_sharing_api.rb
Overview
Wrapper to Federated Cloud Sharing API
Instance Attribute Summary collapse
-
#meta ⇒ Hash
Information about API response.
Instance Method Summary collapse
-
#accept(shareid) ⇒ Object
Accept a request of a Federated Cloud Share.
-
#accepted ⇒ Array
List accepted Federated Cloud Shares.
-
#decline(shareid) ⇒ Object
Decline a request of a Federated Cloud Share.
-
#destroy(shareid) ⇒ Object
Delete an accepted Federated Cloud Share.
-
#find(shareid) ⇒ Hash
Information about accepted Federated Cloud Share.
-
#initialize(api) ⇒ FederatedCloudShares
constructor
Creates Federated Cloud Sharing class instance.
-
#pending ⇒ Array
List pending requests of Federated Cloud Shares.
Methods included from Helpers
#add_meta, #doc_to_hash, #get_meta, #has_dav_errors, #parse_dav_response, #parse_with_meta, #path_from_href
Constructor Details
#initialize(api) ⇒ FederatedCloudShares
Creates Federated Cloud Sharing class instance
140 141 142 |
# File 'lib/nextcloud/ocs/file_sharing_api.rb', line 140 def initialize(api) @api = api end |
Instance Attribute Details
#meta ⇒ Hash
Returns Information about API response.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/nextcloud/ocs/file_sharing_api.rb', line 132 class FederatedCloudShares include Helpers attr_accessor :meta # Creates Federated Cloud Sharing class instance # # @param api [Object] Api object def initialize(api) @api = api end # List accepted Federated Cloud Shares # # @return [Array] List of accepted Federated Cloud Shares def accepted response = @api.request(:get, "/remote_shares") h = doc_to_hash(response, "//data").try(:[], "data").try(:[], "element") h = [h] if h.class == Hash (response, h) end # List pending requests of Federated Cloud Shares # # @return [Array] List of pending Federated Cloud Shares def pending response = @api.request(:get, "/remote_shares/pending") h = doc_to_hash(response, "//data").try(:[], "data").try(:[], "element") h = [h] if h.class == Hash (response, h) end # Accept a request of a Federated Cloud Share # # @param shareid [Integer] Federated Cloud Share identifier # @return [Object] Instance with meta response def accept(shareid) response = @api.request(:post, "/remote_shares/pending/#{shareid}") (@meta = (response)) && self end # Decline a request of a Federated Cloud Share # # @param shareid [Integer] Federated Cloud Share identifier # @return [Object] Instance with meta response def decline(shareid) response = @api.request(:delete, "/remote_shares/pending/#{shareid}") (@meta = (response)) && self end # Delete an accepted Federated Cloud Share # # @param shareid [Integer] Federated Cloud Share identifier # @return [Object] Instance with meta response def destroy(shareid) response = @api.request(:delete, "/remote_shares/#{shareid}") (@meta = (response)) && self end # Information about accepted Federated Cloud Share # # @param shareid [Integer] Federated Cloud Share identifier # @return [Hash] Information about Federated Cloud Share with meta response def find(shareid) response = @api.request(:get, "/remote_shares/#{shareid}") h = doc_to_hash(response, "//data").try(:[], "data") (response, h) end end |
Instance Method Details
#accept(shareid) ⇒ Object
Accept a request of a Federated Cloud Share
168 169 170 171 |
# File 'lib/nextcloud/ocs/file_sharing_api.rb', line 168 def accept(shareid) response = @api.request(:post, "/remote_shares/pending/#{shareid}") (@meta = (response)) && self end |
#accepted ⇒ Array
List accepted Federated Cloud Shares
147 148 149 150 151 152 |
# File 'lib/nextcloud/ocs/file_sharing_api.rb', line 147 def accepted response = @api.request(:get, "/remote_shares") h = doc_to_hash(response, "//data").try(:[], "data").try(:[], "element") h = [h] if h.class == Hash (response, h) end |
#decline(shareid) ⇒ Object
Decline a request of a Federated Cloud Share
177 178 179 180 |
# File 'lib/nextcloud/ocs/file_sharing_api.rb', line 177 def decline(shareid) response = @api.request(:delete, "/remote_shares/pending/#{shareid}") (@meta = (response)) && self end |
#destroy(shareid) ⇒ Object
Delete an accepted Federated Cloud Share
186 187 188 189 |
# File 'lib/nextcloud/ocs/file_sharing_api.rb', line 186 def destroy(shareid) response = @api.request(:delete, "/remote_shares/#{shareid}") (@meta = (response)) && self end |
#find(shareid) ⇒ Hash
Information about accepted Federated Cloud Share
195 196 197 198 199 |
# File 'lib/nextcloud/ocs/file_sharing_api.rb', line 195 def find(shareid) response = @api.request(:get, "/remote_shares/#{shareid}") h = doc_to_hash(response, "//data").try(:[], "data") (response, h) end |
#pending ⇒ Array
List pending requests of Federated Cloud Shares
157 158 159 160 161 162 |
# File 'lib/nextcloud/ocs/file_sharing_api.rb', line 157 def pending response = @api.request(:get, "/remote_shares/pending") h = doc_to_hash(response, "//data").try(:[], "data").try(:[], "element") h = [h] if h.class == Hash (response, h) end |