polymarket_relayer/auth/
mod.rs1pub mod builder;
2pub mod relayer_key;
3
4use reqwest::header::HeaderMap;
5
6#[derive(Debug, Clone)]
8pub enum AuthMethod {
9 Builder(BuilderConfig),
11 RelayerKey { api_key: String, address: String },
13}
14
15impl AuthMethod {
16 pub fn builder(key: &str, secret: &str, passphrase: &str) -> Self {
18 AuthMethod::Builder(BuilderConfig {
19 key: key.to_string(),
20 secret: secret.to_string(),
21 passphrase: passphrase.to_string(),
22 })
23 }
24
25 pub fn relayer_key(api_key: &str, address: &str) -> Self {
27 AuthMethod::RelayerKey {
28 api_key: api_key.to_string(),
29 address: address.to_string(),
30 }
31 }
32
33 pub fn headers(
35 &self,
36 method: &str,
37 path: &str,
38 body: &str,
39 ) -> crate::error::Result<HeaderMap> {
40 match self {
41 AuthMethod::Builder(config) => builder::build_headers(config, method, path, body),
42 AuthMethod::RelayerKey { api_key, address } => {
43 relayer_key::build_headers(api_key, address)
44 }
45 }
46 }
47}
48
49#[derive(Debug, Clone)]
51pub struct BuilderConfig {
52 pub key: String,
53 pub secret: String,
54 pub passphrase: String,
55}