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
//! Official Rust SDK for the [FoPost](https://fopost.com) API — schedule and
//! publish to +30 social platforms from your code.
//!
//! ```no_run
//! use fopost::{Client, models::CreatePost};
//!
//! # async fn run() -> Result<(), fopost::Error> {
//! let client = Client::from_env()?;
//!
//! let workspaces = client.workspaces().list().await?;
//! let workspace = &workspaces[0];
//!
//! let accounts = client.accounts().list(Some(&workspace.id)).await?;
//! let ids: Vec<_> = accounts.iter().map(|a| a.id.clone()).collect();
//!
//! // Create a draft, then send it out.
//! let post = client
//! .posts()
//! .create(&CreatePost::text(&workspace.id, "Hello from Rust").accounts(ids))
//! .await?;
//! client.posts().publish(&post.id, &Default::default()).await?;
//! # Ok(()) }
//! ```
//!
//! # Authentication
//!
//! Every request sends an API key in `X-API-Key`. Keys are created in the
//! dashboard under **Settings → API Keys** and carry only the scopes granted at
//! creation: `posts` (which covers publishing, deliveries, and media),
//! `workspaces`, `accounts`, `labels`, `webhooks`, `analytics`, `automations`,
//! `inbox`, and `ads` (whose four spending calls also need `publish`).
//! A key may also be bound to one workspace, in which case naming any other
//! workspace answers `403`.
//!
//! # Errors
//!
//! Everything returns [`Result<T>`](Result). A non-2xx response becomes
//! [`Error::Api`], carrying the status, the API's machine-readable `code`, and
//! the whole body:
//!
//! ```no_run
//! # async fn run(client: fopost::Client) {
//! match client.posts().publish("9b2f6c1e-…", &Default::default()).await {
//! Ok(result) => println!("{} deliveries queued", result.deliveries().len()),
//! Err(fopost::Error::Api(err)) if err.is_payment_required() => {
//! println!("upgrade at {:?}", err.upgrade_url());
//! }
//! Err(err) => eprintln!("{err}"),
//! }
//! # }
//! ```
//!
//! # Rate limiting
//!
//! Requests are limited per key, per minute. A `429` is retried automatically,
//! waiting for the interval the API asks for in `Retry-After`, up to
//! [`ClientBuilder::max_retries`] attempts. Set it to `1` to handle backoff
//! yourself.
//!
//! # Cargo features
//!
//! | Feature | Default | What it does |
//! | --- | --- | --- |
//! | `rustls-tls` | yes | TLS through rustls, needing no system OpenSSL |
//! | `native-tls` | no | TLS through the platform's own stack |
//! | `multipart` | yes | Media upload and bulk CSV import |
pub use ;
pub use ;
pub use DEFAULT_BASE_URL;
/// Alias for people arriving from the TypeScript SDK, where the class is `FoPost`.
pub type FoPost = Client;
/// The README's examples, compiled as doctests so they cannot rot.
;