Skip to content

Commit

Permalink
Initial client
Browse files Browse the repository at this point in the history
  • Loading branch information
tolyo committed Sep 9, 2024
1 parent 0cf71ea commit a695add
Show file tree
Hide file tree
Showing 72 changed files with 12,128 additions and 314 deletions.
10 changes: 10 additions & 0 deletions api/api.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,14 @@ generate-api: validate-api
--additional-properties=packageName=api \
--additional-properties=sourceFolder=api \
--additional-properties=outputAsLibrary=true

npx @openapitools/openapi-generator-cli generate \
-i $(OUTPUT_YAML) \
-g go \
-o demo/pkg/client \
--additional-properties=packageName=api \
--additional-properties=sourceFolder=api \
--additional-properties=outputAsLibrary=true
make lint

make lint
12 changes: 6 additions & 6 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"private": true,
"scripts": {},
"devDependencies": {
"@openapitools/openapi-generator-cli": "^0.0.6",
"@redocly/cli": "latest"
}
"private": true,
"scripts": {},
"devDependencies": {
"@openapitools/openapi-generator-cli": "latest",
"@redocly/cli": "latest"
}
}
24 changes: 24 additions & 0 deletions demo/pkg/client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof
23 changes: 23 additions & 0 deletions demo/pkg/client/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
61 changes: 61 additions & 0 deletions demo/pkg/client/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.gitignore
.openapi-generator-ignore
.travis.yml
README.md
api/openapi.yaml
api_admin.go
api_public.go
api_user.go
client.go
configuration.go
docs/AdminAPI.md
docs/AppEntity.md
docs/CreateTradeRequest.md
docs/Currency.md
docs/CurrencyList.md
docs/FxInstrument.md
docs/Instrument.md
docs/OrderBook.md
docs/Payment.md
docs/PaymentAccount.md
docs/PaymentAccountList.md
docs/PaymentType.md
docs/PriceVolume.md
docs/PublicAPI.md
docs/Trade.md
docs/TradeOrder.md
docs/TradeOrderSide.md
docs/TradeOrderStatus.md
docs/TradeOrderTimeInForce.md
docs/TradeOrderType.md
docs/TradingAccount.md
docs/TradingAccountInstrument.md
docs/UserAPI.md
git_push.sh
go.mod
go.sum
model_app_entity.go
model_create_trade_request.go
model_currency.go
model_currency_list.go
model_fx_instrument.go
model_instrument.go
model_order_book.go
model_payment.go
model_payment_account.go
model_payment_account_list.go
model_payment_type.go
model_price_volume.go
model_trade.go
model_trade_order.go
model_trade_order_side.go
model_trade_order_status.go
model_trade_order_time_in_force.go
model_trade_order_type.go
model_trading_account.go
model_trading_account_instrument.go
response.go
test/api_admin_test.go
test/api_public_test.go
test/api_user_test.go
utils.go
1 change: 1 addition & 0 deletions demo/pkg/client/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.1.0
8 changes: 8 additions & 0 deletions demo/pkg/client/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: go

install:
- go get -d -v .

script:
- go build -v ./

158 changes: 158 additions & 0 deletions demo/pkg/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Go API client for api

# Introduction
This API is documented in **OpenAPI 3.0 format**.

This API the following operations:
* Retrieve a list of available instruments
* Retrieve a list of executed trades

# Basics
* API calls have to be secured with HTTPS.
* All data has to be submitted UTF-8 encoded.
* The reply is sent JSON encoded.


## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.

- API version: 1.0.0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen

## Installation

Install the following dependencies:

```shell
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
```

Put the package under your project folder and add the following in import:

```golang
import api "github.com/GIT_USER_ID/GIT_REPO_ID"
```

To use a proxy, set the environment variable `HTTP_PROXY`:

```golang
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
```

## Configuration of Server URL

Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.

### Select Server Configuration

For using other server than the one defined on index 0 set context value `api.ContextServerIndex` of type `int`.

```golang
ctx := context.WithValue(context.Background(), api.ContextServerIndex, 1)
```

### Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value `api.ContextServerVariables` of type `map[string]string`.

```golang
ctx := context.WithValue(context.Background(), api.ContextServerVariables, map[string]string{
"basePath": "v2",
})
```

Note, enum values are always validated and all unused variables are silently ignored.

### URLs Configuration per Operation

Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
Similar rules for overriding default operation server index and variables applies by using `api.ContextOperationServerIndices` and `api.ContextOperationServerVariables` context maps.

```golang
ctx := context.WithValue(context.Background(), api.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), api.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
```

