Skip to content

Enhance Mollie Connect API Client Configuration for OAuth Flow #426

@iFlyinq

Description

@iFlyinq

For the Mollie Connect API, we need to use the OAuth flow, which means we will provide an accessToken instead of an apiKey. When creating a client with an apiKey, everything is set up and ready to go, with no need to define profiles or test mode. However, when using an accessToken, it would be convenient to optionally specify a profileId and testmode since these are required for most API calls. This way, we can avoid injecting the profileId and testmode into the API call parameters at every implementation point.

Here's the updated TypeScript type definition to reflect this:

type Options = Xor<{
    /**
     * The Mollie API key, starting with `'test_'` or `'live_'`.
     */
    apiKey: string;
}, {
    /**
     * OAuth access token, starting with `'access_'`.
     */
    accessToken: string;
    /**
     * The profile ID associated with the access token.
     */
    profileId?: string;
    /**
     * Indicates whether the API should operate in test mode.
     */
    testmode?: boolean;
}> & {
    /**
     * One or an array of version strings of the software you are using, such as `'RockenbergCommerce/3.1.12'`.
     */
    versionStrings?: MaybeArray<string>;
    /**
     * The headers set in the requests sent to the Mollie API. `Authorization`, `User-Agent`, `Accept`,
     * `Accept-Encoding`, and `Content-Type` are set by this library directly. Setting them here has no effect.
     */
    headers?: Record<string, string>;
    /**
     * The URL of the root of the Mollie API. Default: `'https://api.mollie.com:443/v2/'`.
     */
    apiEndpoint?: string;
};

With this update, when using an accessToken, you can optionally provide a profileId and testmode to streamline the API calls without needing to inject these parameters manually each time. This approach enhances code readability and maintainability by centralizing the configuration of these essential parameters.

Metadata

Metadata

Labels

enhancementImprovements and changes outside of API endpoints.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions