Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub base_url: String,
    pub subscription_key: String,
    pub api_key: String,
    pub access_key: Option<String>,
    pub timeout: Duration,
}
Expand description

Connection details and credentials for a single ALAT gateway.

A Config is consumed by Client::new. It is cheap to clone and holds no live connections.

§Authentication

APIM gates every product with a subscription key (Ocp-Apim-Subscription-Key). On top of that, ALAT identifies the calling software channel with an API key (x-api-key). A subset of products (bills & airtime) additionally require an access key sent in an access header — supply it via Config::with_access_key when you use those endpoints.

Fields§

§base_url: String

Absolute base URL of the APIM gateway (where API calls go, not the sign-up portal), e.g. https://playground.azure-api.net. Stored without a trailing slash.

§subscription_key: String

APIM subscription key, sent as the Ocp-Apim-Subscription-Key header. Obtained from your subscription on the ALAT developer portal.

§api_key: String

Channel API key, sent as the x-api-key header. Identifies your registered application/partner to ALAT’s core systems.

§access_key: Option<String>

Optional “access” credential required by the bills & airtime products, sent as the access header. None if you do not use those endpoints.

§timeout: Duration

Maximum duration to wait for each request before failing with a Network timeout error.

Implementations§

Source§

impl Config

Source

pub fn new( base_url: impl Into<String>, subscription_key: impl Into<String>, api_key: impl Into<String>, ) -> Self

Creates a configuration pointing at an explicit gateway host.

This is the honest, production-oriented constructor: you name the gateway Wema issued to you. Trailing slashes are trimmed.

use alat::Config;
let config = Config::new("https://your-gateway.wemabank.com", "sub_key", "api_key");
assert_eq!(config.base_url, "https://your-gateway.wemabank.com");
Source

pub fn playground( subscription_key: impl Into<String>, api_key: impl Into<String>, ) -> Self

Configuration for the Playground sandbox gateway (https://playground.azure-api.net; sign up at https://playground.alat.ng).

Use this for wallet creation, account maintenance, statements, bills, and airtime — the products published on that portal.

Source

pub fn apim_dev( subscription_key: impl Into<String>, api_key: impl Into<String>, ) -> Self

Configuration for the APIM Dev sandbox (https://wema-alatdev-apimgt.azure-api.net).

Use this for the funds-transfer / name-enquiry product (/funds-transfer-open), which is published on that portal rather than on Playground.

Source

pub fn with_access_key(self, access_key: impl Into<String>) -> Self

Attaches the access credential required by bills & airtime endpoints (builder style).

use alat::Config;
let config = Config::playground("sub", "api").with_access_key("bills_access_token");
assert!(config.access_key.is_some());
Source

pub fn with_timeout(self, timeout: Duration) -> Self

Overrides the default per-request timeout (builder style).

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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