mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
glassnode: delete all requests
This commit is contained in:
parent
66f923ad0d
commit
5ce5571b5e
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type AddressesRequest -url "/v1/metrics/addresses/:metric" -responseType Response
|
||||
type AddressesRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type AddressesRequest -url /v1/metrics/addresses/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (a *AddressesRequest) SetAsset(Asset string) *AddressesRequest {
|
||||
a.Asset = Asset
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AddressesRequest) SetSince(Since int64) *AddressesRequest {
|
||||
a.Since = Since
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AddressesRequest) SetUntil(Until int64) *AddressesRequest {
|
||||
a.Until = Until
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AddressesRequest) SetInterval(Interval Interval) *AddressesRequest {
|
||||
a.Interval = Interval
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AddressesRequest) SetFormat(Format Format) *AddressesRequest {
|
||||
a.Format = Format
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AddressesRequest) SetTimestampFormat(TimestampFormat string) *AddressesRequest {
|
||||
a.TimestampFormat = TimestampFormat
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AddressesRequest) SetMetric(Metric string) *AddressesRequest {
|
||||
a.Metric = Metric
|
||||
return a
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (a *AddressesRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := a.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := a.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := a.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := a.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := a.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := a.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (a *AddressesRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (a *AddressesRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := a.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (a *AddressesRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := a.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (a *AddressesRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := a.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (a *AddressesRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (a *AddressesRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := a.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (a *AddressesRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := a.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/addresses/:metric"
|
||||
slugs, err := a.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = a.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := a.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := a.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type BlockchainRequest -url "/v1/metrics/blockchain/:metric" -responseType Response
|
||||
type BlockchainRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type BlockchainRequest -url /v1/metrics/blockchain/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (b *BlockchainRequest) SetAsset(Asset string) *BlockchainRequest {
|
||||
b.Asset = Asset
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *BlockchainRequest) SetSince(Since int64) *BlockchainRequest {
|
||||
b.Since = Since
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *BlockchainRequest) SetUntil(Until int64) *BlockchainRequest {
|
||||
b.Until = Until
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *BlockchainRequest) SetInterval(Interval Interval) *BlockchainRequest {
|
||||
b.Interval = Interval
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *BlockchainRequest) SetFormat(Format Format) *BlockchainRequest {
|
||||
b.Format = Format
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *BlockchainRequest) SetTimestampFormat(TimestampFormat string) *BlockchainRequest {
|
||||
b.TimestampFormat = TimestampFormat
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *BlockchainRequest) SetMetric(Metric string) *BlockchainRequest {
|
||||
b.Metric = Metric
|
||||
return b
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (b *BlockchainRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := b.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := b.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := b.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := b.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := b.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := b.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (b *BlockchainRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (b *BlockchainRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := b.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (b *BlockchainRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := b.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (b *BlockchainRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := b.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (b *BlockchainRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (b *BlockchainRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := b.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (b *BlockchainRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := b.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/blockchain/:metric"
|
||||
slugs, err := b.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = b.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := b.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := b.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type DefiRequest -url "/v1/metrics/defi/:metric" -responseType Response
|
||||
type DefiRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type DefiRequest -url /v1/metrics/defi/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (d *DefiRequest) SetAsset(Asset string) *DefiRequest {
|
||||
d.Asset = Asset
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DefiRequest) SetSince(Since int64) *DefiRequest {
|
||||
d.Since = Since
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DefiRequest) SetUntil(Until int64) *DefiRequest {
|
||||
d.Until = Until
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DefiRequest) SetInterval(Interval Interval) *DefiRequest {
|
||||
d.Interval = Interval
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DefiRequest) SetFormat(Format Format) *DefiRequest {
|
||||
d.Format = Format
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DefiRequest) SetTimestampFormat(TimestampFormat string) *DefiRequest {
|
||||
d.TimestampFormat = TimestampFormat
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DefiRequest) SetMetric(Metric string) *DefiRequest {
|
||||
d.Metric = Metric
|
||||
return d
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (d *DefiRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := d.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := d.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := d.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := d.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := d.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := d.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (d *DefiRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (d *DefiRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := d.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (d *DefiRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := d.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (d *DefiRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := d.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (d *DefiRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (d *DefiRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := d.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (d *DefiRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := d.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/defi/:metric"
|
||||
slugs, err := d.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = d.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := d.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := d.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type DerivativesRequest -url "/v1/metrics/derivatives/:metric" -responseType Response
|
||||
type DerivativesRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type DerivativesRequest -url /v1/metrics/derivatives/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (d *DerivativesRequest) SetAsset(Asset string) *DerivativesRequest {
|
||||
d.Asset = Asset
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DerivativesRequest) SetSince(Since int64) *DerivativesRequest {
|
||||
d.Since = Since
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DerivativesRequest) SetUntil(Until int64) *DerivativesRequest {
|
||||
d.Until = Until
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DerivativesRequest) SetInterval(Interval Interval) *DerivativesRequest {
|
||||
d.Interval = Interval
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DerivativesRequest) SetFormat(Format Format) *DerivativesRequest {
|
||||
d.Format = Format
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DerivativesRequest) SetTimestampFormat(TimestampFormat string) *DerivativesRequest {
|
||||
d.TimestampFormat = TimestampFormat
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DerivativesRequest) SetMetric(Metric string) *DerivativesRequest {
|
||||
d.Metric = Metric
|
||||
return d
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (d *DerivativesRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := d.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := d.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := d.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := d.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := d.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := d.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (d *DerivativesRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (d *DerivativesRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := d.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (d *DerivativesRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := d.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (d *DerivativesRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := d.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (d *DerivativesRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (d *DerivativesRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := d.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (d *DerivativesRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := d.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/derivatives/:metric"
|
||||
slugs, err := d.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = d.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := d.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := d.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type DistributionRequest -url "/v1/metrics/distribution/:metric" -responseType Response
|
||||
type DistributionRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type DistributionRequest -url /v1/metrics/distribution/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (d *DistributionRequest) SetAsset(Asset string) *DistributionRequest {
|
||||
d.Asset = Asset
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DistributionRequest) SetSince(Since int64) *DistributionRequest {
|
||||
d.Since = Since
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DistributionRequest) SetUntil(Until int64) *DistributionRequest {
|
||||
d.Until = Until
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DistributionRequest) SetInterval(Interval Interval) *DistributionRequest {
|
||||
d.Interval = Interval
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DistributionRequest) SetFormat(Format Format) *DistributionRequest {
|
||||
d.Format = Format
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DistributionRequest) SetTimestampFormat(TimestampFormat string) *DistributionRequest {
|
||||
d.TimestampFormat = TimestampFormat
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *DistributionRequest) SetMetric(Metric string) *DistributionRequest {
|
||||
d.Metric = Metric
|
||||
return d
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (d *DistributionRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := d.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := d.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := d.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := d.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := d.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := d.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (d *DistributionRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (d *DistributionRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := d.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (d *DistributionRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := d.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (d *DistributionRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := d.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (d *DistributionRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (d *DistributionRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := d.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (d *DistributionRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := d.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/distribution/:metric"
|
||||
slugs, err := d.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = d.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := d.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := d.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type EntitiesRequest -url "/v1/metrics/entities/:metric" -responseType Response
|
||||
type EntitiesRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type EntitiesRequest -url /v1/metrics/entities/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (e *EntitiesRequest) SetAsset(Asset string) *EntitiesRequest {
|
||||
e.Asset = Asset
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EntitiesRequest) SetSince(Since int64) *EntitiesRequest {
|
||||
e.Since = Since
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EntitiesRequest) SetUntil(Until int64) *EntitiesRequest {
|
||||
e.Until = Until
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EntitiesRequest) SetInterval(Interval Interval) *EntitiesRequest {
|
||||
e.Interval = Interval
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EntitiesRequest) SetFormat(Format Format) *EntitiesRequest {
|
||||
e.Format = Format
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EntitiesRequest) SetTimestampFormat(TimestampFormat string) *EntitiesRequest {
|
||||
e.TimestampFormat = TimestampFormat
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EntitiesRequest) SetMetric(Metric string) *EntitiesRequest {
|
||||
e.Metric = Metric
|
||||
return e
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (e *EntitiesRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := e.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := e.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := e.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := e.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := e.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := e.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (e *EntitiesRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (e *EntitiesRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := e.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (e *EntitiesRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := e.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (e *EntitiesRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := e.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (e *EntitiesRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (e *EntitiesRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := e.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (e *EntitiesRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := e.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/entities/:metric"
|
||||
slugs, err := e.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = e.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := e.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := e.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type ETH2Request -url "/v1/metrics/eth2/:metric" -responseType Response
|
||||
type ETH2Request struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type ETH2Request -url /v1/metrics/eth2/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (e *ETH2Request) SetAsset(Asset string) *ETH2Request {
|
||||
e.Asset = Asset
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *ETH2Request) SetSince(Since int64) *ETH2Request {
|
||||
e.Since = Since
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *ETH2Request) SetUntil(Until int64) *ETH2Request {
|
||||
e.Until = Until
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *ETH2Request) SetInterval(Interval Interval) *ETH2Request {
|
||||
e.Interval = Interval
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *ETH2Request) SetFormat(Format Format) *ETH2Request {
|
||||
e.Format = Format
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *ETH2Request) SetTimestampFormat(TimestampFormat string) *ETH2Request {
|
||||
e.TimestampFormat = TimestampFormat
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *ETH2Request) SetMetric(Metric string) *ETH2Request {
|
||||
e.Metric = Metric
|
||||
return e
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (e *ETH2Request) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := e.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := e.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := e.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := e.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := e.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := e.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (e *ETH2Request) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (e *ETH2Request) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := e.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (e *ETH2Request) GetParametersJSON() ([]byte, error) {
|
||||
params, err := e.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (e *ETH2Request) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := e.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (e *ETH2Request) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (e *ETH2Request) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := e.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (e *ETH2Request) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := e.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/eth2/:metric"
|
||||
slugs, err := e.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = e.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := e.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := e.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type FeesRequest -url "/v1/metrics/fees/:metric" -responseType Response
|
||||
type FeesRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type FeesRequest -url /v1/metrics/fees/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (f *FeesRequest) SetAsset(Asset string) *FeesRequest {
|
||||
f.Asset = Asset
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *FeesRequest) SetSince(Since int64) *FeesRequest {
|
||||
f.Since = Since
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *FeesRequest) SetUntil(Until int64) *FeesRequest {
|
||||
f.Until = Until
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *FeesRequest) SetInterval(Interval Interval) *FeesRequest {
|
||||
f.Interval = Interval
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *FeesRequest) SetFormat(Format Format) *FeesRequest {
|
||||
f.Format = Format
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *FeesRequest) SetTimestampFormat(TimestampFormat string) *FeesRequest {
|
||||
f.TimestampFormat = TimestampFormat
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *FeesRequest) SetMetric(Metric string) *FeesRequest {
|
||||
f.Metric = Metric
|
||||
return f
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (f *FeesRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := f.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := f.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := f.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := f.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := f.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := f.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (f *FeesRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (f *FeesRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := f.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (f *FeesRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := f.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (f *FeesRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := f.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (f *FeesRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (f *FeesRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := f.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (f *FeesRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := f.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/fees/:metric"
|
||||
slugs, err := f.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = f.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := f.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := f.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type IndicatorsRequest -url "/v1/metrics/indicators/:metric" -responseType Response
|
||||
type IndicatorsRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type IndicatorsRequest -url /v1/metrics/indicators/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (i *IndicatorsRequest) SetAsset(Asset string) *IndicatorsRequest {
|
||||
i.Asset = Asset
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *IndicatorsRequest) SetSince(Since int64) *IndicatorsRequest {
|
||||
i.Since = Since
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *IndicatorsRequest) SetUntil(Until int64) *IndicatorsRequest {
|
||||
i.Until = Until
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *IndicatorsRequest) SetInterval(Interval Interval) *IndicatorsRequest {
|
||||
i.Interval = Interval
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *IndicatorsRequest) SetFormat(Format Format) *IndicatorsRequest {
|
||||
i.Format = Format
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *IndicatorsRequest) SetTimestampFormat(TimestampFormat string) *IndicatorsRequest {
|
||||
i.TimestampFormat = TimestampFormat
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *IndicatorsRequest) SetMetric(Metric string) *IndicatorsRequest {
|
||||
i.Metric = Metric
|
||||
return i
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (i *IndicatorsRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := i.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := i.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := i.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := i.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := i.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := i.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (i *IndicatorsRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (i *IndicatorsRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := i.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (i *IndicatorsRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := i.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (i *IndicatorsRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := i.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (i *IndicatorsRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (i *IndicatorsRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := i.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (i *IndicatorsRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := i.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/indicators/:metric"
|
||||
slugs, err := i.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = i.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := i.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := i.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type InstitutionsRequest -url "/v1/metrics/institutions/:metric" -responseType Response
|
||||
type InstitutionsRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type InstitutionsRequest -url /v1/metrics/institutions/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (i *InstitutionsRequest) SetAsset(Asset string) *InstitutionsRequest {
|
||||
i.Asset = Asset
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *InstitutionsRequest) SetSince(Since int64) *InstitutionsRequest {
|
||||
i.Since = Since
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *InstitutionsRequest) SetUntil(Until int64) *InstitutionsRequest {
|
||||
i.Until = Until
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *InstitutionsRequest) SetInterval(Interval Interval) *InstitutionsRequest {
|
||||
i.Interval = Interval
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *InstitutionsRequest) SetFormat(Format Format) *InstitutionsRequest {
|
||||
i.Format = Format
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *InstitutionsRequest) SetTimestampFormat(TimestampFormat string) *InstitutionsRequest {
|
||||
i.TimestampFormat = TimestampFormat
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *InstitutionsRequest) SetMetric(Metric string) *InstitutionsRequest {
|
||||
i.Metric = Metric
|
||||
return i
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (i *InstitutionsRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := i.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := i.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := i.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := i.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := i.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := i.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (i *InstitutionsRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (i *InstitutionsRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := i.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (i *InstitutionsRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := i.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (i *InstitutionsRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := i.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (i *InstitutionsRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (i *InstitutionsRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := i.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (i *InstitutionsRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := i.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/institutions/:metric"
|
||||
slugs, err := i.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = i.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := i.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := i.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type LightningRequest -url "/v1/metrics/lightning/:metric" -responseType Response
|
||||
type LightningRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type LightningRequest -url /v1/metrics/lightning/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (l *LightningRequest) SetAsset(Asset string) *LightningRequest {
|
||||
l.Asset = Asset
|
||||
return l
|
||||
}
|
||||
|
||||
func (l *LightningRequest) SetSince(Since int64) *LightningRequest {
|
||||
l.Since = Since
|
||||
return l
|
||||
}
|
||||
|
||||
func (l *LightningRequest) SetUntil(Until int64) *LightningRequest {
|
||||
l.Until = Until
|
||||
return l
|
||||
}
|
||||
|
||||
func (l *LightningRequest) SetInterval(Interval Interval) *LightningRequest {
|
||||
l.Interval = Interval
|
||||
return l
|
||||
}
|
||||
|
||||
func (l *LightningRequest) SetFormat(Format Format) *LightningRequest {
|
||||
l.Format = Format
|
||||
return l
|
||||
}
|
||||
|
||||
func (l *LightningRequest) SetTimestampFormat(TimestampFormat string) *LightningRequest {
|
||||
l.TimestampFormat = TimestampFormat
|
||||
return l
|
||||
}
|
||||
|
||||
func (l *LightningRequest) SetMetric(Metric string) *LightningRequest {
|
||||
l.Metric = Metric
|
||||
return l
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (l *LightningRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := l.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := l.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := l.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := l.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := l.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := l.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (l *LightningRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (l *LightningRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := l.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (l *LightningRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := l.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (l *LightningRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := l.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (l *LightningRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (l *LightningRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := l.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (l *LightningRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := l.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/lightning/:metric"
|
||||
slugs, err := l.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = l.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := l.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := l.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type MarketRequest -url "/v1/metrics/market/:metric" -responseType Response
|
||||
type MarketRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type MarketRequest -url /v1/metrics/market/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (m *MarketRequest) SetAsset(Asset string) *MarketRequest {
|
||||
m.Asset = Asset
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MarketRequest) SetSince(Since int64) *MarketRequest {
|
||||
m.Since = Since
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MarketRequest) SetUntil(Until int64) *MarketRequest {
|
||||
m.Until = Until
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MarketRequest) SetInterval(Interval Interval) *MarketRequest {
|
||||
m.Interval = Interval
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MarketRequest) SetFormat(Format Format) *MarketRequest {
|
||||
m.Format = Format
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MarketRequest) SetTimestampFormat(TimestampFormat string) *MarketRequest {
|
||||
m.TimestampFormat = TimestampFormat
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MarketRequest) SetMetric(Metric string) *MarketRequest {
|
||||
m.Metric = Metric
|
||||
return m
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (m *MarketRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := m.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := m.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := m.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := m.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := m.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := m.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (m *MarketRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (m *MarketRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := m.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (m *MarketRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := m.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (m *MarketRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := m.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (m *MarketRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (m *MarketRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := m.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (m *MarketRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := m.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/market/:metric"
|
||||
slugs, err := m.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = m.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := m.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := m.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type MempoolRequest -url "/v1/metrics/mempool/:metric" -responseType Response
|
||||
type MempoolRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type MempoolRequest -url /v1/metrics/mempool/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (m *MempoolRequest) SetAsset(Asset string) *MempoolRequest {
|
||||
m.Asset = Asset
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MempoolRequest) SetSince(Since int64) *MempoolRequest {
|
||||
m.Since = Since
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MempoolRequest) SetUntil(Until int64) *MempoolRequest {
|
||||
m.Until = Until
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MempoolRequest) SetInterval(Interval Interval) *MempoolRequest {
|
||||
m.Interval = Interval
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MempoolRequest) SetFormat(Format Format) *MempoolRequest {
|
||||
m.Format = Format
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MempoolRequest) SetTimestampFormat(TimestampFormat string) *MempoolRequest {
|
||||
m.TimestampFormat = TimestampFormat
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MempoolRequest) SetMetric(Metric string) *MempoolRequest {
|
||||
m.Metric = Metric
|
||||
return m
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (m *MempoolRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := m.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := m.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := m.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := m.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := m.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := m.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (m *MempoolRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (m *MempoolRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := m.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (m *MempoolRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := m.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (m *MempoolRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := m.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (m *MempoolRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (m *MempoolRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := m.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (m *MempoolRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := m.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/mempool/:metric"
|
||||
slugs, err := m.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = m.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := m.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := m.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type MiningRequest -url "/v1/metrics/mining/:metric" -responseType Response
|
||||
type MiningRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type MiningRequest -url /v1/metrics/mining/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (m *MiningRequest) SetAsset(Asset string) *MiningRequest {
|
||||
m.Asset = Asset
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MiningRequest) SetSince(Since int64) *MiningRequest {
|
||||
m.Since = Since
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MiningRequest) SetUntil(Until int64) *MiningRequest {
|
||||
m.Until = Until
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MiningRequest) SetInterval(Interval Interval) *MiningRequest {
|
||||
m.Interval = Interval
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MiningRequest) SetFormat(Format Format) *MiningRequest {
|
||||
m.Format = Format
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MiningRequest) SetTimestampFormat(TimestampFormat string) *MiningRequest {
|
||||
m.TimestampFormat = TimestampFormat
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MiningRequest) SetMetric(Metric string) *MiningRequest {
|
||||
m.Metric = Metric
|
||||
return m
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (m *MiningRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := m.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := m.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := m.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := m.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := m.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := m.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (m *MiningRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (m *MiningRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := m.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (m *MiningRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := m.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (m *MiningRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := m.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (m *MiningRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (m *MiningRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := m.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (m *MiningRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := m.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/mining/:metric"
|
||||
slugs, err := m.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = m.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := m.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := m.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type ProtocolsRequest -url "/v1/metrics/protocols/:metric" -responseType Response
|
||||
type ProtocolsRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type ProtocolsRequest -url /v1/metrics/protocols/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (p *ProtocolsRequest) SetAsset(Asset string) *ProtocolsRequest {
|
||||
p.Asset = Asset
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *ProtocolsRequest) SetSince(Since int64) *ProtocolsRequest {
|
||||
p.Since = Since
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *ProtocolsRequest) SetUntil(Until int64) *ProtocolsRequest {
|
||||
p.Until = Until
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *ProtocolsRequest) SetInterval(Interval Interval) *ProtocolsRequest {
|
||||
p.Interval = Interval
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *ProtocolsRequest) SetFormat(Format Format) *ProtocolsRequest {
|
||||
p.Format = Format
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *ProtocolsRequest) SetTimestampFormat(TimestampFormat string) *ProtocolsRequest {
|
||||
p.TimestampFormat = TimestampFormat
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *ProtocolsRequest) SetMetric(Metric string) *ProtocolsRequest {
|
||||
p.Metric = Metric
|
||||
return p
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (p *ProtocolsRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := p.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := p.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := p.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := p.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := p.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := p.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (p *ProtocolsRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (p *ProtocolsRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := p.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (p *ProtocolsRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := p.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (p *ProtocolsRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := p.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (p *ProtocolsRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (p *ProtocolsRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := p.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (p *ProtocolsRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := p.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/protocols/:metric"
|
||||
slugs, err := p.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = p.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := p.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := p.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type SupplyRequest -url "/v1/metrics/supply/:metric" -responseType Response
|
||||
type SupplyRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type SupplyRequest -url /v1/metrics/supply/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (s *SupplyRequest) SetAsset(Asset string) *SupplyRequest {
|
||||
s.Asset = Asset
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SupplyRequest) SetSince(Since int64) *SupplyRequest {
|
||||
s.Since = Since
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SupplyRequest) SetUntil(Until int64) *SupplyRequest {
|
||||
s.Until = Until
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SupplyRequest) SetInterval(Interval Interval) *SupplyRequest {
|
||||
s.Interval = Interval
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SupplyRequest) SetFormat(Format Format) *SupplyRequest {
|
||||
s.Format = Format
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SupplyRequest) SetTimestampFormat(TimestampFormat string) *SupplyRequest {
|
||||
s.TimestampFormat = TimestampFormat
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SupplyRequest) SetMetric(Metric string) *SupplyRequest {
|
||||
s.Metric = Metric
|
||||
return s
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (s *SupplyRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := s.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := s.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := s.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := s.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := s.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := s.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (s *SupplyRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (s *SupplyRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := s.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (s *SupplyRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := s.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (s *SupplyRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := s.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (s *SupplyRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (s *SupplyRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := s.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (s *SupplyRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := s.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/supply/:metric"
|
||||
slugs, err := s.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = s.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := s.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := s.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package glassnodeapi
|
||||
|
||||
import "github.com/c9s/requestgen"
|
||||
|
||||
//go:generate requestgen -method GET -type TransactionsRequest -url "/v1/metrics/transactions/:metric" -responseType Response
|
||||
type TransactionsRequest struct {
|
||||
Client requestgen.AuthenticatedAPIClient
|
||||
|
||||
Asset string `param:"a,required,query"`
|
||||
Since int64 `param:"s,query"`
|
||||
Until int64 `param:"u,query"`
|
||||
Interval Interval `param:"i,query"`
|
||||
Format Format `param:"f,query"`
|
||||
TimestampFormat string `param:"timestamp_format,query"`
|
||||
|
||||
Metric string `param:"metric,slug"`
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by "requestgen -method GET -type TransactionsRequest -url /v1/metrics/transactions/:metric -responseType Response"; DO NOT EDIT.
|
||||
|
||||
package glassnodeapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func (t *TransactionsRequest) SetAsset(Asset string) *TransactionsRequest {
|
||||
t.Asset = Asset
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *TransactionsRequest) SetSince(Since int64) *TransactionsRequest {
|
||||
t.Since = Since
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *TransactionsRequest) SetUntil(Until int64) *TransactionsRequest {
|
||||
t.Until = Until
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *TransactionsRequest) SetInterval(Interval Interval) *TransactionsRequest {
|
||||
t.Interval = Interval
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *TransactionsRequest) SetFormat(Format Format) *TransactionsRequest {
|
||||
t.Format = Format
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *TransactionsRequest) SetTimestampFormat(TimestampFormat string) *TransactionsRequest {
|
||||
t.TimestampFormat = TimestampFormat
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *TransactionsRequest) SetMetric(Metric string) *TransactionsRequest {
|
||||
t.Metric = Metric
|
||||
return t
|
||||
}
|
||||
|
||||
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||||
func (t *TransactionsRequest) GetQueryParameters() (url.Values, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Asset field -> json key a
|
||||
Asset := t.Asset
|
||||
|
||||
// TEMPLATE check-required
|
||||
if len(Asset) == 0 {
|
||||
return nil, fmt.Errorf("a is required, empty string given")
|
||||
}
|
||||
// END TEMPLATE check-required
|
||||
|
||||
// assign parameter of Asset
|
||||
params["a"] = Asset
|
||||
// check Since field -> json key s
|
||||
Since := t.Since
|
||||
|
||||
// assign parameter of Since
|
||||
params["s"] = Since
|
||||
// check Until field -> json key u
|
||||
Until := t.Until
|
||||
|
||||
// assign parameter of Until
|
||||
params["u"] = Until
|
||||
// check Interval field -> json key i
|
||||
Interval := t.Interval
|
||||
|
||||
// assign parameter of Interval
|
||||
params["i"] = Interval
|
||||
// check Format field -> json key f
|
||||
Format := t.Format
|
||||
|
||||
// assign parameter of Format
|
||||
params["f"] = Format
|
||||
// check TimestampFormat field -> json key timestamp_format
|
||||
TimestampFormat := t.TimestampFormat
|
||||
|
||||
// assign parameter of TimestampFormat
|
||||
params["timestamp_format"] = TimestampFormat
|
||||
|
||||
query := url.Values{}
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (t *TransactionsRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||||
func (t *TransactionsRequest) GetParametersQuery() (url.Values, error) {
|
||||
query := url.Values{}
|
||||
|
||||
params, err := t.GetParameters()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
query.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||||
func (t *TransactionsRequest) GetParametersJSON() ([]byte, error) {
|
||||
params, err := t.GetParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return json.Marshal(params)
|
||||
}
|
||||
|
||||
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||||
func (t *TransactionsRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check Metric field -> json key metric
|
||||
Metric := t.Metric
|
||||
|
||||
// assign parameter of Metric
|
||||
params["metric"] = Metric
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func (t *TransactionsRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||||
for k, v := range slugs {
|
||||
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||||
url = needleRE.ReplaceAllString(url, v)
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
func (t *TransactionsRequest) GetSlugsMap() (map[string]string, error) {
|
||||
slugs := map[string]string{}
|
||||
params, err := t.GetSlugParameters()
|
||||
if err != nil {
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
slugs[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
return slugs, nil
|
||||
}
|
||||
|
||||
func (t *TransactionsRequest) Do(ctx context.Context) (Response, error) {
|
||||
|
||||
// no body params
|
||||
var params interface{}
|
||||
query, err := t.GetQueryParameters()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/v1/metrics/transactions/:metric"
|
||||
slugs, err := t.GetSlugsMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL = t.applySlugsToUrl(apiURL, slugs)
|
||||
|
||||
req, err := t.Client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := t.Client.SendRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse Response
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiResponse, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user