use crate::FluentRequest;
use serde::{Serialize, Deserialize};
use httpclient::InMemoryResponseExt;
use crate::model::TransactionsRecurringGetRequestOptions;
/**You should use this struct via [`PlaidClient::processor_transactions_recurring_get`].
On request success, this will return a [`ProcessorTransactionsRecurringGetResponse`].*/
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProcessorTransactionsRecurringGetRequest {
pub options: Option<TransactionsRecurringGetRequestOptions>,
pub processor_token: String,
}
impl FluentRequest<'_, ProcessorTransactionsRecurringGetRequest> {
///Set the value of the options field.
pub fn options(mut self, options: TransactionsRecurringGetRequestOptions) -> Self {
self.params.options = Some(options);
self
}
}
impl<'a> ::std::future::IntoFuture
for FluentRequest<'a, ProcessorTransactionsRecurringGetRequest> {
type Output = httpclient::InMemoryResult<
crate::model::ProcessorTransactionsRecurringGetResponse,
>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let url = "/processor/transactions/recurring/get";
let mut r = self.client.client.post(url);
if let Some(ref unwrapped) = self.params.options {
r = r.json(serde_json::json!({ "options" : unwrapped }));
}
r = r
.json(
serde_json::json!(
{ "processor_token" : self.params.processor_token }
),
);
r = self.client.authenticate(r);
let res = r.await?;
res.json().map_err(Into::into)
})
}
}
impl crate::PlaidClient {
/**Fetch recurring transaction streams
The `/processor/transactions/recurring/get` endpoint allows developers to receive a summary of the recurring outflow and inflow streams (expenses and deposits) from a user’s checking, savings or credit card accounts. Additionally, Plaid provides key insights about each recurring stream including the category, merchant, last amount, and more. Developers can use these insights to build tools and experiences that help their users better manage cash flow, monitor subscriptions, reduce spend, and stay on track with bill payments.
This endpoint is offered as an add-on to Transactions. To request access to this endpoint, submit a [product access request](https://dashboard.plaid.com/team/products) or contact your Plaid account manager.
This endpoint can only be called on a processor token that has already been initialized with Transactions (either during Link, by specifying it in `/link/token/create`; or after Link, by calling `/processor/transactions/get` or `/processor/transactions/sync`). Once all historical transactions have been fetched, call `/processor/transactions/recurring/get` to receive the Recurring Transactions streams and subscribe to the [`RECURRING_TRANSACTIONS_UPDATE`](https://plaid.com/docs/api/products/transactions/#recurring_transactions_update) webhook. To know when historical transactions have been fetched, if you are using `/processor/transactions/sync` listen for the [`SYNC_UPDATES_AVAILABLE`](https://plaid.com/docs/api/products/transactions/#SyncUpdatesAvailableWebhook-historical-update-complete) webhook and check that the `historical_update_complete` field in the payload is `true`. If using `/processor/transactions/get`, listen for the [`HISTORICAL_UPDATE`](https://plaid.com/docs/api/products/transactions/#historical_update) webhook.
After the initial call, you can call `/processor/transactions/recurring/get` endpoint at any point in the future to retrieve the latest summary of recurring streams. Listen to the [`RECURRING_TRANSACTIONS_UPDATE`](https://plaid.com/docs/api/products/transactions/#recurring_transactions_update) webhook to be notified when new updates are available.
To receive Transactions webhooks for a processor token, set its webhook URL via the [`/processor/token/webhook/update`](https://plaid.com/docs/api/processor-partners/#processortokenwebhookupdate) endpoint.
See endpoint docs at <https://plaid.com/docs/api/processor-partners/#processortransactionsrecurringget>.*/
pub fn processor_transactions_recurring_get(
&self,
processor_token: &str,
) -> FluentRequest<'_, ProcessorTransactionsRecurringGetRequest> {
FluentRequest {
client: self,
params: ProcessorTransactionsRecurringGetRequest {
options: None,
processor_token: processor_token.to_owned(),
},
}
}
}