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

713 lines (702 loc) 28.7 kB
/** * Shell Card Management APIsLib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ import { ApiResponse, RequestOptions } from '../core.js'; import { AccountRestrictionRequest, accountRestrictionRequestSchema, } from '../models/accountRestrictionRequest.js'; import { AccountRestrictionRes, accountRestrictionResSchema, } from '../models/accountRestrictionRes.js'; import { BudleDetailsReq, budleDetailsReqSchema, } from '../models/budleDetailsReq.js'; import { BundleDetails, bundleDetailsSchema } from '../models/bundleDetails.js'; import { CardRestrictionReq, cardRestrictionReqSchema, } from '../models/cardRestrictionReq.js'; import { CardRestrictionRes, cardRestrictionResSchema, } from '../models/cardRestrictionRes.js'; import { CreateBundleRequest, createBundleRequestSchema, } from '../models/createBundleRequest.js'; import { CreateBundleRes, createBundleResSchema, } from '../models/createBundleRes.js'; import { DeleteBundleRequest, deleteBundleRequestSchema, } from '../models/deleteBundleRequest.js'; import { DeleteBundleResponse, deleteBundleResponseSchema, } from '../models/deleteBundleResponse.js'; import { SearchAccountLimitRequest, searchAccountLimitRequestSchema, } from '../models/searchAccountLimitRequest.js'; import { SearchAccountLimitRes, searchAccountLimitResSchema, } from '../models/searchAccountLimitRes.js'; import { SearchCardRestrictionReq1, searchCardRestrictionReq1Schema, } from '../models/searchCardRestrictionReq1.js'; import { SearchCardRestrictionRes1, searchCardRestrictionRes1Schema, } from '../models/searchCardRestrictionRes1.js'; import { SummaryofbundleRes, summaryofbundleResSchema, } from '../models/summaryofbundleRes.js'; import { SummaryofbundlerRequest, summaryofbundlerRequestSchema, } from '../models/summaryofbundlerRequest.js'; import { UpdateBundleRequest, updateBundleRequestSchema, } from '../models/updateBundleRequest.js'; import { UpdateBundleRes, updateBundleResSchema, } from '../models/updateBundleRes.js'; import { optional, string } from '../schema.js'; import { BaseController } from './baseController.js'; import { ErrorObjectError } from '../errors/errorObjectError.js'; 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 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( requestId: string, body?: SearchCardRestrictionReq1, requestOptions?: RequestOptions ): Promise<ApiResponse<SearchCardRestrictionRes1>> { const req = this.createRequest('POST', '/card-restrictions/v1/search'); const mapped = req.prepareArgs({ requestId: [requestId, string()], body: [body, optional(searchCardRestrictionReq1Schema)], }); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn( 400, ErrorObjectError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).' ); req.throwOn( 401, ErrorObjectError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.' ); req.throwOn(403, ErrorObjectError, 'Forbidden'); req.throwOn( 404, ErrorObjectError, '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, ErrorObjectError, 'The server encountered an unexpected condition that prevented it from fulfilling the request.' ); req.authenticate([{ bearerToken: true }]); return req.callAsJson(searchCardRestrictionRes1Schema, 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 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 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( requestId: string, body?: CardRestrictionReq, requestOptions?: RequestOptions ): Promise<ApiResponse<CardRestrictionRes>> { const req = this.createRequest('POST', '/card-restrictions/v1/update'); const mapped = req.prepareArgs({ requestId: [requestId, string()], body: [body, optional(cardRestrictionReqSchema)], }); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn( 400, ErrorObjectError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).' ); req.throwOn( 401, ErrorObjectError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.' ); req.throwOn(403, ErrorObjectError, 'Forbidden'); req.throwOn( 404, ErrorObjectError, '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, ErrorObjectError, 'The server encountered an unexpected condition that prevented it from fulfilling the request.' ); req.authenticate([{ bearerToken: true }]); return req.callAsJson(cardRestrictionResSchema, 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 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( requestId: string, body?: CreateBundleRequest, requestOptions?: RequestOptions ): Promise<ApiResponse<CreateBundleRes>> { const req = this.createRequest( 'POST', '/card-restrictions/v1/createbundle' ); const mapped = req.prepareArgs({ requestId: [requestId, string()], body: [body, optional(createBundleRequestSchema)], }); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn( 400, ErrorObjectError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).' ); req.throwOn( 401, ErrorObjectError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.' ); req.throwOn(403, ErrorObjectError, 'Forbidden'); req.throwOn( 404, ErrorObjectError, '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, ErrorObjectError, 'The server encountered an unexpected condition that prevented it from fulfilling the request.' ); req.authenticate([{ bearerToken: true }]); return req.callAsJson(createBundleResSchema, 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 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( requestId: string, body?: UpdateBundleRequest, requestOptions?: RequestOptions ): Promise<ApiResponse<UpdateBundleRes>> { const req = this.createRequest( 'POST', '/card-restrictions/v1/updatebundle' ); const mapped = req.prepareArgs({ requestId: [requestId, string()], body: [body, optional(updateBundleRequestSchema)], }); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn( 400, ErrorObjectError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).' ); req.throwOn( 401, ErrorObjectError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.' ); req.throwOn(403, ErrorObjectError, 'Forbidden'); req.throwOn( 404, ErrorObjectError, '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, ErrorObjectError, 'The server encountered an unexpected condition that prevented it from fulfilling the request.' ); req.authenticate([{ bearerToken: true }]); return req.callAsJson(updateBundleResSchema, 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 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( requestId: string, body?: DeleteBundleRequest, requestOptions?: RequestOptions ): Promise<ApiResponse<DeleteBundleResponse>> { const req = this.createRequest( 'POST', '/card-restrictions/v1/deletebundle' ); const mapped = req.prepareArgs({ requestId: [requestId, string()], body: [body, optional(deleteBundleRequestSchema)], }); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn( 400, ErrorObjectError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).' ); req.throwOn( 401, ErrorObjectError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.' ); req.throwOn(403, ErrorObjectError, 'Forbidden'); req.throwOn( 404, ErrorObjectError, '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, ErrorObjectError, 'The server encountered an unexpected condition that prevented it from fulfilling the request.' ); req.authenticate([{ bearerToken: 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 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( requestId: string, body?: SummaryofbundlerRequest, requestOptions?: RequestOptions ): Promise<ApiResponse<SummaryofbundleRes>> { const req = this.createRequest( 'POST', '/card-restrictions/v1/summaryofbundles' ); const mapped = req.prepareArgs({ requestId: [requestId, string()], body: [body, optional(summaryofbundlerRequestSchema)], }); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn( 400, ErrorObjectError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).' ); req.throwOn( 401, ErrorObjectError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.' ); req.throwOn(403, ErrorObjectError, 'Forbidden'); req.throwOn( 404, ErrorObjectError, '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, ErrorObjectError, 'The server encountered an unexpected condition that prevented it from fulfilling the request.' ); req.authenticate([{ bearerToken: true }]); return req.callAsJson(summaryofbundleResSchema, 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 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( requestId: string, body?: AccountRestrictionRequest, requestOptions?: RequestOptions ): Promise<ApiResponse<AccountRestrictionRes>> { const req = this.createRequest('POST', '/card-restrictions/v1/account'); const mapped = req.prepareArgs({ requestId: [requestId, string()], body: [body, optional(accountRestrictionRequestSchema)], }); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn( 400, ErrorObjectError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).' ); req.throwOn( 401, ErrorObjectError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.' ); req.throwOn(403, ErrorObjectError, 'Forbidden'); req.throwOn( 404, ErrorObjectError, '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, ErrorObjectError, 'The server encountered an unexpected condition that prevented it from fulfilling the request.' ); req.authenticate([{ bearerToken: true }]); return req.callAsJson(accountRestrictionResSchema, 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 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( requestId: string, body?: SearchAccountLimitRequest, requestOptions?: RequestOptions ): Promise<ApiResponse<SearchAccountLimitRes>> { const req = this.createRequest( 'POST', '/card-restrictions/v1/searchaccountlimit' ); const mapped = req.prepareArgs({ requestId: [requestId, string()], body: [body, optional(searchAccountLimitRequestSchema)], }); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn( 400, ErrorObjectError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).' ); req.throwOn( 401, ErrorObjectError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.' ); req.throwOn(403, ErrorObjectError, 'Forbidden'); req.throwOn( 404, ErrorObjectError, '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, ErrorObjectError, 'The server encountered an unexpected condition that prevented it from fulfilling the request.' ); req.authenticate([{ bearerToken: true }]); return req.callAsJson(searchAccountLimitResSchema, 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 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( requestId: string, body?: BudleDetailsReq, requestOptions?: RequestOptions ): Promise<ApiResponse<BundleDetails>> { const req = this.createRequest( 'POST', '/card-restrictions/v1/bundledetails' ); const mapped = req.prepareArgs({ requestId: [requestId, string()], body: [body, optional(budleDetailsReqSchema)], }); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn( 400, ErrorObjectError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).' ); req.throwOn( 401, ErrorObjectError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.' ); req.throwOn(403, ErrorObjectError, 'Forbidden'); req.throwOn( 404, ErrorObjectError, '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, ErrorObjectError, 'The server encountered an unexpected condition that prevented it from fulfilling the request.' ); req.authenticate([{ bearerToken: true }]); return req.callAsJson(bundleDetailsSchema, requestOptions); } }