BriteVerifyClient

Struct BriteVerifyClient 

Source
pub struct BriteVerifyClient { /* private fields */ }
Expand description

briteverify-rs’s reqwest-based client

§Basic Usage

let client: BriteVerifyClient = BriteVerifyClient::new("YOUR API KEY")?;

let balance: AccountCreditBalance = client.get_account_balance().await?;

println!("{balance:#?}");

Implementations§

Source§

impl BriteVerifyClient

Source

pub fn new<ApiKey: ToString>( api_key: ApiKey, ) -> Result<Self, BriteVerifyClientError>

Create a new BriteVerifyClient instance

§Example
let client: BriteVerifyClient = BriteVerifyClient::new("YOUR API KEY")?;
Source

pub fn builder() -> BriteVerifyClientBuilder

Create a new builder to incrementally build a BriteVerifyClient with a customised configuration

§Example
let builder: BriteVerifyClientBuilder = BriteVerifyClient::builder();

// ... call various builder methods

let client: BriteVerifyClient = builder.build()?;
Source

pub async fn current_credits(&self) -> Result<u32>

Get your current account credit balance [ref]

§Example
let balance: u32 = client.current_credits().await?;

println!("Current BriteVerify API credit balance: {balance}");
Source

pub async fn current_credits_in_reserve(&self) -> Result<u32>

Get the total number of credits your account currently has in reserve [ref]

§Example
let reserved: u32 = client.current_credits_in_reserve().await?;

println!("Current BriteVerify API reserve credit balance: {reserved}");
Source

pub async fn get_account_balance( &self, ) -> Result<AccountCreditBalance, BriteVerifyClientError>

Get your account credit balance, total number of credits in reserve, and the timestamp of when your balance was most recently recorded [ref]

§Example
let balance_report: AccountCreditBalance = client.get_account_balance().await?;

println!("Current BriteVerify API credit data: {balance_report}");
Source

pub async fn verify_contact<EmailAddress: ToString + Debug, PhoneNumber: ToString + Debug, AddressLine1: ToString + Debug, AddressLine2: ToString + Debug, CityName: ToString + Debug, StateNameOrAbbr: ToString + Debug, ZipCode: ToString + Debug>( &self, email: EmailAddress, phone: PhoneNumber, address1: AddressLine1, address2: Option<AddressLine2>, city: CityName, state: StateNameOrAbbr, zip: ZipCode, ) -> Result<VerificationResponse, BriteVerifyClientError>

Verify a “complete” contact record [ref]

§Example
let verified: VerificationResponse = client.verify_contact(
    "test@example.com",
    "+15555555555",
    "123 Main St",
    Some("P.O. Box 456"),
    "Any Town",
    "CA",
    "90210",
).await?;

println!("Verified contact data: {verified:#?}");
Source

pub async fn verify_email<EmailAddress: ToString + Debug>( &self, email: EmailAddress, ) -> Result<EmailVerificationArray, BriteVerifyClientError>

Verify a single email address [ref]

§Example
let response: EmailVerificationArray = client.verify_email("test@example.com").await?;

println!("Verified email: {response:#?}");
Source

pub async fn verify_phone_number<PhoneNumber: ToString + Debug>( &self, phone: PhoneNumber, ) -> Result<PhoneNumberVerificationArray, BriteVerifyClientError>

Verify a single phone number [ref]

§Example
let response: PhoneNumberVerificationArray = client.verify_phone_number("+15555555555").await?;

println!("Verified phone number: {response:#?}");
Source

pub async fn verify_street_address<AddressLine1: ToString + Debug, AddressLine2: ToString + Debug, CityName: ToString + Debug, StateNameOrAbbr: ToString + Debug, ZipCode: ToString + Debug>( &self, address1: AddressLine1, address2: Option<AddressLine2>, city: CityName, state: StateNameOrAbbr, zip: ZipCode, ) -> Result<AddressVerificationArray, BriteVerifyClientError>

Verify a single street address [ref]

§Example
let verified: AddressVerificationArray = client.verify_street_address(
    "123 Main St",
    Some("P.O. Box 456"),
    "Any Town",
    "CA",
    "90210",
).await?;

println!("Verified address: {verified:#?}");
Source

pub async fn get_lists( &self, ) -> Result<GetListStatesResponse, BriteVerifyClientError>

Retrieve the complete, unfiltered list of all bulk verification lists created within the last 7 calendar days [ref]

§Example
let lists: GetListStatesResponse = client.get_lists().await?;

println!("Available bulk verification lists: {lists:#?}");
Source

