openai_client_cli/service/request.rs
1use crate::{loaders::*, Result, traits::*};
2use url::Url;
3
4/// The request object.
5pub struct OpenAIRequest {
6 /// The HTTP method.
7 pub method: Method,
8
9 /// The parameter object (request body).
10 pub parameter: Option<Parameter>,
11
12 /// The URL.
13 pub url: Url,
14}
15
16impl OpenAIRequest {
17 /// Create a new request object.
18 pub fn new(
19 method: Method,
20 path: Path,
21 parameter: Option<Parameter>,
22 ) -> Result<Self> {
23 Ok(Self {
24 method,
25 parameter,
26 url: Url::parse("https://api.openai.com/v1/")?.join(&path.value())?,
27 })
28 }
29}