Skip to content

Commit a3296b4

Browse files
committed
add method
1 parent 65c4f6b commit a3296b4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/resources/Detour.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ class Detour extends Resource {
1919
});
2020
}
2121

22+
/**
23+
* Fetches historical detours for a given customer.
24+
* @param {Client} client Instance of pre-configured client
25+
* @param {string} customerCode - The customer code.
26+
* @returns {Promise<Array<Detour>>} A promise that resolves to an array of historical detours.
27+
*/
28+
static async getHistoricalDetours(client, customerCode) {
29+
const endpoint = `/2/${customerCode}/serviceadjustments/detours/historical`;
30+
return this.client.get(endpoint)
31+
.then(response => response.json())
32+
.then(detours => detours.map(detour => new Detour(client, detour)));
33+
}
34+
2235
/**
2336
* Makes a href for a given customer code and detour id
2437
* @param {string} customerCode Customer code
@@ -43,7 +56,7 @@ class Detour extends Resource {
4356

4457
/**
4558
* Create a new detour for a customer via the client.
46-
*
59+
*
4760
* @param {Object} data - The data object for creating a new detour.
4861
* @param {number} data.patternId - The ID of the pattern associated with this detour.
4962
* @param {number} data.detourPatternId - The ID of the detour pattern.

0 commit comments

Comments
 (0)