From c01f3c36c00c950b4cc8f2afe78461ea8b4d65f2 Mon Sep 17 00:00:00 2001 From: Anatoly Ostrovsky Date: Thu, 7 Dec 2023 01:21:48 +0200 Subject: [PATCH] Regenerate API --- pkg/api.yaml | 223 +++++++-- pkg/api/endpoints/admin/apps.yaml | 4 +- pkg/api/endpoints/admin/apps_by_id.yaml | 6 +- pkg/api/endpoints/admin/auctions.yaml | 0 pkg/api/endpoints/admin/instruments.yaml | 1 + pkg/api/endpoints/admin/payments.yaml | 16 + pkg/api/endpoints/admin/payments_by_id.yaml | 22 + pkg/api/endpoints/public/currencies.yaml | 2 +- pkg/api/endpoints/user/book_orders.yaml | 18 + pkg/api/endpoints/user/payment_accounts.yaml | 22 + pkg/api/endpoints/user/trade_orders.yaml | 6 +- pkg/api/endpoints/user/trades.yaml | 7 +- pkg/api/endpoints/user/trades_by_id.yaml | 18 + pkg/api/models/payment.yaml | 60 +++ pkg/api/models/payment_account.yaml | 6 +- pkg/api/models/shared.yaml | 5 + pkg/api/openapi.yaml | 23 +- pkg/models/payment.go | 2 +- pkg/rest/.openapi-generator-ignore | 6 +- pkg/rest/.openapi-generator/FILES | 25 +- pkg/rest/README.md | 2 +- pkg/rest/api/api.go | 89 ++-- pkg/rest/api/api_admin.go | 125 +++++ pkg/rest/api/api_admin_service.go | 83 ++++ pkg/rest/api/api_currencies.go | 68 --- pkg/rest/api/api_currencies_service.go | 42 -- pkg/rest/api/api_instruments.go | 68 --- pkg/rest/api/api_instruments_service.go | 41 -- pkg/rest/api/api_order_books.go | 72 --- pkg/rest/api/api_order_books_service.go | 41 -- pkg/rest/api/api_public.go | 123 +++++ pkg/rest/api/api_public_service.go | 85 ++++ pkg/rest/api/api_trade_order.go | 68 --- pkg/rest/api/api_trade_order_service.go | 41 -- pkg/rest/api/api_trades.go | 68 --- pkg/rest/api/api_trades_service.go | 41 -- pkg/rest/api/api_user.go | 149 ++++++ pkg/rest/api/api_user_service.go | 97 ++++ pkg/rest/api/api_users.go | 72 +++ pkg/rest/api/api_users_service.go | 41 ++ pkg/rest/api/helpers.go | 6 - ...ok_200_response.go => model_app_entity.go} | 16 +- pkg/rest/api/model_currency_list.go | 25 + pkg/rest/api/model_fx_instrument.go | 36 ++ pkg/rest/api/model_instrument.go | 3 - pkg/rest/api/model_payment.go | 62 +++ pkg/rest/api/model_payment_account.go | 34 ++ pkg/rest/api/model_payment_account_list.go | 25 + pkg/rest/api/model_payment_type.go | 23 + pkg/rest/api/model_trade.go | 2 +- pkg/rest/api/openapi.yaml | 447 ++++++++++++++++-- pkg/rest/api/utils.go | 7 + pkg/rest/rest.go | 2 +- 53 files changed, 1841 insertions(+), 735 deletions(-) create mode 100644 pkg/api/endpoints/admin/auctions.yaml create mode 100644 pkg/api/endpoints/admin/instruments.yaml create mode 100644 pkg/api/endpoints/admin/payments.yaml create mode 100644 pkg/api/endpoints/admin/payments_by_id.yaml create mode 100644 pkg/api/endpoints/user/book_orders.yaml create mode 100644 pkg/api/endpoints/user/trades_by_id.yaml create mode 100644 pkg/rest/api/api_admin.go create mode 100644 pkg/rest/api/api_admin_service.go delete mode 100644 pkg/rest/api/api_currencies.go delete mode 100644 pkg/rest/api/api_currencies_service.go delete mode 100644 pkg/rest/api/api_instruments.go delete mode 100644 pkg/rest/api/api_instruments_service.go delete mode 100644 pkg/rest/api/api_order_books.go delete mode 100644 pkg/rest/api/api_order_books_service.go create mode 100644 pkg/rest/api/api_public.go create mode 100644 pkg/rest/api/api_public_service.go delete mode 100644 pkg/rest/api/api_trade_order.go delete mode 100644 pkg/rest/api/api_trade_order_service.go delete mode 100644 pkg/rest/api/api_trades.go delete mode 100644 pkg/rest/api/api_trades_service.go create mode 100644 pkg/rest/api/api_user.go create mode 100644 pkg/rest/api/api_user_service.go create mode 100644 pkg/rest/api/api_users.go create mode 100644 pkg/rest/api/api_users_service.go rename pkg/rest/api/{model_get_order_book_200_response.go => model_app_entity.go} (50%) create mode 100644 pkg/rest/api/model_currency_list.go create mode 100644 pkg/rest/api/model_fx_instrument.go create mode 100644 pkg/rest/api/model_payment.go create mode 100644 pkg/rest/api/model_payment_account.go create mode 100644 pkg/rest/api/model_payment_account_list.go create mode 100644 pkg/rest/api/model_payment_type.go create mode 100644 pkg/rest/api/utils.go diff --git a/pkg/api.yaml b/pkg/api.yaml index b4cc7e8..6a64d5f 100644 --- a/pkg/api.yaml +++ b/pkg/api.yaml @@ -16,6 +16,7 @@ info: title: OPEN OUTCRY API servers: - url: http://localhost:4000 +security: [] tags: - name: user description: User facing resources for management by a specific user of their accounts @@ -38,7 +39,7 @@ paths: application/json: schema: $ref: '#/components/schemas/CurrencyList' - '500': + '404': description: Error /fxinstruments: get: @@ -94,69 +95,89 @@ paths: $ref: '#/components/schemas/OrderBook' '404': description: Order book not found for instrument - /trades/{trading_account_id}: + /book_orders/{trading_account_id}: get: tags: - user - summary: trades list - description: Returns list of entity's trades - operationId: getTrades + summary: Get book orders + description: Returns list of user's trade orders currently on the order book + operationId: getBookOrders parameters: - $ref: '#/components/parameters/TradingAccountId' - - $ref: '#/components/parameters/TradeId' responses: '200': - description: trades list + description: Success content: application/json: schema: - $ref: '#/components/schemas/TradeList' - '500': + $ref: '#/components/schemas/TradeOrderList' + '404': + description: Error + /payment-accounts/{app_entity_id}: + get: + tags: + - user + summary: Get payment accounts + description: Returns list of user's payment accounts + operationId: getPaymentAccounts + parameters: + - in: path + name: app_entity_id + required: true + schema: + $ref: '#/components/schemas/Id' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/PaymentAccountList' + '404': description: Error /trades/{trading_account_id}/id/{trade_id}: get: tags: - user - summary: trades list - description: Returns list of entity's trades - operationId: getTrades + summary: Get trade + description: Returns a trade by id + operationId: getTradeById parameters: - $ref: '#/components/parameters/TradingAccountId' - $ref: '#/components/parameters/TradeId' responses: '200': - description: trades list + description: Success content: application/json: schema: - $ref: '#/components/schemas/TradeList' - '500': + $ref: '#/components/schemas/Trade' + '404': description: Error - /trades: + /trades/{trading_account_id}: get: tags: - user - summary: trades list + summary: Trades list description: Returns list of entity's trades operationId: getTrades parameters: - $ref: '#/components/parameters/TradingAccountId' - - $ref: '#/components/parameters/TradeId' responses: '200': - description: trades list + description: Success content: application/json: schema: $ref: '#/components/schemas/TradeList' - '500': + '404': description: Error /trade_orders/{trading_account_id}: get: tags: - user summary: Get trade orders - description: Returns list of user's active trade orders + description: Returns list of user's trade orders operationId: getTradeOrders parameters: - $ref: '#/components/parameters/TradingAccountId' @@ -167,7 +188,7 @@ paths: application/json: schema: $ref: '#/components/schemas/TradeOrderList' - '500': + '404': description: Error post: tags: @@ -184,7 +205,7 @@ paths: application/json: schema: $ref: '#/components/schemas/TradeOrder' - '500': + '404': description: Error /apps/{app_entity_id}: get: @@ -195,13 +216,13 @@ paths: operationId: getAppEntity parameters: - in: path - name: external_id + name: app_entity_id required: true schema: - $ref: '#/components/schemas/AppEntityExternalId' + $ref: '#/components/schemas/Id' responses: '200': - description: List of registered users + description: Success content: application/json: schema: @@ -217,18 +238,52 @@ paths: operationId: getAppEntities responses: '200': - description: List of registered users + description: Success content: application/json: schema: $ref: '#/components/schemas/AppEntityList' - '500': + '404': + description: Error + /apps/payments/{payment_id}: + post: + tags: + - admin + summary: Get payment + description: Returns payment information + operationId: getAdminPaymentById + parameters: + - in: path + name: payment_id + required: true + schema: + $ref: '#/components/schemas/Id' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/Payment' + '404': + description: Error + /apps/payments: + post: + tags: + - admin + summary: Create admin payment + description: Creates a payment on user's account + operationId: createAdminPayment + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/Payment' + '404': description: Error components: - securitySchemes: - basicAuth: - type: http - scheme: basic schemas: CurrencyName: type: string @@ -322,17 +377,6 @@ components: type: array items: $ref: '#/components/schemas/PriceVolume' - Trade: - type: object - description: Executed trade - properties: - id: - $ref: '#/components/schemas/Id' - TradeList: - type: array - description: List of executed trades - items: - $ref: '#/components/schemas/Trade' TradeOrderSide: type: string enum: @@ -369,6 +413,49 @@ components: type: array items: $ref: '#/components/schemas/TradeOrder' + MoneyAmount: + type: string + format: decimal + example: '100.50' + PaymentAccount: + type: object + description: Payment account available to user + properties: + id: + $ref: '#/components/schemas/Id' + currency: + $ref: '#/components/schemas/CurrencyName' + amount: + $ref: '#/components/schemas/MoneyAmount' + amountReserved: + $ref: '#/components/schemas/MoneyAmount' + amountAvailable: + $ref: '#/components/schemas/MoneyAmount' + PaymentAccountList: + type: object + description: List of payment accounts available to user + properties: + data: + type: array + items: + $ref: '#/components/schemas/PaymentAccount' + example: + data: + - name: USD + precision: 2 + - name: BTC + precision: 5 + Trade: + type: object + description: Executed trade + properties: + id: + $ref: '#/components/schemas/Id' + TradeList: + type: array + description: List of executed trades + items: + $ref: '#/components/schemas/Trade' AppEntityExternalId: type: string description: External id @@ -385,6 +472,56 @@ components: description: List of registered users items: $ref: '#/components/schemas/AppEntity' + PaymentType: + type: string + enum: + - DEPOSIT + - WITHDRAWAL + - TRANSFER + - INSTRUMENT_BUY + - INSTRUMENT_SELL + - CHARGE + PaymentDetails: + type: string + example: Bank deposit Bank REF123456 + PaymentExternalReferenceNumber: + type: string + example: REF123456 + Payment: + type: object + properties: + id: + $ref: '#/components/schemas/Id' + type: + $ref: '#/components/schemas/PaymentType' + amount: + $ref: '#/components/schemas/MoneyAmount' + currency: + $ref: '#/components/schemas/CurrencyName' + senderAccountId: + $ref: '#/components/schemas/Id' + beneficiaryAccountId: + $ref: '#/components/schemas/Id' + details: + $ref: '#/components/schemas/PaymentDetails' + externalReferenceNumber: + $ref: '#/components/schemas/PaymentExternalReferenceNumber' + status: + type: string + debitBalanceAmount: + $ref: '#/components/schemas/MoneyAmount' + creditBalanceAmount: + $ref: '#/components/schemas/MoneyAmount' + required: + - id + - type + - amount + - currency + - senderAccountId + - beneficiaryAccountId + - details + - externalReferenceNumber + - status parameters: TradingAccountId: name: trading_account_id diff --git a/pkg/api/endpoints/admin/apps.yaml b/pkg/api/endpoints/admin/apps.yaml index f471324..b9e1817 100644 --- a/pkg/api/endpoints/admin/apps.yaml +++ b/pkg/api/endpoints/admin/apps.yaml @@ -7,10 +7,10 @@ get: responses: "200": - description: List of registered users + description: Success content: application/json: schema: $ref: '../../models/app_entity.yaml#/components/schemas/AppEntityList' - "500": + "404": description: Error diff --git a/pkg/api/endpoints/admin/apps_by_id.yaml b/pkg/api/endpoints/admin/apps_by_id.yaml index 0aff003..eb575a2 100644 --- a/pkg/api/endpoints/admin/apps_by_id.yaml +++ b/pkg/api/endpoints/admin/apps_by_id.yaml @@ -6,14 +6,14 @@ get: operationId: getAppEntity parameters: - in: path - name: external_id + name: app_entity_id required: true schema: - $ref: '../../models/app_entity.yaml#/components/schemas/AppEntityExternalId' + $ref: '../../models/app_entity.yaml#/components/schemas/AppEntityId' responses: "200": - description: List of registered users + description: Success content: application/json: schema: diff --git a/pkg/api/endpoints/admin/auctions.yaml b/pkg/api/endpoints/admin/auctions.yaml new file mode 100644 index 0000000..e69de29 diff --git a/pkg/api/endpoints/admin/instruments.yaml b/pkg/api/endpoints/admin/instruments.yaml new file mode 100644 index 0000000..6adb517 --- /dev/null +++ b/pkg/api/endpoints/admin/instruments.yaml @@ -0,0 +1 @@ +post: diff --git a/pkg/api/endpoints/admin/payments.yaml b/pkg/api/endpoints/admin/payments.yaml new file mode 100644 index 0000000..da132a1 --- /dev/null +++ b/pkg/api/endpoints/admin/payments.yaml @@ -0,0 +1,16 @@ +post: + tags: + - admin + summary: Create admin payment + description: Creates a payment on user's account + operationId: createAdminPayment + + responses: + "200": + description: Success + content: + application/json: + schema: + $ref: '../../models/payment.yaml#/components/schemas/Payment' + "404": + description: Error \ No newline at end of file diff --git a/pkg/api/endpoints/admin/payments_by_id.yaml b/pkg/api/endpoints/admin/payments_by_id.yaml new file mode 100644 index 0000000..f6ed9c6 --- /dev/null +++ b/pkg/api/endpoints/admin/payments_by_id.yaml @@ -0,0 +1,22 @@ +post: + tags: + - admin + summary: Get payment + description: Returns payment information + operationId: getAdminPaymentById + parameters: + - in: path + name: payment_id + required: true + schema: + $ref: '../../models/payment.yaml#/components/schemas/PaymentId' + + responses: + "200": + description: Success + content: + application/json: + schema: + $ref: '../../models/payment.yaml#/components/schemas/Payment' + "404": + description: Error \ No newline at end of file diff --git a/pkg/api/endpoints/public/currencies.yaml b/pkg/api/endpoints/public/currencies.yaml index b30a523..cdb473c 100644 --- a/pkg/api/endpoints/public/currencies.yaml +++ b/pkg/api/endpoints/public/currencies.yaml @@ -11,5 +11,5 @@ get: application/json: schema: $ref: '../../models/currency.yaml#/components/schemas/CurrencyList' - "500": + "404": description: Error diff --git a/pkg/api/endpoints/user/book_orders.yaml b/pkg/api/endpoints/user/book_orders.yaml new file mode 100644 index 0000000..44d5e21 --- /dev/null +++ b/pkg/api/endpoints/user/book_orders.yaml @@ -0,0 +1,18 @@ +get: + tags: + - user + summary: Get book orders + description: Returns list of user's trade orders currently on the order book + operationId: getBookOrders + parameters: + - $ref: '../../models/trading_account.yaml#/components/parameters/TradingAccountId' + + responses: + "200": + description: Success + content: + application/json: + schema: + $ref: '../../models/trade_order.yaml#/components/schemas/TradeOrderList' + "404": + description: Error diff --git a/pkg/api/endpoints/user/payment_accounts.yaml b/pkg/api/endpoints/user/payment_accounts.yaml index e69de29..99c5b6e 100644 --- a/pkg/api/endpoints/user/payment_accounts.yaml +++ b/pkg/api/endpoints/user/payment_accounts.yaml @@ -0,0 +1,22 @@ +get: + tags: + - user + summary: Get payment accounts + description: Returns list of user's payment accounts + operationId: getPaymentAccounts + parameters: + - in: path + name: app_entity_id + required: true + schema: + $ref: '../../models/app_entity.yaml#/components/schemas/AppEntityId' + + responses: + "200": + description: Success + content: + application/json: + schema: + $ref: '../../models/payment_account.yaml#/components/schemas/PaymentAccountList' + "404": + description: Error diff --git a/pkg/api/endpoints/user/trade_orders.yaml b/pkg/api/endpoints/user/trade_orders.yaml index a8f66dd..ef4ec0e 100644 --- a/pkg/api/endpoints/user/trade_orders.yaml +++ b/pkg/api/endpoints/user/trade_orders.yaml @@ -2,7 +2,7 @@ get: tags: - user summary: Get trade orders - description: Returns list of user's active trade orders + description: Returns list of user's trade orders operationId: getTradeOrders parameters: - $ref: '../../models/trading_account.yaml#/components/parameters/TradingAccountId' @@ -14,7 +14,7 @@ get: application/json: schema: $ref: '../../models/trade_order.yaml#/components/schemas/TradeOrderList' - "500": + "404": description: Error post: @@ -33,5 +33,5 @@ post: application/json: schema: $ref: '../../models/trade_order.yaml#/components/schemas/TradeOrder' - "500": + "404": description: Error \ No newline at end of file diff --git a/pkg/api/endpoints/user/trades.yaml b/pkg/api/endpoints/user/trades.yaml index 29e835a..61e203a 100644 --- a/pkg/api/endpoints/user/trades.yaml +++ b/pkg/api/endpoints/user/trades.yaml @@ -1,18 +1,17 @@ get: tags: - user - summary: trades list + summary: Trades list description: Returns list of entity's trades operationId: getTrades parameters: - $ref: '../../models/trading_account.yaml#/components/parameters/TradingAccountId' - - $ref: '../../models/trade.yaml#/components/parameters/TradeId' responses: "200": - description: trades list + description: Success content: application/json: schema: $ref: '../../models/trade.yaml#/components/schemas/TradeList' - "500": + "404": description: Error diff --git a/pkg/api/endpoints/user/trades_by_id.yaml b/pkg/api/endpoints/user/trades_by_id.yaml new file mode 100644 index 0000000..eff194a --- /dev/null +++ b/pkg/api/endpoints/user/trades_by_id.yaml @@ -0,0 +1,18 @@ +get: + tags: + - user + summary: Get trade + description: Returns a trade by id + operationId: getTradeById + parameters: + - $ref: '../../models/trading_account.yaml#/components/parameters/TradingAccountId' + - $ref: '../../models/trade.yaml#/components/parameters/TradeId' + responses: + "200": + description: Success + content: + application/json: + schema: + $ref: '../../models/trade.yaml#/components/schemas/Trade' + "404": + description: Error diff --git a/pkg/api/models/payment.yaml b/pkg/api/models/payment.yaml index e69de29..49d6c65 100644 --- a/pkg/api/models/payment.yaml +++ b/pkg/api/models/payment.yaml @@ -0,0 +1,60 @@ +components: + schemas: + PaymentId: + $ref: './shared.yaml#/components/schemas/Id' + PaymentType: + type: string + enum: + - DEPOSIT + - WITHDRAWAL + - TRANSFER + - INSTRUMENT_BUY + - INSTRUMENT_SELL + - CHARGE + + PaymentDetails: + type: string + example: "Bank deposit Bank REF123456" + + PaymentExternalReferenceNumber: + type: string + example: "REF123456" + + PaymentAccountId: + $ref: './shared.yaml#/components/schemas/Id' + + Payment: + type: object + properties: + id: + $ref: "#/components/schemas/PaymentId" + type: + $ref: "#/components/schemas/PaymentType" + amount: + $ref: './shared.yaml#/components/schemas/MoneyAmount' + currency: + $ref: "./currency.yaml#/components/schemas/CurrencyName" + senderAccountId: + $ref: "#/components/schemas/PaymentAccountId" + beneficiaryAccountId: + $ref: "#/components/schemas/PaymentAccountId" + details: + $ref: "#/components/schemas/PaymentDetails" + externalReferenceNumber: + $ref: "#/components/schemas/PaymentExternalReferenceNumber" + status: + type: string + debitBalanceAmount: + $ref: './shared.yaml#/components/schemas/MoneyAmount' + creditBalanceAmount: + $ref: './shared.yaml#/components/schemas/MoneyAmount' + required: + - id + - type + - amount + - currency + - senderAccountId + - beneficiaryAccountId + - details + - externalReferenceNumber + - status diff --git a/pkg/api/models/payment_account.yaml b/pkg/api/models/payment_account.yaml index a843338..ab85126 100644 --- a/pkg/api/models/payment_account.yaml +++ b/pkg/api/models/payment_account.yaml @@ -24,4 +24,8 @@ components: currency: $ref: './currency.yaml#/components/schemas/CurrencyName' amount: - $ \ No newline at end of file + $ref: './shared.yaml#/components/schemas/MoneyAmount' + amountReserved: + $ref: './shared.yaml#/components/schemas/MoneyAmount' + amountAvailable: + $ref: './shared.yaml#/components/schemas/MoneyAmount' \ No newline at end of file diff --git a/pkg/api/models/shared.yaml b/pkg/api/models/shared.yaml index 5d85f44..316b5ae 100644 --- a/pkg/api/models/shared.yaml +++ b/pkg/api/models/shared.yaml @@ -5,6 +5,11 @@ components: format: uuid example: 29b6e916-0d74-41c3-b004-eb8373bca606 + MoneyAmount: + type: string + format: decimal + example: "100.50" + parameters: PaginationPage: name: page diff --git a/pkg/api/openapi.yaml b/pkg/api/openapi.yaml index 77bc57b..085099b 100644 --- a/pkg/api/openapi.yaml +++ b/pkg/api/openapi.yaml @@ -20,11 +20,8 @@ info: servers: - url: http://localhost:4000 -components: - securitySchemes: - basicAuth: - type: http - scheme: basic +# This API has no security +security: [] tags: - name: user @@ -48,11 +45,13 @@ paths: $ref: ./endpoints/public/order_books_by_instrument_name.yaml # USER OPERATIONS - /trades/{trading_account_id}: - $ref: ./endpoints/user/trades.yaml + /book_orders/{trading_account_id}: + $ref: ./endpoints/user/book_orders.yaml + /payment-accounts/{app_entity_id}: + $ref: ./endpoints/user/payment_accounts.yaml /trades/{trading_account_id}/id/{trade_id}: - $ref: ./endpoints/user/trades.yaml - /trades: + $ref: ./endpoints/user/trades_by_id.yaml + /trades/{trading_account_id}: $ref: ./endpoints/user/trades.yaml /trade_orders/{trading_account_id}: $ref: ./endpoints/user/trade_orders.yaml @@ -62,3 +61,9 @@ paths: $ref: ./endpoints/admin/apps_by_id.yaml /apps: $ref: ./endpoints/admin/apps.yaml + # /apps/auctions: TODO + # $ref: ./endpoints/admin/auctions.yaml + /apps/payments/{payment_id}: + $ref: ./endpoints/admin/payments_by_id.yaml + /apps/payments: + $ref: ./endpoints/admin/payments.yaml diff --git a/pkg/models/payment.go b/pkg/models/payment.go index 573e3e7..d53bbc7 100644 --- a/pkg/models/payment.go +++ b/pkg/models/payment.go @@ -23,7 +23,6 @@ type PaymentExternalReferenceNumber string type Payment struct { Id string - Number string Type PaymentType Amount PaymentAmount Currency CurrencyName @@ -34,4 +33,5 @@ type Payment struct { Status string DebitBalanceAmount string CreditBalanceAmount string + CreatedAt string } diff --git a/pkg/rest/.openapi-generator-ignore b/pkg/rest/.openapi-generator-ignore index cb49dc6..0a21b21 100644 --- a/pkg/rest/.openapi-generator-ignore +++ b/pkg/rest/.openapi-generator-ignore @@ -21,6 +21,6 @@ #docs/*.md # Then explicitly reverse the ignore rule for a single file: #!docs/README.md - -**/api_currencies_service.go -**/helpers.go \ No newline at end of file +# +#**/api_currencies_service.go +#**/helpers.go \ No newline at end of file diff --git a/pkg/rest/.openapi-generator/FILES b/pkg/rest/.openapi-generator/FILES index 3956806..66028f1 100644 --- a/pkg/rest/.openapi-generator/FILES +++ b/pkg/rest/.openapi-generator/FILES @@ -1,20 +1,27 @@ README.md api/api.go -api/api_currencies.go -api/api_instruments.go -api/api_instruments_service.go -api/api_order_books.go -api/api_order_books_service.go -api/api_trade_order.go -api/api_trade_order_service.go -api/api_trades.go -api/api_trades_service.go +api/api_admin.go +api/api_admin_service.go +api/api_public.go +api/api_public_service.go +api/api_user.go +api/api_user_service.go +api/api_users.go +api/api_users_service.go api/error.go +api/helpers.go api/impl.go api/logger.go +api/model_app_entity.go api/model_currency.go +api/model_currency_list.go +api/model_fx_instrument.go api/model_instrument.go api/model_order_book.go +api/model_payment.go +api/model_payment_account.go +api/model_payment_account_list.go +api/model_payment_type.go api/model_price_volume.go api/model_trade.go api/model_trade_order.go diff --git a/pkg/rest/README.md b/pkg/rest/README.md index fb5eff1..8beed4e 100644 --- a/pkg/rest/README.md +++ b/pkg/rest/README.md @@ -24,7 +24,7 @@ To see how to make this your own, look here: [README](https://openapi-generator.tech) - API version: 1.0.0 -- Build date: 2023-12-06T02:18:03.821281+02:00[Europe/Riga] +- Build date: 2023-12-07T01:13:40.551728+02:00[Europe/Riga] ### Running the server diff --git a/pkg/rest/api/api.go b/pkg/rest/api/api.go index 35b5a3d..0378991 100644 --- a/pkg/rest/api/api.go +++ b/pkg/rest/api/api.go @@ -14,77 +14,82 @@ import ( "net/http" ) -// CurrenciesAPIRouter defines the required methods for binding the api requests to a responses for the CurrenciesAPI -// The CurrenciesAPIRouter implementation should parse necessary information from the http request, -// pass the data to a CurrenciesAPIServicer to perform the required actions, then write the service results to the http response. -type CurrenciesAPIRouter interface { - GetCurrencies(http.ResponseWriter, *http.Request) +// AdminAPIRouter defines the required methods for binding the api requests to a responses for the AdminAPI +// The AdminAPIRouter implementation should parse necessary information from the http request, +// pass the data to a AdminAPIServicer to perform the required actions, then write the service results to the http response. +type AdminAPIRouter interface { + CreateAdminPayment(http.ResponseWriter, *http.Request) + GetAdminPaymentById(http.ResponseWriter, *http.Request) + GetAppEntities(http.ResponseWriter, *http.Request) + GetAppEntity(http.ResponseWriter, *http.Request) } -// InstrumentsAPIRouter defines the required methods for binding the api requests to a responses for the InstrumentsAPI -// The InstrumentsAPIRouter implementation should parse necessary information from the http request, -// pass the data to a InstrumentsAPIServicer to perform the required actions, then write the service results to the http response. -type InstrumentsAPIRouter interface { +// PublicAPIRouter defines the required methods for binding the api requests to a responses for the PublicAPI +// The PublicAPIRouter implementation should parse necessary information from the http request, +// pass the data to a PublicAPIServicer to perform the required actions, then write the service results to the http response. +type PublicAPIRouter interface { + GetCurrencies(http.ResponseWriter, *http.Request) + GetFxInstruments(http.ResponseWriter, *http.Request) GetInstruments(http.ResponseWriter, *http.Request) -} - -// OrderBooksAPIRouter defines the required methods for binding the api requests to a responses for the OrderBooksAPI -// The OrderBooksAPIRouter implementation should parse necessary information from the http request, -// pass the data to a OrderBooksAPIServicer to perform the required actions, then write the service results to the http response. -type OrderBooksAPIRouter interface { GetOrderBook(http.ResponseWriter, *http.Request) } -// TradeOrderAPIRouter defines the required methods for binding the api requests to a responses for the TradeOrderAPI -// The TradeOrderAPIRouter implementation should parse necessary information from the http request, -// pass the data to a TradeOrderAPIServicer to perform the required actions, then write the service results to the http response. -type TradeOrderAPIRouter interface { +// UserAPIRouter defines the required methods for binding the api requests to a responses for the UserAPI +// The UserAPIRouter implementation should parse necessary information from the http request, +// pass the data to a UserAPIServicer to perform the required actions, then write the service results to the http response. +type UserAPIRouter interface { + GetBookOrders(http.ResponseWriter, *http.Request) + GetPaymentAccounts(http.ResponseWriter, *http.Request) + GetTradeById(http.ResponseWriter, *http.Request) GetTradeOrders(http.ResponseWriter, *http.Request) -} - -// TradesAPIRouter defines the required methods for binding the api requests to a responses for the TradesAPI -// The TradesAPIRouter implementation should parse necessary information from the http request, -// pass the data to a TradesAPIServicer to perform the required actions, then write the service results to the http response. -type TradesAPIRouter interface { GetTrades(http.ResponseWriter, *http.Request) } -// CurrenciesAPIServicer defines the api actions for the CurrenciesAPI service -// This interface intended to stay up to date with the openapi yaml used to generate it, -// while the service implementation can be ignored with the .openapi-generator-ignore file -// and updated with the logic required for the API. -type CurrenciesAPIServicer interface { - GetCurrencies(context.Context) (ImplResponse, error) +// UsersAPIRouter defines the required methods for binding the api requests to a responses for the UsersAPI +// The UsersAPIRouter implementation should parse necessary information from the http request, +// pass the data to a UsersAPIServicer to perform the required actions, then write the service results to the http response. +type UsersAPIRouter interface { + CreateTrade(http.ResponseWriter, *http.Request) } -// InstrumentsAPIServicer defines the api actions for the InstrumentsAPI service +// AdminAPIServicer defines the api actions for the AdminAPI service // This interface intended to stay up to date with the openapi yaml used to generate it, // while the service implementation can be ignored with the .openapi-generator-ignore file // and updated with the logic required for the API. -type InstrumentsAPIServicer interface { - GetInstruments(context.Context) (ImplResponse, error) +type AdminAPIServicer interface { + CreateAdminPayment(context.Context) (ImplResponse, error) + GetAdminPaymentById(context.Context, interface{}) (ImplResponse, error) + GetAppEntities(context.Context) (ImplResponse, error) + GetAppEntity(context.Context, interface{}) (ImplResponse, error) } -// OrderBooksAPIServicer defines the api actions for the OrderBooksAPI service +// PublicAPIServicer defines the api actions for the PublicAPI service // This interface intended to stay up to date with the openapi yaml used to generate it, // while the service implementation can be ignored with the .openapi-generator-ignore file // and updated with the logic required for the API. -type OrderBooksAPIServicer interface { +type PublicAPIServicer interface { + GetCurrencies(context.Context) (ImplResponse, error) + GetFxInstruments(context.Context) (ImplResponse, error) + GetInstruments(context.Context) (ImplResponse, error) GetOrderBook(context.Context, interface{}) (ImplResponse, error) } -// TradeOrderAPIServicer defines the api actions for the TradeOrderAPI service +// UserAPIServicer defines the api actions for the UserAPI service // This interface intended to stay up to date with the openapi yaml used to generate it, // while the service implementation can be ignored with the .openapi-generator-ignore file // and updated with the logic required for the API. -type TradeOrderAPIServicer interface { - GetTradeOrders(context.Context) (ImplResponse, error) +type UserAPIServicer interface { + GetBookOrders(context.Context, interface{}) (ImplResponse, error) + GetPaymentAccounts(context.Context, interface{}) (ImplResponse, error) + GetTradeById(context.Context, interface{}, interface{}) (ImplResponse, error) + GetTradeOrders(context.Context, interface{}) (ImplResponse, error) + GetTrades(context.Context, interface{}) (ImplResponse, error) } -// TradesAPIServicer defines the api actions for the TradesAPI service +// UsersAPIServicer defines the api actions for the UsersAPI service // This interface intended to stay up to date with the openapi yaml used to generate it, // while the service implementation can be ignored with the .openapi-generator-ignore file // and updated with the logic required for the API. -type TradesAPIServicer interface { - GetTrades(context.Context) (ImplResponse, error) +type UsersAPIServicer interface { + CreateTrade(context.Context, interface{}) (ImplResponse, error) } diff --git a/pkg/rest/api/api_admin.go b/pkg/rest/api/api_admin.go new file mode 100644 index 0000000..412d1e3 --- /dev/null +++ b/pkg/rest/api/api_admin.go @@ -0,0 +1,125 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +import ( + "net/http" + "strings" + + "github.com/gorilla/mux" +) + +// AdminAPIController binds http requests to an api service and writes the service results to the http response +type AdminAPIController struct { + service AdminAPIServicer + errorHandler ErrorHandler +} + +// AdminAPIOption for how the controller is set up. +type AdminAPIOption func(*AdminAPIController) + +// WithAdminAPIErrorHandler inject ErrorHandler into controller +func WithAdminAPIErrorHandler(h ErrorHandler) AdminAPIOption { + return func(c *AdminAPIController) { + c.errorHandler = h + } +} + +// NewAdminAPIController creates a default api controller +func NewAdminAPIController(s AdminAPIServicer, opts ...AdminAPIOption) Router { + controller := &AdminAPIController{ + service: s, + errorHandler: DefaultErrorHandler, + } + + for _, opt := range opts { + opt(controller) + } + + return controller +} + +// Routes returns all the api routes for the AdminAPIController +func (c *AdminAPIController) Routes() Routes { + return Routes{ + "CreateAdminPayment": Route{ + strings.ToUpper("Post"), + "/apps/payments", + c.CreateAdminPayment, + }, + "GetAdminPaymentById": Route{ + strings.ToUpper("Post"), + "/apps/payments/{payment_id}", + c.GetAdminPaymentById, + }, + "GetAppEntities": Route{ + strings.ToUpper("Get"), + "/apps", + c.GetAppEntities, + }, + "GetAppEntity": Route{ + strings.ToUpper("Get"), + "/apps/{app_entity_id}", + c.GetAppEntity, + }, + } +} + +// CreateAdminPayment - Create admin payment +func (c *AdminAPIController) CreateAdminPayment(w http.ResponseWriter, r *http.Request) { + result, err := c.service.CreateAdminPayment(r.Context()) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + +// GetAdminPaymentById - Get payment +func (c *AdminAPIController) GetAdminPaymentById(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + paymentIdParam := params["payment_id"] + result, err := c.service.GetAdminPaymentById(r.Context(), paymentIdParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + +// GetAppEntities - Get application entities +func (c *AdminAPIController) GetAppEntities(w http.ResponseWriter, r *http.Request) { + result, err := c.service.GetAppEntities(r.Context()) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + +// GetAppEntity - Get application entity +func (c *AdminAPIController) GetAppEntity(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + appEntityIdParam := params["app_entity_id"] + result, err := c.service.GetAppEntity(r.Context(), appEntityIdParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} diff --git a/pkg/rest/api/api_admin_service.go b/pkg/rest/api/api_admin_service.go new file mode 100644 index 0000000..42e0e5c --- /dev/null +++ b/pkg/rest/api/api_admin_service.go @@ -0,0 +1,83 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +import ( + "context" + "errors" + "net/http" +) + +// AdminAPIService is a service that implements the logic for the AdminAPIServicer +// This service should implement the business logic for every endpoint for the AdminAPI API. +// Include any external packages or services that will be required by this service. +type AdminAPIService struct { +} + +// NewAdminAPIService creates a default api service +func NewAdminAPIService() AdminAPIServicer { + return &AdminAPIService{} +} + +// CreateAdminPayment - Create admin payment +func (s *AdminAPIService) CreateAdminPayment(ctx context.Context) (ImplResponse, error) { + // TODO - update CreateAdminPayment with the required logic for this service method. + // Add api_admin_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, Payment{}) or use other options such as http.Ok ... + // return Response(200, Payment{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("CreateAdminPayment method not implemented") +} + +// GetAdminPaymentById - Get payment +func (s *AdminAPIService) GetAdminPaymentById(ctx context.Context, paymentId interface{}) (ImplResponse, error) { + // TODO - update GetAdminPaymentById with the required logic for this service method. + // Add api_admin_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, Payment{}) or use other options such as http.Ok ... + // return Response(200, Payment{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetAdminPaymentById method not implemented") +} + +// GetAppEntities - Get application entities +func (s *AdminAPIService) GetAppEntities(ctx context.Context) (ImplResponse, error) { + // TODO - update GetAppEntities with the required logic for this service method. + // Add api_admin_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, interface{}{}) or use other options such as http.Ok ... + // return Response(200, interface{}{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetAppEntities method not implemented") +} + +// GetAppEntity - Get application entity +func (s *AdminAPIService) GetAppEntity(ctx context.Context, appEntityId interface{}) (ImplResponse, error) { + // TODO - update GetAppEntity with the required logic for this service method. + // Add api_admin_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, AppEntity{}) or use other options such as http.Ok ... + // return Response(200, AppEntity{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetAppEntity method not implemented") +} diff --git a/pkg/rest/api/api_currencies.go b/pkg/rest/api/api_currencies.go deleted file mode 100644 index 289fd84..0000000 --- a/pkg/rest/api/api_currencies.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - * OPEN OUTCRY 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. - * - * API version: 1.0.0 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - -package api - -import ( - "net/http" - "strings" -) - -// CurrenciesAPIController binds http requests to an api service and writes the service results to the http response -type CurrenciesAPIController struct { - service CurrenciesAPIServicer - errorHandler ErrorHandler -} - -// CurrenciesAPIOption for how the controller is set up. -type CurrenciesAPIOption func(*CurrenciesAPIController) - -// WithCurrenciesAPIErrorHandler inject ErrorHandler into controller -func WithCurrenciesAPIErrorHandler(h ErrorHandler) CurrenciesAPIOption { - return func(c *CurrenciesAPIController) { - c.errorHandler = h - } -} - -// NewCurrenciesAPIController creates a default api controller -func NewCurrenciesAPIController(s CurrenciesAPIServicer, opts ...CurrenciesAPIOption) Router { - controller := &CurrenciesAPIController{ - service: s, - errorHandler: DefaultErrorHandler, - } - - for _, opt := range opts { - opt(controller) - } - - return controller -} - -// Routes returns all the api routes for the CurrenciesAPIController -func (c *CurrenciesAPIController) Routes() Routes { - return Routes{ - "GetCurrencies": Route{ - strings.ToUpper("Get"), - "/currencies", - c.GetCurrencies, - }, - } -} - -// GetCurrencies - currencies list -func (c *CurrenciesAPIController) GetCurrencies(w http.ResponseWriter, r *http.Request) { - result, err := c.service.GetCurrencies(r.Context()) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) -} diff --git a/pkg/rest/api/api_currencies_service.go b/pkg/rest/api/api_currencies_service.go deleted file mode 100644 index 7b4a1b6..0000000 --- a/pkg/rest/api/api_currencies_service.go +++ /dev/null @@ -1,42 +0,0 @@ -/* - * OPEN OUTCRY 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. - * - * API version: 1.0.0 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - -package api - -import ( - "context" - "net/http" - "open-outcry/pkg/models" -) - -// CurrenciesAPIService is a service that implements the logic for the CurrenciesAPIServicer -// This service should implement the business logic for every endpoint for the CurrenciesAPI API. -// Include any external packages or services that will be required by this service. -type CurrenciesAPIService struct { -} - -// NewCurrenciesAPIService creates a default api service -func NewCurrenciesAPIService() CurrenciesAPIServicer { - return &CurrenciesAPIService{} -} - -// GetCurrencies - currencies list -func (s *CurrenciesAPIService) GetCurrencies(ctx context.Context) (ImplResponse, error) { - currencies := models.GetCurrencies() - res := make([]Currency, 0) - for _, v := range currencies { - cur := Currency{ - Name: NewInterface(v.Name), - Precision: NewInterface(v.Precision), - } - res = append(res, cur) - } - - return Response(http.StatusOK, res), nil -} diff --git a/pkg/rest/api/api_instruments.go b/pkg/rest/api/api_instruments.go deleted file mode 100644 index b499f18..0000000 --- a/pkg/rest/api/api_instruments.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - * OPEN OUTCRY 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. - * - * API version: 1.0.0 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - -package api - -import ( - "net/http" - "strings" -) - -// InstrumentsAPIController binds http requests to an api service and writes the service results to the http response -type InstrumentsAPIController struct { - service InstrumentsAPIServicer - errorHandler ErrorHandler -} - -// InstrumentsAPIOption for how the controller is set up. -type InstrumentsAPIOption func(*InstrumentsAPIController) - -// WithInstrumentsAPIErrorHandler inject ErrorHandler into controller -func WithInstrumentsAPIErrorHandler(h ErrorHandler) InstrumentsAPIOption { - return func(c *InstrumentsAPIController) { - c.errorHandler = h - } -} - -// NewInstrumentsAPIController creates a default api controller -func NewInstrumentsAPIController(s InstrumentsAPIServicer, opts ...InstrumentsAPIOption) Router { - controller := &InstrumentsAPIController{ - service: s, - errorHandler: DefaultErrorHandler, - } - - for _, opt := range opts { - opt(controller) - } - - return controller -} - -// Routes returns all the api routes for the InstrumentsAPIController -func (c *InstrumentsAPIController) Routes() Routes { - return Routes{ - "GetInstruments": Route{ - strings.ToUpper("Get"), - "/instruments", - c.GetInstruments, - }, - } -} - -// GetInstruments - instrument list -func (c *InstrumentsAPIController) GetInstruments(w http.ResponseWriter, r *http.Request) { - result, err := c.service.GetInstruments(r.Context()) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) -} diff --git a/pkg/rest/api/api_instruments_service.go b/pkg/rest/api/api_instruments_service.go deleted file mode 100644 index 2a24a1d..0000000 --- a/pkg/rest/api/api_instruments_service.go +++ /dev/null @@ -1,41 +0,0 @@ -/* - * OPEN OUTCRY 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. - * - * API version: 1.0.0 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - -package api - -import ( - "context" - "errors" - "net/http" -) - -// InstrumentsAPIService is a service that implements the logic for the InstrumentsAPIServicer -// This service should implement the business logic for every endpoint for the InstrumentsAPI API. -// Include any external packages or services that will be required by this service. -type InstrumentsAPIService struct { -} - -// NewInstrumentsAPIService creates a default api service -func NewInstrumentsAPIService() InstrumentsAPIServicer { - return &InstrumentsAPIService{} -} - -// GetInstruments - instrument list -func (s *InstrumentsAPIService) GetInstruments(ctx context.Context) (ImplResponse, error) { - // TODO - update GetInstruments with the required logic for this service method. - // Add api_instruments_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. - - // TODO: Uncomment the next line to return response Response(200, interface{}{}) or use other options such as http.Ok ... - // return Response(200, interface{}{}), nil - - // TODO: Uncomment the next line to return response Response(500, {}) or use other options such as http.Ok ... - // return Response(500, nil),nil - - return Response(http.StatusNotImplemented, nil), errors.New("GetInstruments method not implemented") -} diff --git a/pkg/rest/api/api_order_books.go b/pkg/rest/api/api_order_books.go deleted file mode 100644 index a17ac04..0000000 --- a/pkg/rest/api/api_order_books.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - * OPEN OUTCRY 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. - * - * API version: 1.0.0 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - -package api - -import ( - "net/http" - "strings" - - "github.com/gorilla/mux" -) - -// OrderBooksAPIController binds http requests to an api service and writes the service results to the http response -type OrderBooksAPIController struct { - service OrderBooksAPIServicer - errorHandler ErrorHandler -} - -// OrderBooksAPIOption for how the controller is set up. -type OrderBooksAPIOption func(*OrderBooksAPIController) - -// WithOrderBooksAPIErrorHandler inject ErrorHandler into controller -func WithOrderBooksAPIErrorHandler(h ErrorHandler) OrderBooksAPIOption { - return func(c *OrderBooksAPIController) { - c.errorHandler = h - } -} - -// NewOrderBooksAPIController creates a default api controller -func NewOrderBooksAPIController(s OrderBooksAPIServicer, opts ...OrderBooksAPIOption) Router { - controller := &OrderBooksAPIController{ - service: s, - errorHandler: DefaultErrorHandler, - } - - for _, opt := range opts { - opt(controller) - } - - return controller -} - -// Routes returns all the api routes for the OrderBooksAPIController -func (c *OrderBooksAPIController) Routes() Routes { - return Routes{ - "GetOrderBook": Route{ - strings.ToUpper("Get"), - "/order_books/{instrument_name}", - c.GetOrderBook, - }, - } -} - -// GetOrderBook - get order books -func (c *OrderBooksAPIController) GetOrderBook(w http.ResponseWriter, r *http.Request) { - params := mux.Vars(r) - instrumentNameParam := params["instrument_name"] - result, err := c.service.GetOrderBook(r.Context(), instrumentNameParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) -} diff --git a/pkg/rest/api/api_order_books_service.go b/pkg/rest/api/api_order_books_service.go deleted file mode 100644 index da44d82..0000000 --- a/pkg/rest/api/api_order_books_service.go +++ /dev/null @@ -1,41 +0,0 @@ -/* - * OPEN OUTCRY 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. - * - * API version: 1.0.0 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - -package api - -import ( - "context" - "errors" - "net/http" -) - -// OrderBooksAPIService is a service that implements the logic for the OrderBooksAPIServicer -// This service should implement the business logic for every endpoint for the OrderBooksAPI API. -// Include any external packages or services that will be required by this service. -type OrderBooksAPIService struct { -} - -// NewOrderBooksAPIService creates a default api service -func NewOrderBooksAPIService() OrderBooksAPIServicer { - return &OrderBooksAPIService{} -} - -// GetOrderBook - get order books -func (s *OrderBooksAPIService) GetOrderBook(ctx context.Context, instrumentName interface{}) (ImplResponse, error) { - // TODO - update GetOrderBook with the required logic for this service method. - // Add api_order_books_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. - - // TODO: Uncomment the next line to return response Response(200, OrderBook{}) or use other options such as http.Ok ... - // return Response(200, OrderBook{}), nil - - // TODO: Uncomment the next line to return response Response(500, {}) or use other options such as http.Ok ... - // return Response(500, nil),nil - - return Response(http.StatusNotImplemented, nil), errors.New("GetOrderBook method not implemented") -} diff --git a/pkg/rest/api/api_public.go b/pkg/rest/api/api_public.go new file mode 100644 index 0000000..83dfb44 --- /dev/null +++ b/pkg/rest/api/api_public.go @@ -0,0 +1,123 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +import ( + "net/http" + "strings" + + "github.com/gorilla/mux" +) + +// PublicAPIController binds http requests to an api service and writes the service results to the http response +type PublicAPIController struct { + service PublicAPIServicer + errorHandler ErrorHandler +} + +// PublicAPIOption for how the controller is set up. +type PublicAPIOption func(*PublicAPIController) + +// WithPublicAPIErrorHandler inject ErrorHandler into controller +func WithPublicAPIErrorHandler(h ErrorHandler) PublicAPIOption { + return func(c *PublicAPIController) { + c.errorHandler = h + } +} + +// NewPublicAPIController creates a default api controller +func NewPublicAPIController(s PublicAPIServicer, opts ...PublicAPIOption) Router { + controller := &PublicAPIController{ + service: s, + errorHandler: DefaultErrorHandler, + } + + for _, opt := range opts { + opt(controller) + } + + return controller +} + +// Routes returns all the api routes for the PublicAPIController +func (c *PublicAPIController) Routes() Routes { + return Routes{ + "GetCurrencies": Route{ + strings.ToUpper("Get"), + "/currencies", + c.GetCurrencies, + }, + "GetFxInstruments": Route{ + strings.ToUpper("Get"), + "/fxinstruments", + c.GetFxInstruments, + }, + "GetInstruments": Route{ + strings.ToUpper("Get"), + "/instruments", + c.GetInstruments, + }, + "GetOrderBook": Route{ + strings.ToUpper("Get"), + "/order_books/{instrument_name}", + c.GetOrderBook, + }, + } +} + +// GetCurrencies - Currencies list +func (c *PublicAPIController) GetCurrencies(w http.ResponseWriter, r *http.Request) { + result, err := c.service.GetCurrencies(r.Context()) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + +// GetFxInstruments - Fx instrument list +func (c *PublicAPIController) GetFxInstruments(w http.ResponseWriter, r *http.Request) { + result, err := c.service.GetFxInstruments(r.Context()) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + +// GetInstruments - Instrument list +func (c *PublicAPIController) GetInstruments(w http.ResponseWriter, r *http.Request) { + result, err := c.service.GetInstruments(r.Context()) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + +// GetOrderBook - Get order book +func (c *PublicAPIController) GetOrderBook(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + instrumentNameParam := params["instrument_name"] + result, err := c.service.GetOrderBook(r.Context(), instrumentNameParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} diff --git a/pkg/rest/api/api_public_service.go b/pkg/rest/api/api_public_service.go new file mode 100644 index 0000000..5531fd6 --- /dev/null +++ b/pkg/rest/api/api_public_service.go @@ -0,0 +1,85 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +import ( + "context" + "errors" + "net/http" + "open-outcry/pkg/models" +) + +// PublicAPIService is a service that implements the logic for the PublicAPIServicer +// This service should implement the business logic for every endpoint for the PublicAPI API. +// Include any external packages or services that will be required by this service. +type PublicAPIService struct { +} + +// NewPublicAPIService creates a default api service +func NewPublicAPIService() PublicAPIServicer { + return &PublicAPIService{} +} + +// GetCurrencies - Currencies list +func (s *PublicAPIService) GetCurrencies(ctx context.Context) (ImplResponse, error) { + currencies := models.GetCurrencies() + res := make([]Currency, 0) + for _, v := range currencies { + cur := Currency{ + Name: NewInterface(v.Name), + Precision: NewInterface(v.Precision), + } + res = append(res, cur) + } + + return Response(http.StatusOK, res), nil +} + +// GetFxInstruments - Fx instrument list +func (s *PublicAPIService) GetFxInstruments(ctx context.Context) (ImplResponse, error) { + // TODO - update GetFxInstruments with the required logic for this service method. + // Add api_public_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, interface{}{}) or use other options such as http.Ok ... + // return Response(200, interface{}{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetFxInstruments method not implemented") +} + +// GetInstruments - Instrument list +func (s *PublicAPIService) GetInstruments(ctx context.Context) (ImplResponse, error) { + // TODO - update GetInstruments with the required logic for this service method. + // Add api_public_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, interface{}{}) or use other options such as http.Ok ... + // return Response(200, interface{}{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetInstruments method not implemented") +} + +// GetOrderBook - Get order book +func (s *PublicAPIService) GetOrderBook(ctx context.Context, instrumentName interface{}) (ImplResponse, error) { + // TODO - update GetOrderBook with the required logic for this service method. + // Add api_public_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, OrderBook{}) or use other options such as http.Ok ... + // return Response(200, OrderBook{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetOrderBook method not implemented") +} diff --git a/pkg/rest/api/api_trade_order.go b/pkg/rest/api/api_trade_order.go deleted file mode 100644 index 2fbe4ba..0000000 --- a/pkg/rest/api/api_trade_order.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - * OPEN OUTCRY 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. - * - * API version: 1.0.0 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - -package api - -import ( - "net/http" - "strings" -) - -// TradeOrderAPIController binds http requests to an api service and writes the service results to the http response -type TradeOrderAPIController struct { - service TradeOrderAPIServicer - errorHandler ErrorHandler -} - -// TradeOrderAPIOption for how the controller is set up. -type TradeOrderAPIOption func(*TradeOrderAPIController) - -// WithTradeOrderAPIErrorHandler inject ErrorHandler into controller -func WithTradeOrderAPIErrorHandler(h ErrorHandler) TradeOrderAPIOption { - return func(c *TradeOrderAPIController) { - c.errorHandler = h - } -} - -// NewTradeOrderAPIController creates a default api controller -func NewTradeOrderAPIController(s TradeOrderAPIServicer, opts ...TradeOrderAPIOption) Router { - controller := &TradeOrderAPIController{ - service: s, - errorHandler: DefaultErrorHandler, - } - - for _, opt := range opts { - opt(controller) - } - - return controller -} - -// Routes returns all the api routes for the TradeOrderAPIController -func (c *TradeOrderAPIController) Routes() Routes { - return Routes{ - "GetTradeOrders": Route{ - strings.ToUpper("Get"), - "/trade_orders", - c.GetTradeOrders, - }, - } -} - -// GetTradeOrders - trade order list -func (c *TradeOrderAPIController) GetTradeOrders(w http.ResponseWriter, r *http.Request) { - result, err := c.service.GetTradeOrders(r.Context()) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) -} diff --git a/pkg/rest/api/api_trade_order_service.go b/pkg/rest/api/api_trade_order_service.go deleted file mode 100644 index d0ea70b..0000000 --- a/pkg/rest/api/api_trade_order_service.go +++ /dev/null @@ -1,41 +0,0 @@ -/* - * OPEN OUTCRY 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. - * - * API version: 1.0.0 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - -package api - -import ( - "context" - "errors" - "net/http" -) - -// TradeOrderAPIService is a service that implements the logic for the TradeOrderAPIServicer -// This service should implement the business logic for every endpoint for the TradeOrderAPI API. -// Include any external packages or services that will be required by this service. -type TradeOrderAPIService struct { -} - -// NewTradeOrderAPIService creates a default api service -func NewTradeOrderAPIService() TradeOrderAPIServicer { - return &TradeOrderAPIService{} -} - -// GetTradeOrders - trade order list -func (s *TradeOrderAPIService) GetTradeOrders(ctx context.Context) (ImplResponse, error) { - // TODO - update GetTradeOrders with the required logic for this service method. - // Add api_trade_order_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. - - // TODO: Uncomment the next line to return response Response(200, interface{}{}) or use other options such as http.Ok ... - // return Response(200, interface{}{}), nil - - // TODO: Uncomment the next line to return response Response(500, {}) or use other options such as http.Ok ... - // return Response(500, nil),nil - - return Response(http.StatusNotImplemented, nil), errors.New("GetTradeOrders method not implemented") -} diff --git a/pkg/rest/api/api_trades.go b/pkg/rest/api/api_trades.go deleted file mode 100644 index 623cb70..0000000 --- a/pkg/rest/api/api_trades.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - * OPEN OUTCRY 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. - * - * API version: 1.0.0 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - -package api - -import ( - "net/http" - "strings" -) - -// TradesAPIController binds http requests to an api service and writes the service results to the http response -type TradesAPIController struct { - service TradesAPIServicer - errorHandler ErrorHandler -} - -// TradesAPIOption for how the controller is set up. -type TradesAPIOption func(*TradesAPIController) - -// WithTradesAPIErrorHandler inject ErrorHandler into controller -func WithTradesAPIErrorHandler(h ErrorHandler) TradesAPIOption { - return func(c *TradesAPIController) { - c.errorHandler = h - } -} - -// NewTradesAPIController creates a default api controller -func NewTradesAPIController(s TradesAPIServicer, opts ...TradesAPIOption) Router { - controller := &TradesAPIController{ - service: s, - errorHandler: DefaultErrorHandler, - } - - for _, opt := range opts { - opt(controller) - } - - return controller -} - -// Routes returns all the api routes for the TradesAPIController -func (c *TradesAPIController) Routes() Routes { - return Routes{ - "GetTrades": Route{ - strings.ToUpper("Get"), - "/trades", - c.GetTrades, - }, - } -} - -// GetTrades - trades list -func (c *TradesAPIController) GetTrades(w http.ResponseWriter, r *http.Request) { - result, err := c.service.GetTrades(r.Context()) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) -} diff --git a/pkg/rest/api/api_trades_service.go b/pkg/rest/api/api_trades_service.go deleted file mode 100644 index f3755ea..0000000 --- a/pkg/rest/api/api_trades_service.go +++ /dev/null @@ -1,41 +0,0 @@ -/* - * OPEN OUTCRY 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. - * - * API version: 1.0.0 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - -package api - -import ( - "context" - "errors" - "net/http" -) - -// TradesAPIService is a service that implements the logic for the TradesAPIServicer -// This service should implement the business logic for every endpoint for the TradesAPI API. -// Include any external packages or services that will be required by this service. -type TradesAPIService struct { -} - -// NewTradesAPIService creates a default api service -func NewTradesAPIService() TradesAPIServicer { - return &TradesAPIService{} -} - -// GetTrades - trades list -func (s *TradesAPIService) GetTrades(ctx context.Context) (ImplResponse, error) { - // TODO - update GetTrades with the required logic for this service method. - // Add api_trades_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. - - // TODO: Uncomment the next line to return response Response(200, interface{}{}) or use other options such as http.Ok ... - // return Response(200, interface{}{}), nil - - // TODO: Uncomment the next line to return response Response(500, {}) or use other options such as http.Ok ... - // return Response(500, nil),nil - - return Response(http.StatusNotImplemented, nil), errors.New("GetTrades method not implemented") -} diff --git a/pkg/rest/api/api_user.go b/pkg/rest/api/api_user.go new file mode 100644 index 0000000..100eab3 --- /dev/null +++ b/pkg/rest/api/api_user.go @@ -0,0 +1,149 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +import ( + "net/http" + "strings" + + "github.com/gorilla/mux" +) + +// UserAPIController binds http requests to an api service and writes the service results to the http response +type UserAPIController struct { + service UserAPIServicer + errorHandler ErrorHandler +} + +// UserAPIOption for how the controller is set up. +type UserAPIOption func(*UserAPIController) + +// WithUserAPIErrorHandler inject ErrorHandler into controller +func WithUserAPIErrorHandler(h ErrorHandler) UserAPIOption { + return func(c *UserAPIController) { + c.errorHandler = h + } +} + +// NewUserAPIController creates a default api controller +func NewUserAPIController(s UserAPIServicer, opts ...UserAPIOption) Router { + controller := &UserAPIController{ + service: s, + errorHandler: DefaultErrorHandler, + } + + for _, opt := range opts { + opt(controller) + } + + return controller +} + +// Routes returns all the api routes for the UserAPIController +func (c *UserAPIController) Routes() Routes { + return Routes{ + "GetBookOrders": Route{ + strings.ToUpper("Get"), + "/book_orders/{trading_account_id}", + c.GetBookOrders, + }, + "GetPaymentAccounts": Route{ + strings.ToUpper("Get"), + "/payment-accounts/{app_entity_id}", + c.GetPaymentAccounts, + }, + "GetTradeById": Route{ + strings.ToUpper("Get"), + "/trades/{trading_account_id}/id/{trade_id}", + c.GetTradeById, + }, + "GetTradeOrders": Route{ + strings.ToUpper("Get"), + "/trade_orders/{trading_account_id}", + c.GetTradeOrders, + }, + "GetTrades": Route{ + strings.ToUpper("Get"), + "/trades/{trading_account_id}", + c.GetTrades, + }, + } +} + +// GetBookOrders - Get book orders +func (c *UserAPIController) GetBookOrders(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + tradingAccountIdParam := params["trading_account_id"] + result, err := c.service.GetBookOrders(r.Context(), tradingAccountIdParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + +// GetPaymentAccounts - Get payment accounts +func (c *UserAPIController) GetPaymentAccounts(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + appEntityIdParam := params["app_entity_id"] + result, err := c.service.GetPaymentAccounts(r.Context(), appEntityIdParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + +// GetTradeById - Get trade +func (c *UserAPIController) GetTradeById(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + tradingAccountIdParam := params["trading_account_id"] + tradeIdParam := params["trade_id"] + result, err := c.service.GetTradeById(r.Context(), tradingAccountIdParam, tradeIdParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + +// GetTradeOrders - Get trade orders +func (c *UserAPIController) GetTradeOrders(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + tradingAccountIdParam := params["trading_account_id"] + result, err := c.service.GetTradeOrders(r.Context(), tradingAccountIdParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + +// GetTrades - Trades list +func (c *UserAPIController) GetTrades(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + tradingAccountIdParam := params["trading_account_id"] + result, err := c.service.GetTrades(r.Context(), tradingAccountIdParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} diff --git a/pkg/rest/api/api_user_service.go b/pkg/rest/api/api_user_service.go new file mode 100644 index 0000000..69d460d --- /dev/null +++ b/pkg/rest/api/api_user_service.go @@ -0,0 +1,97 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +import ( + "context" + "errors" + "net/http" +) + +// UserAPIService is a service that implements the logic for the UserAPIServicer +// This service should implement the business logic for every endpoint for the UserAPI API. +// Include any external packages or services that will be required by this service. +type UserAPIService struct { +} + +// NewUserAPIService creates a default api service +func NewUserAPIService() UserAPIServicer { + return &UserAPIService{} +} + +// GetBookOrders - Get book orders +func (s *UserAPIService) GetBookOrders(ctx context.Context, tradingAccountId interface{}) (ImplResponse, error) { + // TODO - update GetBookOrders with the required logic for this service method. + // Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, interface{}{}) or use other options such as http.Ok ... + // return Response(200, interface{}{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetBookOrders method not implemented") +} + +// GetPaymentAccounts - Get payment accounts +func (s *UserAPIService) GetPaymentAccounts(ctx context.Context, appEntityId interface{}) (ImplResponse, error) { + // TODO - update GetPaymentAccounts with the required logic for this service method. + // Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, PaymentAccountList{}) or use other options such as http.Ok ... + // return Response(200, PaymentAccountList{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetPaymentAccounts method not implemented") +} + +// GetTradeById - Get trade +func (s *UserAPIService) GetTradeById(ctx context.Context, tradingAccountId interface{}, tradeId interface{}) (ImplResponse, error) { + // TODO - update GetTradeById with the required logic for this service method. + // Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, Trade{}) or use other options such as http.Ok ... + // return Response(200, Trade{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetTradeById method not implemented") +} + +// GetTradeOrders - Get trade orders +func (s *UserAPIService) GetTradeOrders(ctx context.Context, tradingAccountId interface{}) (ImplResponse, error) { + // TODO - update GetTradeOrders with the required logic for this service method. + // Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, interface{}{}) or use other options such as http.Ok ... + // return Response(200, interface{}{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetTradeOrders method not implemented") +} + +// GetTrades - Trades list +func (s *UserAPIService) GetTrades(ctx context.Context, tradingAccountId interface{}) (ImplResponse, error) { + // TODO - update GetTrades with the required logic for this service method. + // Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, interface{}{}) or use other options such as http.Ok ... + // return Response(200, interface{}{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetTrades method not implemented") +} diff --git a/pkg/rest/api/api_users.go b/pkg/rest/api/api_users.go new file mode 100644 index 0000000..78c5f95 --- /dev/null +++ b/pkg/rest/api/api_users.go @@ -0,0 +1,72 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +import ( + "net/http" + "strings" + + "github.com/gorilla/mux" +) + +// UsersAPIController binds http requests to an api service and writes the service results to the http response +type UsersAPIController struct { + service UsersAPIServicer + errorHandler ErrorHandler +} + +// UsersAPIOption for how the controller is set up. +type UsersAPIOption func(*UsersAPIController) + +// WithUsersAPIErrorHandler inject ErrorHandler into controller +func WithUsersAPIErrorHandler(h ErrorHandler) UsersAPIOption { + return func(c *UsersAPIController) { + c.errorHandler = h + } +} + +// NewUsersAPIController creates a default api controller +func NewUsersAPIController(s UsersAPIServicer, opts ...UsersAPIOption) Router { + controller := &UsersAPIController{ + service: s, + errorHandler: DefaultErrorHandler, + } + + for _, opt := range opts { + opt(controller) + } + + return controller +} + +// Routes returns all the api routes for the UsersAPIController +func (c *UsersAPIController) Routes() Routes { + return Routes{ + "CreateTrade": Route{ + strings.ToUpper("Post"), + "/trade_orders/{trading_account_id}", + c.CreateTrade, + }, + } +} + +// CreateTrade - Create trade order +func (c *UsersAPIController) CreateTrade(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + tradingAccountIdParam := params["trading_account_id"] + result, err := c.service.CreateTrade(r.Context(), tradingAccountIdParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} diff --git a/pkg/rest/api/api_users_service.go b/pkg/rest/api/api_users_service.go new file mode 100644 index 0000000..d3ed2af --- /dev/null +++ b/pkg/rest/api/api_users_service.go @@ -0,0 +1,41 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +import ( + "context" + "errors" + "net/http" +) + +// UsersAPIService is a service that implements the logic for the UsersAPIServicer +// This service should implement the business logic for every endpoint for the UsersAPI API. +// Include any external packages or services that will be required by this service. +type UsersAPIService struct { +} + +// NewUsersAPIService creates a default api service +func NewUsersAPIService() UsersAPIServicer { + return &UsersAPIService{} +} + +// CreateTrade - Create trade order +func (s *UsersAPIService) CreateTrade(ctx context.Context, tradingAccountId interface{}) (ImplResponse, error) { + // TODO - update CreateTrade with the required logic for this service method. + // Add api_users_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, TradeOrder{}) or use other options such as http.Ok ... + // return Response(200, TradeOrder{}), nil + + // TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... + // return Response(404, nil),nil + + return Response(http.StatusNotImplemented, nil), errors.New("CreateTrade method not implemented") +} diff --git a/pkg/rest/api/helpers.go b/pkg/rest/api/helpers.go index ae5631c..7b296b7 100644 --- a/pkg/rest/api/helpers.go +++ b/pkg/rest/api/helpers.go @@ -58,9 +58,3 @@ func AssertRecurseValueRequired[T any](value reflect.Value, callback func(T) err } return nil } - -// NewInterface creates a new empty interface with a given value. -func NewInterface(value interface{}) *interface{} { - v := value - return &v -} diff --git a/pkg/rest/api/model_get_order_book_200_response.go b/pkg/rest/api/model_app_entity.go similarity index 50% rename from pkg/rest/api/model_get_order_book_200_response.go rename to pkg/rest/api/model_app_entity.go index 6ca8984..727d50c 100644 --- a/pkg/rest/api/model_get_order_book_200_response.go +++ b/pkg/rest/api/model_app_entity.go @@ -9,18 +9,20 @@ package api -type GetOrderBook200Response struct { - Sell *interface{} `json:"sell,omitempty"` +// AppEntity - Registered user +type AppEntity struct { + Id *interface{} `json:"id,omitempty"` - Buy *interface{} `json:"buy,omitempty"` + // External id + ExternalId *interface{} `json:"external_id,omitempty"` } -// AssertGetOrderBook200ResponseRequired checks if the required fields are not zero-ed -func AssertGetOrderBook200ResponseRequired(obj GetOrderBook200Response) error { +// AssertAppEntityRequired checks if the required fields are not zero-ed +func AssertAppEntityRequired(obj AppEntity) error { return nil } -// AssertGetOrderBook200ResponseConstraints checks if the values respects the defined constraints -func AssertGetOrderBook200ResponseConstraints(obj GetOrderBook200Response) error { +// AssertAppEntityConstraints checks if the values respects the defined constraints +func AssertAppEntityConstraints(obj AppEntity) error { return nil } diff --git a/pkg/rest/api/model_currency_list.go b/pkg/rest/api/model_currency_list.go new file mode 100644 index 0000000..972ab5f --- /dev/null +++ b/pkg/rest/api/model_currency_list.go @@ -0,0 +1,25 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +// CurrencyList - List of currencies supported by app +type CurrencyList struct { + Data *interface{} `json:"data,omitempty"` +} + +// AssertCurrencyListRequired checks if the required fields are not zero-ed +func AssertCurrencyListRequired(obj CurrencyList) error { + return nil +} + +// AssertCurrencyListConstraints checks if the values respects the defined constraints +func AssertCurrencyListConstraints(obj CurrencyList) error { + return nil +} diff --git a/pkg/rest/api/model_fx_instrument.go b/pkg/rest/api/model_fx_instrument.go new file mode 100644 index 0000000..d4bdb13 --- /dev/null +++ b/pkg/rest/api/model_fx_instrument.go @@ -0,0 +1,36 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +type FxInstrument struct { + Id *interface{} `json:"id,omitempty"` + + // Ticker-like name of the instrument. For monetary instruments, a currency pair is used. + Name *interface{} `json:"name,omitempty"` + + // ISO 4217 Currency symbol + QuoteCurrency *interface{} `json:"quote_currency,omitempty"` + + // Availability for trading + Enabled *interface{} `json:"enabled,omitempty"` + + // ISO 4217 Currency symbol + BaseCurrency *interface{} `json:"base_currency,omitempty"` +} + +// AssertFxInstrumentRequired checks if the required fields are not zero-ed +func AssertFxInstrumentRequired(obj FxInstrument) error { + return nil +} + +// AssertFxInstrumentConstraints checks if the values respects the defined constraints +func AssertFxInstrumentConstraints(obj FxInstrument) error { + return nil +} diff --git a/pkg/rest/api/model_instrument.go b/pkg/rest/api/model_instrument.go index 84ea436..0f2115c 100644 --- a/pkg/rest/api/model_instrument.go +++ b/pkg/rest/api/model_instrument.go @@ -15,9 +15,6 @@ type Instrument struct { // Ticker-like name of the instrument. For monetary instruments, a currency pair is used. Name *interface{} `json:"name,omitempty"` - // ISO 4217 Currency symbol - BaseCurrency *interface{} `json:"base_currency,omitempty"` - // ISO 4217 Currency symbol QuoteCurrency *interface{} `json:"quote_currency,omitempty"` diff --git a/pkg/rest/api/model_payment.go b/pkg/rest/api/model_payment.go new file mode 100644 index 0000000..b4f230d --- /dev/null +++ b/pkg/rest/api/model_payment.go @@ -0,0 +1,62 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +type Payment struct { + Id *interface{} `json:"id"` + + Type PaymentType `json:"type"` + + Amount *interface{} `json:"amount"` + + // ISO 4217 Currency symbol + Currency *interface{} `json:"currency"` + + SenderAccountId *interface{} `json:"senderAccountId"` + + BeneficiaryAccountId *interface{} `json:"beneficiaryAccountId"` + + Details *interface{} `json:"details"` + + ExternalReferenceNumber *interface{} `json:"externalReferenceNumber"` + + Status *interface{} `json:"status"` + + DebitBalanceAmount *interface{} `json:"debitBalanceAmount,omitempty"` + + CreditBalanceAmount *interface{} `json:"creditBalanceAmount,omitempty"` +} + +// AssertPaymentRequired checks if the required fields are not zero-ed +func AssertPaymentRequired(obj Payment) error { + elements := map[string]interface{}{ + "id": obj.Id, + "type": obj.Type, + "amount": obj.Amount, + "currency": obj.Currency, + "senderAccountId": obj.SenderAccountId, + "beneficiaryAccountId": obj.BeneficiaryAccountId, + "details": obj.Details, + "externalReferenceNumber": obj.ExternalReferenceNumber, + "status": obj.Status, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + + return nil +} + +// AssertPaymentConstraints checks if the values respects the defined constraints +func AssertPaymentConstraints(obj Payment) error { + return nil +} diff --git a/pkg/rest/api/model_payment_account.go b/pkg/rest/api/model_payment_account.go new file mode 100644 index 0000000..474ce9d --- /dev/null +++ b/pkg/rest/api/model_payment_account.go @@ -0,0 +1,34 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +// PaymentAccount - Payment account available to user +type PaymentAccount struct { + Id *interface{} `json:"id,omitempty"` + + // ISO 4217 Currency symbol + Currency *interface{} `json:"currency,omitempty"` + + Amount *interface{} `json:"amount,omitempty"` + + AmountReserved *interface{} `json:"amountReserved,omitempty"` + + AmountAvailable *interface{} `json:"amountAvailable,omitempty"` +} + +// AssertPaymentAccountRequired checks if the required fields are not zero-ed +func AssertPaymentAccountRequired(obj PaymentAccount) error { + return nil +} + +// AssertPaymentAccountConstraints checks if the values respects the defined constraints +func AssertPaymentAccountConstraints(obj PaymentAccount) error { + return nil +} diff --git a/pkg/rest/api/model_payment_account_list.go b/pkg/rest/api/model_payment_account_list.go new file mode 100644 index 0000000..1cdf203 --- /dev/null +++ b/pkg/rest/api/model_payment_account_list.go @@ -0,0 +1,25 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +// PaymentAccountList - List of payment accounts available to user +type PaymentAccountList struct { + Data *interface{} `json:"data,omitempty"` +} + +// AssertPaymentAccountListRequired checks if the required fields are not zero-ed +func AssertPaymentAccountListRequired(obj PaymentAccountList) error { + return nil +} + +// AssertPaymentAccountListConstraints checks if the values respects the defined constraints +func AssertPaymentAccountListConstraints(obj PaymentAccountList) error { + return nil +} diff --git a/pkg/rest/api/model_payment_type.go b/pkg/rest/api/model_payment_type.go new file mode 100644 index 0000000..031870e --- /dev/null +++ b/pkg/rest/api/model_payment_type.go @@ -0,0 +1,23 @@ +/* + * OPEN OUTCRY 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. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +type PaymentType struct { +} + +// AssertPaymentTypeRequired checks if the required fields are not zero-ed +func AssertPaymentTypeRequired(obj PaymentType) error { + return nil +} + +// AssertPaymentTypeConstraints checks if the values respects the defined constraints +func AssertPaymentTypeConstraints(obj PaymentType) error { + return nil +} diff --git a/pkg/rest/api/model_trade.go b/pkg/rest/api/model_trade.go index 51de752..1c35b8d 100644 --- a/pkg/rest/api/model_trade.go +++ b/pkg/rest/api/model_trade.go @@ -9,7 +9,7 @@ package api -// Trade - Execute trade +// Trade - Executed trade type Trade struct { Id *interface{} `json:"id,omitempty"` } diff --git a/pkg/rest/api/openapi.yaml b/pkg/rest/api/openapi.yaml index 9750da1..f196122 100644 --- a/pkg/rest/api/openapi.yaml +++ b/pkg/rest/api/openapi.yaml @@ -16,8 +16,13 @@ info: version: 1.0.0 servers: - url: http://localhost:4000 -security: -- basicAuth: [] +tags: +- description: User facing resources for management by a specific user of their accounts + name: user +- description: Public facing resources pertaining to exchange in general + name: public +- description: Admin facing resources for exchange management + name: admin paths: /currencies: get: @@ -29,12 +34,28 @@ paths: application/json: schema: $ref: '#/components/schemas/CurrencyList' - description: currencies list - "500": + description: Success + "404": description: Error - summary: currencies list + summary: Currencies list tags: - - currencies + - public + /fxinstruments: + get: + description: Returns list of available fx instruments + operationId: getFxInstruments + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/FxInstrumentList' + description: Success + "404": + description: Not found + summary: Fx instrument list + tags: + - public /instruments: get: description: Returns list of available instruments @@ -45,15 +66,15 @@ paths: application/json: schema: $ref: '#/components/schemas/InstrumentList' - description: instruments list - "500": - description: Error - summary: instrument list + description: Success + "404": + description: Not found + summary: Instrument list tags: - - instruments + - public /order_books/{instrument_name}: get: - description: Return an order book for an instrument + description: Returns an order book for an specific instrument operationId: getOrderBook parameters: - explode: false @@ -70,44 +91,223 @@ paths: schema: $ref: '#/components/schemas/OrderBook' description: order book - "500": + "404": + description: Order book not found for instrument + summary: Get order book + tags: + - public + /book_orders/{trading_account_id}: + get: + description: Returns list of user's trade orders currently on the order book + operationId: getBookOrders + parameters: + - $ref: '#/components/parameters/TradingAccountId' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/TradeOrderList' + description: Success + "404": + description: Error + summary: Get book orders + tags: + - user + /payment-accounts/{app_entity_id}: + get: + description: Returns list of user's payment accounts + operationId: getPaymentAccounts + parameters: + - explode: false + in: path + name: app_entity_id + required: true + schema: + $ref: '#/components/schemas/Id' + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/PaymentAccountList' + description: Success + "404": description: Error - summary: get order books + summary: Get payment accounts tags: - - order_books - /trades: + - user + /trades/{trading_account_id}/id/{trade_id}: get: - description: Returns list of user's trades + description: Returns a trade by id + operationId: getTradeById + parameters: + - $ref: '#/components/parameters/TradingAccountId' + - $ref: '#/components/parameters/TradeId' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Trade' + description: Success + "404": + description: Error + summary: Get trade + tags: + - user + /trades/{trading_account_id}: + get: + description: Returns list of entity's trades operationId: getTrades + parameters: + - $ref: '#/components/parameters/TradingAccountId' responses: "200": content: application/json: schema: $ref: '#/components/schemas/TradeList' - description: trades list - "500": + description: Success + "404": description: Error - summary: trades list + summary: Trades list tags: - - trades - /trade_orders: + - user + /trade_orders/{trading_account_id}: get: - description: Returns list of user's active trade orders + description: Returns list of user's trade orders operationId: getTradeOrders + parameters: + - $ref: '#/components/parameters/TradingAccountId' responses: "200": content: application/json: schema: $ref: '#/components/schemas/TradeOrderList' - description: trades orders list - "500": + description: Success + "404": + description: Error + summary: Get trade orders + tags: + - user + post: + description: Creates a trade order + operationId: createTrade + parameters: + - $ref: '#/components/parameters/TradingAccountId' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/TradeOrder' + description: Success + "404": + description: Error + summary: Create trade order + tags: + - users + /apps/{app_entity_id}: + get: + description: Return registered user by external id + operationId: getAppEntity + parameters: + - explode: false + in: path + name: app_entity_id + required: true + schema: + $ref: '#/components/schemas/Id' + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/AppEntity' + description: Success + "404": + description: Error + summary: Get application entity + tags: + - admin + /apps: + get: + description: Return a list of registered users + operationId: getAppEntities + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/AppEntityList' + description: Success + "404": + description: Error + summary: Get application entities + tags: + - admin + /apps/payments/{payment_id}: + post: + description: Returns payment information + operationId: getAdminPaymentById + parameters: + - explode: false + in: path + name: payment_id + required: true + schema: + $ref: '#/components/schemas/Id' + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Payment' + description: Success + "404": description: Error - summary: trade order list + summary: Get payment tags: - - trade_order + - admin + /apps/payments: + post: + description: Creates a payment on user's account + operationId: createAdminPayment + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Payment' + description: Success + "404": + description: Error + summary: Create admin payment + tags: + - admin components: + parameters: + TradingAccountId: + explode: false + in: path + name: trading_account_id + required: true + schema: + $ref: '#/components/schemas/Id' + style: simple + TradeId: + explode: false + in: path + name: trade_id + required: true + schema: + $ref: '#/components/schemas/Id' + style: simple schemas: CurrencyName: description: ISO 4217 Currency symbol @@ -123,35 +323,71 @@ components: example: 2 CurrencyList: description: List of currencies supported by app - items: - $ref: '#/components/schemas/Currency' + example: + data: + - name: USD + precision: 2 + - name: BTC + precision: 5 + properties: + data: + items: + $ref: '#/components/schemas/Currency' Id: + example: 29b6e916-0d74-41c3-b004-eb8373bca606 format: uuid InstrumentName: description: "Ticker-like name of the instrument. For monetary instruments,\ \ a currency pair is used." - Instrument: + example: BTC-EUR + InstrumentAvailability: + description: Availability for trading + example: true + FxInstrument: properties: id: + example: 29b6e916-0d74-41c3-b004-eb8373bca606 format: uuid name: description: "Ticker-like name of the instrument. For monetary instruments,\ \ a currency pair is used." + example: BTC-EUR + quote_currency: + description: ISO 4217 Currency symbol + example: USD + enabled: + description: Availability for trading + example: true base_currency: description: ISO 4217 Currency symbol example: USD + FxInstrumentList: + items: + $ref: '#/components/schemas/FxInstrument' + Instrument: + properties: + id: + example: 29b6e916-0d74-41c3-b004-eb8373bca606 + format: uuid + name: + description: "Ticker-like name of the instrument. For monetary instruments,\ + \ a currency pair is used." + example: BTC-EUR quote_currency: description: ISO 4217 Currency symbol example: USD enabled: description: Availability for trading + example: true InstrumentList: items: $ref: '#/components/schemas/Instrument' PriceVolume: properties: - price: {} - volume: {} + price: + example: 120 + volume: + example: 80 OrderBook: example: sell: "" @@ -163,15 +399,6 @@ components: buy: items: $ref: '#/components/schemas/PriceVolume' - Trade: - description: Execute trade - properties: - id: - format: uuid - TradeList: - description: List of executed trades - items: - $ref: '#/components/schemas/Trade' TradeOrderSide: enum: - SELL @@ -189,12 +416,20 @@ components: - REJECTED - CANCELLED TradeOrder: + example: + side: null + instrument: BTC-EUR + id: 29b6e916-0d74-41c3-b004-eb8373bca606 + timeInForce: null + status: null properties: id: + example: 29b6e916-0d74-41c3-b004-eb8373bca606 format: uuid instrument: description: "Ticker-like name of the instrument. For monetary instruments,\ \ a currency pair is used." + example: BTC-EUR side: $ref: '#/components/schemas/TradeOrderSide' timeInForce: @@ -204,7 +439,129 @@ components: TradeOrderList: items: $ref: '#/components/schemas/TradeOrder' - securitySchemes: - basicAuth: - scheme: basic - type: http + MoneyAmount: + example: "100.50" + format: decimal + PaymentAccount: + description: Payment account available to user + properties: + id: + example: 29b6e916-0d74-41c3-b004-eb8373bca606 + format: uuid + currency: + description: ISO 4217 Currency symbol + example: USD + amount: + example: "100.50" + format: decimal + amountReserved: + example: "100.50" + format: decimal + amountAvailable: + example: "100.50" + format: decimal + PaymentAccountList: + description: List of payment accounts available to user + example: + data: + - name: USD + precision: 2 + - name: BTC + precision: 5 + properties: + data: + items: + $ref: '#/components/schemas/PaymentAccount' + Trade: + description: Executed trade + example: + id: 29b6e916-0d74-41c3-b004-eb8373bca606 + properties: + id: + example: 29b6e916-0d74-41c3-b004-eb8373bca606 + format: uuid + TradeList: + description: List of executed trades + items: + $ref: '#/components/schemas/Trade' + AppEntityExternalId: + description: External id + AppEntity: + description: Registered user + example: + external_id: "" + id: 29b6e916-0d74-41c3-b004-eb8373bca606 + properties: + id: + example: 29b6e916-0d74-41c3-b004-eb8373bca606 + format: uuid + external_id: + description: External id + AppEntityList: + description: List of registered users + items: + $ref: '#/components/schemas/AppEntity' + PaymentType: + enum: + - DEPOSIT + - WITHDRAWAL + - TRANSFER + - INSTRUMENT_BUY + - INSTRUMENT_SELL + - CHARGE + PaymentDetails: + example: Bank deposit Bank REF123456 + PaymentExternalReferenceNumber: + example: REF123456 + Payment: + example: + amount: "100.50" + debitBalanceAmount: "100.50" + creditBalanceAmount: "100.50" + currency: USD + beneficiaryAccountId: 29b6e916-0d74-41c3-b004-eb8373bca606 + details: Bank deposit Bank REF123456 + externalReferenceNumber: REF123456 + id: 29b6e916-0d74-41c3-b004-eb8373bca606 + type: null + senderAccountId: 29b6e916-0d74-41c3-b004-eb8373bca606 + status: "" + properties: + id: + example: 29b6e916-0d74-41c3-b004-eb8373bca606 + format: uuid + type: + $ref: '#/components/schemas/PaymentType' + amount: + example: "100.50" + format: decimal + currency: + description: ISO 4217 Currency symbol + example: USD + senderAccountId: + example: 29b6e916-0d74-41c3-b004-eb8373bca606 + format: uuid + beneficiaryAccountId: + example: 29b6e916-0d74-41c3-b004-eb8373bca606 + format: uuid + details: + example: Bank deposit Bank REF123456 + externalReferenceNumber: + example: REF123456 + status: {} + debitBalanceAmount: + example: "100.50" + format: decimal + creditBalanceAmount: + example: "100.50" + format: decimal + required: + - amount + - beneficiaryAccountId + - currency + - details + - externalReferenceNumber + - id + - senderAccountId + - status + - type diff --git a/pkg/rest/api/utils.go b/pkg/rest/api/utils.go new file mode 100644 index 0000000..d141742 --- /dev/null +++ b/pkg/rest/api/utils.go @@ -0,0 +1,7 @@ +package api + +// NewInterface creates a new empty interface with a given value. +func NewInterface(value interface{}) *interface{} { + v := value + return &v +} diff --git a/pkg/rest/rest.go b/pkg/rest/rest.go index 81bfccf..1d35db1 100644 --- a/pkg/rest/rest.go +++ b/pkg/rest/rest.go @@ -8,7 +8,7 @@ import ( func NewServer() http.Server { router := api.NewRouter( - api.NewCurrenciesAPIController(api.NewCurrenciesAPIService()), + api.NewPublicAPIController(api.NewPublicAPIService()), ) return http.Server{ Addr: ":" + conf.Get().RestPort,