File tree Expand file tree Collapse file tree 4 files changed +43
-9
lines changed Expand file tree Collapse file tree 4 files changed +43
-9
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @duffel/api" ,
3- "version" : " 2.12.0 " ,
3+ "version" : " 2.12.1 " ,
44 "description" : " Javascript client library for the Duffel API" ,
55 "main" : " dist/index.js" ,
66 "module" : " dist/index.es.js" ,
Original file line number Diff line number Diff line change @@ -9,12 +9,38 @@ describe('Stays/Accommodation', () => {
99 } )
1010
1111 it ( 'should post to /stays/suggestions when `suggestions` is called' , async ( ) => {
12+ const query = 'rits'
13+ const location = {
14+ geographic_coordinates : { latitude : 51.5287398 , longitude : - 0.2664005 } ,
15+ radius : 5 ,
16+ }
17+
18+ const mockResponse = { data : [ MOCK_ACCOMMODATION_SUGGESTION ] }
19+
20+ nock ( / ( .* ) / )
21+ . post ( '/stays/accommodation/suggestions' , ( body ) => {
22+ expect ( body . data . query ) . toEqual ( query )
23+ expect ( body . data . location ) . toEqual ( location )
24+
25+ return true
26+ } )
27+ . reply ( 200 , mockResponse )
28+
29+ const response = await duffel . stays . accommodation . suggestions (
30+ query ,
31+ location ,
32+ )
33+ expect ( response . data ) . toEqual ( mockResponse . data )
34+ } )
35+
36+ it ( 'should post to /stays/suggestions without a location when `suggestions` is called with only a query' , async ( ) => {
1237 const query = 'rits'
1338 const mockResponse = { data : [ MOCK_ACCOMMODATION_SUGGESTION ] }
1439
1540 nock ( / ( .* ) / )
1641 . post ( '/stays/accommodation/suggestions' , ( body ) => {
1742 expect ( body . data . query ) . toEqual ( query )
43+ expect ( body . data . location ) . toBeUndefined ( )
1844 return true
1945 } )
2046 . reply ( 200 , mockResponse )
Original file line number Diff line number Diff line change 11import { Client } from '../../Client'
2- import { StaysAccommodationSuggestion , StaysAccommodation } from '../StaysTypes'
2+ import {
3+ LocationParams ,
4+ StaysAccommodationSuggestion ,
5+ StaysAccommodation ,
6+ } from '../StaysTypes'
37import { Resource } from '../../Resource'
48import { DuffelResponse } from '../../types'
59
@@ -20,12 +24,14 @@ export class Accommodation extends Resource {
2024 */
2125 public suggestions = async (
2226 query : string ,
27+ location ?: LocationParams ,
2328 ) : Promise < DuffelResponse < StaysAccommodationSuggestion [ ] > > =>
2429 this . request ( {
2530 method : 'POST' ,
2631 path : `${ this . path } /suggestions` ,
2732 data : {
2833 query : query ,
34+ location : location ,
2935 } ,
3036 } )
3137
Original file line number Diff line number Diff line change @@ -633,14 +633,16 @@ type CommonStaysSearchParams = {
633633 check_out_date : string
634634} & OccupancyCriteria
635635
636- type LocationSearchParams = {
637- location : {
638- radius : number
639- geographic_coordinates : {
640- latitude : number
641- longitude : number
642- }
636+ export type LocationParams = {
637+ radius : number
638+ geographic_coordinates : {
639+ latitude : number
640+ longitude : number
643641 }
642+ }
643+
644+ type LocationSearchParams = {
645+ location : LocationParams
644646} & CommonStaysSearchParams
645647
646648type AccommodationSearchParams = {
You can’t perform that action at this time.
0 commit comments