Skip to content

Base

APIResource

An API resource you can consume from the Rated API

Source code in src/rated/base.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class APIResource:
    """An API resource you can consume from the Rated API"""

    path: str

    def __init__(self, network: Network) -> None:
        """
        Initialize the API resource for the given network

        Args:
            network: The network to consume
        """
        self.network = network

    @property
    def client(self) -> Client:
        """Get a Client object ready to access the network"""
        return self.network.client

    @property
    def resource_path(self) -> str:
        """Full path to the API resource"""
        return f"{self.network.path}{self.path}"

client: Client property

Get a Client object ready to access the network

resource_path: str property

Full path to the API resource

__init__(network)

Initialize the API resource for the given network

Parameters:

Name Type Description Default
network Network

The network to consume

required
Source code in src/rated/base.py
32
33
34
35
36
37
38
39
def __init__(self, network: Network) -> None:
    """
    Initialize the API resource for the given network

    Args:
        network: The network to consume
    """
    self.network = network

Network

A supported network you can access with the Rated API

Source code in src/rated/base.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Network:
    """A supported network you can access with the Rated API"""

    path: str
    supported_networks: Sequence[str]

    def __init__(self, client: Client) -> None:
        """
        Initialize the client to access this network

        Args:
            client: HTTP Client to use for requests

        Raises:
             ValueError: If the client is not supported
        """
        if client.network not in self.supported_networks:
            raise ValueError(f"Unknown network: '{client.network}'")
        self.client = client

__init__(client)

Initialize the client to access this network

Parameters:

Name Type Description Default
client Client

HTTP Client to use for requests

required

Raises:

Type Description
ValueError

If the client is not supported

Source code in src/rated/base.py
12
13
14
15
16
17
18
19
20
21
22
23
24
def __init__(self, client: Client) -> None:
    """
    Initialize the client to access this network

    Args:
        client: HTTP Client to use for requests

    Raises:
         ValueError: If the client is not supported
    """
    if client.network not in self.supported_networks:
        raise ValueError(f"Unknown network: '{client.network}'")
    self.client = client