Getting Started
Practical guide for integrating and utilizing PHCGO APIs.
Important
Authentication is required to access our APIs. Make sure you have the appropriate credentials before using the methods.
Authentication
Authentication is the first step in using APIs. It ensures that only authorized users have access to the services. Before calling any method, you must log in and obtain an authentication token.
Login: Use the UserLoginWS/userLoginCompany endpoint to log in.
Request URL: "http://XXXXXXXXXXXXXXXXXXXXXXX/phcws/REST/UserLoginWS/userLoginCompany";
Request Method: POST
Request Headers:
Parameters: suppressWarnings: false,suppressErrors: false,suppressInfos: false
Form Data: array( 'userCode' => $credentials->userCode,
'password' => $credentials->password,
'applicationType' => $credentials->appId,
'company' => $credentials->company);
To get your APP ID, follow the instructions here.
After you have generated your APP ID and associated it with PHC GO, you can use the APP ID in the “applicationType” field in every request.
After authentication, an object is returned:
- Messages: a list of type MessageVO, which will store error messages or relevant information.
- Result: an object of type PHCResult which will be filled in if successful.
If an error occurs, the corresponding messages will be available in the Messages array. If authentication is successful, the Result object will be populated.
In the Result object there is a field called
token. Thistokenshould be copied and sent in the header of all requests, as in the example below:
tokenHeader = array( 'Authorization' => 'Engine-Auth:'.$credentials->token,
'Content-Type' => 'application/json' );
Note
All our endpoints return a PHCResult.
Logout: Use the UserLoginWS/userLogout endpoint to logout.
Request URL: "http://XXXXXXXXXXXXXXXXXXXXXXX/phcws/REST/UserLoginWS/userLogout";
Request Method: POST
Request Headers: array('Authorization' => 'Engine-Auth:'.$response['result'][0]['token'],
'Content-Type' => 'application/json');
Parameters: suppressWarnings: false,suppressErrors: false,suppressInfos: false
Form Data:
Querys
The Query functionality allows you to customize queries. Use the SearchWS call to access the query methods you want to use. See the QueryVO documentation for more details.
Use the REST/SearchWS/queryAsEntity endpoint to call the query methods.
Request URL: "http://XXXXXXXXXXXXXXXXXXXXXXX/phcws/REST/SearchWS/queryAsEntity";
Request Method: POST
Request Headers: array('Authorization' => 'Engine-Auth:'.$response['result'][0]['token'],
'Content-Type' => 'application/json');
Parameters: suppressWarnings: false,suppressErrors: false,suppressInfos: false
Form Data: array( 'itemQuery' => '{"groupByItems":[],
"lazyLoaded":false,
"joinEntities":[],
"orderByItems":[],
"SelectItems":[],
"entityName":"'.$entityName.'",
"filterItems":[{
"comparison":0,
"filterItem":"'.$filterItem.'",
"valueItem":"'.$valueItem.'",
"groupItem":1,
"checkNull":false,
"skipCheckType":false,
"type":"Number"
}]}' );
The queryAsEntity parameter is an object of type QueryVO
QueryAsEntities(QueryVO itemQuery)
Available APIs
After logging in and obtaining the authentication token, you can use the API methods. The most commonly used methods include:
- getNewInstance(ndos): Gets a new instance of the object to be manipulated.
- actEntity(T, int, object): Performs operations or updates on the entity.
- Save(): Saves the changes made to the entity.
Note
To find out more about the methods that can be used, check out the API tab.
The Invoices Module allows you to manage operations related to invoices. Here are the primary methods:
Invoice 🔒 Retrieve a list of issued invoices. Requires authentication.
Get Invoice 🔒
To make calls to our API, refer to the Examples tab, where you will find a sample API call for the invoice. Requires authentication.
Clients Module
Manage operations related to clients.
- List Clients
Too create a new customer, use the getNewInstance(ndos) method shown above, passing the properties of the ClVO (customer) class as parameters. Authentication requirements may vary.