Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
titleJSON-RPC Request
linenumberstrue
{
  "method": "clients.editForm",
  "params": {
    "id_clients": 11,
    "SID": "1-bmdgeu6bn22jlmkuffg391t513"
  },
  "id": 1 
}


Code Block
languagejs
titleJSON-RPC Response
linenumberstrue
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "code": true,
    "session_id": "1-bmdgeu6bn22jlmkuffg391t513",
    "messages": [],
    "return": {
      "client": {
        "id": 11,
        "name": "Customer A",
        "groups": "Customers",
        "c_dt": "2013-03-30 16:26:15+03",
        "status": "active",
        "credit": 100,
        "c_company": "Mancy",
        "c_address": null,
        "c_email": "[email protected]",
        "c_email_tech": "[email protected]",
        "c_email_billing": "[email protected]",
        "c_email_rates": "[email protected]",
        "id_currencies": 27
      },
    },
    "errors": []
  } 
}

Examples: PHP Library

For you convenience, it is always better to have higher level class on top of the simple RPC protocol. You can download an example of such class for PHP. Below is example:

Code Block
languagephp
titlePHP Example
linenumberstrue
include 'class.VcsApi.php';
   
// create an API object 
$api = new VcsApi('vcs.demo.jerasoft.net', 'demo', 'demo', 80);
   
// make a call to the API 
$data = $api->clients->editForm(array('id_clients' => 8));
   
/* 
VcsApiResponse Object
(
   ( [code] => 1
    [messages] => Array
        (
        )
    [data] => Array
        (
            [client] => Array
                (
                    [id] => 8
                    [id_companies] => 3
                    [type] => 0
                    [cc_serial] => 
                    [name] => Customer 01
                    [groups] => Vendors, IntraLATA-IntraState, IntraLATA-InterState, InterLATA-IntraState, InterLATA-InterState, Customers
                    [c_dt] => 2012-03-20 09:29:49+00
                    [status] => active
                    [credit] => 1000
                    ...
                )
        ) 
) 
*/


Examples: Python Library

To download a sample library for Python, please visit /usropt/localjerasoft/vcs/libcore/pycore/tools/vcsapi.py. It will simplify work with API. You can find an example below:

Code Block
languagepy
titlePython Example
linenumberstrue
import vcsapi
   
# create an API object 
api = vcsapi.Api('vcs-demo.jerasoft.net', 'demo', 'demo', 443)
   
# make a call to the API 
response = api.clients.editForm({'id_clients': 8}) 

print response.code      # True 
print response.messages  # [ ] 
print response.data      # {'client': {'id': 8, 'type': 0, 'name': 'Customer 01', ...}}

...

In order to find out arguments for this method, you may look for HTTP request in your browser (using FireBug in Firefox, Developer Tools in Chrome). Another way is to check for dump in /usropt/localjerasoft/vcs/var-data/log/runtime.log which looks like:

...