![]() |
Qore MewsRestClient Module Reference 1.0
|
this class provides the REST client API for communication with Mews servers More...
Public Member Functions | |
| constructor (hash< auto > opts, *softbool do_not_connect) | |
| creates the object with the given options | |
| hash< auto > | doMewsRequest (string path, *hash< auto > body, *reference< hash< auto > > info, *hash< auto > hdr) |
| Makes a POST request to the server with the required tokens and returns the response. | |
| auto | preprocessRequestBody (auto body) |
| Adds authorization keys to the request body. | |
Public Attributes | |
| const | DefaultClient = sprintf("Qore %s", Qore::VersionString) |
| Default client value. | |
| const | DefaultUriPathPrefix = "api/connector/v1" |
| Connector REST API path prefix. | |
Protected Member Functions | |
| checkLogin (*reference< hash< auto > > info) | |
| Checks if a login is necessary; if so, then the login is performed. | |
Static Protected Member Functions | |
| static hash< auto > | getOptions (hash< auto > opts) |
| returns options for MewsRestClient::MewsRestClient::constructor() | |
Protected Attributes | |
| string | access_token |
| Mews access token. | |
| string | client = DefaultClient |
| Mews client values. | |
| string | client_token |
| Mews client token. | |
this class provides the REST client API for communication with Mews servers
You must use an OAuth2 token by setting the token and oauth2_refresh_token options; the following options need to be set as well:
oauth2_client_id: the OAuth2 client IDoauth2_client_secret: the OAuth2 client secretThen an external program has to guide the user through using the authorization_grant flow to get a token to use; this module does not implement that flow.
| MewsRestClient::MewsRestClient::constructor | ( | hash< auto > | opts, |
| *softbool | do_not_connect ) |
creates the object with the given options
| opts | valid options are all the options for the RestClient class |
| do_not_connect | if False (the default), then a connection will be immediately established to the remote server |
| RESTCLIENT-ERROR | invalid option passed to constructor, unsupported data serialization, etc |
| hash< auto > MewsRestClient::MewsRestClient::doMewsRequest | ( | string | path, |
| *hash< auto > | body, | ||
| *reference< hash< auto > > | info, | ||
| *hash< auto > | hdr ) |
Makes a POST request to the server with the required tokens and returns the response.
| path | the URI path to add (will be appended to any root path given in the constructor) |
| body | an optional message body to be included in the request; this will have the AccessToken, ClientToken, as well as the Client value added to it automatically before sending with JSON serialization |
| info | an optional reference to a hash that will be used as an output variable giving a hash of request headers and other information about the HTTP request |
"body" key| REST-RESPONSE-ERROR | if this exception is thrown by the Qore::HTTPClient::send() call in case of an HTTP response code < 100 or >= 300, the message body is still deserialized if possible and the response information can be retrieved in the info hash output keys as follows:
error_passthru option is set to True |
Other exceptions can be thrown by the Qore::HTTPClient::send() call used to make the HTTP request.