package client

// Code generated by x-ranger site-docs. DO NOT EDIT.
// x-gql API

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
}

func (c *Client) client() *http.Client {
	if c.HTTPClient != nil {
		return c.HTTPClient
	}
	return http.DefaultClient
}

func (c *Client) do(method, path string, body io.Reader) (*http.Response, error) {
	base := strings.TrimRight(c.BaseURL, "/")
	if !strings.HasPrefix(path, "/") {
		path = "/" + path
	}
	req, err := http.NewRequest(method, base+path, body)
	if err != nil {
		return nil, err
	}
	return c.client().Do(req)
}

// FederationChain — Resolve a knotchain federation record by chain id.
func (c *Client) FederationChain() (*http.Response, error) {
	return c.do("GET", "/api/federationChain", nil)
}

// FederationLookup — N1 two-step lookup (route + witness + admissible path proof).
func (c *Client) FederationLookup() (*http.Response, error) {
	return c.do("GET", "/api/federationLookup", nil)
}

// FederationSnapshot — Fetch signed federation index snapshot metadata.
func (c *Client) FederationSnapshot() (*http.Response, error) {
	return c.do("GET", "/api/federationSnapshot", nil)
}

// ReadUser — Query: root → read_user
func (c *Client) ReadUser() (*http.Response, error) {
	return c.do("GET", "/api/readUser", nil)
}

// SaveUser — Mutation fold: input_user → save_user
func (c *Client) SaveUser() (*http.Response, error) {
	return c.do("POST", "/api/saveUser", nil)
}

// ScanResult — Query: request → scan_result
func (c *Client) ScanResult() (*http.Response, error) {
	return c.do("GET", "/api/scanResult", nil)
}

// Ensure unused import does not fail empty packages.
var _ = fmt.Sprintf
