Crates.io | loops_sdk |
lib.rs | loops_sdk |
version | 1.0.0 |
source | src |
created_at | 2024-01-23 22:48:28.34421 |
updated_at | 2024-01-23 22:48:28.34421 |
description | Rust API bindings - loops_sdk |
homepage | |
repository | |
max_upload_size | |
id | 1111293 |
size | 81,516 |
This is the OpenAPI Spec for the Loops API.
use loops_sdk::Client;
let client = Client::default().with_api_key(&std::env::var("API_TOKEN").expect("API token not defined"));
Retrieve a list of your account's custom contact properties.
use loops_sdk::Client;
let client = Client::default()
.with_api_key(&std::env::var("API_TOKEN").expect("API token not defined"));
let response = client.get_contacts_custom_fields();
Search for a contact by email
.
use loops_sdk::Client;
use loops_sdk::request_types::*;
let client = Client::default()
.with_api_key(&std::env::var("API_TOKEN").expect("API token not defined"));
let response = client
.get_contacts_find(GetContactsFindRequest {
email: "string".to_string(),
});
Add a contact to your audience.
use loops_sdk::Client;
use loops_sdk::request_types::*;
use loops_sdk::schemas::*;
let client = Client::default()
.with_api_key(&std::env::var("API_TOKEN").expect("API token not defined"));
let response = client
.post_contacts_create(PostContactsCreateRequest {
data: ContactRequest {
email: "string".to_string(),
..Default::default()
},
});
Delete a contact by email
or userId
.
use loops_sdk::Client;
use loops_sdk::request_types::*;
use loops_sdk::schemas::*;
let client = Client::default()
.with_api_key(&std::env::var("API_TOKEN").expect("API token not defined"));
let response = client
.post_contacts_delete(PostContactsDeleteRequest {
data: ContactDeleteRequest {
..Default::default()
},
});
Send events to trigger emails in Loops.
If a contact with the provided email
doesn't exist, one will be created.
use loops_sdk::Client;
use loops_sdk::request_types::*;
use loops_sdk::schemas::*;
let client = Client::default()
.with_api_key(&std::env::var("API_TOKEN").expect("API token not defined"));
let response = client
.post_events_send(PostEventsSendRequest {
data: EventRequest {
event_name: "string".to_string(),
..Default::default()
},
});
Send a transactional email to a contact.
use loops_sdk::Client;
use loops_sdk::request_types::*;
use loops_sdk::schemas::*;
let client = Client::default()
.with_api_key(&std::env::var("API_TOKEN").expect("API token not defined"));
let response = client
.post_transactional(PostTransactionalRequest {
data: TransactionalRequest {
email: "string".to_string(),
transactional_id: "string".to_string(),
..Default::default()
},
});
Update a contact by email
or userId
.
If you want to update a contact’s email address, the contact will first need a userId
value. You can then make a request containing the userId field along with an updated email address.
use loops_sdk::Client;
use loops_sdk::request_types::*;
use loops_sdk::schemas::*;
let client = Client::default()
.with_api_key(&std::env::var("API_TOKEN").expect("API token not defined"));
let response = client
.put_contacts_update(PutContactsUpdateRequest {
data: ContactRequest {
email: "string".to_string(),
..Default::default()
},
});