Merchant API: generate API clients
About this article
This article lists ChannelEngine's API clients for merchants.
Table of contents
Generate an API client library
Introduction
You can generate language-specific API client libraries to create custom connections with ChannelEngine's Merchant API. These libraries are packages that allow for easier interaction with the APIs and a streamlined way to access their latest features and functionality.
API clients for merchants
You can find ChannelEngine's REST API client libraries and language-specific package managers on ChannelEngine's GitHub page. If the programming language or package manager of your choice is not listed in the following table, get in touch with your contact point at ChannelEngine.
PHP | .NET | Java | Ruby |
Source code | Source code | Source code | Source code |
Composer package | NuGet package | JAR | RubyGems package |
Generate an API client library
You can generate an API client library from ChannelEngine's OpenAPI specification via the OpenAPI generator and the command-line interface. As a result, you get access to ChannelEngine's language-specific API client libraries, server stubs, documentation, and configuration.
Prerequisites
Before you start, make sure to meet the following prerequisites:
- Install Java on your local machine.
- Install Powershell on your local machine if you use macOS or Linux.
-
Install OpenAPI Generator's CLI on your local machine. To do so, use either:
- The npm package wrapper
npm install @openapitools/openapi-generator-cli
- The yarn package manager
yarn add @openapitools/openapi-generator-cli
- The npm package wrapper
Procedure
- Open PowerShell. To configure the security settings and set the security protocol, run the command:
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
- To configure the environment settings so that your application trusts remote URLs when parsing OpenAPI documents, run the command:
[System.Environment]::SetEnvironmentVariable('JAVA_TOOL_OPTIONS','-Dio.swagger.parser.util.RemoteUrl.trustAll=true -Dio.swagger.v3.parser.util.RemoteUrl.trustAll=true')
- To generate the API library, run the OpenAPI generator CLI command:
openapi-generator-cli generate -g {language} -i {swagger_file_url} -o {destination_folder}--config {configuration_file}--additional-properties{additional_properties}
In the command above, provide your information for the following:- {language} - the programming language of your application. E.g.: Java, Ruby.
- {swagger_file_url} - the URL to the OpenAPI specification file (i.e.: Merchant API).
- {destination_folder} - the path to where you want the generated code saved on your local machine.
- {configuration_file} - the path to the configuration file, in the JSON or YAML format. The next section contains examples of configuration files per programming language. For more information on the configuration supported by the OpenAPI Generator, check out the article Configuration options on OpenAPI generator.
- {additional_properties} - additional options in the form of comma-separated key-value pairs. E.g.: the version number for the generated package.
Below you can see an example of the command that generates a Java client library for ChannelEngine's Merchant API:
openapi-generator-cli generate -g java -i https://demo.channelengine.net/api/swagger/merchant/swagger.json -o "C:\Projects\api-client-generation\clients\merchant-api-client-java"--config "C:\Projects\api-client-generation\clients\merchant-api-client-java\swagger-config.json"--additional-properties "packageVersion=3.0.0,gemVersion=3.0.0,podVersion=3.0.0,artifactVersion=3.0.0"
Remove-Item "pom.xml", "build.gradle", "build.sbt" -ErrorAction Ignore
--global-property "modelDocs=false,modelTests=false,apiDocs=false,apiTests=false"
Configuration files
Language | Merchant API |
C# | { |
Java |
|
PHP |
{ |
Python |
{ |
Ruby |
{ |
Swift |
{ |
Comments
0 comments
Article is closed for comments.