digital-payments-sdk
Version:
The APIs detailed within this SDK will enable Shell's Fleet Solutions Customers to digitalize Shell Card/s and use them to pay to refuel their vehicles at Shell Stations.
97 lines (94 loc) • 4.95 kB
text/typescript
/**
* Shell SmartPay APILib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
import { ApiResponse, RequestOptions } from '../core';
import {
AroundLocationArray,
aroundLocationArraySchema,
} from '../models/aroundLocationArray';
import { TypeEnum, typeEnumSchema } from '../models/typeEnum';
import { array, number, optional, string } from '../schema';
import { BaseController } from './baseController';
import { StationLocatorBadRequestError } from '../errors/stationLocatorBadRequestError';
import { StationLocatorForbiddenError } from '../errors/stationLocatorForbiddenError';
import { StationLocatorInternalServerError } from '../errors/stationLocatorInternalServerError';
import { StationLocatorNotFoundError } from '../errors/stationLocatorNotFoundError';
import { StationLocatorUnauthorizedError } from '../errors/stationLocatorUnauthorizedError';
export class StationLocatorController extends BaseController {
/**
* Returns all sites within specified radius of specified GPS location. Sites of all Types are returned.
* This call must be used when attempting to establish the station the user is located at as part of
* fuelling journey (i.e. user has to be within 300m of station to be considered located at the
* station). This API could also be used as a general query to find nearby Shell locations
*
* @param m API Method to be executed
* @param lon The user’s current longitude
* @param lat The user’s current latitude
* @param radius The search radius in kilometers
* @param offerCode This enables requestor to specify locations that will honour the specified
* (advanced) offer code
* @param n This enables requestor to limit the number of locations that are returned and
* defaulted to a maximum of 250 locations. Locations returned based on distance to
* User’s location as-the-crow-flies.
* @param amenities This enables requestor to filter locations based on one or more amenities (e.g.
* Filter locations so that only those with a Toilet are returned).
* @param countries This enables requestor to filter locations based on one or more Countries (i.e. by
* country codes).
* @param type All fuel stations are of at least one Type, indicating whether it is Shell-branded
* or not, and if the station can be used by trucks. Note that a station can have more
* than one Type (e.g. Shell retail sites (Type=0) can also be truck friendly (Type=2)).
* Type values are as follows: * 0 = Shell owned/branded stations that are not
* also Type=2 or Type=3 * 1 = Partner stations accepting Shell Card * 2 = Shell
* owned/branded stations that are truck friendly but not Type=3 * 3 = Shell
* owned/branded stations that are truck only <br/>**When type is not provided, API
* will return type 0 and 2 only.**
* @return Response from the API call
*/
async stationlocatorV1StationsGetAroundLocation(
m: string,
lon: number,
lat: number,
radius: number,
offerCode?: string,
n?: number,
amenities?: string[],
countries?: string[],
type?: TypeEnum,
requestOptions?: RequestOptions
): Promise<ApiResponse<AroundLocationArray>> {
const req = this.createRequest('GET', '/SiteData/v1/stations');
const mapped = req.prepareArgs({
m: [m, string()],
lon: [lon, number()],
lat: [lat, number()],
radius: [radius, number()],
offerCode: [offerCode, optional(string())],
n: [n, optional(number())],
amenities: [amenities, optional(array(string()))],
countries: [countries, optional(array(string()))],
type: [type, optional(typeEnumSchema)],
});
req.query('m', mapped.m);
req.query('lon', mapped.lon);
req.query('lat', mapped.lat);
req.query('radius', mapped.radius);
req.query('offer_code', mapped.offerCode);
req.query('n', mapped.n);
req.query('amenities', mapped.amenities);
req.query('countries', mapped.countries);
req.query('type', mapped.type);
req.throwOn(400, StationLocatorBadRequestError, 'Bad request');
req.throwOn(401, StationLocatorUnauthorizedError, 'Unauthorized');
req.throwOn(403, StationLocatorForbiddenError, 'Forbbiden');
req.throwOn(404, StationLocatorNotFoundError, 'Not Found');
req.throwOn(
500,
StationLocatorInternalServerError,
'Internal Server Error'
);
req.authenticate([{ oAuthTokenPost: true }]);
return req.callAsJson(aroundLocationArraySchema, requestOptions);
}
}