Skip to content

Latest commit

 

History

History
86 lines (62 loc) · 3.77 KB

File metadata and controls

86 lines (62 loc) · 3.77 KB

C++ API client

Please visit our official Documentation and/or our GitHub repository and/or our NuGet package. Always use Version 2 of this API (Version 1.3 is deprecated).

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI spec from a remote server, you can easily generate an API client.

  • API version: v2

  • Package version:

  • Generator version: 7.11.0-SNAPSHOT

  • Build package: org.openapitools.codegen.languages.CppRestSdkClientCodegen For more information, please visit https://slascone.com/contact/

  • API namespace: org.openapitools.client.api

  • Model namespace: org.openapitools.client.model

Installation

Prerequisites

The client uses the cpprestsdk library. If you are using the dev container the library is already installed. If not you have to install it by yourself:

  • Windows: vcpkg install cpprestsdk cpprestsdk:x64-windows boost-uuid boost-uuid:x64-windows
  • Mac: brew install cpprestsdk
  • Linux: sudo apt-get install libcpprest-dev

Generate the sources

An easy way to generate the client is running the OpenAPI Generator from a docker container. The command could look like this: (Don't forget to replace your local project path):

docker run --rm -v "<local project root>:/local" openapitools/openapi-generator-cli generate -i /local/in/swagger.json -c /local/in/config.json -g cpp-restsdk -o /local/out/cpp-restsdk

You can provide a config.json file to configure the generator. To generate the client for this demo application the package name was set.

{
    "packageName": "SlasconeOpenApiClient"
}

Due to an issue in the generator you have to do some slightly modifications to the swagger.json file to get compilable code from the generator. You have to modify all occurencies of oneOf.

Example: You have to change this:

"oneOf": [
    {
    "$ref": "#/components/schemas/TemplateDto"
    }
]

to this:

    "$ref": "#/components/schemas/TemplateDto"

You can download the OpenAPI document from https://api365.slascone.com/swagger/v2/swagger.json.

Signature check and (temporarily) offline files

To prevent fraud the SLASCONE API sends a cryptographic signature with each response. It is possible to set a callback in the API client that is triggered by every response, but unfortunately the callback function is provided with the response status and the response headers only. For the verification of the signature the response body is also needed.

For more information, please visit Digital signature and data integrity in the SLASCONE help pages.

Make callAPI virtual

virtual pplx::task<web::http::http_response> callApi(
    const utility::string_t& path,
    const utility::string_t& method,
    const std::map<utility::string_t, utility::string_t>& queryParams,
    const std::shared_ptr<IHttpBody> postBody,
    const std::map<utility::string_t, utility::string_t>& headerParams,
    const std::map<utility::string_t, utility::string_t>& formParams,
    const std::map<utility::string_t, std::shared_ptr<HttpContent>>& fileParams,
    const utility::string_t& contentType
) const;

Derive ApiClient class

The derived class SlasconeApiClient overrides the callAPI method to verify the response of the SLASCONE WebAPI with the signature header and save both to the local file system. This ensures that the client has access to license information even if there is temporarily no internet connection.