elemento-loyalty-processing 1.0.5__tar.gz → 1.0.7__tar.gz
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.
- {elemento_loyalty_processing-1.0.5 → elemento_loyalty_processing-1.0.7}/PKG-INFO +2 -1
- {elemento_loyalty_processing-1.0.5 → elemento_loyalty_processing-1.0.7}/app/__init__.py +1 -1
- {elemento_loyalty_processing-1.0.5 → elemento_loyalty_processing-1.0.7}/app/client.py +53 -30
- {elemento_loyalty_processing-1.0.5 → elemento_loyalty_processing-1.0.7}/app/types.py +33 -22
- {elemento_loyalty_processing-1.0.5 → elemento_loyalty_processing-1.0.7}/pyproject.toml +2 -1
- {elemento_loyalty_processing-1.0.5 → elemento_loyalty_processing-1.0.7}/MANIFEST.in +0 -0
- {elemento_loyalty_processing-1.0.5 → elemento_loyalty_processing-1.0.7}/README.md +0 -0
- {elemento_loyalty_processing-1.0.5 → elemento_loyalty_processing-1.0.7}/elemento_loyalty_processing.egg-info/SOURCES.txt +0 -0
- {elemento_loyalty_processing-1.0.5 → elemento_loyalty_processing-1.0.7}/setup.cfg +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: elemento-loyalty-processing
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: Elemento Loyalty Processing
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Requires-Dist: kaiju-tools<3,>=2.4.9
|
|
7
|
+
Requires-Dist: elemento-customers>=1.0.0
|
|
7
8
|
Requires-Dist: kaiju-models<2,>=1.0.4
|
|
8
9
|
Provides-Extra: server
|
|
9
10
|
Requires-Dist: kaiju-db<3,>=2.3.0; extra == "server"
|
|
@@ -5,6 +5,7 @@ from typing import Any
|
|
|
5
5
|
|
|
6
6
|
from kaiju_tools.http import RPCClientService
|
|
7
7
|
from kaiju_tools.services import SERVICE_CLASS_REGISTRY
|
|
8
|
+
from msgspec import convert
|
|
8
9
|
|
|
9
10
|
from .types import *
|
|
10
11
|
|
|
@@ -18,22 +19,6 @@ class ElementoLoyaltyProcessingClient(RPCClientService):
|
|
|
18
19
|
method="Lists.products.set", params=dict(id=id, items=items), max_timeout=_max_timeout, nowait=_nowait
|
|
19
20
|
)
|
|
20
21
|
|
|
21
|
-
async def lists_get_product_list(self, id: str, _max_timeout: int = None, _nowait: bool = False):
|
|
22
|
-
"""Call Lists.products.get."""
|
|
23
|
-
return await self.call(
|
|
24
|
-
method="Lists.products.get", params=dict(id=id), max_timeout=_max_timeout, nowait=_nowait
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
async def lists_set_store_list(self, id: str, items: list, _max_timeout: int = None, _nowait: bool = False):
|
|
28
|
-
"""Call Lists.stores.set."""
|
|
29
|
-
return await self.call(
|
|
30
|
-
method="Lists.stores.set", params=dict(id=id, items=items), max_timeout=_max_timeout, nowait=_nowait
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
async def lists_get_store_list(self, id: str, _max_timeout: int = None, _nowait: bool = False):
|
|
34
|
-
"""Call Lists.stores.get."""
|
|
35
|
-
return await self.call(method="Lists.stores.get", params=dict(id=id), max_timeout=_max_timeout, nowait=_nowait)
|
|
36
|
-
|
|
37
22
|
async def balance_get_balance(
|
|
38
23
|
self, customer_id: CustomerId, _max_timeout: int = None, _nowait: bool = False
|
|
39
24
|
) -> Points:
|
|
@@ -45,21 +30,40 @@ class ElementoLoyaltyProcessingClient(RPCClientService):
|
|
|
45
30
|
async def balance_calculate(
|
|
46
31
|
self,
|
|
47
32
|
customer: Customer.Fields | dict[str, Any],
|
|
33
|
+
items: list[Item] | list[dict[str, Any]],
|
|
48
34
|
store_id: StoreId,
|
|
49
|
-
payment_type: str,
|
|
35
|
+
payment_type: str = None,
|
|
36
|
+
points_sub: Points = 0,
|
|
37
|
+
_max_timeout: int = None,
|
|
38
|
+
_nowait: bool = False,
|
|
39
|
+
):
|
|
40
|
+
data = await self.call(
|
|
41
|
+
method="Balance.calculate",
|
|
42
|
+
params=dict(
|
|
43
|
+
customer=customer, store_id=store_id, items=items, payment_type=payment_type, points_sub=points_sub
|
|
44
|
+
),
|
|
45
|
+
max_timeout=_max_timeout,
|
|
46
|
+
nowait=_nowait,
|
|
47
|
+
)
|
|
48
|
+
return convert(data, Cart)
|
|
49
|
+
|
|
50
|
+
async def balance_set_transaction(
|
|
51
|
+
self,
|
|
52
|
+
customer: Customer.Fields | dict[str, Any],
|
|
50
53
|
items: list[Item] | list[dict[str, Any]],
|
|
51
|
-
|
|
54
|
+
source: str,
|
|
55
|
+
store_id: StoreId,
|
|
56
|
+
payment_type: str,
|
|
57
|
+
transaction_id: TransactionExtId,
|
|
52
58
|
action: str = BalanceAction.CALC.value,
|
|
53
59
|
points_sub: Points = 0,
|
|
54
|
-
|
|
55
|
-
timestamp: datetime = None,
|
|
56
|
-
meta: dict[str, Any] = None,
|
|
60
|
+
timestamp: datetime | str = None,
|
|
57
61
|
_max_timeout: int = None,
|
|
58
62
|
_nowait: bool = False,
|
|
59
|
-
) ->
|
|
63
|
+
) -> Transaction:
|
|
60
64
|
"""Call Balance.calculate_cart."""
|
|
61
65
|
data = await self.call(
|
|
62
|
-
method="Balance.
|
|
66
|
+
method="Balance.transaction.set",
|
|
63
67
|
params=dict(
|
|
64
68
|
customer=customer,
|
|
65
69
|
store_id=store_id,
|
|
@@ -67,26 +71,26 @@ class ElementoLoyaltyProcessingClient(RPCClientService):
|
|
|
67
71
|
payment_type=payment_type,
|
|
68
72
|
points_sub=points_sub,
|
|
69
73
|
transaction_id=transaction_id,
|
|
70
|
-
|
|
74
|
+
source=source,
|
|
71
75
|
timestamp=timestamp,
|
|
72
76
|
action=action,
|
|
73
|
-
meta=meta,
|
|
74
77
|
),
|
|
75
78
|
max_timeout=_max_timeout,
|
|
76
79
|
nowait=_nowait,
|
|
77
80
|
)
|
|
78
|
-
return
|
|
81
|
+
return convert(data, Transaction)
|
|
79
82
|
|
|
80
83
|
async def balance_confirm_transaction(
|
|
81
84
|
self, transaction_id: TransactionId, _max_timeout: int = None, _nowait: bool = False
|
|
82
|
-
) ->
|
|
85
|
+
) -> Transaction:
|
|
83
86
|
"""Call Balance.transaction.confirm."""
|
|
84
|
-
|
|
87
|
+
data = await self.call(
|
|
85
88
|
method="Balance.transaction.confirm",
|
|
86
89
|
params=dict(transaction_id=transaction_id),
|
|
87
90
|
max_timeout=_max_timeout,
|
|
88
91
|
nowait=_nowait,
|
|
89
92
|
)
|
|
93
|
+
return convert(data, Transaction)
|
|
90
94
|
|
|
91
95
|
async def balance_revert_transaction(
|
|
92
96
|
self, transaction_id: TransactionId, _max_timeout: int = None, _nowait: bool = False
|
|
@@ -101,14 +105,33 @@ class ElementoLoyaltyProcessingClient(RPCClientService):
|
|
|
101
105
|
|
|
102
106
|
async def balance_commit_transaction(
|
|
103
107
|
self, transaction_id: TransactionId, _max_timeout: int = None, _nowait: bool = False
|
|
104
|
-
) ->
|
|
108
|
+
) -> Transaction:
|
|
105
109
|
"""Call Balance.transaction.commit."""
|
|
106
|
-
|
|
110
|
+
data = await self.call(
|
|
107
111
|
method="Balance.transaction.commit",
|
|
108
112
|
params=dict(transaction_id=transaction_id),
|
|
109
113
|
max_timeout=_max_timeout,
|
|
110
114
|
nowait=_nowait,
|
|
111
115
|
)
|
|
116
|
+
return convert(data, Transaction)
|
|
117
|
+
|
|
118
|
+
async def balance_refund(
|
|
119
|
+
self,
|
|
120
|
+
customer_id: CustomerId,
|
|
121
|
+
source: str,
|
|
122
|
+
transaction_id: TransactionExtId,
|
|
123
|
+
positions: list[int],
|
|
124
|
+
_max_timeout: int = None,
|
|
125
|
+
_nowait: bool = False,
|
|
126
|
+
) -> Points:
|
|
127
|
+
"""Call Balance.refund."""
|
|
128
|
+
data = await self.call(
|
|
129
|
+
method="Balance.refund",
|
|
130
|
+
params=dict(customer_id=customer_id, source=source, transaction_id=transaction_id, positions=positions),
|
|
131
|
+
max_timeout=_max_timeout,
|
|
132
|
+
nowait=_nowait,
|
|
133
|
+
)
|
|
134
|
+
return Points(data)
|
|
112
135
|
|
|
113
136
|
async def balance_create_event(
|
|
114
137
|
self,
|
|
@@ -17,7 +17,6 @@ __all__ = [
|
|
|
17
17
|
"BalanceStatus",
|
|
18
18
|
"Balance",
|
|
19
19
|
"TransactionType",
|
|
20
|
-
"OrderItem",
|
|
21
20
|
"TransactionId",
|
|
22
21
|
"CustomerId",
|
|
23
22
|
"Transaction",
|
|
@@ -36,16 +35,19 @@ __all__ = [
|
|
|
36
35
|
"Points",
|
|
37
36
|
"StoreId",
|
|
38
37
|
"AppliedOffer",
|
|
38
|
+
"PointType",
|
|
39
|
+
"TransactionExtId",
|
|
39
40
|
]
|
|
40
41
|
|
|
41
42
|
DATE_MAXVALUE = date.fromisoformat("3000-01-01")
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
TransactionExtId = NewType("TransactionExtId", str)
|
|
45
|
+
TransactionId = NewType("TransactionId", int)
|
|
44
46
|
EventTypeId = NewType("EventTypeId", str)
|
|
45
47
|
ListId = NewType("ListId", int)
|
|
46
48
|
StoreId = NewType("StoreId", int)
|
|
47
49
|
OfferId = NewType("OfferId", int)
|
|
48
|
-
LifetimeId = NewType("LifetimeId",
|
|
50
|
+
LifetimeId = NewType("LifetimeId", str)
|
|
49
51
|
GroupId = NewType("GroupId", int)
|
|
50
52
|
ConditionId = NewType("ConditionId", int)
|
|
51
53
|
ActionId = NewType("ActionId", int)
|
|
@@ -88,28 +90,23 @@ class Balance(Struct):
|
|
|
88
90
|
transaction_id: TransactionId | None = None
|
|
89
91
|
|
|
90
92
|
|
|
91
|
-
class OrderItem(Struct):
|
|
92
|
-
product_id: str
|
|
93
|
-
quantity: int
|
|
94
|
-
price: Decimal
|
|
95
|
-
balance: Points
|
|
96
|
-
active: bool
|
|
97
|
-
|
|
98
|
-
|
|
99
93
|
class TransactionType(Enum):
|
|
100
94
|
ORDER = "ORDER"
|
|
101
95
|
SCRIPT = "SCRIPT"
|
|
102
96
|
|
|
103
97
|
|
|
104
|
-
class
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
98
|
+
class _PointTypeData(TypedDict, total=False):
|
|
99
|
+
func: str
|
|
100
|
+
value: Any
|
|
101
|
+
time_unit: str
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class PointType(Struct):
|
|
105
|
+
updated: datetime
|
|
106
|
+
id: LifetimeId
|
|
107
|
+
label: str
|
|
108
|
+
activation: _PointTypeData
|
|
109
|
+
expiration: _PointTypeData
|
|
113
110
|
|
|
114
111
|
|
|
115
112
|
class BalanceAction(Enum):
|
|
@@ -156,9 +153,23 @@ class Cart(Struct):
|
|
|
156
153
|
customer_message: str | None = None
|
|
157
154
|
|
|
158
155
|
|
|
156
|
+
class StoredTransaction(Struct):
|
|
157
|
+
id: TransactionId
|
|
158
|
+
created: datetime
|
|
159
|
+
customer_id: CustomerId
|
|
160
|
+
type: TransactionType
|
|
161
|
+
balance: list[int]
|
|
162
|
+
ext_id: TransactionExtId
|
|
163
|
+
source: str
|
|
164
|
+
data: dict[str, Any] = None
|
|
165
|
+
active: bool = True
|
|
166
|
+
|
|
167
|
+
|
|
159
168
|
class Transaction(Struct):
|
|
160
|
-
|
|
161
|
-
|
|
169
|
+
ext_id: TransactionExtId
|
|
170
|
+
id: TransactionId
|
|
171
|
+
source: str
|
|
172
|
+
order_id: str | None = None
|
|
162
173
|
customer_id: CustomerId = None
|
|
163
174
|
timestamp: datetime = None
|
|
164
175
|
cart: Cart = None
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "elemento-loyalty-processing"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.7"
|
|
4
4
|
description = "Elemento Loyalty Processing"
|
|
5
5
|
requires-python = ">=3.11"
|
|
6
6
|
dependencies = [
|
|
7
7
|
"kaiju-tools>=2.4.9,<3",
|
|
8
|
+
"elemento-customers>=1.0.0",
|
|
8
9
|
"kaiju-models>=1.0.4,<2"
|
|
9
10
|
]
|
|
10
11
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|