Class: Skydrive::Client
- Inherits:
-
Object
- Object
- Skydrive::Client
- Includes:
- HTTMultiParty, Operations
- Defined in:
- lib/skydrive/client.rb
Overview
The client class
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
Instance Method Summary collapse
-
#delete(url) ⇒ Object
Do a ‘delete’ request.
-
#get(url, options = {}) ⇒ Object
Do a ‘get’ request.
-
#initialize(access_token) ⇒ Client
constructor
A new instance of Client.
-
#me ⇒ Hash
Get the acting user.
-
#move(url, options = {}) ⇒ Object
Do a ‘move’ request.
-
#object(response) ⇒ Object
Return a Skdrive::Object sub class.
-
#post(url, options = {}) ⇒ Object
Do a ‘post’ request.
-
#put(url, body = nil, options = {}) ⇒ Object
Do a put request.
-
#refresh_access_token! ⇒ Object
Refresh the access token.
Methods included from Operations
#create_album, #create_comment, #create_folder, #delete_comment, #delete_skydrive_object, #get_skydrive_object_by_id, #my_camera_roll, #my_documents, #my_photos, #my_public_documents, #my_recent_documents, #my_shared_stuff, #my_skydrive, #my_storage_quota, #object_comments, #update_skydrive_object, #upload, #user_camera_roll, #user_documents, #user_photos, #user_public_documents, #user_recent_documents, #user_shared_stuff, #user_skydrive, #user_storage_quota
Constructor Details
#initialize(access_token) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/skydrive/client.rb', line 9 def initialize access_token @access_token = access_token self.class.default_params :access_token => @access_token.token end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
4 5 6 |
# File 'lib/skydrive/client.rb', line 4 def access_token @access_token end |
Instance Method Details
#delete(url) ⇒ Object
Do a ‘delete’ request
37 38 39 |
# File 'lib/skydrive/client.rb', line 37 def delete url response = filtered_response(self.class.delete(url)) end |
#get(url, options = {}) ⇒ Object
Do a ‘get’ request
17 18 19 |
# File 'lib/skydrive/client.rb', line 17 def get url, ={} response = filtered_response(self.class.get(url, {:query => })) end |
#me ⇒ Hash
Get the acting user
50 51 52 |
# File 'lib/skydrive/client.rb', line 50 def me response = JSON.load(self.class.get("/me").parsed_response) end |
#move(url, options = {}) ⇒ Object
Do a ‘move’ request
31 32 33 |
# File 'lib/skydrive/client.rb', line 31 def move url, ={} response = filtered_response(self.class.move(url, {:body => })) end |
#object(response) ⇒ Object
Return a Skdrive::Object sub class
62 63 64 65 66 67 68 |
# File 'lib/skydrive/client.rb', line 62 def object response if response.is_a? Array return response.collect{ |object| "Skydrive::#{object["type"].capitalize}".constantize.new(self, object)} else return "Skydrive::#{response["type"].capitalize}" end end |
#post(url, options = {}) ⇒ Object
Do a ‘post’ request
24 25 26 |
# File 'lib/skydrive/client.rb', line 24 def post url, ={} response = filtered_response(self.class.post(url, {:body => })) end |
#put(url, body = nil, options = {}) ⇒ Object
Do a put request
44 45 46 |
# File 'lib/skydrive/client.rb', line 44 def put url, body=nil, ={} response = filtered_response(self.class.put(url, { :body => body, :query => , headers: { 'content-type' => ''} })) end |
#refresh_access_token! ⇒ Object
Refresh the access token
55 56 57 58 59 |
# File 'lib/skydrive/client.rb', line 55 def refresh_access_token! @access_token = access_token.refresh! self.class.default_params :access_token => @access_token.token @access_token end |