@tonder.io/ionic-lite-sdk 0.0.19 → 0.0.21-beta
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/types/requests.d.ts
CHANGED
|
@@ -3,19 +3,19 @@ import { SkyflowRecord } from "./skyflow";
|
|
|
3
3
|
export interface CreateOrderRequest {
|
|
4
4
|
business: string;
|
|
5
5
|
client: string;
|
|
6
|
-
billing_address_id?:
|
|
7
|
-
shipping_address_id?:
|
|
6
|
+
billing_address_id?: number | null;
|
|
7
|
+
shipping_address_id?: number | null;
|
|
8
8
|
amount: number;
|
|
9
|
-
status
|
|
9
|
+
status?: string;
|
|
10
10
|
reference: string | number;
|
|
11
11
|
is_oneclick: boolean;
|
|
12
12
|
items: OrderItem[];
|
|
13
13
|
}
|
|
14
14
|
export type CreatePaymentRequest = {
|
|
15
|
-
business_pk
|
|
15
|
+
business_pk?: string | number;
|
|
16
16
|
amount: number;
|
|
17
|
-
date
|
|
18
|
-
order
|
|
17
|
+
date?: string;
|
|
18
|
+
order?: string | number;
|
|
19
19
|
};
|
|
20
20
|
export type StartCheckoutRequest = {
|
|
21
21
|
card: any;
|
package/package.json
CHANGED
package/src/types/requests.ts
CHANGED
|
@@ -4,20 +4,20 @@ import { SkyflowRecord } from "./skyflow";
|
|
|
4
4
|
export interface CreateOrderRequest {
|
|
5
5
|
business: string,
|
|
6
6
|
client: string,
|
|
7
|
-
billing_address_id?:
|
|
8
|
-
shipping_address_id?:
|
|
7
|
+
billing_address_id?: number | null,
|
|
8
|
+
shipping_address_id?: number | null,
|
|
9
9
|
amount: number,
|
|
10
|
-
status
|
|
10
|
+
status?: string,
|
|
11
11
|
reference: string | number,
|
|
12
12
|
is_oneclick: boolean,
|
|
13
13
|
items: OrderItem[]
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export type CreatePaymentRequest = {
|
|
17
|
-
business_pk
|
|
17
|
+
business_pk?: string | number,
|
|
18
18
|
amount: number,
|
|
19
|
-
date
|
|
20
|
-
order
|
|
19
|
+
date?: string,
|
|
20
|
+
order?: string | number
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export type StartCheckoutRequest = {
|
package/src/types/responses.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ErrorResponse } from "../../src/classes/errorResponse";
|
|
|
4
4
|
import { LiteCheckoutConstructor } from "../../src/classes/liteCheckout";
|
|
5
5
|
import { IErrorResponse } from "../../src/types/responses";
|
|
6
6
|
import { constructorFields } from "../utils/defaultMock";
|
|
7
|
-
import { OrderResponseClass, OrderClass } from "../utils/mockClasses";
|
|
7
|
+
import { OrderResponseClass, OrderClass, OrderClassEmptyValues, OrderEmptyValuesResponse } from "../utils/mockClasses";
|
|
8
8
|
|
|
9
9
|
declare global {
|
|
10
10
|
interface Window {
|
|
@@ -90,6 +90,26 @@ describe("createOrder", () => {
|
|
|
90
90
|
expect(response).toBeInstanceOf(ErrorResponse);
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
+
it("createOrder empty values", async () => {
|
|
94
|
+
liteCheckoutSpy = jest.spyOn(liteCheckout, "createOrder");
|
|
95
|
+
|
|
96
|
+
fetchSpy.mockImplementation(() =>
|
|
97
|
+
Promise.resolve({
|
|
98
|
+
json: () => Promise.resolve(OrderEmptyValuesResponse),
|
|
99
|
+
ok: false,
|
|
100
|
+
status: 400,
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const response = (await liteCheckout.createOrder({
|
|
105
|
+
...new OrderClassEmptyValues(),
|
|
106
|
+
})) as IErrorResponse;
|
|
107
|
+
|
|
108
|
+
expect(liteCheckoutSpy).toHaveBeenCalled();
|
|
109
|
+
expect(response.body).toStrictEqual(OrderEmptyValuesResponse);
|
|
110
|
+
expect(liteCheckoutSpy).rejects.toThrow();
|
|
111
|
+
});
|
|
112
|
+
|
|
93
113
|
it("createOrder errorCatch", async () => {
|
|
94
114
|
liteCheckoutSpy = jest.spyOn(liteCheckout, "createOrder");
|
|
95
115
|
|
|
@@ -4,7 +4,7 @@ import { ErrorResponse } from "../../src/classes/errorResponse";
|
|
|
4
4
|
import { LiteCheckoutConstructor } from "../../src/classes/liteCheckout";
|
|
5
5
|
import { IErrorResponse } from "../../src/types/responses";
|
|
6
6
|
import { constructorFields } from "../utils/defaultMock";
|
|
7
|
-
import { BusinessClass } from "../utils/mockClasses";
|
|
7
|
+
import { BusinessClass, CustomerRegisterClass } from "../utils/mockClasses";
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
declare global {
|
|
@@ -43,7 +43,7 @@ describe("customerRegister", () => {
|
|
|
43
43
|
Promise.resolve({
|
|
44
44
|
json: () =>
|
|
45
45
|
Promise.resolve({
|
|
46
|
-
...new
|
|
46
|
+
...new CustomerRegisterClass(),
|
|
47
47
|
}),
|
|
48
48
|
ok: true,
|
|
49
49
|
})
|
|
@@ -51,7 +51,7 @@ describe("customerRegister", () => {
|
|
|
51
51
|
|
|
52
52
|
const response = await liteCheckout.customerRegister("email@gmail.com");
|
|
53
53
|
|
|
54
|
-
expect(response).toStrictEqual({ ...new
|
|
54
|
+
expect(response).toStrictEqual({ ...new CustomerRegisterClass() });
|
|
55
55
|
expect(liteCheckoutSpy).toHaveBeenCalled();
|
|
56
56
|
expect(liteCheckoutSpy).toHaveBeenCalledWith("email@gmail.com");
|
|
57
57
|
});
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
CreatePaymentRequest,
|
|
5
5
|
RegisterCustomerCardRequest,
|
|
6
6
|
StartCheckoutRequest,
|
|
7
|
-
TokensRequest
|
|
7
|
+
TokensRequest
|
|
8
8
|
} from "../../src/types/requests";
|
|
9
9
|
import {
|
|
10
10
|
CreateOrderResponse,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
GetCustomerCardsResponse,
|
|
14
14
|
RegisterCustomerCardResponse,
|
|
15
15
|
StartCheckoutResponse,
|
|
16
|
+
CustomerRegisterResponse
|
|
16
17
|
} from "../../src/types/responses";
|
|
17
18
|
|
|
18
19
|
export class BusinessClass implements Business {
|
|
@@ -69,8 +70,8 @@ export class BusinessClass implements Business {
|
|
|
69
70
|
export class OrderClass implements CreateOrderRequest {
|
|
70
71
|
business!: string;
|
|
71
72
|
client!: string;
|
|
72
|
-
billing_address_id!:
|
|
73
|
-
shipping_address_id!:
|
|
73
|
+
billing_address_id!: number | null;
|
|
74
|
+
shipping_address_id!: number | null;
|
|
74
75
|
amount!: number;
|
|
75
76
|
status!: string;
|
|
76
77
|
reference!: string;
|
|
@@ -81,8 +82,8 @@ export class OrderClass implements CreateOrderRequest {
|
|
|
81
82
|
return {
|
|
82
83
|
business: "The business pk",
|
|
83
84
|
client: "Client auth token",
|
|
84
|
-
billing_address_id:
|
|
85
|
-
shipping_address_id:
|
|
85
|
+
billing_address_id: null,
|
|
86
|
+
shipping_address_id: null,
|
|
86
87
|
amount: 25,
|
|
87
88
|
status: "PENDING",
|
|
88
89
|
reference: "XXXXXXX",
|
|
@@ -95,6 +96,35 @@ export class OrderClass implements CreateOrderRequest {
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
|
|
99
|
+
export class OrderClassEmptyValues implements CreateOrderRequest {
|
|
100
|
+
business!: string;
|
|
101
|
+
client!: string;
|
|
102
|
+
billing_address_id!: number | null;
|
|
103
|
+
shipping_address_id!: number | null;
|
|
104
|
+
amount!: number;
|
|
105
|
+
status!: string;
|
|
106
|
+
reference!: string;
|
|
107
|
+
is_oneclick!: boolean;
|
|
108
|
+
items!: OrderItem[];
|
|
109
|
+
|
|
110
|
+
get mockObject(): CreateOrderRequest {
|
|
111
|
+
return {
|
|
112
|
+
business: "",
|
|
113
|
+
client: "Client auth token",
|
|
114
|
+
billing_address_id: 1,
|
|
115
|
+
shipping_address_id: 2,
|
|
116
|
+
amount: 25,
|
|
117
|
+
status: "PENDING",
|
|
118
|
+
reference: "",
|
|
119
|
+
is_oneclick: false,
|
|
120
|
+
items: [
|
|
121
|
+
{ ...new OrderItemClass() }
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
98
128
|
export class OrderItemClass implements OrderItem {
|
|
99
129
|
description!: string;
|
|
100
130
|
quantity!: number;
|
|
@@ -536,3 +566,28 @@ export class GetCustomerCardsResponseClass implements GetCustomerCardsResponse {
|
|
|
536
566
|
};
|
|
537
567
|
}
|
|
538
568
|
}
|
|
569
|
+
|
|
570
|
+
export const OrderEmptyValuesResponse = {
|
|
571
|
+
"business": [
|
|
572
|
+
"This field may not be blank."
|
|
573
|
+
],
|
|
574
|
+
"reference": [
|
|
575
|
+
"This field may not be null."
|
|
576
|
+
]
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
export class CustomerRegisterClass implements CustomerRegisterResponse {
|
|
580
|
+
id!: number;
|
|
581
|
+
email!: string;
|
|
582
|
+
auth_token!: string;
|
|
583
|
+
first_name!: string;
|
|
584
|
+
last_name!: string;
|
|
585
|
+
|
|
586
|
+
get mockObject(): CustomerRegisterResponse {
|
|
587
|
+
return {
|
|
588
|
+
id: 10,
|
|
589
|
+
email: "email@gmail.com",
|
|
590
|
+
auth_token: "string"
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
}
|