UNPKG

card-management-sdk

Version:

The Shell Card Management API is REST-based and employs OAUTH 2.0,Basic and ApiKey authentication. The API endpoints accept JSON-encoded request bodies, return JSON-encoded responses and use standard HTTP response codes. All resources are located in the S

492 lines 30.5 kB
/** * Shell Card Management APIsLib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ import { accountRestrictionRequestSchema, } from '../models/accountRestrictionRequest'; import { accountRestrictionResponseSchema, } from '../models/accountRestrictionResponse'; import { budleDetailsRequestSchema, } from '../models/budleDetailsRequest'; import { bundleDetailsResponseSchema, } from '../models/bundleDetailsResponse'; import { cardRestrictionReqSchema, } from '../models/cardRestrictionReq'; import { cardRestrictionResponseSchema, } from '../models/cardRestrictionResponse'; import { createBundleRequestSchema, } from '../models/createBundleRequest'; import { createBundleResponseSchema, } from '../models/createBundleResponse'; import { deleteBundleRequestSchema, } from '../models/deleteBundleRequest'; import { deleteBundleResponseSchema, } from '../models/deleteBundleResponse'; import { searchAccountLimitRequestSchema, } from '../models/searchAccountLimitRequest'; import { searchAccountLimitResponseSchema, } from '../models/searchAccountLimitResponse'; import { searchCardRestrictionReqSchema, } from '../models/searchCardRestrictionReq'; import { searchCardRestrictionResSchema, } from '../models/searchCardRestrictionRes'; import { summaryofbundleResponseSchema, } from '../models/summaryofbundleResponse'; import { summaryofbundlerRequestSchema, } from '../models/summaryofbundlerRequest'; import { updateBundleRequestSchema, } from '../models/updateBundleRequest'; import { updateBundleResponseSchema, } from '../models/updateBundleResponse'; import { optional, string } from '../schema'; import { BaseController } from './baseController'; import { ApiError } from '@apimatic/core'; import { FleetmanagementV2RestrictionSearchcard401Error } from '../errors/fleetmanagementV2RestrictionSearchcard401Error'; import { FleetmanagementV2RestrictionSearchcard500Error } from '../errors/fleetmanagementV2RestrictionSearchcard500Error'; export class RestrictionController extends BaseController { /** * This API will allows querying card details including the day/time and product restrictions. * #### Supported operations * * * Search by list of cards or bundle * * * Include card bundle details (optional) * * * * @param apikey This is the API key of the specific environment which * needs to be passed by the client. * @param requestId Mandatory UUID (according to RFC 4122 standards) for * requests and responses. This will be played back in the * response from the request. * @param body Restriction search card request body * @return Response from the API call */ async searchCardRestriction(apikey, requestId, body, requestOptions) { const req = this.createRequest('POST', '/fleetmanagement/v2/restriction/searchcard'); const mapped = req.prepareArgs({ apikey: [apikey, string()], requestId: [requestId, string()], body: [body, optional(searchCardRestrictionReqSchema)], }); req.header('apikey', mapped.apikey); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiError, 'The server cannot or will not process the request due to something that is perceived to be a client\r\n error (e.g., malformed request syntax, invalid \r\n request message framing, or deceptive request routing).'); req.throwOn(401, FleetmanagementV2RestrictionSearchcard401Error, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(403, ApiError, 'The server understood the request but refuses to authorize it.'); req.throwOn(404, ApiError, 'The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.'); req.throwOn(500, FleetmanagementV2RestrictionSearchcard500Error, 'The server encountered an unexpected condition the prevented it from fulfilling the request.'); req.authenticate([{ basicAuth: true }]); return req.callAsJson(searchCardRestrictionResSchema, requestOptions); } /** * The Card Limit and Restriction API is REST-based and employs Basic and ApiKey authentication. The * API endpoints accept JSON-encoded request bodies, return JSON-encoded responses and use standard * HTTP response codes. * * * * All resources are located in the Shell Card Platform. The Shell Card Platform is the overall * platform that encompasses all the internal Shell systems used to manage resources. The internal * workings of the platform are not important when interacting with the API. However, it is worth * noting that the platform uses a microservice architecture to communicate with various backend * systems and some API calls are processed asynchronously. * * * * All endpoints use the `POST` verb for retrieving, updating, creating and deleting resources in the * Shell Card Platform. The endpoints that retrieve resources from the Shell Card Platform allow * flexible search parameters in the API request body. * * * * **Important Note** - This operation allows setting or updating the restrictions on existing cards. * (For up to 3 cards in a single call). * * * * All restrictions of the cards are submitted and executed after successful below condition. * * • The card exists. * * • Day time restriction cannot be set to restrict the use of a card on all days of the week i.e., * the values for all the days in the restriction cannot be set to false. * * • Either of the usage, daytime, location or product restriction ‘Reset’ is set to ‘True’ or * applied on the card. * * • All the limits in the usage restriction profile for a card is not set to ‘0’/null. * * • If IsVelocityCeiling is ‘true’, API will validate below condition: * * Usage restrictions for a card are lower than Customer Card Type level limits, if there are no * customer level overrides available then lower than OU card type limits. * * • In usage restrictions, the limits per transaction should be less than or equal to Daily, Daily * should be less than or equal to Weekly, Weekly should be less than or equal to Monthly, Monthly * should be less than or equal to Yearly (Annually). Exception being null/blank will be skipped. i.e., * Daily value should be less than equal to Monthly value if Weekly value is null/blank. Lifetime limit * is not considered for usage restrictions limits validation. * * • Apply the card type limit to Gateway when a value is NULL in the input. However, if the card * type limit is NULL for the same field, then no limit will be applied in Gateway. * * • If ‘SetDefaultOnVelocityUpdate’ is ‘true’ then the operation will apply customer cardtype or OU * level velocity limits on existing cards when restrictions are modified without providing custom * values for all fields. * * * * @param apikey This is the API key of the specific environment which needs to * be passed by the client. * @param requestId Mandatory UUID (according to RFC 4122 standards) for requests * and responses. This will be played back in the response from the * request. * @param body Card Restriction request body * @return Response from the API call */ async applyRestriction(apikey, requestId, body, requestOptions) { const req = this.createRequest('POST', '/fleetmanagement/v2/restriction/card'); const mapped = req.prepareArgs({ apikey: [apikey, string()], requestId: [requestId, string()], body: [body, optional(cardRestrictionReqSchema)], }); req.header('apikey', mapped.apikey); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiError, 'The server cannot or will not process the request due to something that is perceived to be a client\r\n error (e.g., malformed request syntax, invalid \r\n request message framing, or deceptive request routing).'); req.throwOn(401, ApiError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(403, ApiError, 'The server understood the request but refuses to authorize it.'); req.throwOn(404, ApiError, 'The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.'); req.throwOn(500, ApiError, 'The server encountered an unexpected condition the prevented it from fulfilling the request.'); req.authenticate([{ basicAuth: true }]); return req.callAsJson(cardRestrictionResponseSchema, requestOptions); } /** * This API enables clients to create a new card bundle and apply restrictions. * * #### Supported operations * * * Create bundle and include mandatory - * * * Usage, day/time, product and location restrictions * * * List of cards to add to bundle * * * Create bundle and include optional identifier of bundle in external system * * #### Validation rules * * The following are the key validation rules with the associated error codes for failed validation- * * * `7012` - At least one card must be added to the bundle * * * `7011` - The total number of cards passed in the input must be 500 or less. * * * `7014` - All the cards passed in the input are part of the selected account. * * * `7013` - At least one restriction must be applied to the bundle i.e. either of usage, day/time, * location or product restriction. * * * `7005` - Day time restriction cannot be set to restrict the use of a card on all days of the * week. * * * `7000` - Usage restriction of the bundle is not open ended i.e. all the limits within the usage * restriction must not be set to 0/null. * * * `7004` - In the usage restrictions, the limits per transaction should be less than or equal to * Daily, Daily should be less than or equal to Weekly, Weekly should be less than or equal to Monthly. * Exception being 0/blank will be skipped, i.e. Daily value should be less than equal to Monthly value * if Weekly value is 0/blank. * * * `0007` - Error returned if request parameters fail validation e.g. mandatory check. * * @param apikey This is the API key of the specific environment which needs to * be passed by the client. * @param requestId Mandatory UUID (according to RFC 4122 standards) for requests * and responses. This will be played back in the response from the * request. * @param body CreateBundle request body * @return Response from the API call */ async createBundle(apikey, requestId, body, requestOptions) { const req = this.createRequest('POST', '/fleetmanagement/v1/restriction/createbundle'); const mapped = req.prepareArgs({ apikey: [apikey, string()], requestId: [requestId, string()], body: [body, optional(createBundleRequestSchema)], }); req.header('apikey', mapped.apikey); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiError, 'The server cannot or will not process the request due to something that is perceived to be a client\r\n error (e.g., malformed request syntax, invalid \r\n request message framing, or deceptive request routing).'); req.throwOn(401, ApiError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(403, ApiError, 'The server understood the request but refuses to authorize it.'); req.throwOn(404, ApiError, 'The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.'); req.throwOn(500, ApiError, 'The server encountered an unexpected condition the prevented it from fulfilling the request.'); req.authenticate([{ basicAuth: true }]); return req.callAsJson(createBundleResponseSchema, requestOptions); } /** * This API enables clients to update an existing card bundle and its associated restrictions. * * #### Supported operations * * * Add new cards to an existing bundle * * * Remove cards from existing bundle * * * Update restrictions applied to existing bundle * * * * The following are the key validation rules with the associated error codes for failed validation- * * * #### Validation rules * * * `9007` - The cards must exist in the cards platform for adding or removing cards. * * * `7014` - All the cards passed in the input are part of the selected account. * * * `7018` - All the cards passed in the input are part of the selected bundle. * * * `7011` - The total number of cards passed in the input must be 500 or less. * * * `7012` - The action to remove cards should not result in removing all the cards from the bundle. * * * `7016` - At least one restriction must be modified for “Update†request action. * * * `7013` - All restrictions cannot be marked for “Reset†for “Update†request action. * * * `7005` - Day time restriction cannot be set to restrict the use of a card on all days of the * week. This validation is applicable for Update request action. * * * `7000` - Usage restriction of the bundle is not open ended i.e., all the limits within the * usage restriction must not be set to 0/null. This validation is applicable for Update request action. * * * `7004` - In the usage restrictions, the limits per transaction should be less than or equal to * Daily, Daily should be less than or equal to Weekly, Weekly should be less than or equal to Monthly. * Exception being 0/blank will be skipped, i.e., Daily value should be less than equal to Monthly * value if Weekly value is 0/blank. This validation is applicable for Update request action. * * * `0007` - Error returned if request parameters fail validation e.g. at least one card must be * provided in the input. * * @param apikey This is the API key of the specific environment which needs to * be passed by the client. * @param requestId Mandatory UUID (according to RFC 4122 standards) for requests * and responses. This will be played back in the response from the * request. * @param body Update Bundle request body * @return Response from the API call */ async updateBundle(apikey, requestId, body, requestOptions) { const req = this.createRequest('POST', '/fleetmanagement/v1/restriction/updatebundle'); const mapped = req.prepareArgs({ apikey: [apikey, string()], requestId: [requestId, string()], body: [body, optional(updateBundleRequestSchema)], }); req.header('apikey', mapped.apikey); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiError, 'The server cannot or will not process the request due to something that is perceived to be a client\r\n error (e.g., malformed request syntax, invalid \r\n request message framing, or deceptive request routing).'); req.throwOn(401, ApiError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(403, ApiError, 'The server understood the request but refuses to authorize it.'); req.throwOn(404, ApiError, 'The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.'); req.throwOn(500, ApiError, 'The server encountered an unexpected condition the prevented it from fulfilling the request.'); req.authenticate([{ basicAuth: true }]); return req.callAsJson(updateBundleResponseSchema, requestOptions); } /** * This API enables clients to delete an existing card bundle in the Shell Card Platform. Once the card * bundle is deleted the usage and product restrictions of the cards that were present in the bundle * will be reset based on the request. * * #### Supported operations * * * Delete card bundle by bundle Id * * #### Validation rules * * The following are the key validation rules with the associated error codes for failed validation- * * * `7019` - The given card bundle is not available in the Shell Card Platform. * * * `0007` - Error returned if request parameters fail validation e.g. mandatory check. * * @param apikey This is the API key of the specific environment which needs to * be passed by the client. * @param requestId Mandatory UUID (according to RFC 4122 standards) for requests * and responses. This will be played back in the response from the * request. * @param body Update Bundle request body * @return Response from the API call */ async deleteBundle(apikey, requestId, body, requestOptions) { const req = this.createRequest('POST', '/fleetmanagement/v1/restriction/deletebundle'); const mapped = req.prepareArgs({ apikey: [apikey, string()], requestId: [requestId, string()], body: [body, optional(deleteBundleRequestSchema)], }); req.header('apikey', mapped.apikey); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiError, 'The server cannot or will not process the request due to something that is perceived to be a client\r\n error (e.g., malformed request syntax, invalid \r\n request message framing, or deceptive request routing).'); req.throwOn(401, ApiError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(403, ApiError, 'The server understood the request but refuses to authorize it.'); req.throwOn(404, ApiError, 'The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.'); req.throwOn(500, ApiError, 'The server encountered an unexpected condition the prevented it from fulfilling the request.'); req.authenticate([{ basicAuth: true }]); return req.callAsJson(deleteBundleResponseSchema, requestOptions); } /** * This API allows clients to get a summary of card bundles associated with Payer/Account. This API * will return the basic bundle details including card and restriction details. Optionally the API will * also include a count of cards that are not associated with the bundle but returned by the search * criteria. * * * Note - to include count of cards of an account that are not associated with any bundles, in the * input parameter SearchCardBundles either pass all the bundles of the account in the list or pass * only account with bundle id left blank/null. * * * #### Supported operations * * * Get summary of bundles by list of bundle Ids * * @param apikey This is the API key of the specific environment which needs * to be passed by the client. * @param requestId Mandatory UUID (according to RFC 4122 standards) for * requests and responses. This will be played back in the * response from the request. * @param body Summary of Bundle request body * @return Response from the API call */ async summaryOfBundles(apikey, requestId, body, requestOptions) { const req = this.createRequest('POST', '/fleetmanagement/v1/restriction/summaryofbundles'); const mapped = req.prepareArgs({ apikey: [apikey, string()], requestId: [requestId, string()], body: [body, optional(summaryofbundlerRequestSchema)], }); req.header('apikey', mapped.apikey); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiError, 'The server cannot or will not process the request due to something that is perceived to be a client\r\n error (e.g., malformed request syntax, invalid \r\n request message framing, or deceptive request routing).'); req.throwOn(401, ApiError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(403, ApiError, 'The server understood the request but refuses to authorize it.'); req.throwOn(404, ApiError, 'The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.'); req.throwOn(500, ApiError, 'The server encountered an unexpected condition the prevented it from fulfilling the request.'); req.authenticate([{ basicAuth: true }]); return req.callAsJson(summaryofbundleResponseSchema, requestOptions); } /** * This API allows setting or updating the usage restrictions of an existing account. * * * * Then validation rules applied for this API. * * * * • The account exists. * * • Day time restriction cannot be set to restrict the use of a card, under the account, on all * days of the week. * * • Either of the usage, daytime or location is either marked for reset or new restriction values * provided for the account. * * • In usage restrictions, the limits per transaction should be less than or equal to Daily, Daily * should be less than or equal to Weekly, Weekly should be less than or equal to Monthly. Exception * being 0/blank will be skipped, i.e., Daily value should be less than equal to Monthly value if * Weekly value is 0/blank. * * * * @param apikey This is the API key of the specific environment which * needs to be passed by the client. * @param requestId Mandatory UUID (according to RFC 4122 standards) for * requests and responses. This will be played back in the * response from the request. * @param body Account Restriction request body * @return Response from the API call */ async restrictionAccount(apikey, requestId, body, requestOptions) { const req = this.createRequest('POST', '/fleetmanagement/v1/restriction/account'); const mapped = req.prepareArgs({ apikey: [apikey, string()], requestId: [requestId, string()], body: [body, optional(accountRestrictionRequestSchema)], }); req.header('apikey', mapped.apikey); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiError, 'The server cannot or will not process the request due to something that is perceived to be a client\r\n error (e.g., malformed request syntax, invalid \r\n request message framing, or deceptive request routing).'); req.throwOn(401, ApiError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(403, ApiError, 'The server understood the request but refuses to authorize it.'); req.throwOn(404, ApiError, 'The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.'); req.throwOn(500, ApiError, 'The server encountered an unexpected condition the prevented it from fulfilling the request.'); req.authenticate([{ bearerToken: true }]); return req.callAsJson(accountRestrictionResponseSchema, requestOptions); } /** * This API will allow user to get account level limits for the given account. It returns the velocity * limits if its overridden at the account else the values will be null/empty. * * @param apikey This is the API key of the specific environment which * needs to be passed by the client. * @param requestId Mandatory UUID (according to RFC 4122 standards) for * requests and responses. This will be played back in the * response from the request. * @param body Search Account Limit RequestBody * @return Response from the API call */ async searchAccountLimit(apikey, requestId, body, requestOptions) { const req = this.createRequest('POST', '/fleetmanagement/v1/restriction/searchaccountlimit'); const mapped = req.prepareArgs({ apikey: [apikey, string()], requestId: [requestId, string()], body: [body, optional(searchAccountLimitRequestSchema)], }); req.header('apikey', mapped.apikey); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiError, 'The server cannot or will not process the request due to something that is perceived to be a client\r\n error (e.g., malformed request syntax, invalid \r\n request message framing, or deceptive request routing).'); req.throwOn(401, ApiError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(403, ApiError, 'The server understood the request but refuses to authorize it.'); req.throwOn(404, ApiError, 'The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.'); req.throwOn(500, ApiError, 'The server encountered an unexpected condition the prevented it from fulfilling the request.'); req.authenticate([{ basicAuth: true }]); return req.callAsJson(searchAccountLimitResponseSchema, requestOptions); } /** * This API allows to get the details of a specific card bundle. It returns the bundle basic details * along with the cards in the bundle and restrictions applied on them. * * @param apikey This is the API key of the specific environment which needs to * be passed by the client. * @param requestId Mandatory UUID (according to RFC 4122 standards) for requests * and responses. This will be played back in the response from the * request. * @param body Bundle Details Request body * @return Response from the API call */ async bundleDetails(apikey, requestId, body, requestOptions) { const req = this.createRequest('POST', '/fleetmanagement/v1/restriction/bundledetails'); const mapped = req.prepareArgs({ apikey: [apikey, string()], requestId: [requestId, string()], body: [body, optional(budleDetailsRequestSchema)], }); req.header('apikey', mapped.apikey); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiError, 'The server cannot or will not process the request due to something that is perceived to be a client\r\n error (e.g., malformed request syntax, invalid \r\n request message framing, or deceptive request routing).'); req.throwOn(401, ApiError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(403, ApiError, 'The server understood the request but refuses to authorize it.'); req.throwOn(404, ApiError, 'The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.'); req.throwOn(500, ApiError, 'The server encountered an unexpected condition the prevented it from fulfilling the request.'); req.authenticate([{ basicAuth: true }]); return req.callAsJson(bundleDetailsResponseSchema, requestOptions); } } //# sourceMappingURL=restrictionController.js.map