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"
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 in the increment/decrement API call.

"__op"
KEY_INCREMENT =
"Increment"
KEY_DECREMENT =
"Decrement"
KEY_DELETE =
"Delete"
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]
OP_INCREMENT =

Operation name for incrementing an objects field value remotely

"Increment"
OP_DECREMENT =

Operation name for decrementing an objects field value remotely

"Decrement"
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"
KEY_USER_SESSION_TOKEN =
"sessionToken"
CLOUD_FUNCTIONS_PATH =
"functions"

Class Method Summary collapse

Class Method Details

.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).



124
125
126
127
128
129
130
# File 'lib/parse/protocol.rb', line 124

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



153
154
155
# File 'lib/parse/protocol.rb', line 153

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

.file_uri(file_name) ⇒ Object

Construct a uri referencing a file stored by the API.



144
145
146
# File 'lib/parse/protocol.rb', line 144

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

.push_uriObject

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



149
150
151
# File 'lib/parse/protocol.rb', line 149

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.



135
136
137
138
139
140
141
# File 'lib/parse/protocol.rb', line 135

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