Module: Parse::Protocol

Defined in:
lib/parse/protocol.rb

Overview

A module which encapsulates the specifics of Parse's REST API.

Constant Summary collapse

HOST =

The default hostname for communication with the Parse API.

"api.parse.com"
VERSION =

The version of the REST API implemented by this module.

1
HEADER_APP_ID =

The HTTP header used for passing your application ID to the Parse API.

"X-Parse-Application-Id"
HEADER_API_KEY =

The HTTP header used for passing your API key to the Parse API.

"X-Parse-REST-API-Key"
HEADER_MASTER_KEY =

The HTTP header used for passing your API Master key to the Parse API.

"X-Parse-Master-Key"
HEADER_SESSION_TOKEN =

The HTTP header used for passing your authenticated session

"X-Parse-Session-Token"
KEY_CLASS_NAME =

The JSON key used to store the class name of an object in a Pointer datatype.

"className"
KEY_OBJECT_ID =

The JSON key used to store the ID of Parse objects in their JSON representation.

"objectId"
KEY_CREATED_AT =

The JSON key used to store the creation timestamp of Parse objects in their JSON representation.

"createdAt"
KEY_UPDATED_AT =

The JSON key used to store the last modified timestamp of Parse objects in their JSON representation.

"updatedAt"
KEY_USER_SESSION_TOKEN =
"sessionToken"
RESPONSE_KEY_RESULTS =

The JSON key used in the top-level response object to indicate that the response contains an array of objects.

"results"
KEY_RESULTS =
RESPONSE_KEY_RESULTS
KEY_OP =

The JSON key used to identify an operator

"__op"
KEY_INCREMENT =
"Increment"
KEY_DELETE =
"Delete"
KEY_OBJECTS =

array ops

"objects"
KEY_ADD =
"Add"
KEY_ADD_RELATION =
"AddRelation"
KEY_REMOVE_RELATION =
"RemoveRelation"
KEY_ADD_UNIQUE =
"AddUnique"
KEY_REMOVE =
"Remove"
DELETE_OP =
{ KEY_OP => KEY_DELETE }
KEY_TYPE =

The JSON key used to identify the datatype of a special value.

"__type"
KEY_AMOUNT =

The JSON key used to specify the numerical value in the increment/decrement API call.

"amount"
RESERVED_KEYS =
[ KEY_CLASS_NAME, KEY_CREATED_AT, KEY_OBJECT_ID, KEY_UPDATED_AT, KEY_USER_SESSION_TOKEN]
OP_INCREMENT =

Operation name for incrementing an objects field value remotely

"Increment"
TYPE_OBJECT =

The data type name for special JSON objects representing a full object

"Object"
TYPE_POINTER =

The data type name for special JSON objects representing a reference to another Parse object.

"Pointer"
TYPE_BYTES =

The data type name for special JSON objects containing an array of encoded bytes.

"Bytes"
TYPE_DATE =

The data type name for special JSON objects representing a date/time.

"Date"
TYPE_GEOPOINT =

The data type name for special JSON objects representing a location specified as a latitude/longitude pair.

"GeoPoint"
TYPE_FILE =

The data type name for special JSON objects representing a file.

"File"
TYPE_RELATION =

The data type name for special JSON objects representing a Relation.

"Relation"
CLASS_USER =

The class name for User objects, when referenced by a Pointer.

"_User"
CLASS_INSTALLATION =
"_Installation"
USER_LOGIN_URI =
"/#{VERSION}/login"
PASSWORD_RESET_URI =
"/#{VERSION}/requestPasswordReset"
CLOUD_FUNCTIONS_PATH =
"functions"
BATCH_REQUEST_URI =
"batch"
ERROR_INTERNAL =
1
ERROR_TIMEOUT =
124
ERROR_EXCEEDED_BURST_LIMIT =
155
ERROR_OBJECT_NOT_FOUND_FOR_GET =
101

Class Method Summary collapse

Class Method Details

.batch_request_uriObject


184
185
186
# File 'lib/parse/protocol.rb', line 184

def Protocol.batch_request_uri
  "/#{VERSION}/#{BATCH_REQUEST_URI}"
end

.class_uri(class_name, object_id = nil) ⇒ Object

Construct a uri referencing a given Parse object class or instance (of object_id is non-nil).


142
143
144
145
146
147
148
# File 'lib/parse/protocol.rb', line 142

def Protocol.class_uri(class_name, object_id = nil)
  if object_id
    "/#{VERSION}/classes/#{class_name}/#{object_id}"
  else
    "/#{VERSION}/classes/#{class_name}"
  end
end

.cloud_function_uri(function_name) ⇒ Object


180
181
182
# File 'lib/parse/protocol.rb', line 180

def Protocol.cloud_function_uri(function_name)
  "/#{VERSION}/#{CLOUD_FUNCTIONS_PATH}/#{function_name}"
end

.config_uriObject

URI Helpers



136
137
138
# File 'lib/parse/protocol.rb', line 136

def Protocol.config_uri
  "/#{VERSION}/config"
end

.file_uri(file_name) ⇒ Object

Construct a uri referencing a file stored by the API.


171
172
173
# File 'lib/parse/protocol.rb', line 171

def Protocol.file_uri(file_name)
  "/#{VERSION}/files/#{file_name}"
end

.installation_uri(object_id = nil) ⇒ Object

Construct a uri referencing a given Parse installation class or instance (of object_id is non-nil).


152
153
154
155
156
157
158
# File 'lib/parse/protocol.rb', line 152

def Protocol.installation_uri(object_id = nil)
  if object_id
    "/#{VERSION}/installations/#{object_id}"
  else
    "/#{VERSION}/installations"
  end
end

.push_uriObject

Construct a uri to send a push notification via the API.


176
177
178
# File 'lib/parse/protocol.rb', line 176

def Protocol.push_uri
  "/#{VERSION}/push"
end

.user_uri(user_id = nil) ⇒ Object

Construct a uri referencing a given Parse user instance or the users category.


162
163
164
165
166
167
168
# File 'lib/parse/protocol.rb', line 162

def Protocol.user_uri(user_id = nil)
  if user_id
    "/#{VERSION}/users/#{user_id}"
  else
    "/#{VERSION}/users"
  end
end