Class: Bubble::KnockKnock::Request
- Inherits:
-
Object
- Object
- Bubble::KnockKnock::Request
- Includes:
- Bubble::KnockKnock, Exceptions
- Defined in:
- lib/bubble/knock_knock/request.rb
Overview
This class gives you an easy way to request informations from Google.
Constant Summary
Constants included from Bubble::KnockKnock
Instance Attribute Summary collapse
-
#header ⇒ Object
readonly
Returns the value of attribute header.
Class Method Summary collapse
-
.delete(uri, params = nil) ⇒ Object
Delete data at any Google Service.
-
.get(uri, params = nil) ⇒ Object
Get the data from any Google Service.
-
.post(uri, params = nil) ⇒ Object
Post data to any Google Service.
-
.put(uri, params = nil) ⇒ Object
Update data at any Google Service.
Instance Method Summary collapse
-
#initialize ⇒ Request
constructor
Finds the Singleton Connection and creates the header structure to requesting informations.
Constructor Details
#initialize ⇒ Request
Finds the Singleton Connection and creates the header structure to requesting informations.
11 12 13 14 15 16 17 18 19 |
# File 'lib/bubble/knock_knock/request.rb', line 11 def initialize raise UnstablishedConnection if Connection.instance.auth.nil? connection = Connection.instance @header = {'Cookie' => "Name=#{connection.auth};Auth=#{connection.auth};Domain=.google.com;Path=/;Expires=160000000000", 'Content-length' => '0', 'Authorization' => "GoogleLogin auth=#{connection.auth}" } end |
Instance Attribute Details
#header ⇒ Object (readonly)
Returns the value of attribute header.
8 9 10 |
# File 'lib/bubble/knock_knock/request.rb', line 8 def header @header end |
Class Method Details
.delete(uri, params = nil) ⇒ Object
Delete data at any Google Service. You just need to indicate the URI of the API and also get the entity’s ID you’re trying to delete. For more information on how to get the entity’s ID,go to google code and check it out.
Example
You must to be connected. Take a look at Connection for more information.
Request.delete('http://www.google.com/m8/feeds/contacts/email%40gmail.com/full/6f669dbb0f3d75ce/1228698987605000')
52 53 54 55 |
# File 'lib/bubble/knock_knock/request.rb', line 52 def self.delete(uri,params=nil) @response, body = action(:delete, uri, params) handling end |
.get(uri, params = nil) ⇒ Object
Get the data from any Google Service. You just need to indicate the URI of the API and the attributes must that be sent with the request. The response’s content will be returned if all occur as well.
Example
You must to be connected. Take a look in Connection for more information.
Request.get('http://www.google.com/m8/feeds/contacts/email%40gmail.com/full')
28 29 30 31 |
# File 'lib/bubble/knock_knock/request.rb', line 28 def self.get(uri, params=nil) response, body = action(:get, uri, params) body end |
.post(uri, params = nil) ⇒ Object
Post data to any Google Service. You just need to indicate the URI of the API and the attributes must that be sent in the request’s body. A Status code 201 CREATED will be return in case everything goes as planned!
Example
You must to be connected. Take a look at Connection for more information.
Request.post('http://www.google.com/m8/feeds/contacts/email%40gmail.com/full', body)
40 41 42 43 |
# File 'lib/bubble/knock_knock/request.rb', line 40 def self.post(uri, params=nil) @response, @body = action(:post, uri, params) handling end |
.put(uri, params = nil) ⇒ Object
Update data at any Google Service. You just need to indicate the URI of the API and also get the entity’s ID you’re trying to delete. For more information on how to get the entity’s ID,go to google code and check it out.
Example
You must to be connected. Take a look at Connection for more information.
Request.put('http://www.google.com/m8/feeds/contacts/email%40gmail.com/full/6f669dbb0f3d75ce/1228698987605000')
64 65 66 67 |
# File 'lib/bubble/knock_knock/request.rb', line 64 def self.put(uri,params=nil) @response, @body = action(:put, uri, params) handling end |