package hilltopapi /** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.0.1-SNAPSHOT * User agent: apibuilder app.apibuilder.io/gimbalabs/hilltop-api/0.0.1-SNAPSHOT/go_1_5_client */ import ( "bytes" "encoding/json" "errors" "fmt" "html" "io" "io/ioutil" "net/http" "net/url" "strconv" "strings" ) const BaseUrl = "https://hilltop-api.mainnet.dandelion.link" const UserAgent = "apibuilder app.apibuilder.io/gimbalabs/hilltop-api/0.0.1-SNAPSHOT/go_1_5_client" const Version = "0.0.1-SNAPSHOT" const VersionMajor = 0 type Client struct { HttpClient *http.Client Username string Password string BaseUrl string Headers http.Header } type ClientRequestBody struct { contentType string bytes io.Reader } type Country string const ( CountryIe Country = "IE" CountryUk = "UK" CountryUNDEFINED = "UNDEFINED" ) func CountryFromString(value string) Country { switch strings.TrimSpace(strings.ToLower(value)) { case "ie": return CountryIe case "uk": return CountryUk default: return CountryUNDEFINED } } type ActiveStakeAmount struct { AmountInLovelaces int64 `json:"amount_in_lovelaces"` } func ActiveStakeAmountFromMap(data interface{}) ActiveStakeAmount { b, err := json.Marshal(data) if err == nil { return ActiveStakeAmountFromJson(bytes.NewReader(b)) } else { panic(err) } } func ActiveStakeAmountFromJson(bytes io.Reader) ActiveStakeAmount { var activeStakeAmount ActiveStakeAmount json.NewDecoder(bytes).Decode(&activeStakeAmount) return activeStakeAmount } type AddressStakeAmount struct { StakeAddress string `json:"stake_address"` AmountInLovelaces int64 `json:"amount_in_lovelaces"` } func AddressStakeAmountFromMap(data interface{}) AddressStakeAmount { b, err := json.Marshal(data) if err == nil { return AddressStakeAmountFromJson(bytes.NewReader(b)) } else { panic(err) } } func AddressStakeAmountFromJson(bytes io.Reader) AddressStakeAmount { var addressStakeAmount AddressStakeAmount json.NewDecoder(bytes).Decode(&addressStakeAmount) return addressStakeAmount } type Block struct { Number int64 `json:"number"` EpochNumber int64 `json:"epoch_number"` SlotNumber int64 `json:"slot_number"` EpochSlotNumber int64 `json:"epoch_slot_number"` Size int64 `json:"size"` TransactionCount int64 `json:"transaction_count"` Time string `json:"time"` } func BlockFromMap(data interface{}) Block { b, err := json.Marshal(data) if err == nil { return BlockFromJson(bytes.NewReader(b)) } else { panic(err) } } func BlockFromJson(bytes io.Reader) Block { var block Block json.NewDecoder(bytes).Decode(&block) return block } type CnftMetadataV001 struct { PolicyId string `json:"policyId"` Tokens map[string]string `json:"tokens"` Asset CnftMetadataV001Asset `json:"asset"` } func CnftMetadataV001FromMap(data interface{}) CnftMetadataV001 { b, err := json.Marshal(data) if err == nil { return CnftMetadataV001FromJson(bytes.NewReader(b)) } else { panic(err) } } func CnftMetadataV001FromJson(bytes io.Reader) CnftMetadataV001 { var cnftMetadataV001 CnftMetadataV001 json.NewDecoder(bytes).Decode(&cnftMetadataV001) return cnftMetadataV001 } type CnftMetadataV001Asset struct { AssetName string `json:"assetName,omitempty"` Attributes interface{} `json:"attributes,omitempty"` Ipfs string `json:"ipfs"` MimeType string `json:"mimeType,omitempty"` } func CnftMetadataV001AssetFromMap(data interface{}) CnftMetadataV001Asset { b, err := json.Marshal(data) if err == nil { return CnftMetadataV001AssetFromJson(bytes.NewReader(b)) } else { panic(err) } } func CnftMetadataV001AssetFromJson(bytes io.Reader) CnftMetadataV001Asset { var cnftMetadataV001Asset CnftMetadataV001Asset json.NewDecoder(bytes).Decode(&cnftMetadataV001Asset) return cnftMetadataV001Asset } type DayBlock struct { First Block `json:"first"` Last Block `json:"last"` } func DayBlockFromMap(data interface{}) DayBlock { b, err := json.Marshal(data) if err == nil { return DayBlockFromJson(bytes.NewReader(b)) } else { panic(err) } } func DayBlockFromJson(bytes io.Reader) DayBlock { var dayBlock DayBlock json.NewDecoder(bytes).Decode(&dayBlock) return dayBlock } type Delegation struct { StakingAddress string `json:"staking_address"` Delegations []StakepoolDelegation `json:"delegations"` } func DelegationFromMap(data interface{}) Delegation { b, err := json.Marshal(data) if err == nil { return DelegationFromJson(bytes.NewReader(b)) } else { panic(err) } } func DelegationFromJson(bytes io.Reader) Delegation { var delegation Delegation json.NewDecoder(bytes).Decode(&delegation) return delegation } type DelegatorsCount struct { DelegatorsCountTotal int32 `json:"delegators_count_total"` } func DelegatorsCountFromMap(data interface{}) DelegatorsCount { b, err := json.Marshal(data) if err == nil { return DelegatorsCountFromJson(bytes.NewReader(b)) } else { panic(err) } } func DelegatorsCountFromJson(bytes io.Reader) DelegatorsCount { var delegatorsCount DelegatorsCount json.NewDecoder(bytes).Decode(&delegatorsCount) return delegatorsCount } type Epoch struct { OutSum int64 `json:"out_sum"` Fees int64 `json:"fees"` TxCount int32 `json:"tx_count"` BlkCount int32 `json:"blk_count"` Number int32 `json:"number"` StartTime string `json:"start_time"` EndTime string `json:"end_time"` } func EpochFromMap(data interface{}) Epoch { b, err := json.Marshal(data) if err == nil { return EpochFromJson(bytes.NewReader(b)) } else { panic(err) } } func EpochFromJson(bytes io.Reader) Epoch { var epoch Epoch json.NewDecoder(bytes).Decode(&epoch) return epoch } type GenericError struct { Description string `json:"description"` } func GenericErrorFromMap(data interface{}) GenericError { b, err := json.Marshal(data) if err == nil { return GenericErrorFromJson(bytes.NewReader(b)) } else { panic(err) } } func GenericErrorFromJson(bytes io.Reader) GenericError { var genericError GenericError json.NewDecoder(bytes).Decode(&genericError) return genericError } /** * Response for the healthcheck's endpoint of the service */ type Healthcheck struct { Status string `json:"status"` } func HealthcheckFromMap(data interface{}) Healthcheck { b, err := json.Marshal(data) if err == nil { return HealthcheckFromJson(bytes.NewReader(b)) } else { panic(err) } } func HealthcheckFromJson(bytes io.Reader) Healthcheck { var healthcheck Healthcheck json.NewDecoder(bytes).Decode(&healthcheck) return healthcheck } type NativeAsset struct { TransactionId string `json:"transaction_id"` PolicyId string `json:"policy_id"` TokenName string `json:"token_name"` Metadata interface{} `json:"metadata"` BlockNumber int64 `json:"block_number"` EpochSlotNumber int64 `json:"epoch_slot_number"` EpochNumber int64 `json:"epoch_number"` InvalidBefore int64 `json:"invalid_before,omitempty"` InvalidHereafter int64 `json:"invalid_hereafter,omitempty"` Quantity int64 `json:"quantity"` } func NativeAssetFromMap(data interface{}) NativeAsset { b, err := json.Marshal(data) if err == nil { return NativeAssetFromJson(bytes.NewReader(b)) } else { panic(err) } } func NativeAssetFromJson(bytes io.Reader) NativeAsset { var nativeAsset NativeAsset json.NewDecoder(bytes).Decode(&nativeAsset) return nativeAsset } type NativeAssetDetails struct { PolicyId string `json:"policy_id"` AssetName string `json:"asset_name"` Metadata interface{} `json:"metadata"` MintedAt string `json:"minted_at"` LastMintedAt string `json:"last_minted_at"` FirstMintingTxBlock int64 `json:"first_minting_tx_block"` LastMintingTxBlock int64 `json:"last_minting_tx_block"` MintingTxHash string `json:"minting_tx_hash"` CirculatingSupply int64 `json:"circulating_supply"` Fingerprint string `json:"fingerprint"` } func NativeAssetDetailsFromMap(data interface{}) NativeAssetDetails { b, err := json.Marshal(data) if err == nil { return NativeAssetDetailsFromJson(bytes.NewReader(b)) } else { panic(err) } } func NativeAssetDetailsFromJson(bytes io.Reader) NativeAssetDetails { var nativeAssetDetails NativeAssetDetails json.NewDecoder(bytes).Decode(&nativeAssetDetails) return nativeAssetDetails } type NativeAssetDetailsRequest struct { PolicyId string `json:"policy_id"` AssetNames []string `json:"asset_names,omitempty"` } func NativeAssetDetailsRequestFromMap(data interface{}) NativeAssetDetailsRequest { b, err := json.Marshal(data) if err == nil { return NativeAssetDetailsRequestFromJson(bytes.NewReader(b)) } else { panic(err) } } func NativeAssetDetailsRequestFromJson(bytes io.Reader) NativeAssetDetailsRequest { var nativeAssetDetailsRequest NativeAssetDetailsRequest json.NewDecoder(bytes).Decode(&nativeAssetDetailsRequest) return nativeAssetDetailsRequest } type NativeAssetId struct { PolicyId string `json:"policy_id"` AssetName string `json:"asset_name"` BlockNumber int64 `json:"block_number"` BlockTime string `json:"block_time"` Fingerprint string `json:"fingerprint"` } func NativeAssetIdFromMap(data interface{}) NativeAssetId { b, err := json.Marshal(data) if err == nil { return NativeAssetIdFromJson(bytes.NewReader(b)) } else { panic(err) } } func NativeAssetIdFromJson(bytes io.Reader) NativeAssetId { var nativeAssetId NativeAssetId json.NewDecoder(bytes).Decode(&nativeAssetId) return nativeAssetId } type NftDetails struct { PolicyId string `json:"policy_id"` AssetNameRaw string `json:"asset_name_raw"` AssetName string `json:"asset_name,omitempty"` Metadata interface{} `json:"metadata"` MintedAt string `json:"minted_at"` MintedAtBlock int64 `json:"minted_at_block"` MintingTxHash string `json:"minting_tx_hash"` Amount int64 `json:"amount"` Fingerprint string `json:"fingerprint"` } func NftDetailsFromMap(data interface{}) NftDetails { b, err := json.Marshal(data) if err == nil { return NftDetailsFromJson(bytes.NewReader(b)) } else { panic(err) } } func NftDetailsFromJson(bytes io.Reader) NftDetails { var nftDetails NftDetails json.NewDecoder(bytes).Decode(&nftDetails) return nftDetails } type NftMetadata struct { Name string `json:"name,omitempty"` Image string `json:"image,omitempty"` MediaType string `json:"mediaType,omitempty"` Files []NftMetadataFile `json:"files,omitempty"` } func NftMetadataFromMap(data interface{}) NftMetadata { b, err := json.Marshal(data) if err == nil { return NftMetadataFromJson(bytes.NewReader(b)) } else { panic(err) } } func NftMetadataFromJson(bytes io.Reader) NftMetadata { var nftMetadata NftMetadata json.NewDecoder(bytes).Decode(&nftMetadata) return nftMetadata } type NftMetadataFile struct { Name string `json:"name,omitempty"` Src string `json:"src,omitempty"` MediaType string `json:"mediaType,omitempty"` } func NftMetadataFileFromMap(data interface{}) NftMetadataFile { b, err := json.Marshal(data) if err == nil { return NftMetadataFileFromJson(bytes.NewReader(b)) } else { panic(err) } } func NftMetadataFileFromJson(bytes io.Reader) NftMetadataFile { var nftMetadataFile NftMetadataFile json.NewDecoder(bytes).Decode(&nftMetadataFile) return nftMetadataFile } type NftMetadataFilesAsObject struct { Name string `json:"name,omitempty"` Image string `json:"image,omitempty"` MediaType string `json:"mediaType,omitempty"` Files NftMetadataFile `json:"files,omitempty"` } func NftMetadataFilesAsObjectFromMap(data interface{}) NftMetadataFilesAsObject { b, err := json.Marshal(data) if err == nil { return NftMetadataFilesAsObjectFromJson(bytes.NewReader(b)) } else { panic(err) } } func NftMetadataFilesAsObjectFromJson(bytes io.Reader) NftMetadataFilesAsObject { var nftMetadataFilesAsObject NftMetadataFilesAsObject json.NewDecoder(bytes).Decode(&nftMetadataFilesAsObject) return nftMetadataFilesAsObject } type NftMetadataImgArray struct { Name string `json:"name,omitempty"` Image []string `json:"image,omitempty"` MediaType string `json:"mediaType,omitempty"` Files []NftMetadataFile `json:"files,omitempty"` } func NftMetadataImgArrayFromMap(data interface{}) NftMetadataImgArray { b, err := json.Marshal(data) if err == nil { return NftMetadataImgArrayFromJson(bytes.NewReader(b)) } else { panic(err) } } func NftMetadataImgArrayFromJson(bytes io.Reader) NftMetadataImgArray { var nftMetadataImgArray NftMetadataImgArray json.NewDecoder(bytes).Decode(&nftMetadataImgArray) return nftMetadataImgArray } type NftMetadataNoFiles struct { Name string `json:"name,omitempty"` Image string `json:"image,omitempty"` MediaType string `json:"mediaType,omitempty"` } func NftMetadataNoFilesFromMap(data interface{}) NftMetadataNoFiles { b, err := json.Marshal(data) if err == nil { return NftMetadataNoFilesFromJson(bytes.NewReader(b)) } else { panic(err) } } func NftMetadataNoFilesFromJson(bytes io.Reader) NftMetadataNoFiles { var nftMetadataNoFiles NftMetadataNoFiles json.NewDecoder(bytes).Decode(&nftMetadataNoFiles) return nftMetadataNoFiles } type PoolRetiring struct { TickerName string `json:"ticker_name,omitempty"` PoolId string `json:"pool_id"` CertificateIndex int32 `json:"certificate_index"` EpochNumber int64 `json:"epoch_number"` BlockNumber int64 `json:"block_number"` RetiringAtEpoch int64 `json:"retiring_at_epoch"` TxHash string `json:"tx_hash"` } func PoolRetiringFromMap(data interface{}) PoolRetiring { b, err := json.Marshal(data) if err == nil { return PoolRetiringFromJson(bytes.NewReader(b)) } else { panic(err) } } func PoolRetiringFromJson(bytes io.Reader) PoolRetiring { var poolRetiring PoolRetiring json.NewDecoder(bytes).Decode(&poolRetiring) return poolRetiring } type PoolUpdate struct { EpochNumber int32 `json:"epoch_number"` BlockNumber int64 `json:"block_number"` TxHash string `json:"tx_hash"` PoolTickerName string `json:"pool_ticker_name,omitempty"` PoolBech32Id string `json:"pool_bech32_id"` CertificateIndex int32 `json:"certificate_index"` VrfKeyHash string `json:"vrf_key_hash"` Pledge int64 `json:"pledge"` RewardAddress string `json:"reward_address"` ActiveEpochNumber int64 `json:"active_epoch_number"` Margin float64 `json:"margin"` FixedCost int64 `json:"fixed_cost"` } func PoolUpdateFromMap(data interface{}) PoolUpdate { b, err := json.Marshal(data) if err == nil { return PoolUpdateFromJson(bytes.NewReader(b)) } else { panic(err) } } func PoolUpdateFromJson(bytes io.Reader) PoolUpdate { var poolUpdate PoolUpdate json.NewDecoder(bytes).Decode(&poolUpdate) return poolUpdate } type Reward struct { StakingAddress string `json:"staking_address"` Epoch int32 `json:"epoch"` Amount int64 `json:"amount"` PoolId string `json:"pool_id"` } func RewardFromMap(data interface{}) Reward { b, err := json.Marshal(data) if err == nil { return RewardFromJson(bytes.NewReader(b)) } else { panic(err) } } func RewardFromJson(bytes io.Reader) Reward { var reward Reward json.NewDecoder(bytes).Decode(&reward) return reward } type Sigma struct { Sigma float64 `json:"sigma"` Epoch int32 `json:"epoch"` TotalStaked int64 `json:"total_staked"` ActiveStake int64 `json:"active_stake"` Nonce string `json:"nonce"` D float64 `json:"d"` } func SigmaFromMap(data interface{}) Sigma { b, err := json.Marshal(data) if err == nil { return SigmaFromJson(bytes.NewReader(b)) } else { panic(err) } } func SigmaFromJson(bytes io.Reader) Sigma { var sigma Sigma json.NewDecoder(bytes).Decode(&sigma) return sigma } type Stakepool struct { Id string `json:"id"` PoolIdBech32 string `json:"pool_id_bech32"` Metadata StakepoolMetadata `json:"metadata,omitempty"` Cost int64 `json:"cost"` Margin float64 `json:"margin"` Pledge int64 `json:"pledge"` ActiveStake int64 `json:"active_stake"` Saturation float64 `json:"saturation"` RetiringAtEpoch int64 `json:"retiring_at_epoch,omitempty"` } func StakepoolFromMap(data interface{}) Stakepool { b, err := json.Marshal(data) if err == nil { return StakepoolFromJson(bytes.NewReader(b)) } else { panic(err) } } func StakepoolFromJson(bytes io.Reader) Stakepool { var stakepool Stakepool json.NewDecoder(bytes).Decode(&stakepool) return stakepool } type StakepoolDelegation struct { Stakepool Stakepool `json:"stakepool"` Epoch int32 `json:"epoch"` } func StakepoolDelegationFromMap(data interface{}) StakepoolDelegation { b, err := json.Marshal(data) if err == nil { return StakepoolDelegationFromJson(bytes.NewReader(b)) } else { panic(err) } } func StakepoolDelegationFromJson(bytes io.Reader) StakepoolDelegation { var stakepoolDelegation StakepoolDelegation json.NewDecoder(bytes).Decode(&stakepoolDelegation) return stakepoolDelegation } /** * Stake Pool Offline Metadata */ type StakepoolMetadata struct { Name string `json:"name"` Ticker string `json:"ticker"` Homepage string `json:"homepage"` Description string `json:"description"` Extended string `json:"extended,omitempty"` } func StakepoolMetadataFromMap(data interface{}) StakepoolMetadata { b, err := json.Marshal(data) if err == nil { return StakepoolMetadataFromJson(bytes.NewReader(b)) } else { panic(err) } } func StakepoolMetadataFromJson(bytes io.Reader) StakepoolMetadata { var stakepoolMetadata StakepoolMetadata json.NewDecoder(bytes).Decode(&stakepoolMetadata) return stakepoolMetadata } type Transaction struct { Hash string `json:"hash"` Block int64 `json:"block"` Timestamp string `json:"timestamp"` } func TransactionFromMap(data interface{}) Transaction { b, err := json.Marshal(data) if err == nil { return TransactionFromJson(bytes.NewReader(b)) } else { panic(err) } } func TransactionFromJson(bytes io.Reader) Transaction { var transaction Transaction json.NewDecoder(bytes).Decode(&transaction) return transaction } type TransactionHistoryRequest struct { Addresses []string `json:"addresses"` } func TransactionHistoryRequestFromMap(data interface{}) TransactionHistoryRequest { b, err := json.Marshal(data) if err == nil { return TransactionHistoryRequestFromJson(bytes.NewReader(b)) } else { panic(err) } } func TransactionHistoryRequestFromJson(bytes io.Reader) TransactionHistoryRequest { var transactionHistoryRequest TransactionHistoryRequest json.NewDecoder(bytes).Decode(&transactionHistoryRequest) return transactionHistoryRequest } type WalletBalance struct { Balance int64 `json:"balance"` } func WalletBalanceFromMap(data interface{}) WalletBalance { b, err := json.Marshal(data) if err == nil { return WalletBalanceFromJson(bytes.NewReader(b)) } else { panic(err) } } func WalletBalanceFromJson(bytes io.Reader) WalletBalance { var walletBalance WalletBalance json.NewDecoder(bytes).Decode(&walletBalance) return walletBalance } type ActiveStakeAmountsGetParams struct { EpochNumber int32 } type ActiveStakeAmountsGetResponse struct { StatusCode int Response *http.Response Error error ActiveStakeAmount ActiveStakeAmount } func ActiveStakeAmountsGet(client Client, params ActiveStakeAmountsGetParams) ActiveStakeAmountsGetResponse { requestUrl := fmt.Sprintf("%s/active_stake_amounts", client.BaseUrl) urlValues := url.Values{} if 0 != params.EpochNumber { urlValues.Add("epoch_number", strconv.FormatInt(params.EpochNumber, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return ActiveStakeAmountsGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ActiveStakeAmountsGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ActiveStakeAmountsGetResponse{StatusCode: resp.StatusCode, Response: resp, ActiveStakeAmount: ActiveStakeAmountFromJson(resp.Body)} default: return ActiveStakeAmountsGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ActiveStakeAmountsGetByPoolBech32IdParams struct { EpochNumber int32 } type ActiveStakeAmountsGetByPoolBech32IdResponse struct { StatusCode int Response *http.Response Error error ActiveStakeAmount ActiveStakeAmount } func ActiveStakeAmountsGetByPoolBech32Id(client Client, poolBech32Id string, params ActiveStakeAmountsGetByPoolBech32IdParams) ActiveStakeAmountsGetByPoolBech32IdResponse { requestUrl := fmt.Sprintf("%s/active_stake_amounts/%s", client.BaseUrl, html.EscapeString(poolBech32Id)) urlValues := url.Values{} if 0 != params.EpochNumber { urlValues.Add("epoch_number", strconv.FormatInt(params.EpochNumber, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return ActiveStakeAmountsGetByPoolBech32IdResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ActiveStakeAmountsGetByPoolBech32IdResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ActiveStakeAmountsGetByPoolBech32IdResponse{StatusCode: resp.StatusCode, Response: resp, ActiveStakeAmount: ActiveStakeAmountFromJson(resp.Body)} default: return ActiveStakeAmountsGetByPoolBech32IdResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ActiveStakeAmountsGetAddressesByPoolBech32IdParams struct { EpochNumber int32 } type ActiveStakeAmountsGetAddressesByPoolBech32IdResponse struct { StatusCode int Response *http.Response Error error AddressStakeAmounts []AddressStakeAmount } func ActiveStakeAmountsGetAddressesByPoolBech32Id(client Client, poolBech32Id string, params ActiveStakeAmountsGetAddressesByPoolBech32IdParams) ActiveStakeAmountsGetAddressesByPoolBech32IdResponse { requestUrl := fmt.Sprintf("%s/active_stake_amounts/%s/addresses", client.BaseUrl, html.EscapeString(poolBech32Id)) urlValues := url.Values{} if 0 != params.EpochNumber { urlValues.Add("epoch_number", strconv.FormatInt(params.EpochNumber, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return ActiveStakeAmountsGetAddressesByPoolBech32IdResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ActiveStakeAmountsGetAddressesByPoolBech32IdResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ActiveStakeAmountsGetAddressesByPoolBech32IdResponse{StatusCode: resp.StatusCode, Response: resp, AddressStakeAmounts: func() []AddressStakeAmount { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []AddressStakeAmount for _, el := range tmp { all = append(all, AddressStakeAmountFromMap(el)) } return all }()} default: return ActiveStakeAmountsGetAddressesByPoolBech32IdResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type BlocksGetBlocksInDayParams struct { Date string } type BlocksGetBlocksInDayResponse struct { StatusCode int Response *http.Response Error error DayBlock DayBlock GenericError GenericError } func BlocksGetBlocksInDay(client Client, params BlocksGetBlocksInDayParams) BlocksGetBlocksInDayResponse { requestUrl := fmt.Sprintf("%s/blocks/blocks_in_day", client.BaseUrl) urlValues := url.Values{} if "" != params.Date { urlValues.Add("date", params.Date) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return BlocksGetBlocksInDayResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return BlocksGetBlocksInDayResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return BlocksGetBlocksInDayResponse{StatusCode: resp.StatusCode, Response: resp, DayBlock: DayBlockFromJson(resp.Body)} case 404: return BlocksGetBlocksInDayResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return BlocksGetBlocksInDayResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type BlocksGetByBlockNumberResponse struct { StatusCode int Response *http.Response Error error Block Block GenericError GenericError } func BlocksGetByBlockNumber(client Client, blockNumber int64) BlocksGetByBlockNumberResponse { requestUrl := fmt.Sprintf("%s/blocks/%s", client.BaseUrl, strconv.FormatInt(blockNumber, 10)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return BlocksGetByBlockNumberResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return BlocksGetByBlockNumberResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return BlocksGetByBlockNumberResponse{StatusCode: resp.StatusCode, Response: resp, Block: BlockFromJson(resp.Body)} case 404: return BlocksGetByBlockNumberResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return BlocksGetByBlockNumberResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type DelegationsGetSafePaymentByStakingAddressResponse struct { StatusCode int Response *http.Response Error error GenericError GenericError Value string } func DelegationsGetSafePaymentByStakingAddress(client Client, stakingAddress string) DelegationsGetSafePaymentByStakingAddressResponse { requestUrl := fmt.Sprintf("%s/delegations/%s/safe_payment", client.BaseUrl, html.EscapeString(stakingAddress)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return DelegationsGetSafePaymentByStakingAddressResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return DelegationsGetSafePaymentByStakingAddressResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return DelegationsGetSafePaymentByStakingAddressResponse{StatusCode: resp.StatusCode, Response: resp, Value: func() string { body, _ := ioutil.ReadAll(resp.Body) return string(body) }()} case 404: return DelegationsGetSafePaymentByStakingAddressResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return DelegationsGetSafePaymentByStakingAddressResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type DelegationsGetStakepoolByStakingAddressResponse struct { StatusCode int Response *http.Response Error error Delegation Delegation GenericError GenericError } func DelegationsGetStakepoolByStakingAddress(client Client, stakingAddress string) DelegationsGetStakepoolByStakingAddressResponse { requestUrl := fmt.Sprintf("%s/delegations/%s/stakepool", client.BaseUrl, html.EscapeString(stakingAddress)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return DelegationsGetStakepoolByStakingAddressResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return DelegationsGetStakepoolByStakingAddressResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return DelegationsGetStakepoolByStakingAddressResponse{StatusCode: resp.StatusCode, Response: resp, Delegation: DelegationFromJson(resp.Body)} case 404: return DelegationsGetStakepoolByStakingAddressResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return DelegationsGetStakepoolByStakingAddressResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type DelegatorsCountsGetByPoolBech32IdResponse struct { StatusCode int Response *http.Response Error error DelegatorsCount DelegatorsCount } func DelegatorsCountsGetByPoolBech32Id(client Client, poolBech32Id string) DelegatorsCountsGetByPoolBech32IdResponse { requestUrl := fmt.Sprintf("%s/delegators_counts/%s", client.BaseUrl, html.EscapeString(poolBech32Id)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return DelegatorsCountsGetByPoolBech32IdResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return DelegatorsCountsGetByPoolBech32IdResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return DelegatorsCountsGetByPoolBech32IdResponse{StatusCode: resp.StatusCode, Response: resp, DelegatorsCount: DelegatorsCountFromJson(resp.Body)} default: return DelegatorsCountsGetByPoolBech32IdResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type EpochsGetCurrentResponse struct { StatusCode int Response *http.Response Error error Epoch Epoch } func EpochsGetCurrent(client Client) EpochsGetCurrentResponse { requestUrl := fmt.Sprintf("%s/epochs/current", client.BaseUrl) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return EpochsGetCurrentResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return EpochsGetCurrentResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return EpochsGetCurrentResponse{StatusCode: resp.StatusCode, Response: resp, Epoch: EpochFromJson(resp.Body)} default: return EpochsGetCurrentResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type EpochsGetByEpochNumberResponse struct { StatusCode int Response *http.Response Error error Epoch Epoch } func EpochsGetByEpochNumber(client Client, epochNumber int32) EpochsGetByEpochNumberResponse { requestUrl := fmt.Sprintf("%s/epochs/%s", client.BaseUrl, strconv.FormatInt(epochNumber, 10)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return EpochsGetByEpochNumberResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return EpochsGetByEpochNumberResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return EpochsGetByEpochNumberResponse{StatusCode: resp.StatusCode, Response: resp, Epoch: EpochFromJson(resp.Body)} default: return EpochsGetByEpochNumberResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type HealthchecksGetResponse struct { StatusCode int Response *http.Response Error error Healthcheck Healthcheck } func HealthchecksGet(client Client) HealthchecksGetResponse { requestUrl := fmt.Sprintf("%s/healthchecks", client.BaseUrl) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return HealthchecksGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return HealthchecksGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return HealthchecksGetResponse{StatusCode: resp.StatusCode, Response: resp, Healthcheck: HealthcheckFromJson(resp.Body)} default: return HealthchecksGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type NativeAssetsGetIdsParams struct { BlockNumberFrom int64 Limit int64 } type NativeAssetsGetIdsResponse struct { StatusCode int Response *http.Response Error error NativeAssetIds []NativeAssetId } func NativeAssetsGetIds(client Client, params NativeAssetsGetIdsParams) NativeAssetsGetIdsResponse { requestUrl := fmt.Sprintf("%s/native_assets/ids", client.BaseUrl) urlValues := url.Values{} if 0 != params.BlockNumberFrom { urlValues.Add("block_number_from", strconv.FormatInt(params.BlockNumberFrom, 10)) } if 0 != params.Limit { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return NativeAssetsGetIdsResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return NativeAssetsGetIdsResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return NativeAssetsGetIdsResponse{StatusCode: resp.StatusCode, Response: resp, NativeAssetIds: func() []NativeAssetId { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []NativeAssetId for _, el := range tmp { all = append(all, NativeAssetIdFromMap(el)) } return all }()} default: return NativeAssetsGetIdsResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type NativeAssetsGetAssetNamesByPolicyIdResponse struct { StatusCode int Response *http.Response Error error Values []string } func NativeAssetsGetAssetNamesByPolicyId(client Client, policyId string) NativeAssetsGetAssetNamesByPolicyIdResponse { requestUrl := fmt.Sprintf("%s/native_assets/%s/asset_names", client.BaseUrl, html.EscapeString(policyId)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return NativeAssetsGetAssetNamesByPolicyIdResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return NativeAssetsGetAssetNamesByPolicyIdResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return NativeAssetsGetAssetNamesByPolicyIdResponse{StatusCode: resp.StatusCode, Response: resp, Values: func() []string { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []string for _, el := range tmp { all = append(all, el.(string)) } return all }()} default: return NativeAssetsGetAssetNamesByPolicyIdResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type NativeAssetsGetNftsParams struct { BlockNumberFrom int64 BlockNumberTo int64 } type NativeAssetsGetNftsResponse struct { StatusCode int Response *http.Response Error error GenericError GenericError NftDetailses []NftDetails } func NativeAssetsGetNfts(client Client, params NativeAssetsGetNftsParams) NativeAssetsGetNftsResponse { requestUrl := fmt.Sprintf("%s/native_assets/nfts", client.BaseUrl) urlValues := url.Values{} if 0 != params.BlockNumberFrom { urlValues.Add("block_number_from", strconv.FormatInt(params.BlockNumberFrom, 10)) } if 0 != params.BlockNumberTo { urlValues.Add("block_number_to", strconv.FormatInt(params.BlockNumberTo, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return NativeAssetsGetNftsResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return NativeAssetsGetNftsResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return NativeAssetsGetNftsResponse{StatusCode: resp.StatusCode, Response: resp, NftDetailses: func() []NftDetails { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []NftDetails for _, el := range tmp { all = append(all, NftDetailsFromMap(el)) } return all }()} case 404: return NativeAssetsGetNftsResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return NativeAssetsGetNftsResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type NativeAssetsPostNativeAssetsDetailsResponse struct { StatusCode int Response *http.Response Error error NativeAssetDetailses []NativeAssetDetails } func NativeAssetsPostNativeAssetsDetails(client Client, nativeAssetDetailsRequest NativeAssetDetailsRequest) NativeAssetsPostNativeAssetsDetailsResponse { requestUrl := fmt.Sprintf("%s/native_assets/native_assets_details", client.BaseUrl) bodyDocument, err := json.Marshal(nativeAssetDetailsRequest) if err != nil { return NativeAssetsPostNativeAssetsDetailsResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return NativeAssetsPostNativeAssetsDetailsResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return NativeAssetsPostNativeAssetsDetailsResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return NativeAssetsPostNativeAssetsDetailsResponse{StatusCode: resp.StatusCode, Response: resp, NativeAssetDetailses: func() []NativeAssetDetails { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []NativeAssetDetails for _, el := range tmp { all = append(all, NativeAssetDetailsFromMap(el)) } return all }()} default: return NativeAssetsPostNativeAssetsDetailsResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type NativeAssetsGetByStakeAddressResponse struct { StatusCode int Response *http.Response Error error NativeAssets []NativeAsset } func NativeAssetsGetByStakeAddress(client Client, stakeAddress string) NativeAssetsGetByStakeAddressResponse { requestUrl := fmt.Sprintf("%s/native_assets/%s", client.BaseUrl, html.EscapeString(stakeAddress)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return NativeAssetsGetByStakeAddressResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return NativeAssetsGetByStakeAddressResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return NativeAssetsGetByStakeAddressResponse{StatusCode: resp.StatusCode, Response: resp, NativeAssets: func() []NativeAsset { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []NativeAsset for _, el := range tmp { all = append(all, NativeAssetFromMap(el)) } return all }()} default: return NativeAssetsGetByStakeAddressResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type PoolUpdatesGetRetiringParams struct { BlockNumberFrom int64 Limit int64 } type PoolUpdatesGetRetiringResponse struct { StatusCode int Response *http.Response Error error GenericError GenericError PoolRetirings []PoolRetiring } func PoolUpdatesGetRetiring(client Client, params PoolUpdatesGetRetiringParams) PoolUpdatesGetRetiringResponse { requestUrl := fmt.Sprintf("%s/pool_updates/retiring", client.BaseUrl) urlValues := url.Values{} if 0 != params.BlockNumberFrom { urlValues.Add("block_number_from", strconv.FormatInt(params.BlockNumberFrom, 10)) } if 0 != params.Limit { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return PoolUpdatesGetRetiringResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return PoolUpdatesGetRetiringResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return PoolUpdatesGetRetiringResponse{StatusCode: resp.StatusCode, Response: resp, PoolRetirings: func() []PoolRetiring { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []PoolRetiring for _, el := range tmp { all = append(all, PoolRetiringFromMap(el)) } return all }()} case 404: return PoolUpdatesGetRetiringResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return PoolUpdatesGetRetiringResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type PoolUpdatesGetByPoolIdParams struct { BlockNumberFrom int64 Limit int64 } type PoolUpdatesGetByPoolIdResponse struct { StatusCode int Response *http.Response Error error GenericError GenericError PoolUpdates []PoolUpdate } func PoolUpdatesGetByPoolId(client Client, poolId string, params PoolUpdatesGetByPoolIdParams) PoolUpdatesGetByPoolIdResponse { requestUrl := fmt.Sprintf("%s/pool_updates/%s", client.BaseUrl, html.EscapeString(poolId)) urlValues := url.Values{} if 0 != params.BlockNumberFrom { urlValues.Add("block_number_from", strconv.FormatInt(params.BlockNumberFrom, 10)) } if 0 != params.Limit { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return PoolUpdatesGetByPoolIdResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return PoolUpdatesGetByPoolIdResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return PoolUpdatesGetByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, PoolUpdates: func() []PoolUpdate { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []PoolUpdate for _, el := range tmp { all = append(all, PoolUpdateFromMap(el)) } return all }()} case 404: return PoolUpdatesGetByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return PoolUpdatesGetByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type PoolUpdatesGetParams struct { BlockNumberFrom int64 Limit int64 } type PoolUpdatesGetResponse struct { StatusCode int Response *http.Response Error error GenericError GenericError PoolUpdates []PoolUpdate } func PoolUpdatesGet(client Client, params PoolUpdatesGetParams) PoolUpdatesGetResponse { requestUrl := fmt.Sprintf("%s/pool_updates", client.BaseUrl) urlValues := url.Values{} if 0 != params.BlockNumberFrom { urlValues.Add("block_number_from", strconv.FormatInt(params.BlockNumberFrom, 10)) } if 0 != params.Limit { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return PoolUpdatesGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return PoolUpdatesGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return PoolUpdatesGetResponse{StatusCode: resp.StatusCode, Response: resp, PoolUpdates: func() []PoolUpdate { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []PoolUpdate for _, el := range tmp { all = append(all, PoolUpdateFromMap(el)) } return all }()} case 404: return PoolUpdatesGetResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return PoolUpdatesGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type RewardsGetByStakingAddressParams struct { EpochFrom int32 EpochTo int32 } type RewardsGetByStakingAddressResponse struct { StatusCode int Response *http.Response Error error Rewards []Reward } func RewardsGetByStakingAddress(client Client, stakingAddress string, params RewardsGetByStakingAddressParams) RewardsGetByStakingAddressResponse { requestUrl := fmt.Sprintf("%s/rewards/%s", client.BaseUrl, html.EscapeString(stakingAddress)) urlValues := url.Values{} if 0 != params.EpochFrom { urlValues.Add("epoch_from", strconv.FormatInt(params.EpochFrom, 10)) } if 0 != params.EpochTo { urlValues.Add("epoch_to", strconv.FormatInt(params.EpochTo, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return RewardsGetByStakingAddressResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return RewardsGetByStakingAddressResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return RewardsGetByStakingAddressResponse{StatusCode: resp.StatusCode, Response: resp, Rewards: func() []Reward { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Reward for _, el := range tmp { all = append(all, RewardFromMap(el)) } return all }()} default: return RewardsGetByStakingAddressResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type SigmasGetByPoolIdParams struct { EpochNumber int32 } type SigmasGetByPoolIdResponse struct { StatusCode int Response *http.Response Error error Sigma Sigma } func SigmasGetByPoolId(client Client, poolId string, params SigmasGetByPoolIdParams) SigmasGetByPoolIdResponse { requestUrl := fmt.Sprintf("%s/sigmas/%s", client.BaseUrl, html.EscapeString(poolId)) urlValues := url.Values{} if 0 != params.EpochNumber { urlValues.Add("epoch_number", strconv.FormatInt(params.EpochNumber, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return SigmasGetByPoolIdResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return SigmasGetByPoolIdResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return SigmasGetByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, Sigma: SigmaFromJson(resp.Body)} default: return SigmasGetByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type StakepoolsGetVrfVkeyByVrfVkeyHashResponse struct { StatusCode int Response *http.Response Error error GenericError GenericError Stakepool Stakepool } func StakepoolsGetVrfVkeyByVrfVkeyHash(client Client, vrfVkeyHash string) StakepoolsGetVrfVkeyByVrfVkeyHashResponse { requestUrl := fmt.Sprintf("%s/stakepools/vrf_vkey/%s", client.BaseUrl, html.EscapeString(vrfVkeyHash)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return StakepoolsGetVrfVkeyByVrfVkeyHashResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return StakepoolsGetVrfVkeyByVrfVkeyHashResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return StakepoolsGetVrfVkeyByVrfVkeyHashResponse{StatusCode: resp.StatusCode, Response: resp, Stakepool: StakepoolFromJson(resp.Body)} case 404: return StakepoolsGetVrfVkeyByVrfVkeyHashResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return StakepoolsGetVrfVkeyByVrfVkeyHashResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type StakepoolsGetEstablishedEpochByPoolIdResponse struct { StatusCode int Response *http.Response Error error GenericError GenericError Value int32 } func StakepoolsGetEstablishedEpochByPoolId(client Client, poolId string) StakepoolsGetEstablishedEpochByPoolIdResponse { requestUrl := fmt.Sprintf("%s/stakepools/%s/established_epoch", client.BaseUrl, html.EscapeString(poolId)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return StakepoolsGetEstablishedEpochByPoolIdResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return StakepoolsGetEstablishedEpochByPoolIdResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return StakepoolsGetEstablishedEpochByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, Value: string(resp.Body)} case 404: return StakepoolsGetEstablishedEpochByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return StakepoolsGetEstablishedEpochByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type StakepoolsGetLiveStakeByPoolIdResponse struct { StatusCode int Response *http.Response Error error GenericError GenericError Value int64 } func StakepoolsGetLiveStakeByPoolId(client Client, poolId string) StakepoolsGetLiveStakeByPoolIdResponse { requestUrl := fmt.Sprintf("%s/stakepools/%s/live_stake", client.BaseUrl, html.EscapeString(poolId)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return StakepoolsGetLiveStakeByPoolIdResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return StakepoolsGetLiveStakeByPoolIdResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return StakepoolsGetLiveStakeByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, Value: string(resp.Body)} case 404: return StakepoolsGetLiveStakeByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return StakepoolsGetLiveStakeByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type StakepoolsGetBlocksByPoolIdParams struct { Epoch int32 } type StakepoolsGetBlocksByPoolIdResponse struct { StatusCode int Response *http.Response Error error GenericError GenericError Value int32 } func StakepoolsGetBlocksByPoolId(client Client, poolId string, params StakepoolsGetBlocksByPoolIdParams) StakepoolsGetBlocksByPoolIdResponse { requestUrl := fmt.Sprintf("%s/stakepools/%s/blocks", client.BaseUrl, html.EscapeString(poolId)) urlValues := url.Values{} if 0 != params.Epoch { urlValues.Add("epoch", strconv.FormatInt(params.Epoch, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return StakepoolsGetBlocksByPoolIdResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return StakepoolsGetBlocksByPoolIdResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return StakepoolsGetBlocksByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, Value: string(resp.Body)} case 404: return StakepoolsGetBlocksByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return StakepoolsGetBlocksByPoolIdResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type StakepoolsGetResponse struct { StatusCode int Response *http.Response Error error Stakepools []Stakepool } func StakepoolsGet(client Client) StakepoolsGetResponse { requestUrl := fmt.Sprintf("%s/stakepools", client.BaseUrl) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return StakepoolsGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return StakepoolsGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return StakepoolsGetResponse{StatusCode: resp.StatusCode, Response: resp, Stakepools: func() []Stakepool { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Stakepool for _, el := range tmp { all = append(all, StakepoolFromMap(el)) } return all }()} default: return StakepoolsGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type StakepoolMetadataGetByPoolIdBech32Response struct { StatusCode int Response *http.Response Error error GenericError GenericError StakepoolMetadata StakepoolMetadata } func StakepoolMetadataGetByPoolIdBech32(client Client, poolIdBech32 string) StakepoolMetadataGetByPoolIdBech32Response { requestUrl := fmt.Sprintf("%s/stakepool_metadata/%s", client.BaseUrl, html.EscapeString(poolIdBech32)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return StakepoolMetadataGetByPoolIdBech32Response{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return StakepoolMetadataGetByPoolIdBech32Response{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return StakepoolMetadataGetByPoolIdBech32Response{StatusCode: resp.StatusCode, Response: resp, StakepoolMetadata: StakepoolMetadataFromJson(resp.Body)} case 404: return StakepoolMetadataGetByPoolIdBech32Response{StatusCode: resp.StatusCode, Response: resp, GenericError: GenericErrorFromJson(resp.Body)} default: return StakepoolMetadataGetByPoolIdBech32Response{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type TransactionsPostHistoryResponse struct { StatusCode int Response *http.Response Error error Transactions []Transaction } func TransactionsPostHistory(client Client, transactionHistoryRequest TransactionHistoryRequest) TransactionsPostHistoryResponse { requestUrl := fmt.Sprintf("%s/transactions/history", client.BaseUrl) bodyDocument, err := json.Marshal(transactionHistoryRequest) if err != nil { return TransactionsPostHistoryResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return TransactionsPostHistoryResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return TransactionsPostHistoryResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return TransactionsPostHistoryResponse{StatusCode: resp.StatusCode, Response: resp, Transactions: func() []Transaction { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Transaction for _, el := range tmp { all = append(all, TransactionFromMap(el)) } return all }()} default: return TransactionsPostHistoryResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type WalletBalancesGetByStakingAddressResponse struct { StatusCode int Response *http.Response Error error WalletBalance WalletBalance } func WalletBalancesGetByStakingAddress(client Client, stakingAddress string) WalletBalancesGetByStakingAddressResponse { requestUrl := fmt.Sprintf("%s/wallet_balances/%s", client.BaseUrl, html.EscapeString(stakingAddress)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return WalletBalancesGetByStakingAddressResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return WalletBalancesGetByStakingAddressResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return WalletBalancesGetByStakingAddressResponse{StatusCode: resp.StatusCode, Response: resp, WalletBalance: WalletBalanceFromJson(resp.Body)} default: return WalletBalancesGetByStakingAddressResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } func buildRequest(client Client, method, urlStr string, body ClientRequestBody) (*http.Request, error) { request, err := http.NewRequest(method, urlStr, body.bytes) if err != nil { return nil, err } request.Header.Add("User-Agent", UserAgent) request.Header.Add("X-Apidoc-Version", Version) request.Header.Add("X-Apidoc-Version-Major", strconv.Itoa(VersionMajor)) if client.Headers != nil { for key, values := range client.Headers { for _, value := range values { request.Header.Add(key, value) } } } if body.contentType != "" { request.Header.Add("Content-Type", body.contentType) } if client.Username != "" { request.SetBasicAuth(client.Username, client.Password) } return request, nil }