Class: OpenSocial::FetchActivitiesRequest
- Defined in:
- lib/opensocial/activity.rb
Overview
Provides the ability to request a Collection of activities for a given user or set of users.
The FetchActivitiesRequest wraps a simple request to an OpenSocial endpoint for a Collection of activities. As parameters, it accepts a user ID and selector (and optionally an ID of a particular activity). This request may be used, standalone, by calling send, or bundled into an RpcRequest.
Constant Summary collapse
- SERVICE =
Defines the service fragment for use in constructing the request URL or JSON
"activities"
- RPC_SERVICE =
This is only necessary because of a spec inconsistency
"activity"
Constants inherited from Request
Instance Attribute Summary
Attributes inherited from Request
#connection, #guid, #key, #pid, #selector
Instance Method Summary collapse
-
#initialize(connection = nil, guid = "@me", selector = "@self", pid = nil) ⇒ FetchActivitiesRequest
constructor
Initializes a request to fetch activities for the specified user and group, or the default (@me, @self).
-
#parse_rpc_response(response) ⇒ Object
Selects the appropriate fragment from the JSON response in order to create a native object.
-
#send ⇒ Object
Sends the request, passing in the appropriate SERVICE and specified instance variables.
-
#to_json(*a) ⇒ Object
Converts the request into a JSON fragment that can be used as part of a larger RpcRequest.
Methods inherited from Request
Constructor Details
#initialize(connection = nil, guid = "@me", selector = "@self", pid = nil) ⇒ FetchActivitiesRequest
Initializes a request to fetch activities for the specified user and group, or the default (@me, @self). A valid Connection is not necessary if the request is to be used as part of an RpcRequest.
66 67 68 69 |
# File 'lib/opensocial/activity.rb', line 66 def initialize(connection = nil, guid = "@me", selector = "@self", pid = nil) super end |
Instance Method Details
#parse_rpc_response(response) ⇒ Object
Selects the appropriate fragment from the JSON response in order to create a native object.
81 82 83 |
# File 'lib/opensocial/activity.rb', line 81 def parse_rpc_response(response) return parse_response(response["data"]["list"]) end |
#send ⇒ Object
Sends the request, passing in the appropriate SERVICE and specified instance variables.
73 74 75 76 77 |
# File 'lib/opensocial/activity.rb', line 73 def send json = send_request(SERVICE, @guid, @selector, @pid) return parse_response(json["entry"]) end |
#to_json(*a) ⇒ Object
Converts the request into a JSON fragment that can be used as part of a larger RpcRequest.
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/opensocial/activity.rb', line 87 def to_json(*a) value = { "method" => RPC_SERVICE + GET, "params" => { "userId" => ["#{@guid}"], "groupId" => "#{@selector}", "appId" => "#{@pid}" }, "id" => @key }.to_json(*a) end |