Module: Parse::Protocol
- Defined in:
- lib/parse/protocol.rb
Overview
A module which encapsulates the specifics of Parse’s REST API.
Constant Summary collapse
- PATH =
The default path for communication with the Parse API.
'/parse'
- 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 =
'/login'
- PASSWORD_RESET_URI =
'/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
- .batch_request_uri ⇒ Object
-
.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).
- .cloud_function_uri(function_name) ⇒ Object
-
.config_uri ⇒ Object
URI Helpers —————————————-.
-
.file_uri(file_name) ⇒ Object
Construct a uri referencing a file stored by the API.
-
.installation_uri(object_id = nil) ⇒ Object
Construct a uri referencing a given Parse installation class or instance (of object_id is non-nil).
-
.push_uri ⇒ Object
Construct a uri to send a push notification via the API.
-
.user_uri(user_id = nil) ⇒ Object
Construct a uri referencing a given Parse user instance or the users category.
Class Method Details
.batch_request_uri ⇒ Object
182 183 184 |
# File 'lib/parse/protocol.rb', line 182 def self.batch_request_uri "/#{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).
140 141 142 143 144 145 146 |
# File 'lib/parse/protocol.rb', line 140 def self.class_uri(class_name, object_id = nil) if object_id "/classes/#{class_name}/#{object_id}" else "/classes/#{class_name}" end end |
.cloud_function_uri(function_name) ⇒ Object
178 179 180 |
# File 'lib/parse/protocol.rb', line 178 def self.cloud_function_uri(function_name) "/#{CLOUD_FUNCTIONS_PATH}/#{function_name}" end |
.config_uri ⇒ Object
URI Helpers
134 135 136 |
# File 'lib/parse/protocol.rb', line 134 def self.config_uri '/config' end |
.file_uri(file_name) ⇒ Object
Construct a uri referencing a file stored by the API.
169 170 171 |
# File 'lib/parse/protocol.rb', line 169 def self.file_uri(file_name) "/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).
150 151 152 153 154 155 156 |
# File 'lib/parse/protocol.rb', line 150 def self.installation_uri(object_id = nil) if object_id "/installations/#{object_id}" else '/installations' end end |
.push_uri ⇒ Object
Construct a uri to send a push notification via the API.
174 175 176 |
# File 'lib/parse/protocol.rb', line 174 def self.push_uri '/push' end |
.user_uri(user_id = nil) ⇒ Object
Construct a uri referencing a given Parse user instance or the users category.
160 161 162 163 164 165 166 |
# File 'lib/parse/protocol.rb', line 160 def self.user_uri(user_id = nil) if user_id "/users/#{user_id}" else '/users' end end |