power_reqwest_lib/
model.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
use proc_macro2::Span;
use syn::{Ident, LitBool, LitFloat, LitInt, LitStr};

pub struct Client {
    pub name: Ident,
    pub config: Option<Vec<DataField>>,
    pub common: Option<Common>,
    pub auth: Option<Auth>,
    pub signing: Option<Signing>,
    pub apis: Vec<Api>,
}

pub struct Common {
    pub(crate) span: Span,
    pub unwrap_response: Option<syn::Path>,
}

pub struct Signing {
    pub(crate) span: Span,
    pub sign_fn: Option<syn::Path>,
}

pub struct Auth {
    pub(crate) span: Span,
    pub url: LitStr,
}

pub struct Api {
    pub name: LitStr,
    pub method: Ident,
    pub url: LitStr,
    pub request: Option<ApiRequest>,
    pub response: Vec<DataField>,
}

pub struct ApiRequest {
    pub header: Option<Vec<ApiHeader>>,
    pub data: Option<Vec<DataField>>,
}

pub struct ApiHeader {
    pub name: LitStr,
    pub value: Value,
}

pub struct DataField {
    pub name: Ident,
    pub typ: DataType,
    pub optional: Option<Span>,
    pub value: Option<Value>,
}

pub enum DataType {
    String(Span),
    Bool(Span),
    Int(Span),
    Uint(Span),
    Float(Span),
    Object(ObjectType),
    List(Box<DataType>),
}

pub struct ObjectType {
    pub fields: Vec<ObjectFieldType>,
}

pub struct ObjectFieldType {
    pub name: Ident,
    pub value_type: DataType,
    pub value: Option<Value>,
}

pub enum Value {
    Var(Ident),
    String(LitStr),
    Bool(LitBool),
    Int(LitInt),
    Float(LitFloat),
    Object(ObjectValue),
    Array(ArrayValue),
}

pub struct ObjectValue {
    pub span: Span,
    pub fields: Vec<ObjectFieldValue>,
}

pub struct ObjectFieldValue {
    pub name: Ident,
    pub value: Value,
}

pub struct ArrayValue {
    pub(crate) span: Span,
    pub elements: Vec<Value>,
}