## Documentation for API Endpoints

All URIs are relative to *http://localhost:4000*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AdminAPI* | [**CreateAdminPayment**](docs/AdminAPI.md#createadminpayment) | **Post** /apps/payments | Create admin payment
*AdminAPI* | [**GetAdminPaymentById**](docs/AdminAPI.md#getadminpaymentbyid) | **Post** /apps/payments/{payment_id} | Get payment
*AdminAPI* | [**GetAppEntities**](docs/AdminAPI.md#getappentities) | **Get** /apps | Get application entities
*AdminAPI* | [**GetAppEntity**](docs/AdminAPI.md#getappentity) | **Get** /apps/{app_entity_id} | Get application entity
*PublicAPI* | [**GetCurrencies**](docs/PublicAPI.md#getcurrencies) | **Get** /currencies | Currencies list
*PublicAPI* | [**GetFxInstruments**](docs/PublicAPI.md#getfxinstruments) | **Get** /fxinstruments | Fx instrument list
*PublicAPI* | [**GetInstruments**](docs/PublicAPI.md#getinstruments) | **Get** /instruments | Instrument list
*PublicAPI* | [**GetOrderBook**](docs/PublicAPI.md#getorderbook) | **Get** /order-books/{instrument_name} | Get order book
*UserAPI* | [**CreateTrade**](docs/UserAPI.md#createtrade) | **Post** /trade-orders/{trading_account_id} | Create trade order
*UserAPI* | [**DeleteTradeOrderById**](docs/UserAPI.md#deletetradeorderbyid) | **Delete** /trade-orders/{trading_account_id}/id/{trade_order_id} | Cancel trade order
*UserAPI* | [**GetBookOrders**](docs/UserAPI.md#getbookorders) | **Get** /book-orders/{trading_account_id} | Get book orders
*UserAPI* | [**GetPaymentAccounts**](docs/UserAPI.md#getpaymentaccounts) | **Get** /payment-accounts/{app_entity_id} | Get payment accounts
*UserAPI* | [**GetTradeById**](docs/UserAPI.md#gettradebyid) | **Get** /trades/{trading_account_id}/id/{trade_id} | Get trade
*UserAPI* | [**GetTradeOrderById**](docs/UserAPI.md#gettradeorderbyid) | **Get** /trade-orders/{trading_account_id}/id/{trade_order_id} | Get trade order
*UserAPI* | [**GetTradeOrders**](docs/UserAPI.md#gettradeorders) | **Get** /trade-orders/{trading_account_id} | Get trade orders
*UserAPI* | [**GetTrades**](docs/UserAPI.md#gettrades) | **Get** /trades/{trading_account_id} | Trades list
*UserAPI* | [**GetTradingAccount**](docs/UserAPI.md#gettradingaccount) | **Get** /trading-accounts/{trading_account_id} | Get trading account


## Documentation For Models

- [AppEntity](docs/AppEntity.md)
- [CreateTradeRequest](docs/CreateTradeRequest.md)
- [Currency](docs/Currency.md)
- [CurrencyList](docs/CurrencyList.md)
- [FxInstrument](docs/FxInstrument.md)
- [Instrument](docs/Instrument.md)
- [OrderBook](docs/OrderBook.md)
- [Payment](docs/Payment.md)
- [PaymentAccount](docs/PaymentAccount.md)
- [PaymentAccountList](docs/PaymentAccountList.md)
- [PaymentType](docs/PaymentType.md)
- [PriceVolume](docs/PriceVolume.md)
- [Trade](docs/Trade.md)
- [TradeOrder](docs/TradeOrder.md)
- [TradeOrderSide](docs/TradeOrderSide.md)
- [TradeOrderStatus](docs/TradeOrderStatus.md)
- [TradeOrderTimeInForce](docs/TradeOrderTimeInForce.md)
- [TradeOrderType](docs/TradeOrderType.md)
- [TradingAccount](docs/TradingAccount.md)
- [TradingAccountInstrument](docs/TradingAccountInstrument.md)


## Documentation For Authorization

Endpoints do not require authorization.


## Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains
a number of utility functions to easily obtain pointers to values of basic types.
Each of these functions takes a value of the given basic type and returns a pointer to it:

* `PtrBool`
* `PtrInt`
* `PtrInt32`
* `PtrInt64`
* `PtrFloat`
* `PtrFloat32`
* `PtrFloat64`
* `PtrString`
* `PtrTime`

## Author



Loading

0 comments on commit a695add

Please sign in to comment.