diff --git a/README.md b/README.md index b9813ae..69dfbbd 100644 --- a/README.md +++ b/README.md @@ -370,7 +370,7 @@ You can also specify custom headers on requests: ```js SDK.appointments - .headers({'X-Scheduling-Rules', 'disallow-appointment-overlap'}) + .headers({ 'X-Scheduling-Rules' : 'disallow-appointment-overlap' }) .update({ /* insert properties of appointment here */ }) diff --git a/src/Skedify.test.js b/src/Skedify.test.js index e23dad6..225ff16 100644 --- a/src/Skedify.test.js +++ b/src/Skedify.test.js @@ -387,6 +387,31 @@ describe('API/Config', () => { uninstallSkedifySDKMock(SDK) }) + it('should be possible to set custom headers', async () => { + const SDK = new API({ + auth_provider: API.createAuthProviderString('public_client', { + client_id: 'someclientidtokengoeshere', + realm: 'http://127.0.0.1', + }), + locale: 'nl-BE', + headers: { + Host: 'api.example.com', + }, + }) + + installSkedifySDKMock(SDK) + + expect( + await matchRequest( + SDK.appointments().headers({ + 'X-Scheduling-Rules': 'disallow-appointment-overlap', + }) + ) + ).toMatchSnapshot() + + uninstallSkedifySDKMock(SDK) + }) + it('should throw when a resource requires a custom domain endpoint when it is not defined', () => { const SDK = new API({ auth_provider: API.createAuthProviderString('public_client', { diff --git a/src/__snapshots__/Skedify.test.js.snap b/src/__snapshots__/Skedify.test.js.snap index 33691f8..1e533b8 100644 --- a/src/__snapshots__/Skedify.test.js.snap +++ b/src/__snapshots__/Skedify.test.js.snap @@ -1874,6 +1874,24 @@ Object { } `; +exports[`API/Config should be possible to set custom headers 1`] = ` +Object { + "data": undefined, + "headers": Object { + "Accept": "application/json, text/plain, */*", + "Accept-Language": "nl-BE, nl;q=0.667, *;q=0.333", + "Authorization": "Bearer fake_example_access_token", + "Cache-Control": "no-store", + "Host": "api.example.com", + "Pragma": "no-cache", + "X-Scheduling-Rules": "disallow-appointment-overlap", + }, + "method": "get", + "params": undefined, + "url": "http://127.0.0.1/appointments", +} +`; + exports[`API/Config should throw an error when onConfigurationChange is not passed a function 1`] = `"[CONFIG]: You tried to call \`.onConfigurationChange(null)\` but it must receive a function."`; exports[`API/Config should throw an error when overriding items on the configuration object directly 1`] = `"Cannot assign to read only property 'locale' of object '#'"`; diff --git a/src/resources/__snapshots__/index.test.js.snap b/src/resources/__snapshots__/index.test.js.snap index 8d708ec..8a36265 100644 --- a/src/resources/__snapshots__/index.test.js.snap +++ b/src/resources/__snapshots__/index.test.js.snap @@ -78,6 +78,7 @@ Object { "start", "end", "contact", + "office", "page", "per_page", ], @@ -1045,6 +1046,14 @@ Object { "key": "location[geolocation]", "name": "geolocation", }, + Object { + "key": "location[country]", + "name": "country", + }, + Object { + "key": "location[postal_code]", + "name": "postal_code", + }, "limit", "page", "per_page", diff --git a/src/resources/appointments.js b/src/resources/appointments.js index 105b1e2..51ac0e5 100644 --- a/src/resources/appointments.js +++ b/src/resources/appointments.js @@ -20,7 +20,7 @@ export const appointments = createResourceDescription( 'outcomes', 'appointment_outcomes', ], - filters: ['uuid', 'state', 'start', 'end', 'contact'], + filters: ['uuid', 'state', 'start', 'end', 'contact', 'office'], headers: { [HTTP_VERB_POST]: { recaptcha: (value) => { diff --git a/src/resources/offices.js b/src/resources/offices.js index a9f17f9..6797c01 100644 --- a/src/resources/offices.js +++ b/src/resources/offices.js @@ -31,6 +31,8 @@ export const offices = createResourceDescription( 'schedulable', 'nearest_to_geo', { name: 'geolocation', key: 'location[geolocation]' }, + { name: 'country', key: 'location[country]' }, + { name: 'postal_code', key: 'location[postal_code]' }, 'limit', ], },