pub struct Options { /* private fields */ }
Expand description
Struct containing needed options for API clients.
Implementations§
Source§impl Options
impl Options
Sourcepub fn new(api_key: String, authorization: String) -> Options
pub fn new(api_key: String, authorization: String) -> Options
Creates new Options struct for production access.
Keep in mind that authorization must be feched from the OAuth and passed here without ‘Bearer’ included.
Sourcepub fn new_dev(api_key: String) -> Options
pub fn new_dev(api_key: String) -> Options
Creates new Options struct for sandbox access.
Authorization for this is not required as it uses one of the predefined authorization keys in https://op-developer.fi/docs
Sourcepub fn base_url(&self) -> &str
pub fn base_url(&self) -> &str
Gets base URL for requests.
This is different for production and sandbox environments.
Sourcepub fn with_base_url(self, base_url: String) -> Self
pub fn with_base_url(self, base_url: String) -> Self
Sets base URL for all API requests.
This is useful when testing the clients and can be used together with local test or mock server.
Sourcepub fn api_key(&self) -> &str
pub fn api_key(&self) -> &str
Gets API key for requests.
This is used as HTTP header x-api-key.
Sourcepub fn with_api_key(self, api_key: String) -> Self
pub fn with_api_key(self, api_key: String) -> Self
Sets API key for API requests using these options.
Gets Authorization for requests.
This is used together with ’Bearer ’ in the Authorization HTTP header.
Sets authorization header value for API requests using these options.
The authorization should not contain ’Bearer ’ in front of the authorization key as it will be automatically preprended by the clients.
Sourcepub fn with_version(self, version: String) -> Self
pub fn with_version(self, version: String) -> Self
Sets API version for requests.
Some APIs are on different version (AccountsV3 for example). This is information is used to construct the request URL.