pcs_external/lib.rs
1//! PCS External API client — `v0.3.0`.
2//!
3//! Phantom-typed gRPC client for the PCS External Developer Platform
4//! (`chat.external` package). OAuth2 JWT auth is built-in via
5//! `ppoppo-sdk-core`'s `TokenCache` + `AuthInterceptor`.
6//!
7//! ## Quick start
8//!
9//! ```no_run
10//! # async fn example() -> Result<(), pcs_external::Error> {
11//! use pcs_external::{PcsExternalClientBuilder, scopes::SendOnly};
12//! use pcs_external::types::{Ppnum, RecipientList, TemplateId};
13//!
14//! // Build a send-only client from environment variables.
15//! let client = PcsExternalClientBuilder::from_env()
16//! .ok_or_else(|| pcs_external::Error::Transport("missing env vars".into()))?
17//! .build::<SendOnly>()
18//! .await?;
19//!
20//! let recipients = RecipientList::from_ppnums(vec![
21//! Ppnum::try_new("12345678901").map_err(|e| pcs_external::Error::Transport(e.to_string()))?,
22//! ])
23//! .map_err(|e| pcs_external::Error::Transport(e.to_string()))?;
24//!
25//! let outcome = client.send_alert(&TemplateId::new("tmpl_v1"), &recipients, None).await?;
26//! println!("queued: {:?}", outcome.id);
27//! # Ok(())
28//! # }
29//! ```
30//!
31//! ## Scope sets
32//!
33//! Construct the client with the scope set that matches your OAuth2 grant.
34//! Method availability is enforced at compile time:
35//!
36//! | Scope set | `send_alert` | `get_send_status` |
37//! |---|:---:|:---:|
38//! | `ReadOnly` | — | ✓ |
39//! | `SendOnly` | ✓ | — |
40//! | `ReadAndSend` | ✓ | ✓ |
41//! | `FullAccess` | ✓ | ✓ |
42
43#![deny(rust_2018_idioms)]
44
45mod builder;
46mod client;
47mod error;
48mod proto;
49pub mod scopes;
50#[cfg(feature = "test-support")]
51pub mod test_support;
52mod transport;
53pub mod types;
54
55pub use builder::PcsExternalClientBuilder;
56pub use client::PcsExternalClient;
57pub use error::Error;
58pub use prost_types;
59pub use tonic;