Class: Pcloud::Client
- Inherits:
-
Object
- Object
- Pcloud::Client
- Defined in:
- lib/pcloud/client.rb
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
-
#password ⇒ Object
writeonly
Sets the attribute password.
-
#username ⇒ Object
writeonly
Sets the attribute username.
Instance Method Summary collapse
- #authenticate(options = {}) ⇒ Object
- #file ⇒ Object
- #get(path, params = {}) ⇒ Object
- #http_client ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #post(path, payload = {}, params = {}) ⇒ Object
- #request(verb, path, params, payload = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 |
# File 'lib/pcloud/client.rb', line 11 def initialize( = {}) @username, @password = .values_at(:username, :password) @auth_token = [:auth_token] end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
9 10 11 |
# File 'lib/pcloud/client.rb', line 9 def auth_token @auth_token end |
#password=(value) ⇒ Object (writeonly)
Sets the attribute password
8 9 10 |
# File 'lib/pcloud/client.rb', line 8 def password=(value) @password = value end |
#username=(value) ⇒ Object (writeonly)
Sets the attribute username
8 9 10 |
# File 'lib/pcloud/client.rb', line 8 def username=(value) @username = value end |
Instance Method Details
#authenticate(options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/pcloud/client.rb', line 32 def authenticate( = {}) @auth_token = ()['auth'] self end |
#file ⇒ Object
24 25 26 |
# File 'lib/pcloud/client.rb', line 24 def file @file ||= FileHandler.new(self) end |
#get(path, params = {}) ⇒ Object
16 17 18 |
# File 'lib/pcloud/client.rb', line 16 def get(path, params={}) request(:get, path, params) end |
#http_client ⇒ Object
28 29 30 |
# File 'lib/pcloud/client.rb', line 28 def http_client @http_client ||= RestClient::Resource.new(BASE_URL) end |
#post(path, payload = {}, params = {}) ⇒ Object
20 21 22 |
# File 'lib/pcloud/client.rb', line 20 def post(path, payload={}, params={}) request(:post, path, params, payload) end |