Skip to content

Commit 7911c8e

Browse files
axshaniilyamerman
andauthored
Atm locations (#81)
* atm-locations is done * rename file * rename and lint-fix * no need for that optionals Co-authored-by: ilyamerman <[email protected]>
1 parent f80eaa8 commit 7911c8e

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

resources/atmLocations.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { AtmLocation } from "../types/atmLocation"
2+
import { UnitResponse, UnitConfig, Coordinates, Address } from "../types/common"
3+
import { BaseResource } from "./baseResource"
4+
5+
export class AtmLocations extends BaseResource {
6+
7+
constructor(token: string, basePath: string, config?: UnitConfig) {
8+
super(token, basePath + "/atm-locations", config)
9+
}
10+
11+
public async list(params?: AtmLocationListParams): Promise<UnitResponse<AtmLocation[]>> {
12+
const parameters = {
13+
...(params?.coordinates && { "filter[coordinates]": params.coordinates }),
14+
...(params?.address && { "filter[address]": params.address }),
15+
...(params?.postalCode && { "filter[postalCode]": params.postalCode }),
16+
...(params?.searchRadius && { "filter[searchRadius]": params.searchRadius })
17+
}
18+
19+
return this.httpGet<UnitResponse<AtmLocation[]>>("", { params: parameters })
20+
}
21+
}
22+
23+
export interface AtmLocationListParams {
24+
coordinates?: Coordinates
25+
address?: Address
26+
postalCode?: string
27+
searchRadius?: number
28+
}

types/atmLocation.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { Coordinates } from "."
2+
3+
export interface AtmLocation {
4+
/**
5+
* Type of the ATM location resource. The value is always atmLocation.
6+
*/
7+
type: "atmLocation"
8+
9+
/**
10+
* JSON object representing the ATM location data.
11+
*/
12+
attributes: {
13+
/**
14+
* Name of the ATM network.
15+
*/
16+
network: string
17+
18+
/**
19+
* Name of the ATM's location.
20+
*/
21+
locationName: string
22+
23+
/**
24+
* Coordinates (latitude, longitude) of the ATM.
25+
*/
26+
coordinates: Coordinates
27+
28+
/**
29+
* Address of the ATM.
30+
*/
31+
address: string
32+
33+
/**
34+
* Distance to the ATM (in miles).
35+
*/
36+
distance: number
37+
38+
/**
39+
* Indicates if the ATM is surcharge free.
40+
*/
41+
surchargeFree: boolean
42+
43+
/**
44+
* Indicates if the ATM accepts deposits.
45+
*/
46+
acceptDeposits: boolean
47+
}
48+
}

unit.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ApplicationForms } from "./resources/applicationForm"
2020
import { AccountsEndOfDay } from "./resources/accountEndOfDay"
2121
import { BillPays } from "./resources"
2222
import { Institutions } from "./resources/institutions"
23+
import { AtmLocations } from "./resources/atmLocations"
2324

2425
export class Unit {
2526
public applications: Applications
@@ -43,6 +44,7 @@ export class Unit {
4344
public returns: Returns
4445
public billPays: BillPays
4546
public institutions: Institutions
47+
public atmLocations: AtmLocations
4648

4749
constructor(token: string, basePath: string, config?: UnitConfig) {
4850
// remove all trailing slashes from user-provided basePath
@@ -68,6 +70,7 @@ export class Unit {
6870
this.returns = new Returns(token, basePath, config)
6971
this.billPays = new BillPays(token, basePath, config)
7072
this.institutions = new Institutions(token, basePath, config)
73+
this.atmLocations = new AtmLocations(token, basePath, config)
7174
this.helpers = helpers
7275
}
7376

0 commit comments

Comments
 (0)