1use crate::methods::Method;
2use crate::model::*;
3use crate::params::*;
4
5const API_JSON_RPC_VERSION: &str = "2.0";
6
7pub type EmptyRequest = Request<ApiKeyParams>;
10impl EmptyRequest {
11 pub fn new(method: Method, api_key: ApiKey) -> EmptyRequest {
13 EmptyRequest {
14 json_rpc: API_JSON_RPC_VERSION.to_owned(),
15 method,
16 params: ApiKeyParams { api_key },
17 id: RequestId(1),
18 }
19 }
20}
21
22pub type GenerateIntegersRequest = Request<GenerateIntegersParams>;
24impl GenerateIntegersRequest {
25 pub fn new(
27 api_key: ApiKey,
28 min: i32,
29 max: i32,
30 limit: u16,
31 replacement: bool,
32 ) -> GenerateIntegersRequest {
33 GenerateIntegersRequest {
34 json_rpc: API_JSON_RPC_VERSION.to_owned(),
35 method: Method::GenerateIntegers,
36 params: GenerateIntegersParams {
37 api_key,
38 min,
39 max,
40 limit,
41 replacement,
42 },
43 id: RequestId(1),
44 }
45 }
46}
47
48pub type GenerateDecimalFractionsRequest = Request<GenerateDecimalFractionsParams>;
50impl GenerateDecimalFractionsRequest {
51 pub fn new(api_key: ApiKey, limit: u16, decimal_places: u8) -> GenerateDecimalFractionsRequest {
53 GenerateDecimalFractionsRequest {
54 json_rpc: API_JSON_RPC_VERSION.to_owned(),
55 method: Method::GenerateDecimalFractions,
56 params: GenerateDecimalFractionsParams {
57 api_key,
58 limit,
59 decimal_places,
60 },
61 id: RequestId(1),
62 }
63 }
64}
65
66pub type GenerateGaussiansRequest = Request<GenerateGaussiansParams>;
68impl GenerateGaussiansRequest {
69 pub fn new(
71 api_key: ApiKey,
72 limit: u16,
73 mean: i32,
74 standard_deviation: i32,
75 significant_digits: u8,
76 ) -> GenerateGaussiansRequest {
77 GenerateGaussiansRequest {
78 json_rpc: API_JSON_RPC_VERSION.to_owned(),
79 method: Method::GenerateGaussians,
80 params: GenerateGaussiansParams {
81 api_key,
82 limit,
83 mean,
84 standard_deviation,
85 significant_digits,
86 },
87 id: RequestId(1),
88 }
89 }
90}
91
92pub type GenerateStringsRequest = Request<GenerateStringsParams>;
94impl GenerateStringsRequest {
95 pub fn new(
97 api_key: ApiKey,
98 limit: u16,
99 length: u8,
100 characters: AllowedCharacters,
101 ) -> GenerateStringsRequest {
102 GenerateStringsRequest {
103 json_rpc: API_JSON_RPC_VERSION.to_owned(),
104 method: Method::GenerateStrings,
105 params: GenerateStringsParams {
106 api_key,
107 limit,
108 length,
109 characters: characters.0.iter().collect::<String>(),
110 },
111 id: RequestId(1),
112 }
113 }
114}
115
116pub type GenerateUUIDsRequest = Request<GenerateUUIDsParams>;
118impl GenerateUUIDsRequest {
119 pub fn new(api_key: ApiKey, limit: u16) -> GenerateUUIDsRequest {
121 GenerateUUIDsRequest {
122 json_rpc: API_JSON_RPC_VERSION.to_owned(),
123 method: Method::GenerateUUIDs,
124 params: GenerateUUIDsParams { api_key, limit },
125 id: RequestId(1),
126 }
127 }
128}
129
130pub type GenerateBlobsRequest = Request<GenerateBlobsParams>;
132impl GenerateBlobsRequest {
133 pub fn new(api_key: ApiKey, limit: u16, size: u32) -> GenerateBlobsRequest {
135 GenerateBlobsRequest {
136 json_rpc: API_JSON_RPC_VERSION.to_owned(),
137 method: Method::GenerateBlobs,
138 params: GenerateBlobsParams {
139 api_key,
140 limit,
141 size,
142 },
143 id: RequestId(1),
144 }
145 }
146}