Skip to content

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.

License

Notifications You must be signed in to change notification settings

threecolts/selling-partner-api-models

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Selling Patner API Models

This is the repo maintained by IL to generate client code using AutoRest, to know more about AutoRest, check Azure AutoRest.

Prerequisites

  • AutoRest. Installing AutoRest on Windows, MacOS or Linux involves two steps:
  1. Install Node.js (12.19.x LTS preferred. May not function with Node < 10.x.)

if you want an easy way to install and update Node, I recommend NVS - Node Version Switcher or NVM - Node Version Manager

  1. Install AutoRest using npm
# Depending on your configuration you may need to be elevated or root to run this. (on OSX/Linux use 'sudo' )
The latest version is V3, but it doesn't accept HttpClient as a parameter in its constructors, so we have to fall back to V2, 

npm install -g autorest@previous

# run using command 'autorest' to check if installation worked
autorest --help

Steps to generate client code

Take Orders API as example, orders.ps1:

Import-Module .\generator.psm1
Import-Module .\replace.psm1
Import-Module .\factory.psm1

$templatFile = '.\models\orders-api-model\ordersV0.json'
$outputFolder = '.\clients\IL\Orders'
$namespace = 'IL.Library.Amazon.SPAPI.Orders'
$clientname = 'OrdersClient'

generate $templatFile $outputFolder $namespace $clientname

addcode $outputFolder'\'$clientname'.cs' 'HttpClient.SendAsync'  '            PrepareRequest(_httpRequest);'

createfactory '.\factory.template' $outputFolder $clientname'Factory.cs' $namespace $clientname
 
  • generate.psm1 uses AutoRest command to generate the Models and API interface.
  • addcode.psm1 embeds one line code 'PrepareRequest(_httpRequest)' before the line of 'HttpClient.SendAsync', so we can chime in and add the required auth headers.
  • factory.psm1 generates another source code file that implements PrepareRequest and a static instance create function.

To generate the code for an API, such as Orders API, just execute orders.ps1, you will get all you need.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

About

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 91.1%
  • Java 4.4%
  • Mustache 4.1%
  • PowerShell 0.4%