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
// Generated by hey-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
#![allow(clippy::too_many_arguments)]
use crate::client::Client;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
pub struct Messages<'a> {
client: &'a Client,
}
impl<'a> Messages<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
/// The client this service sends through.
pub fn client(&self) -> &'a Client {
self.client
}
/// Create a new message (start a new topic).
/// The acting sender ID must be included; the Go SDK resolves this automatically.
/// Every message is created drafted on HEY's side; without entry.status the server
/// delivers it, while entry.status "drafted" leaves it as a draft and answers
/// 204 with a Location header naming /messages/{entry_id}.
pub async fn create(&self, body: &CreateMessageRequestContent) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::CREATE_MESSAGE, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
/// Get a message
pub async fn get(&self, message_id: i64) -> Result<GetMessageResponseContent, Error> {
let mut operation = self.client.operation(&routes::GET_MESSAGE, &[&message_id]);
operation.resource_id(message_id);
self.client.send(operation).await
}
/// A draft's editable state: content, recipients and scheduled delivery as the
/// composer would load them (GET /messages/{id}/edit).
pub async fn get_edit(&self, message_id: i64) -> Result<GetMessageEditResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::GET_MESSAGE_EDIT, &[&message_id]);
operation.resource_id(message_id);
self.client.send(operation).await
}
/// Revise a message entry (MessagesController#update). With entry.status "drafted" the
/// entry is saved as a draft (204 + Location, like CreateMessage); without it a draft is
/// delivered through the undo-delay window. A trashed draft is silently restored first.
/// The revision is not a patch: subject, content and any scheduled delivery are rewritten
/// from this request (an omitted scheduled delivery clears one), while recipients are
/// replaced only when entry.addressed is present.
///
/// Not naturally idempotent despite the PUT: without the drafted status this request
/// *delivers*, so a transparent retry after an ambiguous first attempt could send the
/// message again. The client must not retry it.
pub async fn update(
&self,
message_id: i64,
body: &CreateMessageRequestContent,
) -> Result<(), Error> {
let mut operation = self
.client
.operation(&routes::UPDATE_MESSAGE, &[&message_id]);
operation.resource_id(message_id);
operation.json(body)?;
self.client.send_unit(operation).await
}
}