ai-lls-lib 1.3.2__py3-none-any.whl → 1.4.0__py3-none-any.whl
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.
- ai_lls_lib/__init__.py +1 -1
- ai_lls_lib/cli/commands/stripe.py +49 -1
- ai_lls_lib/payment/credit_manager.py +8 -15
- ai_lls_lib/payment/models.py +7 -1
- {ai_lls_lib-1.3.2.dist-info → ai_lls_lib-1.4.0.dist-info}/METADATA +1 -1
- {ai_lls_lib-1.3.2.dist-info → ai_lls_lib-1.4.0.dist-info}/RECORD +8 -8
- {ai_lls_lib-1.3.2.dist-info → ai_lls_lib-1.4.0.dist-info}/WHEEL +0 -0
- {ai_lls_lib-1.3.2.dist-info → ai_lls_lib-1.4.0.dist-info}/entry_points.txt +0 -0
ai_lls_lib/__init__.py
CHANGED
@@ -13,7 +13,7 @@ from ai_lls_lib.core.verifier import PhoneVerifier
|
|
13
13
|
from ai_lls_lib.core.processor import BulkProcessor
|
14
14
|
from ai_lls_lib.core.cache import DynamoDBCache
|
15
15
|
|
16
|
-
__version__ = "1.
|
16
|
+
__version__ = "1.4.0"
|
17
17
|
__all__ = [
|
18
18
|
"PhoneVerification",
|
19
19
|
"BulkJob",
|
@@ -180,7 +180,8 @@ def seed_products(environment: str, api_key: Optional[str], dry_run: bool):
|
|
180
180
|
for p in existing_products.data:
|
181
181
|
if (p.metadata.get("product_type") == "landline_scrubber" and
|
182
182
|
p.metadata.get("environment") == environment and
|
183
|
-
p.metadata.get("tier") == config["metadata"]["tier"]
|
183
|
+
p.metadata.get("tier") == config["metadata"]["tier"] and
|
184
|
+
p.active): # Only use active products
|
184
185
|
product = p
|
185
186
|
click.echo(f"Found existing product: {product.name}")
|
186
187
|
break
|
@@ -219,6 +220,53 @@ def seed_products(environment: str, api_key: Optional[str], dry_run: bool):
|
|
219
220
|
click.echo(f" {price_id}")
|
220
221
|
|
221
222
|
|
223
|
+
@stripe_group.command("clean")
|
224
|
+
@click.option("--environment", type=click.Choice(["staging", "production"]), default="staging")
|
225
|
+
@click.option("--api-key", help="Stripe API key (overrides environment)")
|
226
|
+
@click.option("--force", is_flag=True, help="Skip confirmation")
|
227
|
+
def clean_products(environment: str, api_key: Optional[str], force: bool):
|
228
|
+
"""Remove all Landline Scrubber products and prices."""
|
229
|
+
import stripe
|
230
|
+
|
231
|
+
# Load API key from environment if not provided
|
232
|
+
if not api_key:
|
233
|
+
api_key = get_stripe_key(environment)
|
234
|
+
if not api_key:
|
235
|
+
click.echo(f"Error: No Stripe API key found for {environment} environment", err=True)
|
236
|
+
return
|
237
|
+
|
238
|
+
stripe.api_key = api_key
|
239
|
+
|
240
|
+
if not force:
|
241
|
+
if not click.confirm(f"This will DELETE all Landline Scrubber products in {environment}. Continue?"):
|
242
|
+
return
|
243
|
+
|
244
|
+
try:
|
245
|
+
# List all products
|
246
|
+
products = stripe.Product.list(limit=100)
|
247
|
+
deleted_count = 0
|
248
|
+
|
249
|
+
for product in products.data:
|
250
|
+
if (product.metadata.get("product_type") == "landline_scrubber" and
|
251
|
+
product.metadata.get("environment") == environment):
|
252
|
+
# Archive all prices first
|
253
|
+
prices = stripe.Price.list(product=product.id, limit=100)
|
254
|
+
for price in prices.data:
|
255
|
+
if price.active:
|
256
|
+
stripe.Price.modify(price.id, active=False)
|
257
|
+
click.echo(f" Archived price: {price.id}")
|
258
|
+
|
259
|
+
# Archive the product
|
260
|
+
stripe.Product.modify(product.id, active=False)
|
261
|
+
click.echo(f"Archived product: {product.name}")
|
262
|
+
deleted_count += 1
|
263
|
+
|
264
|
+
click.echo(f"\nArchived {deleted_count} products in {environment} environment")
|
265
|
+
|
266
|
+
except stripe.error.StripeError as e:
|
267
|
+
click.echo(f"Error: {e}", err=True)
|
268
|
+
|
269
|
+
|
222
270
|
@stripe_group.command("list")
|
223
271
|
@click.option("--environment", type=click.Choice(["staging", "production"]), default="staging")
|
224
272
|
@click.option("--api-key", help="Stripe API key (overrides environment)")
|
@@ -23,12 +23,10 @@ class CreditManager:
|
|
23
23
|
def __init__(self, table_name: Optional[str] = None):
|
24
24
|
"""Initialize with DynamoDB table."""
|
25
25
|
if not boto3:
|
26
|
-
|
27
|
-
self.table = None
|
28
|
-
return
|
26
|
+
raise RuntimeError("boto3 is required for CreditManager")
|
29
27
|
|
30
28
|
self.dynamodb = boto3.resource("dynamodb")
|
31
|
-
self.table_name = table_name
|
29
|
+
self.table_name = table_name if table_name else os.environ['CREDITS_TABLE']
|
32
30
|
|
33
31
|
try:
|
34
32
|
self.table = self.dynamodb.Table(self.table_name)
|
@@ -39,7 +37,7 @@ class CreditManager:
|
|
39
37
|
def get_balance(self, user_id: str) -> int:
|
40
38
|
"""Get current credit balance for a user."""
|
41
39
|
if not self.table:
|
42
|
-
|
40
|
+
raise RuntimeError(f"DynamoDB table {self.table_name} not accessible")
|
43
41
|
|
44
42
|
try:
|
45
43
|
response = self.table.get_item(Key={"user_id": user_id})
|
@@ -53,7 +51,7 @@ class CreditManager:
|
|
53
51
|
def add_credits(self, user_id: str, amount: int) -> int:
|
54
52
|
"""Add credits to user balance and return new balance."""
|
55
53
|
if not self.table:
|
56
|
-
|
54
|
+
raise RuntimeError(f"DynamoDB table {self.table_name} not accessible")
|
57
55
|
|
58
56
|
try:
|
59
57
|
response = self.table.update_item(
|
@@ -76,7 +74,7 @@ class CreditManager:
|
|
76
74
|
Returns True if successful, False if insufficient balance.
|
77
75
|
"""
|
78
76
|
if not self.table:
|
79
|
-
|
77
|
+
raise RuntimeError(f"DynamoDB table {self.table_name} not accessible")
|
80
78
|
|
81
79
|
try:
|
82
80
|
# Conditional update - only deduct if balance >= amount
|
@@ -107,7 +105,7 @@ class CreditManager:
|
|
107
105
|
) -> None:
|
108
106
|
"""Update subscription state in CreditsTable."""
|
109
107
|
if not self.table:
|
110
|
-
|
108
|
+
raise RuntimeError(f"DynamoDB table {self.table_name} not accessible")
|
111
109
|
|
112
110
|
try:
|
113
111
|
update_expr = "SET subscription_status = :status, updated_at = :now"
|
@@ -136,12 +134,7 @@ class CreditManager:
|
|
136
134
|
def get_user_payment_info(self, user_id: str) -> Dict[str, Any]:
|
137
135
|
"""Get user's payment-related information."""
|
138
136
|
if not self.table:
|
139
|
-
|
140
|
-
"credits": 1000,
|
141
|
-
"stripe_customer_id": None,
|
142
|
-
"stripe_subscription_id": None,
|
143
|
-
"subscription_status": None
|
144
|
-
}
|
137
|
+
raise RuntimeError(f"DynamoDB table {self.table_name} not accessible")
|
145
138
|
|
146
139
|
try:
|
147
140
|
response = self.table.get_item(Key={"user_id": user_id})
|
@@ -176,7 +169,7 @@ class CreditManager:
|
|
176
169
|
def set_stripe_customer_id(self, user_id: str, stripe_customer_id: str) -> None:
|
177
170
|
"""Store Stripe customer ID for a user."""
|
178
171
|
if not self.table:
|
179
|
-
|
172
|
+
raise RuntimeError(f"DynamoDB table {self.table_name} not accessible")
|
180
173
|
|
181
174
|
try:
|
182
175
|
self.table.update_item(
|
ai_lls_lib/payment/models.py
CHANGED
@@ -41,7 +41,7 @@ class Plan:
|
|
41
41
|
|
42
42
|
def to_dict(self) -> Dict[str, Any]:
|
43
43
|
"""Convert to dictionary for JSON serialization."""
|
44
|
-
|
44
|
+
result = {
|
45
45
|
"plan_reference": self.plan_reference,
|
46
46
|
"plan_type": self.plan_type,
|
47
47
|
"plan_name": self.plan_name,
|
@@ -52,6 +52,12 @@ class Plan:
|
|
52
52
|
"percent_off": self.percent_off
|
53
53
|
}
|
54
54
|
|
55
|
+
# Add variable_amount flag for VARIABLE product
|
56
|
+
if self.plan_name == "VARIABLE":
|
57
|
+
result["variable_amount"] = True
|
58
|
+
|
59
|
+
return result
|
60
|
+
|
55
61
|
@classmethod
|
56
62
|
def from_stripe_price(cls, price: Dict[str, Any], product: Dict[str, Any]) -> "Plan":
|
57
63
|
"""
|
@@ -1,4 +1,4 @@
|
|
1
|
-
ai_lls_lib/__init__.py,sha256=
|
1
|
+
ai_lls_lib/__init__.py,sha256=NNpPTkf1qHhG__iFZ3UxlCDivEaQknAI0RbzHB1y0TM,584
|
2
2
|
ai_lls_lib/auth/__init__.py,sha256=c6zomHSB6y9Seakf84ciGsD3XgWarIty9xty6P8fxVw,194
|
3
3
|
ai_lls_lib/auth/context_parser.py,sha256=8I0vGbtykNLWqm8ldedxXjE-E3nqsCy113JgeyuiJoM,2222
|
4
4
|
ai_lls_lib/cli/__init__.py,sha256=m9qjZTW1jpENwXAUeuRrlP0b66BWRcqSO28MSjvOyCs,74
|
@@ -7,7 +7,7 @@ ai_lls_lib/cli/aws_client.py,sha256=YcCWCpTNOW9JPLxSNLRy5-F5HPKguJJk7dPNrPqhJv0,
|
|
7
7
|
ai_lls_lib/cli/commands/__init__.py,sha256=_kROrYuR_p2i110c0OvNeArfEFQbn15zR1c3pdeZOoo,28
|
8
8
|
ai_lls_lib/cli/commands/admin.py,sha256=bNBJi2fZBP0J40JQP6HP7NYadNmI214iII1TeLhooyE,6687
|
9
9
|
ai_lls_lib/cli/commands/cache.py,sha256=vWt0vy4L9CEgUEWUzfdehU6u43PE8vUvHx7xxg4e5tw,5680
|
10
|
-
ai_lls_lib/cli/commands/stripe.py,sha256=
|
10
|
+
ai_lls_lib/cli/commands/stripe.py,sha256=h2OhZEppHuFbvW2kFMIp62fr7MNt_PcaUKRwd0gWGoc,14639
|
11
11
|
ai_lls_lib/cli/commands/test_stack.py,sha256=rNq4mhRXX7Ixo67kSoEPWlxqgXCzM9e2PR96qTAG7pE,7378
|
12
12
|
ai_lls_lib/cli/commands/verify.py,sha256=V5ucjmjCUxqN8_AeEJWWgrmYin8BNV3h4WbZ-iX3loU,4238
|
13
13
|
ai_lls_lib/cli/env_loader.py,sha256=YTCB6QDyknOuedPbQsW4bezB5SgHzJMGjhpSPArHFVc,3762
|
@@ -17,8 +17,8 @@ ai_lls_lib/core/models.py,sha256=ABRYaeMCWahQh4WdbkCxt3AO0-EvPWZwlL-JITQSnEM,238
|
|
17
17
|
ai_lls_lib/core/processor.py,sha256=6752IPDQ-Mz5i_CU7aBM0UjvV7IjyZFl35LKVPkHMpc,9974
|
18
18
|
ai_lls_lib/core/verifier.py,sha256=6uB_jawWoIqsNYAadTKr0lSolIWygg2gK6ykf8lrul0,2716
|
19
19
|
ai_lls_lib/payment/__init__.py,sha256=xhUWgfLnk3syXXQItswmDXdfXUyJTXTQAA0zIUuCVII,295
|
20
|
-
ai_lls_lib/payment/credit_manager.py,sha256=
|
21
|
-
ai_lls_lib/payment/models.py,sha256=
|
20
|
+
ai_lls_lib/payment/credit_manager.py,sha256=gQABSr8Lgy_IqNwQ5Dg-Ep-_7P7Q9Atx77RGMgmW0V8,7154
|
21
|
+
ai_lls_lib/payment/models.py,sha256=Du5sRc_cCsnyFJv0G3Rp67tLvZ68gq61Cm3QLC9jERI,3507
|
22
22
|
ai_lls_lib/payment/stripe_manager.py,sha256=R_M4Bii9BGianL_STqvz4UU8ww8mlCByGo66V-e2C6Y,18027
|
23
23
|
ai_lls_lib/payment/webhook_processor.py,sha256=cIZqCS98Q305SCI3-4AJ1h-IJ-l-7fMby1FFy1ckP6k,8765
|
24
24
|
ai_lls_lib/providers/__init__.py,sha256=AEv3ARenWDwDo5PLCoszP2fQ70RgSHkrSLSUz7xHJDk,179
|
@@ -27,7 +27,7 @@ ai_lls_lib/providers/external.py,sha256=-Hhnlm8lQWRcWr5vG0dmD3sca2rohURrx0usOR2y
|
|
27
27
|
ai_lls_lib/providers/stub.py,sha256=847Tmw522B3HQ2j38BH1sdcZQy--RdtDcXsrIrFKNBQ,1150
|
28
28
|
ai_lls_lib/testing/__init__.py,sha256=RUxRYBzzPCPS15Umb6bUrE6rL5BQXBQf4SJM2E3ffrg,39
|
29
29
|
ai_lls_lib/testing/fixtures.py,sha256=_n6bbr95LnQf9Dvu1qKs2HsvHEA7AAbe59B75qxE10w,3310
|
30
|
-
ai_lls_lib-1.
|
31
|
-
ai_lls_lib-1.
|
32
|
-
ai_lls_lib-1.
|
33
|
-
ai_lls_lib-1.
|
30
|
+
ai_lls_lib-1.4.0.dist-info/METADATA,sha256=YwV6CkXROIqTTQTfl9OWQqqrDX47ZHF76bajnAs2nhk,7248
|
31
|
+
ai_lls_lib-1.4.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
32
|
+
ai_lls_lib-1.4.0.dist-info/entry_points.txt,sha256=Pi0V_HBViEKGFbNQKatl5lhhnHHBXlxaom-5gH9gXZ0,55
|
33
|
+
ai_lls_lib-1.4.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|