addio-admin-sdk 1.7.120 → 1.7.121
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/Interfaces/Context/IContextProps.d.ts +1 -1
- package/dist/Interfaces/Payment/index.d.ts +13 -0
- package/dist/Interfaces/Payment/index.js +12 -0
- package/dist/Interfaces/Payment/index.js.map +1 -1
- package/dist/lib/Customer/index.d.ts +7 -0
- package/dist/lib/Customer/index.js +11 -0
- package/dist/lib/Customer/index.js.map +1 -1
- package/dist/lib/Space/index.d.ts +2 -2
- package/dist/lib/Space/index.js +5 -8
- package/dist/lib/Space/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,3 +11,16 @@ export default interface IPayment {
|
|
|
11
11
|
readonly is_deposit?: boolean;
|
|
12
12
|
readonly ref?: string;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Generates and returns a Payment object with props provided.
|
|
16
|
+
* @param method The PaymentTypeEnum for specific payment method.
|
|
17
|
+
* @param amount The money amount to associate to payement. Can be a negative value or 0, but must be provided.
|
|
18
|
+
* @param options.reference Optionnal. The reference or comment string for payement.
|
|
19
|
+
* @param options.userEmail Optionnal. The email of the Addio user that took the payment.
|
|
20
|
+
* @param options.paidAtDate Optionnal. If not provided, sets "today" date.
|
|
21
|
+
*/
|
|
22
|
+
export declare const generatePaymentObj: (method: PaymentTypeEnum, amount: number, options?: {
|
|
23
|
+
reference?: string | undefined;
|
|
24
|
+
userEmail?: string | undefined;
|
|
25
|
+
paidAtDate?: Date | undefined;
|
|
26
|
+
}) => IPayment;
|
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePaymentObj = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Generates and returns a Payment object with props provided.
|
|
6
|
+
* @param method The PaymentTypeEnum for specific payment method.
|
|
7
|
+
* @param amount The money amount to associate to payement. Can be a negative value or 0, but must be provided.
|
|
8
|
+
* @param options.reference Optionnal. The reference or comment string for payement.
|
|
9
|
+
* @param options.userEmail Optionnal. The email of the Addio user that took the payment.
|
|
10
|
+
* @param options.paidAtDate Optionnal. If not provided, sets "today" date.
|
|
11
|
+
*/
|
|
12
|
+
const generatePaymentObj = (method, amount, options = {}) => (Object.assign(Object.assign({ amount,
|
|
13
|
+
method, paid_at: options.paidAtDate || new Date() }, (options.userEmail ? { user_email: options.userEmail } : {})), (options.reference ? { ref: options.reference } : {})));
|
|
14
|
+
exports.generatePaymentObj = generatePaymentObj;
|
|
3
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Interfaces/Payment/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Interfaces/Payment/index.ts"],"names":[],"mappings":";;;AAiBA;;;;;;;GAOG;AACI,MAAM,kBAAkB,GAAG,CACjC,MAAuB,EACvB,MAAc,EACd,UAA6G,EAAE,EACpG,EAAE,CAAC,+BACd,MAAM;IACN,MAAM,EACN,OAAO,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI,IAAI,EAAE,IACtC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAC5D,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACvD,CAAA;AAVW,QAAA,kBAAkB,sBAU7B"}
|
|
@@ -3,6 +3,7 @@ import { IIndexedCustomer } from '../../Interfaces/Algolia';
|
|
|
3
3
|
import ICustomer from '../../Interfaces/Customer';
|
|
4
4
|
import { IQueryProps } from '../../Interfaces/Product';
|
|
5
5
|
import { BaseServiceClass } from '../baseService';
|
|
6
|
+
import { ICustomerStoreCredit } from '../../Interfaces/Customer/IStoreCredit';
|
|
6
7
|
/**
|
|
7
8
|
* Customer class
|
|
8
9
|
*/
|
|
@@ -20,4 +21,10 @@ export default class Customer extends BaseServiceClass<ICustomer> {
|
|
|
20
21
|
* @returns the amount
|
|
21
22
|
*/
|
|
22
23
|
getStoreCredit: (creditSlug: string) => Promise<number>;
|
|
24
|
+
/**
|
|
25
|
+
* Fetch store credit for customer by slug
|
|
26
|
+
* @param customerStoreCredit
|
|
27
|
+
* @param slug
|
|
28
|
+
*/
|
|
29
|
+
static getStoreCreditAmountBySlug: (customerStoreCredit: ICustomerStoreCredit[] | undefined, slug: string) => number;
|
|
23
30
|
}
|
|
@@ -79,4 +79,15 @@ Customer.fetch = async ({ app, api, hpp = 10, page = 0, query = '', filters = ''
|
|
|
79
79
|
throw error;
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* Fetch store credit for customer by slug
|
|
84
|
+
* @param customerStoreCredit
|
|
85
|
+
* @param slug
|
|
86
|
+
*/
|
|
87
|
+
Customer.getStoreCreditAmountBySlug = (customerStoreCredit = [], slug) => {
|
|
88
|
+
const credit = customerStoreCredit.find((x) => x.credit_slug == slug);
|
|
89
|
+
if (!credit)
|
|
90
|
+
return 0;
|
|
91
|
+
return credit.amount;
|
|
92
|
+
};
|
|
82
93
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/Customer/index.ts"],"names":[],"mappings":";;;AACA,6BAAiC;AAIjC,iDAAkD;AAClD,iDAAkD;AAClD,gDAAiD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/Customer/index.ts"],"names":[],"mappings":";;;AACA,6BAAiC;AAIjC,iDAAkD;AAClD,iDAAkD;AAClD,gDAAiD;AAGjD;;GAEG;AACH,MAAqB,QAAS,SAAQ,8BAA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G,EAAE,CAAC,CAAC,CAAC,GAAG;YAC7F,MAAM,EAAE,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,SAAS;SACrC,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,CAAmB,KAAK,EAAE;YAC7D,WAAW,EAAE,GAAG;YAChB,YAAY,EAAE,OAAO;YACrB,OAAO,EAAE,CAAC;YACV,IAAI;YACJ,+BAA+B;YAC/B,MAAM,EAAE,CAAC,GAAG,CAAC;SACb,CAAC,CAAA;QAEF,OAAO,OAAO,CAAA;KACd;IAAC,OAAO,KAAK,EAAE;QACf,IAAA,sBAAY,EAAC,KAAY,CAAC,CAAA;QAC1B,MAAM,KAAK,CAAA;KACX;AACF,CAAC,CAAA;AA0DD;;;;GAIG;AACI,mCAA0B,GAAG,CACnC,sBAA0D,EAAE,EAC5D,IAAY,EACH,EAAE;IACX,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,IAAI,IAAI,CAAC,CAAA;IACrE,IAAI,CAAC,MAAM;QAAE,OAAO,CAAC,CAAA;IACrB,OAAO,MAAM,CAAC,MAAM,CAAA;AACrB,CAAC,CAAA"}
|
|
@@ -566,7 +566,7 @@ export default class Space {
|
|
|
566
566
|
* @param creditSlug The slug of the credit to get
|
|
567
567
|
* @returns The amount
|
|
568
568
|
*/
|
|
569
|
-
private
|
|
569
|
+
private _getStoreCreditForCustomer;
|
|
570
570
|
/**
|
|
571
571
|
* Get the full history of credit for a customer
|
|
572
572
|
* @param customerId The customer ID
|
|
@@ -768,7 +768,7 @@ export default class Space {
|
|
|
768
768
|
};
|
|
769
769
|
};
|
|
770
770
|
storeCredits: {
|
|
771
|
-
getStoreCreditToUse: () =>
|
|
771
|
+
getStoreCreditToUse: () => IStoreCreditEntry | undefined;
|
|
772
772
|
};
|
|
773
773
|
bookings: {
|
|
774
774
|
get: (options?: IQueryOptions) => Promise<Booking[]>;
|
package/dist/lib/Space/index.js
CHANGED
|
@@ -4990,7 +4990,7 @@ class Space {
|
|
|
4990
4990
|
throw new Error('Unable to save new credit value');
|
|
4991
4991
|
return true;
|
|
4992
4992
|
};
|
|
4993
|
-
this._getStoreCreditToUse =
|
|
4993
|
+
this._getStoreCreditToUse = () => {
|
|
4994
4994
|
const allCredits = this.data().store_credits || [];
|
|
4995
4995
|
// TODO - Add logic here when ready to support more than one store credit type
|
|
4996
4996
|
// DEFAULT - return default option
|
|
@@ -5002,7 +5002,7 @@ class Space {
|
|
|
5002
5002
|
* @param creditSlug The slug of the credit to get
|
|
5003
5003
|
* @returns The amount
|
|
5004
5004
|
*/
|
|
5005
|
-
this.
|
|
5005
|
+
this._getStoreCreditForCustomer = async (customerId, creditSlug) => {
|
|
5006
5006
|
if (!customerId)
|
|
5007
5007
|
throw new Error('Customer ID is required');
|
|
5008
5008
|
if (!creditSlug)
|
|
@@ -5012,10 +5012,7 @@ class Space {
|
|
|
5012
5012
|
const customer = await DatabaseService_1.default.getDocument(customerPath, customerId);
|
|
5013
5013
|
if (!customer.exists)
|
|
5014
5014
|
new Error('Could not find customer');
|
|
5015
|
-
|
|
5016
|
-
if (!credit)
|
|
5017
|
-
return 0;
|
|
5018
|
-
return credit.amount;
|
|
5015
|
+
return Customer_2.default.getStoreCreditAmountBySlug(customer.data.store_credits, creditSlug);
|
|
5019
5016
|
};
|
|
5020
5017
|
/**
|
|
5021
5018
|
* Get the full history of credit for a customer
|
|
@@ -5053,7 +5050,7 @@ class Space {
|
|
|
5053
5050
|
throw new Error('The credit slug is required');
|
|
5054
5051
|
if (amount <= 0)
|
|
5055
5052
|
return true;
|
|
5056
|
-
const current = await this.
|
|
5053
|
+
const current = await this._getStoreCreditForCustomer(customerId, creditSlug);
|
|
5057
5054
|
return amount <= current;
|
|
5058
5055
|
};
|
|
5059
5056
|
/**
|
|
@@ -5268,7 +5265,7 @@ class Space {
|
|
|
5268
5265
|
updateCustomerLastActivity: this._updateCustomerLastActivity,
|
|
5269
5266
|
credits: {
|
|
5270
5267
|
modify: this._modifyStoreCredit,
|
|
5271
|
-
get: this.
|
|
5268
|
+
get: this._getStoreCreditForCustomer,
|
|
5272
5269
|
getHistory: this._getStoreCreditHistory,
|
|
5273
5270
|
validate: this._validateCredit,
|
|
5274
5271
|
getAvailableCredits: this._getSpaceCredits
|