Module: LC::Protocol
- Defined in:
- lib/leancloud/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.leancloud.cn"- VERSION =
The version of the REST API implemented by this module.
1.1- HEADER_APP_ID =
The HTTP header used for passing your application ID to the Parse API.
"X-LC-Id"- HEADER_API_KEY =
The HTTP header used for passing your API Sign to the Parse API.
"X-LC-Sign"- HEADER_SESSION_TOKEN =
The HTTP header used for passing your authenticated session
"X-LC-Session"- 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"- USER_CURRENT_URI =
"/#{VERSION}/users/me"- PASSWORD_RESET_URI =
"/#{VERSION}/requestPasswordReset"- SMS_URI =
"/#{VERSION}/requestSmsCode"- 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 —————————————-.
- .cql_uri ⇒ Object
-
.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
194 195 196 |
# File 'lib/leancloud/protocol.rb', line 194 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).
148 149 150 151 152 153 154 |
# File 'lib/leancloud/protocol.rb', line 148 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
190 191 192 |
# File 'lib/leancloud/protocol.rb', line 190 def Protocol.cloud_function_uri(function_name) "/#{VERSION}/#{CLOUD_FUNCTIONS_PATH}/#{function_name}" end |
.config_uri ⇒ Object
URI Helpers
142 143 144 |
# File 'lib/leancloud/protocol.rb', line 142 def Protocol.config_uri "/#{VERSION}/config" end |
.cql_uri ⇒ Object
186 187 188 |
# File 'lib/leancloud/protocol.rb', line 186 def Protocol.cql_uri "/#{VERSION}/cloudQuery" end |
.file_uri(file_name) ⇒ Object
Construct a uri referencing a file stored by the API.
177 178 179 |
# File 'lib/leancloud/protocol.rb', line 177 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).
158 159 160 161 162 163 164 |
# File 'lib/leancloud/protocol.rb', line 158 def Protocol.installation_uri(object_id = nil) if object_id "/#{VERSION}/installations/#{object_id}" else "/#{VERSION}/installations" end end |
.push_uri ⇒ Object
Construct a uri to send a push notification via the API.
182 183 184 |
# File 'lib/leancloud/protocol.rb', line 182 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.
168 169 170 171 172 173 174 |
# File 'lib/leancloud/protocol.rb', line 168 def Protocol.user_uri(user_id = nil) if user_id "/#{VERSION}/users/#{user_id}" else "/#{VERSION}/users" end end |