|
|
(7 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
| {{Stability-experimental}}
| | The content on this page has moved to https://documentation.open-xchange.com/7.10.2/ui/ |
|
| |
|
| <div class="title">Requesting server api with http.js</div>
| | Note: Open-Xchange is in the process of migrating all its technical documentation to a new and improved documentation system (documentation.open-xchange.com). Please note as the migration takes place more information will be available on the new system and less on this system. Thank you for your understanding during this period of transition. |
| {{Template:Status-UnderConstruction}}
| |
| | |
| '''Abstract'''
| |
| Http is intended as centralized server communication layer currently heavily used in our [[AppSuite:APIs | front end APIs]]. For more details than covered in this article dive into it's source code found in ''io.ox/core/http.js''.
| |
| | |
| __TOC__
| |
| | |
| = HTTP facades =
| |
| | |
| ''general example''
| |
| | |
| <pre>http.GET({
| |
| module: 'mail',
| |
| params: {
| |
| action: 'all',
| |
| folder: 'default0/INBOX'
| |
| }
| |
| });</pre>
| |
| == GET(options) ==
| |
| | |
| <pre>/**
| |
| * Send a GET request
| |
| * @param {Object} options Request options
| |
| * @returns {Object} jQuery's Deferred
| |
| */</pre>
| |
| == POST(options) ==
| |
| | |
| <pre>/**
| |
| * Send a POST request
| |
| * @param {Object} options Request options
| |
| * @returns {Object} jQuery's Deferred
| |
| */</pre>
| |
| == FORM(options) ==
| |
| | |
| <pre>/**
| |
| * Send a POST request using a FormData object
| |
| * @param {Object} options Request options
| |
| * @param {string} options.module Module, e.g. folder, mail, calendar etc.
| |
| * @param {Object} options.params URL parameters
| |
| * @returns {Object} jQuery's Deferred
| |
| */</pre>
| |
| == PUT(options) ==
| |
| | |
| <pre>/**
| |
| * Send a PUT request
| |
| * @param {Object} options Request options
| |
| * @returns {Object} jQuery's Deferred
| |
| */
| |
| </pre>
| |
| == DELETE(options) ==
| |
| | |
| <pre>/**
| |
| * Send a DELETE request
| |
| * @param {Object} options Request options
| |
| * @returns {Object} jQuery's Deferred
| |
| */</pre>
| |
| == UPLOAD(options) ==
| |
| | |
| <pre>/**
| |
| * Send a UPLOAD request
| |
| * @param {Object} options Request options
| |
| * @returns {Object} jQuery's Deferred
| |
| */</pre>
| |
| = Column Mappings =
| |
| | |
| * server requests
| |
| ** still require use of columns ids
| |
| * server response
| |
| ** column_id keys will be replaced with column names to ease handling
| |
| | |
| == getAllColumns(module, join) ==
| |
| <pre>/**
| |
| * get all columns of a module
| |
| * @param {string} module (name)
| |
| * @param {boolean} join (join array with comma separator )
| |
| * @return {arrray|string} ids */ ```
| |
| </pre>
| |
| | |
| == getColumnMapping(module) ==
| |
| | |
| <pre>/**
| |
| * returns the column mapping of a module
| |
| * @param {string} module The module name.
| |
| * @returns {object} A map from numeric column IDs to the corresponding field names.
| |
| */</pre>
| |
| == makeObject(data, module, columns) ==
| |
| | |
| <pre>/**
| |
| * transform objects with array-based columns into key-value-based columns
| |
| * @param {Array} data Data
| |
| * @param {string} module Module name
| |
| * @param {Array} columns Columns
| |
| * @returns {Object} Transformed object
| |
| */</pre>
| |
| | |
| = request stacking =
| |
| | |
| * stack ability for calls to minimize overhead of server communication
| |
| | |
| == pause() ''and'' resume() ==
| |
| | |
| '''example'''
| |
| | |
| <pre>// pause http layer
| |
| http.pause();
| |
| | |
| // process all updates
| |
| _(list).map(function (item) {
| |
| return http.PUT({
| |
| module: 'calendar',
| |
| params: {
| |
| action: 'update',
| |
| id: item.id,
| |
| folder: item.folder_id,
| |
| timestamp: item.timestamp
| |
| },
| |
| data: { ... },
| |
| });
| |
| });
| |
| | |
| // resume & trigger refresh
| |
| http.resume()</pre>
| |
| == retry (request) ==
| |
| | |
| * retry request
| |
| | |
| = utils =
| |
| | |
| == simplify(list) ==
| |
| | |
| * simplify objects in array for list requests
| |
| * returns array of items
| |
| * possible returned item types
| |
| ** { id: '8978989' }
| |
| ** { folder: 'inbox' }<br />
| |
| ** { recurrence_position: 'inbox' }
| |
| ** 8978989
| |
| ** 'inbox'
| |
| | |
| <pre>/**
| |
| * Simplify objects in array for list requests
| |
| * @param {array} list
| |
| * @returns {array} list
| |
| */</pre>
| |
| == fixList(ids, deferred) ==
| |
| | |
| <pre>/**
| |
| * Fixes order of list requests (temp. fixes backend bug)
| |
| * @param {array} ids
| |
| * @param {deferred} deferred
| |
| * @return {deferred} resolve returns array
| |
| */</pre>
| |
| | |
| | |
| = logging =
| |
| | |
| == log() ==
| |
| | |
| <pre>/**
| |
| * returns failed calls
| |
| * @return {backbone.collection}
| |
| */</pre>
| |
| | |
| [[Category:AppSuite]]
| |
| [[Category:UI]]
| |