Skip to content

Commit 06a08ff

Browse files
axshaniilyamerman
andauthored
fix: Search ATM locations (#436)
* JSON.stringify to send objects * remove console.log * longitude and latitude could be a string representing a number * test address --------- Co-authored-by: Ilya Merman <[email protected]>
1 parent bc1c2c1 commit 06a08ff

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

resources/atmLocations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export class AtmLocations extends BaseResource {
1010

1111
public async list(params?: AtmLocationListParams): Promise<UnitResponse<AtmLocation[]>> {
1212
const parameters = {
13-
...(params?.coordinates && { "filter[coordinates]": params.coordinates }),
14-
...(params?.address && { "filter[address]": params.address }),
13+
...(params?.coordinates && { "filter[coordinates]": JSON.stringify(params.coordinates) }),
14+
...(params?.address && { "filter[address]": JSON.stringify(params.address) }),
1515
...(params?.postalCode && { "filter[postalCode]": params.postalCode }),
1616
...(params?.searchRadius && { "filter[searchRadius]": params.searchRadius })
1717
}

tests/atmLocations.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Unit } from "../unit"
2+
3+
import dotenv from "dotenv"
4+
dotenv.config()
5+
const unit = new Unit(process.env.UNIT_TOKEN || "test", process.env.UNIT_API_URL || "test")
6+
7+
describe("Get ATM Locations", () => {
8+
test("Get ATM Locations by coordinates",async () => {
9+
const res = await unit.atmLocations.list({coordinates: {longitude: -73.93041, latitude: 42.79894}})
10+
11+
res.data.forEach(element => {
12+
expect(element.type).toBe("atmLocation")
13+
})
14+
})
15+
16+
test("Get ATM Locations by address",async () => {
17+
const res = await unit.atmLocations.list({address: {"street":"1240 EASTERN AVE", "city":"SCHENECTADY", "state":"NY", "postalCode":"", "country":"US"}})
18+
19+
res.data.forEach(element => {
20+
expect(element.type).toBe("atmLocation")
21+
})
22+
})
23+
})

types/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,12 @@ export interface Coordinates {
230230
/**
231231
* The longitude value.
232232
*/
233-
longitude: number
233+
longitude: number | string
234234

235235
/**
236236
* The latitude value.
237237
*/
238-
latitude: number
238+
latitude: number | string
239239
}
240240

241241
export interface Statement {

0 commit comments

Comments
 (0)