Categorygithub.com/moon-up/moon-sdk-go
repositorypackage
1.0.4
Repository: https://github.com/moon-up/moon-sdk-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Go API client for moonsdk

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

Overview

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

  • API version: 1.0.0
  • Package version: 1.0.0
  • Generator version: 7.4.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

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

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

import moonsdk "github.com/moon-up/moon-sdk-go"

To use a proxy, set the environment variable HTTP_PROXY:

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

Configuration of Server URL

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

Select Server Configuration

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

ctx := context.WithValue(context.Background(), moonsdk.ContextServerIndex, 1)

Templated Server URL

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

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

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

URLs Configuration per Operation

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

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

Documentation for API Endpoints

All URIs are relative to https://beta.usemoon.ai

ClassMethodHTTP requestDescription
AaveAPIBorrowPost /aave/{name}/borrow
AaveAPILendPost /aave/{name}/lend
AaveAPIRepayPost /aave/{name}/repay
AaveAPIUserReserveDataPost /aave/{name}/user-reserve-data
AccountsAPIBroadcastTxPost /accounts/{accountName}/broadcast-tx
AccountsAPICreateAccountPost /accounts
AccountsAPIDeleteAccountDelete /accounts/{accountName}
AccountsAPIDeployContractPost /accounts/{accountName}/deploy
AccountsAPIGetAccountGet /accounts/{accountName}
AccountsAPIGetBalanceGet /accounts/{accountName}/balance
AccountsAPIGetNonceGet /accounts/{accountName}/nonce
AccountsAPIListAccountsGet /accounts
AccountsAPISignMessagePost /accounts/{accountName}/sign-message
AccountsAPISignTransactionPost /accounts/{accountName}/sign-transaction
AccountsAPISignTypedDataPost /accounts/{accountName}/sign-typed-data
AccountsAPITransferEthPost /accounts/{accountName}/transfer-eth
BitcoinAPICreateBitcoinAccountPost /bitcoin
BitcoinAPIGetBitcoinAccountGet /bitcoin/{accountName}
BitcoinAPIListBitcoinAccountsGet /bitcoin
BitcoinAPISignBitcoinTransactionPost /bitcoin/{accountName}/sign-tx
BitcoincashAPICreateBitcoinCashAccountPost /bitcoincash
BitcoincashAPIGetBitcoinCashAccountGet /bitcoincash/{accountName}
BitcoincashAPIListBitcoinCashAccountsGet /bitcoincash
BitcoincashAPISignBitcoinCashTransactionPost /bitcoincash/{accountName}/sign-tx
ConveyorFinanceAPISwapPost /conveyorfinance/{name}/swap
CosmosAPICreateCosmosAccountPost /cosmos
CosmosAPIGetCosmosAccountGet /cosmos/{accountName}
CosmosAPIListCosmosAccountsGet /cosmos
CosmosAPISignCosmosTransactionPost /cosmos/{accountName}/sign-tx
DefaultAPIGetMessageGet /ping
DogeCoinAPICreateDogeCoinAccountPost /dogecoin
DogeCoinAPIGetDogeCoinAccountGet /dogecoin/{accountName}
DogeCoinAPIListDogeCoinAccountsGet /dogecoin
DogeCoinAPISignDogeCoinTransactionPost /dogecoin/{accountName}/sign-tx
ENSAPIResolvePost /ens/resolve
ERC1155APIBalanceOfPost /erc1155/{name}/balance-of
ERC1155APIBalanceOfBatchPost /erc1155/{name}/balance-of-batch
ERC1155APIIsApprovedForAllPost /erc1155/{name}/is-approved-for-all
ERC1155APISafeBatchTransferFromPost /erc1155/{name}/safe-batch-transfer-from
ERC1155APISafeTransferFromPost /erc1155/{name}/safe-transfer-from
ERC1155APISetApprovalForAllPost /erc1155/{name}/set-approval-for-all
EosAPICreateEosAccountPost /eos
EosAPIGetEosAccountGet /eos/{accountName}
EosAPIListEosAccountsGet /eos
EosAPISignEosTransactionPost /eos/{accountName}/sign-tx
Erc20APIAllowanceErc20Post /erc20/{name}/allowance
Erc20APIApproveErc20Post /erc20/{name}/approve
Erc20APIBalanceOfErc20Post /erc20/{name}/balance-of
Erc20APIDecimalsErc20Post /erc20/{name}/decimals
Erc20APINameErc20Post /erc20/{name}/name
Erc20APISymbolErc20Post /erc20/{name}/symbol
Erc20APITotalSupplyErc20Post /erc20/{name}/total-supply
Erc20APITransferErc20Post /erc20/{name}/transfer
Erc20APITransferFromErc20Post /erc20/{name}/transfer-from
Erc721APIApprovePost /erc721/{name}/approve
Erc721APIBalanceOfPost /erc721/{name}/balance-of
Erc721APIGetApprovedPost /erc721/{name}/get-approved
Erc721APIIsApprovedForAllPost /erc721/{name}/is-approved-for-all
Erc721APINamePost /erc721/{name}/name
Erc721APIOwnerOfPost /erc721/{name}/owner-of
Erc721APISafeTransferFromPost /erc721/{name}/safe-transfer-from
Erc721APISetApprovalForAllPost /erc721/{name}/set-approval-for-all
Erc721APISymbolPost /erc721/{name}/symbol
Erc721APITokenUriPost /erc721/{name}/token-uri
Erc721APITransferPost /erc721/{name}/transfer
Erc721APITransferFromPost /erc721/{name}/transfer-from
LitecoinAPICreateLitecoinAccountPost /litecoin
LitecoinAPIGetLitecoinAccountGet /litecoin/{accountName}
LitecoinAPIListLitecoinAccountsGet /litecoin
LitecoinAPISignLitecoinTransactionPost /litecoin/{accountName}/sign-tx
OneinchAPIApproveCallDataPost /oneinch/approve-call-data
OneinchAPIApproveSpenderPost /oneinch/approve-spender
OneinchAPIProtocolsPost /oneinch/protocols
OneinchAPIQuotePost /oneinch/quote
OneinchAPISwapPost /oneinch/{accountName}/swap
OneinchAPITokensPost /oneinch/tokens
OnramperAPIOnRamperCheckoutPost /onramper/fund/${accountName}
OnramperAPIOnRamperGetQuotesBuyGet /onramper/quotes/buy
OnramperAPIOnRamperGetQuotesSellGet /onramper/quotes/sell
OnramperAPIOnRamperGetSupportedAssetsGet /onramper/assets
OnramperAPIOnRamperGetSupportedCurrenciesGet /onramper/currencies
OnramperAPIOnRamperGetSupportedDefaultsAllGet /onramper/defaults
OnramperAPIOnRamperGetSupportedOnRampsAllGet /onramper/onramps
OnramperAPIOnRamperGetSupportedPaymentTypesGet /onramper/payment-types
OnramperAPIOnRamperGetSupportedPaymentTypesFiatGet /onramper/payment-types/fiat
RippleAPICreateRippleAccountPost /ripple
RippleAPIGetRippleAccountGet /ripple/{accountName}
RippleAPIListRippleAccountsGet /ripple
RippleAPISignRippleTransactionPost /ripple/{accountName}/sign-tx
SolanaAPICreateSolanaAccountPost /solana
SolanaAPIGetSolanaAccountGet /solana/{accountName}
SolanaAPIListSolanaAccountsGet /solana
SolanaAPISignSolanaTransactionPost /solana/{accountName}/sign-tx
TronAPICreateTronAccountPost /tron
TronAPIGetTronAccountGet /tron/{accountName}
TronAPIListTronAccountsGet /tron
TronAPISignTronTransactionPost /tron/{accountName}/sign-tx
UniSwapAPIAddLiquidityPost /uniswap/{name}/add-liquidity
UniSwapAPIRemoveLiquidityPost /uniswap/{name}/remove-liquidity
UniSwapAPISwapExactETHForTokensPost /uniswap/{name}/swap-exact-eth-for-tokens
UniSwapAPISwapExactTokensForTokensPost /uniswap/{name}/swap-exact-tokens-for-tokens
YearnAPIAddLiquidityPost /yearn/{name}/add-liquidity
YearnAPIAddLiquidityWethPost /yearn/{name}/add-liquidity-weth
YearnAPIRemoveLiquidityPost /yearn/{name}/remove-liquidity
YearnAPIRemoveLiquidityWethPost /yearn/{name}/remove-liquidity-weth

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

BearerAuth

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: Authorization and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		moonsdk.ContextAPIKeys,
		map[string]moonsdk.APIKey{
			"Authorization": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

OAuth2

  • Type: OAuth
  • Flow: password
  • Authorization URL:
  • Scopes:
  • authorization_code: grants authorization_code

Example

auth := context.WithValue(context.Background(), moonsdk.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, moonsdk.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

ApiKeyAuth

  • Type: API key
  • API key parameter name: x-api-key
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: x-api-key and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		moonsdk.ContextAPIKeys,
		map[string]moonsdk.APIKey{
			"x-api-key": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

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

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author