ti2-ventrata 1.0.38 → 1.0.40

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/index.js CHANGED
@@ -435,18 +435,19 @@ class Plugin {
435
435
  ), unitItemCFV);
436
436
  }
437
437
  }
438
-
438
+ const { settlementMethods } = dataForCreateBooking;
439
439
  const settlementMethod = Plugin.getSettlementMethod(
440
440
  reference,
441
- dataForCreateBooking.settlementMethods,
441
+ settlementMethods,
442
442
  );
443
+
443
444
  let booking = R.path(['data'], await axios({
444
445
  method: rebookingId ? 'patch' : 'post',
445
446
  url: `${endpoint || this.endpoint}/bookings${rebookingId ? `/${rebookingId}` : ''}`,
446
447
  data: {
447
448
  orderId,
448
449
  settlementMethod,
449
- ...dataForCreateBooking,
450
+ ...R.omit(['settlementMethods'], dataForCreateBooking),
450
451
  notes,
451
452
  ...(pickupPoint ? { pickupRequested: true, pickupPointId: pickupPoint } : {}),
452
453
  },
@@ -487,7 +488,7 @@ class Plugin {
487
488
  notes,
488
489
  resellerReference: reference,
489
490
  settlementMethod,
490
- ...(emailAddress ? { emailReceipt: true } : {}), // Send email receipt since we have a valid email address
491
+ emailReceipt: true, // always send email to the customer
491
492
  };
492
493
 
493
494
  try {
package/index.test.js CHANGED
@@ -33,7 +33,7 @@ const app = new Plugin({
33
33
  describe('search tests', () => {
34
34
  let products;
35
35
  let testProduct = {
36
- productName: '[ED3D] Edinburgh 3 Day Pass',
36
+ productName: 'Edinburgh 3 Day Pass',
37
37
  };
38
38
  const token = {
39
39
  apiKey: process.env.ti2_ventrata_apiKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-ventrata",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "Ventrata's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -5,15 +5,16 @@ const jwt = require('jsonwebtoken');
5
5
 
6
6
  const resolvers = {
7
7
  Query: {
8
- key: (root, args) => {
8
+ key: (root, args, context) => {
9
9
  const {
10
10
  productId,
11
11
  optionId,
12
12
  currency,
13
13
  unitsWithQuantity,
14
14
  jwtKey,
15
- settlementMethods,
16
15
  } = args;
16
+ // Get settlementMethods from context if not in args
17
+ const settlementMethods = args.settlementMethods || (context && context.settlementMethods) || [];
17
18
  if (!jwtKey) return null;
18
19
  return jwt.sign({
19
20
  productId,
@@ -58,11 +59,16 @@ const translateAvailability = async ({ rootValue, variableValues, typeDefs, quer
58
59
  typeDefs,
59
60
  resolvers,
60
61
  });
62
+ // Extract settlementMethods from variableValues to pass via context
63
+ const settlementMethods = variableValues.settlementMethods || [];
61
64
  const retVal = await graphql({
62
65
  schema,
63
66
  rootValue,
64
67
  source: query,
65
68
  variableValues,
69
+ contextValue: {
70
+ settlementMethods,
71
+ },
66
72
  });
67
73
  if (retVal.errors) throw new Error(retVal.errors);
68
74
  return retVal.data;