Class: Nextcloud::Ocs::App
- Inherits:
-
Nextcloud::OcsApi
- Object
- Api
- Nextcloud::OcsApi
- Nextcloud::Ocs::App
- Includes:
- Helpers
- Defined in:
- lib/nextcloud/ocs/app.rb
Overview
Application class used for interfering with app specific actions
Instance Attribute Summary collapse
-
#appid ⇒ Integer
Application identifier.
-
#meta ⇒ Hash
Information about API response.
Instance Method Summary collapse
-
#disable ⇒ Object
Disable an application.
-
#disabled ⇒ Array
List disabled applications.
-
#enable ⇒ Object
Enable an application.
-
#enabled ⇒ Array
List enabled applications.
-
#find(appid) ⇒ Hash
Get information about an applicaiton.
-
#initialize(args, appid = nil) ⇒ App
constructor
Application initializer.
-
#set(appid) ⇒ Obeject
Sets app (useful if class is initiated without OcsApi.app).
Methods included from Helpers
#add_meta, #doc_to_hash, #get_meta, #has_dav_errors, #parse_dav_response, #parse_with_meta, #path_from_href
Methods inherited from Nextcloud::OcsApi
#app, #file_sharing, #group, #user
Methods inherited from Api
Constructor Details
Instance Attribute Details
#appid ⇒ Integer
Returns Application identifier.
9 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/nextcloud/ocs/app.rb', line 9 class App < OcsApi include Helpers attr_accessor :meta, :appid # Application initializer # # @param api [Object] Api instance # @param appid [Integer,nil] Application identifier def initialize(args, appid = nil) @appid = appid if appid if args.class == Nextcloud::OcsApi @api = args else super(args) @api = self end end # Sets app (useful if class is initiated without OcsApi.app) # # @param appid [String] App identifier # @return [Obeject] self def set(appid) @appid = appid self end # List enabled applications # # @return [Array] List of applications that are enabled on an instance def enabled filter("enabled") end # List disabled applications # # @return [Array] List of applications that are disabled on an instance def disabled filter("disabled") end # Get information about an applicaiton # # @param appid [Integer] Application identifier # @return [Hash] Application information def find(appid) response = @api.request(:get, "apps/#{appid}") h = doc_to_hash(response, "//data")["data"] (response, h) end # Enable an application # # @return [Object] Instance with meta response def enable response = @api.request(:post, "apps/#{@appid}") (@meta = (response)) && self end # Disable an application # # @return [Object] Instance with meta response def disable response = @api.request(:delete, "apps/#{@appid}") (@meta = (response)) && self end private # Retrieve enabled or disabled applications # # @param filter [String] Either enabled or disabled # @return [Array] List of applications with meta method def filter(filter) response = @api.request(:get, "apps?filter=#{filter}") (response, "//data/apps/element") end end |
#meta ⇒ Hash
Returns Information about API response.
9 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/nextcloud/ocs/app.rb', line 9 class App < OcsApi include Helpers attr_accessor :meta, :appid # Application initializer # # @param api [Object] Api instance # @param appid [Integer,nil] Application identifier def initialize(args, appid = nil) @appid = appid if appid if args.class == Nextcloud::OcsApi @api = args else super(args) @api = self end end # Sets app (useful if class is initiated without OcsApi.app) # # @param appid [String] App identifier # @return [Obeject] self def set(appid) @appid = appid self end # List enabled applications # # @return [Array] List of applications that are enabled on an instance def enabled filter("enabled") end # List disabled applications # # @return [Array] List of applications that are disabled on an instance def disabled filter("disabled") end # Get information about an applicaiton # # @param appid [Integer] Application identifier # @return [Hash] Application information def find(appid) response = @api.request(:get, "apps/#{appid}") h = doc_to_hash(response, "//data")["data"] (response, h) end # Enable an application # # @return [Object] Instance with meta response def enable response = @api.request(:post, "apps/#{@appid}") (@meta = (response)) && self end # Disable an application # # @return [Object] Instance with meta response def disable response = @api.request(:delete, "apps/#{@appid}") (@meta = (response)) && self end private # Retrieve enabled or disabled applications # # @param filter [String] Either enabled or disabled # @return [Array] List of applications with meta method def filter(filter) response = @api.request(:get, "apps?filter=#{filter}") (response, "//data/apps/element") end end |
Instance Method Details
#disable ⇒ Object
Disable an application
73 74 75 76 |
# File 'lib/nextcloud/ocs/app.rb', line 73 def disable response = @api.request(:delete, "apps/#{@appid}") (@meta = (response)) && self end |
#disabled ⇒ Array
List disabled applications
48 49 50 |
# File 'lib/nextcloud/ocs/app.rb', line 48 def disabled filter("disabled") end |
#enable ⇒ Object
Enable an application
65 66 67 68 |
# File 'lib/nextcloud/ocs/app.rb', line 65 def enable response = @api.request(:post, "apps/#{@appid}") (@meta = (response)) && self end |
#enabled ⇒ Array
List enabled applications
41 42 43 |
# File 'lib/nextcloud/ocs/app.rb', line 41 def enabled filter("enabled") end |
#find(appid) ⇒ Hash
Get information about an applicaiton
56 57 58 59 60 |
# File 'lib/nextcloud/ocs/app.rb', line 56 def find(appid) response = @api.request(:get, "apps/#{appid}") h = doc_to_hash(response, "//data")["data"] (response, h) end |
#set(appid) ⇒ Obeject
Sets app (useful if class is initiated without OcsApi.app)
33 34 35 36 |
# File 'lib/nextcloud/ocs/app.rb', line 33 def set(appid) @appid = appid self end |