Skip to content

Commit

Permalink
[backend] add renewal_period to get_budget response
Browse files Browse the repository at this point in the history
  • Loading branch information
bsiaotickchong committed Oct 1, 2024
1 parent a672893 commit 07afe53
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nwc_backend/event_handlers/__tests__/get_budget_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ async def test_get_budget_success__spending_limit_SAT_enabled(
"total_budget": 1000000,
"used_budget": 0,
"renews_at": round(spending_cycle.end_time.timestamp()),
"renewal_period": "monthly",
}


Expand Down Expand Up @@ -107,6 +108,7 @@ async def test_pay_invoice_success__spending_limit_USD_enabled(
"total_budget": estimated_budget_currency_amount * 1000,
"used_budget": 0,
"renews_at": ANY,
"renewal_period": "monthly",
"currency": {
"code": "USD",
"total_budget": total_budget_currency_amount,
Expand Down
2 changes: 2 additions & 0 deletions nwc_backend/event_handlers/get_budget_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ async def get_budget(access_token: str, request: Nip47Request) -> Nip47BudgetRes
total_budget=current_spending_limit.amount * 1000,
used_budget=used_budget_sats * 1000,
renews_at=current_cycle_renews_at,
renewal_period=current_spending_limit.frequency.value,
)

budget_estimate_response = await VaspUmaClient.instance().get_budget_estimate(
Expand Down Expand Up @@ -56,4 +57,5 @@ async def get_budget(access_token: str, request: Nip47Request) -> Nip47BudgetRes
total_budget=total_budget_sats * 1000,
used_budget=used_budget_sats * 1000,
renews_at=current_cycle_renews_at,
renewal_period=current_spending_limit.frequency.value,
)
1 change: 1 addition & 0 deletions nwc_backend/models/nip47_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Nip47BudgetResponse:
used_budget: Optional[int] = None
total_budget: Optional[int] = None
renews_at: Optional[int] = None
renewal_period: Optional[str] = None
currency: Optional[Nip47BudgetCurrency] = None

def to_dict(self):
Expand Down

0 comments on commit 07afe53

Please sign in to comment.