@monada-ai/monada-cargofive-integration 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/server.js +5 -1
- package/dist/utils/utils.js +5 -1
- package/package.json +1 -1
- package/src/server/server.js +5 -1
- package/src/utils/utils.js +5 -1
- package/test/server.test.js +0 -28
package/dist/server/server.js
CHANGED
|
@@ -50,8 +50,12 @@ function Server({ apiKey, serverUri = PRODUCTION_URI, uuidv4 = _uuidv4, now = _n
|
|
|
50
50
|
include_imo_charges: false,
|
|
51
51
|
cargo_details: products.map(p => productToCargoDetails({ product: p })).join(','),
|
|
52
52
|
departure_date: new Date(dateBegin).toISOString().split('T')[0],
|
|
53
|
+
}
|
|
53
54
|
|
|
55
|
+
if (verbose) {
|
|
56
|
+
console.log('[CargoFive] Rates request:', `${baseUrl}/v1/public/rates?${new URLSearchParams(params).toString()}`);
|
|
54
57
|
}
|
|
58
|
+
|
|
55
59
|
// Try to search rates by origin/destination
|
|
56
60
|
const { data: ratesResponse } = await axios.get(
|
|
57
61
|
`${baseUrl}/v1/public/rates?${new URLSearchParams(params).toString()}`,
|
|
@@ -182,8 +186,8 @@ function convertCargofiveRateToMonadaRate({ rate, sourcePort, destinationPort, p
|
|
|
182
186
|
cargofiveRate: rate,
|
|
183
187
|
},
|
|
184
188
|
product: {
|
|
185
|
-
id: productId,
|
|
186
189
|
...monadaProduct,
|
|
190
|
+
id: productId,
|
|
187
191
|
},
|
|
188
192
|
offer: {
|
|
189
193
|
validFrom: productPrice.valid_from || null,
|
package/dist/utils/utils.js
CHANGED
package/package.json
CHANGED
package/src/server/server.js
CHANGED
|
@@ -50,8 +50,12 @@ function Server({ apiKey, serverUri = PRODUCTION_URI, uuidv4 = _uuidv4, now = _n
|
|
|
50
50
|
include_imo_charges: false,
|
|
51
51
|
cargo_details: products.map(p => productToCargoDetails({ product: p })).join(','),
|
|
52
52
|
departure_date: new Date(dateBegin).toISOString().split('T')[0],
|
|
53
|
+
}
|
|
53
54
|
|
|
55
|
+
if (verbose) {
|
|
56
|
+
console.log('[CargoFive] Rates request:', `${baseUrl}/v1/public/rates?${new URLSearchParams(params).toString()}`);
|
|
54
57
|
}
|
|
58
|
+
|
|
55
59
|
// Try to search rates by origin/destination
|
|
56
60
|
const { data: ratesResponse } = await axios.get(
|
|
57
61
|
`${baseUrl}/v1/public/rates?${new URLSearchParams(params).toString()}`,
|
|
@@ -182,8 +186,8 @@ function convertCargofiveRateToMonadaRate({ rate, sourcePort, destinationPort, p
|
|
|
182
186
|
cargofiveRate: rate,
|
|
183
187
|
},
|
|
184
188
|
product: {
|
|
185
|
-
id: productId,
|
|
186
189
|
...monadaProduct,
|
|
190
|
+
id: productId,
|
|
187
191
|
},
|
|
188
192
|
offer: {
|
|
189
193
|
validFrom: productPrice.valid_from || null,
|
package/src/utils/utils.js
CHANGED
package/test/server.test.js
CHANGED
|
@@ -13,34 +13,6 @@ function uuidv4() { return '' + id++ };
|
|
|
13
13
|
// Increase jest timeout to 10 seconds
|
|
14
14
|
jest.setTimeout(120000);
|
|
15
15
|
|
|
16
|
-
// Mock CargoFive API responses
|
|
17
|
-
const CARGOFIVE_CONTRACTS_RESPONSE = {
|
|
18
|
-
data: [
|
|
19
|
-
{
|
|
20
|
-
id: 1,
|
|
21
|
-
supplier: { name: 'Test Supplier', code: 'TEST' },
|
|
22
|
-
validFrom: '2024-01-01',
|
|
23
|
-
validUntil: '2024-12-31',
|
|
24
|
-
type: 'Contract'
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const CARGOFIVE_CHARGES_RESPONSE = {
|
|
30
|
-
data: [
|
|
31
|
-
{
|
|
32
|
-
contract_id: 1,
|
|
33
|
-
surcharge: {
|
|
34
|
-
name: 'Ocean Freight',
|
|
35
|
-
application: 'Freight',
|
|
36
|
-
amount: 1000,
|
|
37
|
-
currency: 'USD',
|
|
38
|
-
unit: 'CTR'
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
};
|
|
43
|
-
|
|
44
16
|
const mockServer = setupServer(
|
|
45
17
|
http.get('http://localhost:9999/api/v1/public/rates', ({ request }) => {
|
|
46
18
|
if (request.headers.get('x-api-key') !== 'TEST_API_KEY') {
|