Class: OpenSocial::FetchPersonRequest

Inherits:
Request
  • Object
show all
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

Constructor Details

#initialize(connection = nil, guid = '@me', selector = '@self') ⇒ FetchPersonRequest

Initializes a request to the specified user, or the default (@me, @self). A valid Connection is not necessary if the request is to be used as part of an RpcRequest.



97
98
99
# File 'lib/opensocial/person.rb', line 97

def initialize(connection = nil, guid = '@me', selector = '@self')
  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.



111
112
113
# File 'lib/opensocial/person.rb', line 111

def parse_rpc_response(response)
  return parse_response(response['data'])
end

#sendObject

Sends the request, passing in the appropriate SERVICE and specified instance variables.



103
104
105
106
107
# File 'lib/opensocial/person.rb', line 103

def send
  json = send_request(SERVICE, @guid, @selector)
  
  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.



117
118
119
120
121
122
123
124
125
126
# File 'lib/opensocial/person.rb', line 117

def to_json(*a)
  value = {
    'method' => SERVICE + GET,
    'params' => {
      'userId' => ["#{@guid}"],
      'groupId' => "#{@selector}"
    },
    'id' => @key
  }.to_json(*a)
end