Skip to content

moon-up/moon-sdk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Class Method HTTP request Description
AaveAPI Borrow Post /aave/{name}/borrow
AaveAPI Lend Post /aave/{name}/lend
AaveAPI Repay Post /aave/{name}/repay
AaveAPI UserReserveData Post /aave/{name}/user-reserve-data
AccountsAPI BroadcastTx Post /accounts/{accountName}/broadcast-tx
AccountsAPI CreateAccount Post /accounts
AccountsAPI DeleteAccount Delete /accounts/{accountName}
AccountsAPI DeployContract Post /accounts/{accountName}/deploy
AccountsAPI GetAccount Get /accounts/{accountName}
AccountsAPI GetBalance Get /accounts/{accountName}/balance
AccountsAPI GetNonce Get /accounts/{accountName}/nonce
AccountsAPI ListAccounts Get /accounts
AccountsAPI SignMessage Post /accounts/{accountName}/sign-message
AccountsAPI SignTransaction Post /accounts/{accountName}/sign-transaction
AccountsAPI SignTypedData Post /accounts/{accountName}/sign-typed-data
AccountsAPI TransferEth Post /accounts/{accountName}/transfer-eth
BitcoinAPI CreateBitcoinAccount Post /bitcoin
BitcoinAPI GetBitcoinAccount Get /bitcoin/{accountName}
BitcoinAPI ListBitcoinAccounts Get /bitcoin
BitcoinAPI SignBitcoinTransaction Post /bitcoin/{accountName}/sign-tx
BitcoincashAPI CreateBitcoinCashAccount Post /bitcoincash
BitcoincashAPI GetBitcoinCashAccount Get /bitcoincash/{accountName}
BitcoincashAPI ListBitcoinCashAccounts Get /bitcoincash
BitcoincashAPI SignBitcoinCashTransaction Post /bitcoincash/{accountName}/sign-tx
ConveyorFinanceAPI Swap Post /conveyorfinance/{name}/swap
CosmosAPI CreateCosmosAccount Post /cosmos
CosmosAPI GetCosmosAccount Get /cosmos/{accountName}
CosmosAPI ListCosmosAccounts Get /cosmos
CosmosAPI SignCosmosTransaction Post /cosmos/{accountName}/sign-tx
DefaultAPI GetMessage Get /ping
DogeCoinAPI CreateDogeCoinAccount Post /dogecoin
DogeCoinAPI GetDogeCoinAccount Get /dogecoin/{accountName}
DogeCoinAPI ListDogeCoinAccounts Get /dogecoin
DogeCoinAPI SignDogeCoinTransaction Post /dogecoin/{accountName}/sign-tx
ENSAPI Resolve Post /ens/resolve
ERC1155API BalanceOf Post /erc1155/{name}/balance-of
ERC1155API BalanceOfBatch Post /erc1155/{name}/balance-of-batch
ERC1155API IsApprovedForAll Post /erc1155/{name}/is-approved-for-all
ERC1155API SafeBatchTransferFrom Post /erc1155/{name}/safe-batch-transfer-from
ERC1155API SafeTransferFrom Post /erc1155/{name}/safe-transfer-from
ERC1155API SetApprovalForAll Post /erc1155/{name}/set-approval-for-all
EosAPI CreateEosAccount Post /eos
EosAPI GetEosAccount Get /eos/{accountName}
EosAPI ListEosAccounts Get /eos
EosAPI SignEosTransaction Post /eos/{accountName}/sign-tx
Erc20API AllowanceErc20 Post /erc20/{name}/allowance
Erc20API ApproveErc20 Post /erc20/{name}/approve
Erc20API BalanceOfErc20 Post /erc20/{name}/balance-of
Erc20API DecimalsErc20 Post /erc20/{name}/decimals
Erc20API NameErc20 Post /erc20/{name}/name
Erc20API SymbolErc20 Post /erc20/{name}/symbol
Erc20API TotalSupplyErc20 Post /erc20/{name}/total-supply
Erc20API TransferErc20 Post /erc20/{name}/transfer
Erc20API TransferFromErc20 Post /erc20/{name}/transfer-from
Erc721API Approve Post /erc721/{name}/approve
Erc721API BalanceOf Post /erc721/{name}/balance-of
Erc721API GetApproved Post /erc721/{name}/get-approved
Erc721API IsApprovedForAll Post /erc721/{name}/is-approved-for-all
Erc721API Name Post /erc721/{name}/name
Erc721API OwnerOf Post /erc721/{name}/owner-of
Erc721API SafeTransferFrom Post /erc721/{name}/safe-transfer-from
Erc721API SetApprovalForAll Post /erc721/{name}/set-approval-for-all
Erc721API Symbol Post /erc721/{name}/symbol
Erc721API TokenUri Post /erc721/{name}/token-uri
Erc721API Transfer Post /erc721/{name}/transfer
Erc721API TransferFrom Post /erc721/{name}/transfer-from
LitecoinAPI CreateLitecoinAccount Post /litecoin
LitecoinAPI GetLitecoinAccount Get /litecoin/{accountName}
LitecoinAPI ListLitecoinAccounts Get /litecoin
LitecoinAPI SignLitecoinTransaction Post /litecoin/{accountName}/sign-tx
OneinchAPI ApproveCallData Post /oneinch/approve-call-data
OneinchAPI ApproveSpender Post /oneinch/approve-spender
OneinchAPI Protocols Post /oneinch/protocols
OneinchAPI Quote Post /oneinch/quote
OneinchAPI Swap Post /oneinch/{accountName}/swap
OneinchAPI Tokens Post /oneinch/tokens
OnramperAPI OnRamperCheckout Post /onramper/fund/${accountName}
OnramperAPI OnRamperGetQuotesBuy Get /onramper/quotes/buy
OnramperAPI OnRamperGetQuotesSell Get /onramper/quotes/sell
OnramperAPI OnRamperGetSupportedAssets Get /onramper/assets
OnramperAPI OnRamperGetSupportedCurrencies Get /onramper/currencies
OnramperAPI OnRamperGetSupportedDefaultsAll Get /onramper/defaults
OnramperAPI OnRamperGetSupportedOnRampsAll Get /onramper/onramps
OnramperAPI OnRamperGetSupportedPaymentTypes Get /onramper/payment-types
OnramperAPI OnRamperGetSupportedPaymentTypesFiat Get /onramper/payment-types/fiat
RippleAPI CreateRippleAccount Post /ripple
RippleAPI GetRippleAccount Get /ripple/{accountName}
RippleAPI ListRippleAccounts Get /ripple
RippleAPI SignRippleTransaction Post /ripple/{accountName}/sign-tx
SolanaAPI CreateSolanaAccount Post /solana
SolanaAPI GetSolanaAccount Get /solana/{accountName}
SolanaAPI ListSolanaAccounts Get /solana
SolanaAPI SignSolanaTransaction Post /solana/{accountName}/sign-tx
TronAPI CreateTronAccount Post /tron
TronAPI GetTronAccount Get /tron/{accountName}
TronAPI ListTronAccounts Get /tron
TronAPI SignTronTransaction Post /tron/{accountName}/sign-tx
UniSwapAPI AddLiquidity Post /uniswap/{name}/add-liquidity
UniSwapAPI RemoveLiquidity Post /uniswap/{name}/remove-liquidity
UniSwapAPI SwapExactETHForTokens Post /uniswap/{name}/swap-exact-eth-for-tokens
UniSwapAPI SwapExactTokensForTokens Post /uniswap/{name}/swap-exact-tokens-for-tokens
YearnAPI AddLiquidity Post /yearn/{name}/add-liquidity
YearnAPI AddLiquidityWeth Post /yearn/{name}/add-liquidity-weth
YearnAPI RemoveLiquidity Post /yearn/{name}/remove-liquidity
YearnAPI RemoveLiquidityWeth Post /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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages