tangled
alpha
login
or
join now
altagos.dev
/
space
0
fork
atom
A SpaceTraders Agent
0
fork
atom
overview
issues
pulls
pipelines
agent model + get/list requests
altagos.dev
4 months ago
febe319b
19b97ed3
verified
This commit was signed with the committer's
known signature
.
altagos.dev
SSH Key Fingerprint:
SHA256:UbTjEcCZlc6GzQWLCuDK3D//HESWD2xFPkzue9XMras=
+42
2 changed files
expand all
collapse all
unified
split
src
st
models
agents.zig
models.zig
+1
src/st/models.zig
···
1
1
pub const accounts = @import("models/accounts.zig");
2
2
+
pub const agents = @import("models/agents.zig");
2
3
pub const factions = @import("models/factions.zig");
3
4
4
5
pub const Info = @import("models/Info.zig");
+41
src/st/models/agents.zig
···
1
1
+
const st = @import("../root.zig");
2
2
+
const Client = st.http.Client;
3
3
+
const Response = st.http.Response;
4
4
+
const Wrapper = st.models.Wrapper;
5
5
+
const Query = st.models.Query;
6
6
+
const FactionSymbol = st.models.factions.Symbol;
7
7
+
8
8
+
pub const Agent = struct {
9
9
+
symbol: []const u8,
10
10
+
headquarters: []const u8,
11
11
+
credits: u64,
12
12
+
startingFaction: FactionSymbol,
13
13
+
shipCount: u64,
14
14
+
};
15
15
+
16
16
+
pub fn list(client: *Client, opts: Query) !Response([]Agent) {
17
17
+
return client.request(
18
18
+
Wrapper([]Agent),
19
19
+
"/agents?page={}&limit={}",
20
20
+
.{ opts.page, opts.limit },
21
21
+
.{ .auth = .agent },
22
22
+
);
23
23
+
}
24
24
+
25
25
+
pub fn get(client: *Client, symbol: []const u8) !Response(Agent) {
26
26
+
return client.request(
27
27
+
Wrapper(Agent),
28
28
+
"/agents/{s}",
29
29
+
.{symbol},
30
30
+
.{ .auth = .agent },
31
31
+
);
32
32
+
}
33
33
+
34
34
+
pub fn own(client: *Client) !Response(Agent) {
35
35
+
return client.request(
36
36
+
Wrapper(Agent),
37
37
+
"/my/agent",
38
38
+
.{},
39
39
+
.{ .auth = .agent },
40
40
+
);
41
41
+
}