Commits

Greg Salt  committed 429c0fd

Starting on API and response codes

  • Participants
  • Parent commits 1432a3e

Comments (0)

Files changed (3)

File docs/developers.rst

 
 We have made a library available that makes it easy for you to integrate Cerberus into your own addons. It is released under the MIT licence so you can use it for commercial purposes if required.
 
-Cerberus Library
-----------------
+Cerberus Library Requirements
+-----------------------------
+
+You must have the PHP MCRYPT and Curl extensions installed.
+
+Cerberus Library Usage
+----------------------
 
 The library can be used just like any other EE or CodeIgniter library. Here is an example of loading the library and passing in an array of configuration parameters an EE addon:
 
 
    $this->EE->load->library('cerberus', $params);
 
-The hostname and access key are the only required parameters. See the `API`_ for full details of how to use the library.
+The hostname and access key are the only required parameters. See the :doc:`updater/api` for full details of how to use the library.
 
 You should then pass your data as a JSON-encoded array of arrays to the library ``encrypt`` method:
 
 
    $response = $this->EE->cerberus->update($encrypted);
 
-If all goes will the ``$response`` will contain a JSON-encoded string indicated success:
+If all goes will the ``$response`` will contain a JSON-encoded string indicating success:
 
 .. code-block:: json
 
    {"code": 200, "message": "Ok"}
 
-Please see `Response Codes`_ for all the possible API responses.
+Please see :doc:`updater/response-codes` for all the possible API responses.
 
-.. _`API`: api.html
-.. _`Response Codes`: response-codes.html
-

File docs/updater/api.rst

+API
+===
+
+``__construct(array $params)``
+------------------------------
+
+Possible parameters:
+
+    ``hostname``
+
+    ``update_access_key``
+
+    ``api``
+
+.. code-block:: php
+   set_access_key(string $key)``
+-------------------------------
+
+The access key for your site.
+
+``set_hostname(string $host)``
+------------------------------
+
+The hostname of your site.
+
+``set_async_mode(bool)``
+------------------------
+
+Set the async mode for updates.
+
+``set_api(string $api)``
+------------------------
+
+You can change the target of the update method if you want to use a testing service in development.
+
+``encrypt(string $data)``
+-------------------------
+
+Encrypt your JSON-encoded data ready to send to Cerberus.
+
+``update(string $encrypted, [int $timeout])``
+-------------------------------------------
+
+Send your data to Cerberus. The default timeout for the update is 1 second. 
+

File docs/updater/response-codes.rst

+Response Codes
+==============
+
+200 Ok
+-------
+
+.. code-block:: json
+
+   {"code": 200, "message": "Ok"}
+
+If async mode is on you will always see this response even if there might be an error.
+
+402 Resource exists
+-------------------
+
+.. code-block:: json
+
+   402 Resource exists
+
+Each host is only allowed to update a set of member data once.
+
+.. code-block:: json
+
+   403 Not allowed
+
+You may get this response if your account has not been activated yet.
+
+.. code-block:: json
+
+   404 Resource does not exist
+
+If you've modified the library then make sure that the API endpoints are correct.
+
+405 Guardian limit reached
+
+501 Incorrect user agent
+
+502 Invalid remote host
+503 Unable to find access key
+504 Data too long
+505 Unable to decrypt
+506 Invalid POST data
+507 Invalid data format
+508 Duplicate host update
+509 Unknown error
+510 Invalid member data
+511 Unable to base64 decode
+512 Unable to decode JSON
+513 Username not valid
+514 Screen name not valid
+515 Email is not valid
+516 IP Address not valid
+517 URL is not valid
+