pix-api-client
You don't need to wrap the client into an Arc
, since its inner reqwest client already is wrapped.
Note
You need to take care munually of renewing your oauth token. This is accomplished very easily
with the helper functions provided by the PixClient
.
Example: Create a new client and fetch the oauth token
use CobrancaImediata;
use ;
use header;
let mut cert_buffer = Vec new;
open?.read_to_end?;
// format your headers the way your PSP expects it
// this is just an example
let pix_client = new_with_custom_headers;
let oauth_response = pix_client
.oauth
.autenticar
.execute
.await?;
// retrieve your new access token, and store it as your new authorization header
let token = oauth_response.access_token;
pix_client.swap_authorization_token;
// Your client is ready for any further api calls.
Example: Create a new QRCode from a create immediate transaction endpoint
use ;
use ;
use PixDinamicoSchema;
use FromResponse;
let devedor = new_pessoa_fisica;
let payload = new;
let response: CobrancaImediata = pix_client
.cob
.criar_cobranca_imediata
.execute
.await?;
let pix: String = from_cobranca_imediata_basic.serialize_with_src;
License: MIT