pub async fn get_filtered_lists<'header, Date: Datelike + Debug, Page: Into<u32> + Debug, State: Clone + Debug + Into<BatchState>, ExternalId: Display + Debug>( &self, page: Option<Page>, date: Option<Date>, state: Option<State>, ext_id: Option<ExternalId>, ) -> Result<GetListStatesResponse, BriteVerifyClientError>

Retrieve the complete list of all bulk verification lists created within the last 7 calendar days filtered by the specified criteria [ref]

§Example
use chrono::{NaiveDate, Utc};
use briteverify_rs::{BriteVerifyClient, types::GetListStatesResponse};

let today: NaiveDate = Utc::now().date_naive();

let page: Option<u32> = Some(5u32);
let state: Option<&str> = Some("open");
let date: Option<NaiveDate> = today.with_day(today.day() - 2);
let ext_id: Option<&str> = None;

let lists: GetListStatesResponse = client.get_filtered_lists(page, date, state, ext_id).await?;

println!("Filtered bulk verification lists: {lists:#?}");
Source

pub async fn get_lists_by_date<Date: Datelike + Debug>( &self, date: Date, ) -> Result<GetListStatesResponse, BriteVerifyClientError>

Retrieve the complete list of all bulk verification lists filtered by the specified date [ref]


NOTE: Regardless of specified date, the BriteVerify API does not appear to persist bulk verification lists older than 7 calendar days


§Example
use chrono::{NaiveDate, Utc};
use briteverify_rs::{BriteVerifyClient, types::GetListStatesResponse};

let today: NaiveDate = Utc::now().date_naive();
let date: NaiveDate = today.with_day(today.day() - 2).unwrap();

let lists: GetListStatesResponse = client.get_lists_by_date(date.clone()).await?;

println!("Bulk verification lists for '{date}': {lists:#?}");
Source

pub async fn get_lists_by_page<Page: Into<u32> + Debug>( &self, page: Page, ) -> Result<GetListStatesResponse, BriteVerifyClientError>

Retrieve the specified “page” of bulk verification lists [ref]

§Example
use briteverify_rs::{BriteVerifyClient, types::GetListStatesResponse};

let page: u32 = 2;
let lists: GetListStatesResponse = client.get_lists_by_page(page).await?;

println!("Bulk verification lists page {page}: {lists:#?}");
Source

pub async fn get_lists_by_state( &self, state: BatchState, ) -> Result<GetListStatesResponse, BriteVerifyClientError>

Retrieve the complete list of all bulk verification lists created within the last 7 calendar days whose status matches the specified value [ref]

§Example
use briteverify_rs::{BriteVerifyClient, types::{BatchState, GetListStatesResponse}};

let state: BatchState = BatchState::Closed;
let lists: GetListStatesResponse = client.get_lists_by_state(state).await?;

println!("Bulk verification lists w/ state '{state}': {lists:#?}");
Source

pub async fn create_list<Contact: Into<VerificationRequest> + Debug, ContactCollection: IntoIterator<Item = Contact> + Debug>( &self, contacts: Option<ContactCollection>, auto_start: bool, ) -> Result<CreateListResponse, BriteVerifyClientError>

Create a new bulk verification list with the supplied records and (optionally) queue it for immediate processing [ref]

§Examples
§Create Empty List
use briteverify_rs::types::{CreateListResponse, VerificationRequest};

let contacts = <Option<Vec<VerificationRequest>>>::None;
let list: CreateListResponse = client.create_list(contacts, false).await?;

println!("New bulk verification list: {list:#?}");
§Create Populated List & Start Immediately
use briteverify_rs::{
    types::{
      CreateListResponse,
      VerificationRequest,
    },
};

let contacts: [VerificationRequest; 2] = [
    VerificationRequest::try_from("test@example.com")?,
    VerificationRequest::try_from("+15555555555")?
];

let list: CreateListResponse = client.create_list(Some(contacts), true).await?;

println!("New bulk verification list: {list:#?}");
Source

pub async fn update_list<ListId: ToString + Debug, Contact: Into<VerificationRequest> + Debug, ContactCollection: IntoIterator<Item = Contact> + Debug>( &self, list_id: ListId, contacts: ContactCollection, auto_start: bool, ) -> Result<UpdateListResponse, BriteVerifyClientError>

Append records to the specified bulk verification list and (optionally) queue it for immediate processing [ref]

§Example
use briteverify_rs::{
    types::{
      UpdateListResponse,
      VerificationRequest,
    },
};

let contacts: [VerificationRequest; 2] = [
    VerificationRequest::try_from("some-email@bounce-me.net")?,
    VerificationRequest::try_from("another-email@a-real-domain.org")?,
];

