Class: OpenSocial::FetchPeopleRequest
- Inherits:
-
Request
- Object
- Request
- OpenSocial::FetchPeopleRequest
- Defined in:
- lib/opensocial/person.rb
Constant Summary collapse
- SERVICE =
Defines the service fragment for use in constructing the request URL or JSON
'people'
Instance Method Summary collapse
-
#initialize(connection = nil, guid = '@me', selector = '@friends', extra_fields = {}) ⇒ FetchPeopleRequest
constructor
Initializes a request to the specified user’s group, or the default (@me, @friends).
-
#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 RPC request.
Constructor Details
#initialize(connection = nil, guid = '@me', selector = '@friends', extra_fields = {}) ⇒ FetchPeopleRequest
Initializes a request to the specified user’s group, or the default (@me, @friends). A valid Connection is not necessary if the request is to be used as part of an RpcRequest.
155 156 157 158 |
# File 'lib/opensocial/person.rb', line 155 def initialize(connection = nil, guid = '@me', selector = '@friends', extra_fields = {}) super @extra_fields = extra_fields end |
Instance Method Details
#parse_rpc_response(response) ⇒ Object
Selects the appropriate fragment from the JSON response in order to create a native object.
171 172 173 |
# File 'lib/opensocial/person.rb', line 171 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.
162 163 164 165 166 167 |
# File 'lib/opensocial/person.rb', line 162 def send @extra_fields[:fields] ||= FetchPersonRequest::DEFAULT_FIELDS.join(",") json = send_request(SERVICE, @guid, @selector, nil, false, @extra_fields) 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 RPC request.
177 178 179 180 181 182 183 184 185 186 |
# File 'lib/opensocial/person.rb', line 177 def to_json(*a) value = { 'method' => SERVICE + GET, 'params' => { 'userId' => ["#{@guid}"], 'groupId' => "#{@selector}" }, 'id' => @key }.to_json(*a) end |