pub struct PixClient { /* private fields */ }
Expand description
A strongly typed client for performing requests to a pix-api compliant provider.
§Example
Implementations§
Source§impl PixClient
impl PixClient
Sourcepub fn new_with_custom_headers<F>(
endpoint: &str,
custom_headers: F,
certificate: Vec<u8>,
) -> PixClient
pub fn new_with_custom_headers<F>( endpoint: &str, custom_headers: F, certificate: Vec<u8>, ) -> PixClient
Creates a new PixClient
with customized headers.
This is specially useful, since how the authorization is encoded varies between PSP’s.
§Example
use pix_api_client::PixClient;
use reqwest::header;
let mut cert_buffer = Vec::new();
File::open("my_cert.pem")?.read_to_end(&mut cert_buffer)?;
let username = "my-id";
let secret = "my-secret";
let formatted_authorization = format!("{}:{}", username, secret);
let encoded_auth = base64::encode(formatted_authorization);
let pix_client = PixClient::new_with_custom_headers(
"https://*",
|headers| {
headers
.insert(header::AUTHORIZATION, encoded_auth.parse().unwrap())
.unwrap();
},
cert_buffer,
);
Call this method in order to change the value of your Authorization
header.
For Bearer: format!("Bearer {}", token)
For Basic: format!("Basic {}:{}", id, secret)
This is usually done after you fetch the oauth token.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PixClient
impl !RefUnwindSafe for PixClient
impl Send for PixClient
impl Sync for PixClient
impl Unpin for PixClient
impl !UnwindSafe for PixClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more