let list: UpdateListResponse = client.update_list("some-list-id", contacts, false).await?;

println!("Updated bulk verification list: {list:#?}");
Source

pub async fn get_list_by_id<ListId: ToString + Debug>( &self, list_id: ListId, ) -> Result<VerificationListState, BriteVerifyClientError>

Retrieve current “state” of the specified bulk verification list [ref]

§Example
use briteverify_rs::types::VerificationListState;

let list_id: &str = "some-list-id";
let list: VerificationListState = client.get_list_by_id(list_id).await?;

println!("Bulk verification list '{list_id}': {list:#?}");
Source

pub async fn get_list_by_external_id<ListId: ToString + Debug, ExternalId: Display + Debug>( &self, list_id: ListId, external_id: ExternalId, ) -> Result<VerificationListState, BriteVerifyClientError>

Retrieve current “state” of a bulk verification list tied to an externally supplied / customer-specific identifier [ref]

§Example
use briteverify_rs::types::VerificationListState;

let list_id: &str = "some-list-id";
let customer_id: &str = "some-customer-id";
let list: VerificationListState = client.get_list_by_external_id(list_id, customer_id).await?;

println!("Bulk verification list '{list_id}': {list:#?}");
Source

pub async fn delete_list_by_id<ListId: ToString + Debug>( &self, list_id: ListId, ) -> Result<DeleteListResponse, BriteVerifyClientError>

Delete the specified batch verification list [ref]


NOTE: This action cannot be reversed and once completed, the list will no longer exist. The list must be in one of the following states to be deleted:


§Example
use briteverify_rs::types::DeleteListResponse;

let list_id: &str = "some-list-id";
let response: DeleteListResponse = client.delete_list_by_id(list_id).await?;

println!("Bulk verification list '{list_id}' final state: {response:#?}");
Source

pub async fn terminate_list_by_id<ListId: ToString + Debug>( &self, list_id: ListId, ) -> Result<UpdateListResponse, BriteVerifyClientError>

Abandon the specified unprocessed bulk verification list [ref]


NOTE: This action is only applicable to lists that have not yet begun processing. For any list that has already been “started”, the equivalent action would be delete_list_by_id.


§Example
use briteverify_rs::types::UpdateListResponse;

let list_id: &str = "some-list-id";
let response: UpdateListResponse = client.terminate_list_by_id(list_id).await?;

println!("Bulk verification list '{list_id}' final state: {response:#?}");
Source

pub async fn queue_list_for_processing<ListId: ToString + Debug>( &self, list_id: ListId, ) -> Result<UpdateListResponse, BriteVerifyClientError>

Queue the specified (open) bulk verification list for immediate processing [ref]

§Example
use briteverify_rs::types::UpdateListResponse;

let list_id: &str = "some-list-id";
let response: UpdateListResponse = client.queue_list_for_processing(list_id).await?;

println!("Bulk verification list '{list_id}' state: {response:#?}");
Source

pub async fn get_results_by_list_id<ListId: ToString + Debug>( &self, list_id: ListId, ) -> Result<Vec<BulkVerificationResult>, BriteVerifyClientError>

Get the verification results for the specified bulk verification list [ref]


NOTE: Verification results are only available once a list has finished verifying in its entirety. It is not possible to retrieve verification results piecemeal.


§Example
use briteverify_rs::types::BulkVerificationResult;

let list_id: &str = "some-list-id";
let data: Vec<BulkVerificationResult> = client.get_results_by_list_id(list_id).await?;

println!("Bulk verification list '{list_id}' results: {data:#?}");

Methods from Deref<Target = Client>§

Source

pub fn get<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a GET request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn post<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a POST request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn put<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a PUT request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn patch<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a PATCH request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn delete<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a DELETE request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn head<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a HEAD request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn request<U>(&self, method: Method, url: U) -> RequestBuilder
where U: IntoUrl,

Start building a Request with the Method and Url.

Returns a RequestBuilder, which will allow setting headers and the request body before sending.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn execute( &self, request: Request, ) -> impl Future<Output = Result<Response, Error>>

Executes a Request.

A Request can be built manually with Request::new() or obtained from a RequestBuilder with RequestBuilder::build().

You should prefer to use the RequestBuilder and RequestBuilder::send().

§Errors

This method fails if there was an error while sending request, redirect loop was detected or redirect limit was exhausted.

Trait Implementations§

Source§

impl Debug for BriteVerifyClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for BriteVerifyClient

Source§

type Target = Client

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl TryFrom<Client> for BriteVerifyClient

Source§

type Error = BriteVerifyClientError

The type returned in the event of a conversion error.
Source§

fn try_from(client: Client) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,