# GENERATED BY Accumulate gen-sdk. DO NOT EDIT.

import json
import requests
from typing import Any, Dict, Optional


class AccumulateClient:
    """Accumulate JSON-RPC API client for v2"""

    def __init__(self, server_url: str):
        self.server_url = server_url
        self.session = requests.Session()

    def call(self, method: str, params: Any = None) -> Any:
        """Make a JSON-RPC call"""
        payload = {
            "jsonrpc": "2.0",
            "method": method,
            "params": params or {},
            "id": 1
        }

        response = self.session.post(
            self.server_url,
            json=payload,
            headers={"Content-Type": "application/json"}
        )
        response.raise_for_status()

        result = response.json()
        if "error" in result:
            raise Exception(f"JSON-RPC Error: {result['error']}")

        return result.get("result")


    def describe(self) -> Dict[str, Any]:
        """queries the basic configuration of the node"""
        return self.call('describe')

    def execute(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a transaction"""
        return self.call('execute', request)

    def execute_add_credits(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits an AddCredits transaction"""
        return self.call('add-credits', request)

    def execute_burn_tokens(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a BurnTokens transaction"""
        return self.call('burn-tokens', request)

    def execute_create_adi(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a CreateIdentity transaction"""
        return self.call('create-adi', request)

    def execute_create_data_account(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a CreateDataAccount transaction"""
        return self.call('create-data-account', request)

    def execute_create_identity(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a CreateIdentity transaction"""
        return self.call('create-identity', request)

    def execute_create_key_book(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a CreateKeyBook transaction"""
        return self.call('create-key-book', request)

    def execute_create_key_page(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a CreateKeyPage transaction"""
        return self.call('create-key-page', request)

    def execute_create_token(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a CreateToken transaction"""
        return self.call('create-token', request)

    def execute_create_token_account(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a CreateTokenAccount transaction"""
        return self.call('create-token-account', request)

    def execute_direct(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a transaction"""
        return self.call('execute-direct', request)

    def execute_issue_tokens(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits an IssueTokens transaction"""
        return self.call('issue-tokens', request)

    def execute_local(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a transaction without routing it. INTENDED FOR INTERNAL USE ONLY"""
        return self.call('execute-local', request)

    def execute_send_tokens(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a SendTokens transaction"""
        return self.call('send-tokens', request)

    def execute_update_account_auth(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits an UpdateAccountAuth transaction"""
        return self.call('update-account-auth', request)

    def execute_update_key(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits an UpdateKey transaction"""
        return self.call('update-key', request)

    def execute_update_key_page(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits an UpdateKeyPage transaction"""
        return self.call('update-key-page', request)

    def execute_write_data(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a WriteData transaction"""
        return self.call('write-data', request)

    def execute_write_data_to(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """submits a WriteDataTo transaction"""
        return self.call('write-data-to', request)

    def faucet(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """requests tokens from the ACME faucet"""
        return self.call('faucet', request)

    def metrics(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """queries network metrics, such as transactions per second"""
        return self.call('metrics', request)

    def query(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """queries an account or account chain by URL"""
        return self.call('query', request)

    def query_data(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """queries an entry on an account's data chain"""
        return self.call('query-data', request)

    def query_data_set(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """queries a range of entries on an account's data chain"""
        return self.call('query-data-set', request)

    def query_directory(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """queries the directory entries of an account"""
        return self.call('query-directory', request)

    def query_key_page_index(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """queries the location of a key within an account's key book(s)"""
        return self.call('query-key-index', request)

    def query_major_blocks(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """queries an account's major blocks"""
        return self.call('query-major-blocks', request)

    def query_minor_blocks(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """queries an account's minor blocks"""
        return self.call('query-minor-blocks', request)

    def query_synth(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """"""
        return self.call('query-synth', request)

    def query_tx(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """queries a transaction by ID"""
        return self.call('query-tx', request)

    def query_tx_history(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """queries an account's transaction history"""
        return self.call('query-tx-history', request)

    def query_tx_local(self , request: Dict[str, Any]) -> Dict[str, Any]:
        """queries a transaction by ID"""
        return self.call('query-tx-local', request)

    def status(self) -> Dict[str, Any]:
        """queries the status of the node"""
        return self.call('status')

    def version(self) -> Dict[str, Any]:
        """queries the software version of the node"""
        return self.call('version')


    def close(self):
        """Close the session"""
        self.session.close()