reso_webapi_js
The RESO Web API JS provides a basic API client that supports the OData protocol as specified by the RESO standards group.
Installing
$ yarn add reso_webapi_js
Setup
Import a client:
const RESOWebApiClient = ;
Initialize a client:
const client = 'http://services.odata.org/V4/OData/OData.svc' auth = {};
API
To get items list of some entity use get
method:
client
To find some item by attribute from entity list, use find_by
:
client
OR if you are using async/await
:
{ try const products_response = await client; console; const product_response = await client; console; catcherror console };
To add new item use send
method:
client
To change item data use edit
method:
client
To delete item use remove
method:
client
Basic Authentication
To secure an oData Web API calls using basic authentication over HTTPS you need to pass the second parameter in your client instance:
const client = 'http://services.odata.org/V4/OData/OData.svc' username: 'xxxxxxxxxxxxx' password: 'xxxxxxxxxxxxx' ;
Examples
Examples of the SDK usage are provided in the example folder.
To run the example:
$ cd example$ node basic.js
Contributing
Bug reports and pull requests are welcome on: https://github.com/jetthoughts/reso_webapi_js.
Service for testing requests: [https://services.odata.org/V3/(S(fsb41nprwii3l3eo2dhgwecc))/OData/OData.svc/](https://services.odata.org/V3/(S(fsb41nprwii3l3eo2dhgwecc))/OData/OData.svc/).
Tests
You can check how we test requests in the test/specs
folder which contains tests for our library API. In the test/mocks
folder we hold fake data for testing our requests.
If you want to add tests for existing API you just need to add test case/file in one of the following folders inside specs
.
But if you want to add new API you need to create folder with appropriate name, put your test files and add test endpoint inside test/test.js
file to make tests work.
License
MIT