power_reqwest_lib/
model.rs

1use proc_macro2::Span;
2use syn::{Ident, LitBool, LitFloat, LitInt, LitStr};
3
4pub struct Client {
5    pub name: Ident,
6    pub config: Option<Vec<DataField>>,
7    pub common: Option<Common>,
8    pub auth: Option<Auth>,
9    pub signing: Option<Signing>,
10    pub apis: Vec<Api>,
11}
12
13pub struct Common {
14    pub(crate) span: Span,
15    pub unwrap_response: Option<syn::Path>,
16}
17
18pub struct Signing {
19    pub(crate) span: Span,
20    pub sign_fn: Option<syn::Path>,
21}
22
23pub struct Auth {
24    pub(crate) span: Span,
25    pub url: LitStr,
26}
27
28pub struct Api {
29    pub name: LitStr,
30    pub method: Ident,
31    pub url: LitStr,
32    pub request: Option<ApiRequest>,
33    pub response: Vec<DataField>,
34}
35
36pub struct ApiRequest {
37    pub header: Option<Vec<ApiHeader>>,
38    pub data: Option<Vec<DataField>>,
39}
40
41pub struct ApiHeader {
42    pub name: LitStr,
43    pub value: Value,
44}
45
46pub struct DataField {
47    pub name: Ident,
48    pub typ: DataType,
49    pub optional: Option<Span>,
50    pub value: Option<Value>,
51}
52
53pub enum DataType {
54    String(Span),
55    Bool(Span),
56    Int(Span),
57    Uint(Span),
58    Float(Span),
59    Object(ObjectType),
60    List(Box<DataType>),
61}
62
63pub struct ObjectType {
64    pub fields: Vec<ObjectFieldType>,
65}
66
67pub struct ObjectFieldType {
68    pub name: Ident,
69    pub value_type: DataType,
70    pub value: Option<Value>,
71}
72
73pub enum Value {
74    Var(Ident),
75    String(LitStr),
76    Bool(LitBool),
77    Int(LitInt),
78    Float(LitFloat),
79    Object(ObjectValue),
80    Array(ArrayValue),
81}
82
83pub struct ObjectValue {
84    pub span: Span,
85    pub fields: Vec<ObjectFieldValue>,
86}
87
88pub struct ObjectFieldValue {
89    pub name: Ident,
90    pub value: Value,
91}
92
93pub struct ArrayValue {
94    pub(crate) span: Span,
95    pub elements: Vec<Value>,
96}