Class: Nextcloud::Ruby::Api
- Inherits:
-
Object
- Object
- Nextcloud::Ruby::Api
- Defined in:
- lib/nextcloud/ruby/api.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method, path, payload = nil) ⇒ Api
constructor
A new instance of Api.
- #request ⇒ Object
Constructor Details
#initialize(method, path, payload = nil) ⇒ Api
Returns a new instance of Api.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/nextcloud/ruby/api.rb', line 4 def initialize(method, path, payload = nil) @method = method @payload = payload @path = Addressable::URI .join(Nextcloud::Ruby.configuration.dav_url.to_s, path) @uri = Nextcloud::Ruby.configuration.dav_url @username = Nextcloud::Ruby.configuration.username @password = Nextcloud::Ruby.configuration.password init_request end |
Class Method Details
.request(method, path, payload = nil) ⇒ Object
15 16 17 |
# File 'lib/nextcloud/ruby/api.rb', line 15 def self.request(method, path, payload = nil) new(method, path, payload).request end |
Instance Method Details
#request ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/nextcloud/ruby/api.rb', line 19 def request response = Net::HTTP.start(@uri.host, @uri.port, use_ssl: @uri.scheme == 'https') do |http| http.request(@request) end Response.new(response.body, response.code.to_i) end |