pub struct BrazeClient { /* private fields */ }Expand description
Cheap-to-clone Braze API client. Internally Arc-shares the API key
and reqwest::Client’s connection pool, so cloning for a parallel
batch is essentially free.
Implementations§
Source§impl BrazeClient
impl BrazeClient
Sourcepub async fn list_catalogs(&self) -> Result<Vec<Catalog>, BrazeApiError>
pub async fn list_catalogs(&self) -> Result<Vec<Catalog>, BrazeApiError>
GET /catalogs — list every catalog schema in the workspace.
Fails closed on next_cursor rather than returning page 1: a
partial view would let apply re-create page-2 catalogs and
mis-report drift. Mirrors list_content_blocks.
Sourcepub async fn get_catalog(&self, name: &str) -> Result<Catalog, BrazeApiError>
pub async fn get_catalog(&self, name: &str) -> Result<Catalog, BrazeApiError>
GET /catalogs/{name} — fetch a single catalog schema.
404 from Braze and an empty catalogs array in the response are
both mapped to BrazeApiError::NotFound so callers can branch
on “this catalog doesn’t exist” without string matching on the
HTTP body.
Sourcepub async fn create_catalog(
&self,
catalog: &Catalog,
) -> Result<(), BrazeApiError>
pub async fn create_catalog( &self, catalog: &Catalog, ) -> Result<(), BrazeApiError>
POST /catalogs — create a new catalog with its initial schema.
Duplicate names surface as 400 with body
error_id: "catalog-name-already-exists" per Braze docs and are
propagated to the caller; a subsequent apply will see the
existing catalog and no-op on the create.
Sourcepub async fn add_catalog_field(
&self,
catalog_name: &str,
field: &CatalogField,
) -> Result<(), BrazeApiError>
pub async fn add_catalog_field( &self, catalog_name: &str, field: &CatalogField, ) -> Result<(), BrazeApiError>
POST /catalogs/{name}/fields — add one field to a catalog schema.
ASSUMED wire format {"fields": [{"name": "...", "type": "..."}]}
per IMPLEMENTATION.md §8.3 + Braze public docs. v0.1.0 sends one
POST per added field.
Sourcepub async fn delete_catalog_field(
&self,
catalog_name: &str,
field_name: &str,
) -> Result<(), BrazeApiError>
pub async fn delete_catalog_field( &self, catalog_name: &str, field_name: &str, ) -> Result<(), BrazeApiError>
DELETE /catalogs/{name}/fields/{field} — remove a field. Destructive.
404 from Braze stays as Http { status: 404, .. } rather than
being mapped to NotFound. The use case is different from
get_catalog: a 404 here means “the field you wanted to delete is
already gone”, which is a state-drift signal the user should see
rather than silently no-op. A future --ignore-missing flag in
apply can opt into idempotent behavior.
Source§impl BrazeClient
impl BrazeClient
Sourcepub async fn list_content_blocks(
&self,
) -> Result<Vec<ContentBlockSummary>, BrazeApiError>
pub async fn list_content_blocks( &self, ) -> Result<Vec<ContentBlockSummary>, BrazeApiError>
Braze has no has_more/cursor field, so we loop until a short page.
offset is omitted on the first request because this endpoint rejects
offset=0 with 400 "Offset must be greater than 0.".
Sourcepub async fn get_content_block(
&self,
id: &str,
) -> Result<ContentBlock, BrazeApiError>
pub async fn get_content_block( &self, id: &str, ) -> Result<ContentBlock, BrazeApiError>
Braze returns 200 with a non-success message field for unknown
ids instead of a 404, so we need to discriminate here rather than
relying on HTTP status. Recognised not-found phrases remap to
NotFound so callers can branch cleanly; any other non-“success”
message surfaces verbatim as UnexpectedApiMessage so a real
failure is not silently swallowed. The wire shapes are ASSUMED
per IMPLEMENTATION.md §8.3 — a blanket “non-success → NotFound”
rule would misclassify every future surprise as a missing id.
pub async fn create_content_block( &self, cb: &ContentBlock, ) -> Result<String, BrazeApiError>
Sourcepub async fn update_content_block(
&self,
id: &str,
cb: &ContentBlock,
) -> Result<(), BrazeApiError>
pub async fn update_content_block( &self, id: &str, cb: &ContentBlock, ) -> Result<(), BrazeApiError>
Used both for body changes and for the --archive-orphans rename
(same id, [ARCHIVED-...] name).
state is intentionally omitted from the request body. The
diff layer excludes it from syncable_eq (there is no state
field on /content_blocks/info, so we cannot read it back and
cannot compare it), and the README documents it as a local-only
field. Forwarding cb.state here would let local edits leak
into Braze piggyback-style whenever another field changed, and
could silently overwrite a real remote state that braze-sync
has no way to observe — the same “infinite drift” trap the
honest-orphan design exists to avoid. Leaving state off makes
the wire-level behavior match the documented semantics.
Source§impl BrazeClient
impl BrazeClient
Sourcepub async fn list_custom_attributes(
&self,
) -> Result<Vec<CustomAttribute>, BrazeApiError>
pub async fn list_custom_attributes( &self, ) -> Result<Vec<CustomAttribute>, BrazeApiError>
List all Custom Attributes from Braze. Follows RFC 5988 Link
headers through every page until the server stops returning
rel="next".
Sourcepub async fn set_custom_attribute_blocklist(
&self,
names: &[&str],
blocklisted: bool,
) -> Result<(), BrazeApiError>
pub async fn set_custom_attribute_blocklist( &self, names: &[&str], blocklisted: bool, ) -> Result<(), BrazeApiError>
Toggle the blocklisted (deprecated) flag on one or more Custom
Attributes. This is the only write operation braze-sync
performs for Custom Attributes.
Source§impl BrazeClient
impl BrazeClient
Sourcepub async fn list_email_templates(
&self,
) -> Result<Vec<EmailTemplateSummary>, BrazeApiError>
pub async fn list_email_templates( &self, ) -> Result<Vec<EmailTemplateSummary>, BrazeApiError>
Braze has no has_more/cursor field, so we loop until a short page.
offset is omitted on the first request because this endpoint rejects
offset=0 with 400 "Offset must be greater than 0.".
Sourcepub async fn get_email_template(
&self,
id: &str,
) -> Result<EmailTemplate, BrazeApiError>
pub async fn get_email_template( &self, id: &str, ) -> Result<EmailTemplate, BrazeApiError>
Fetch full template details by id. Uses the same 200+message classifier pattern as content_block::get_content_block.
pub async fn create_email_template( &self, et: &EmailTemplate, ) -> Result<String, BrazeApiError>
Sourcepub async fn update_email_template(
&self,
id: &str,
et: &EmailTemplate,
) -> Result<(), BrazeApiError>
pub async fn update_email_template( &self, id: &str, et: &EmailTemplate, ) -> Result<(), BrazeApiError>
Update an existing email template. description is intentionally
omitted — Braze /info returns it but create/update cannot set it.
Source§impl BrazeClient
impl BrazeClient
pub fn from_resolved(resolved: &ResolvedConfig) -> Self
pub fn new(base_url: Url, api_key: SecretString) -> Self
Trait Implementations§
Source§impl Clone for BrazeClient
impl Clone for BrazeClient
Source§fn clone(&self) -> BrazeClient
fn clone(&self) -> BrazeClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more