Class: OpenSocial::Request
- Inherits:
-
Object
- Object
- OpenSocial::Request
- Defined in:
- lib/opensocial/request.rb
Direct Known Subclasses
FetchActivitiesRequest, FetchAppDataRequest, FetchGroupsRequest, FetchPeopleRequest, FetchPersonRequest, RpcRequest
Constant Summary collapse
- GET =
".get"
Instance Attribute Summary collapse
-
#connection ⇒ Object
Defines the connection that will be used in the request.
-
#guid ⇒ Object
Defines the guid for the request.
-
#key ⇒ Object
Defines the key used to lookup the request result in an RPC request.
-
#pid ⇒ Object
Defines the pid for the request.
-
#selector ⇒ Object
Defines the selector for the request.
Instance Method Summary collapse
-
#initialize(connection = nil, guid = nil, selector = nil, pid = nil) ⇒ Request
constructor
Initializes a request using the optionally supplied connection, guid, selector, and pid.
-
#send_request(service, guid, selector = nil, pid = nil, unescape = false, extra_fields = {}) ⇒ Object
Generates a request given the service, guid, selector, and pid, to the OpenSocial endpoint by constructing the service URI and dispatching the request.
Constructor Details
#initialize(connection = nil, guid = nil, selector = nil, pid = nil) ⇒ Request
Initializes a request using the optionally supplied connection, guid, selector, and pid.
49 50 51 52 53 54 |
# File 'lib/opensocial/request.rb', line 49 def initialize(connection = nil, guid = nil, selector = nil, pid = nil) @connection = connection @guid = guid @selector = selector @pid = pid end |
Instance Attribute Details
#connection ⇒ Object
Defines the connection that will be used in the request.
33 34 35 |
# File 'lib/opensocial/request.rb', line 33 def connection @connection end |
#guid ⇒ Object
Defines the guid for the request.
36 37 38 |
# File 'lib/opensocial/request.rb', line 36 def guid @guid end |
#key ⇒ Object
Defines the key used to lookup the request result in an RPC request.
45 46 47 |
# File 'lib/opensocial/request.rb', line 45 def key @key end |
#pid ⇒ Object
Defines the pid for the request.
42 43 44 |
# File 'lib/opensocial/request.rb', line 42 def pid @pid end |
#selector ⇒ Object
Defines the selector for the request.
39 40 41 |
# File 'lib/opensocial/request.rb', line 39 def selector @selector end |
Instance Method Details
#send_request(service, guid, selector = nil, pid = nil, unescape = false, extra_fields = {}) ⇒ Object
Generates a request given the service, guid, selector, and pid, to the OpenSocial endpoint by constructing the service URI and dispatching the request. When data is returned, it is parsed as JSON after being optionally unescaped.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/opensocial/request.rb', line 60 def send_request(service, guid, selector = nil, pid = nil, unescape = false, extra_fields = {}) if !@connection raise RequestException.new("Request requires a valid connection.") end uri = @connection.service_uri(@connection.container[:rest] + service, guid, selector, pid, extra_fields) data = dispatch(uri) if unescape JSON.parse(os_unescape(data)) else JSON.parse(data) end end |