Skip to content

Commit e82eb69

Browse files
viambotnjooma
andauthored
AI update based on proto changes (#1016)
Co-authored-by: njooma <[email protected]> Co-authored-by: Naveed Jooma <[email protected]>
1 parent c421743 commit e82eb69

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/viam/app/billing_client.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ async def get_org_billing_information(self, org_id: str, timeout: Optional[float
143143
return await self._billing_client.GetOrgBillingInformation(request, metadata=self._metadata, timeout=timeout)
144144

145145
async def create_invoice_and_charge_immediately(
146-
self, org_id_to_charge: str, amount: float, description: Optional[str] = None, org_id_for_branding: Optional[str] = None
146+
self,
147+
org_id_to_charge: str,
148+
amount: float,
149+
description: Optional[str] = None,
150+
org_id_for_branding: Optional[str] = None,
151+
disable_email: bool = False,
147152
) -> None:
148153
"""Create a flat fee invoice and charge the organization on the spot. The caller must be an owner of the organization being charged.
149154
This function blocks until payment is confirmed, but will time out after 2 minutes if there is no confirmation.
@@ -157,9 +162,14 @@ async def create_invoice_and_charge_immediately(
157162
amount (float): the amount to charge in dollars
158163
description (str): a short description of the charge to display on the invoice PDF (must be 100 characters or less)
159164
org_id_for_branding (str): the organization whose branding to use in the invoice confirmation email
165+
disable_email (bool): whether or not to disable sending an email confirmation for the invoice
160166
"""
161167
request = CreateInvoiceAndChargeImmediatelyRequest(
162-
org_id_to_charge=org_id_to_charge, amount=amount, description=description, org_id_for_branding=org_id_for_branding
168+
org_id_to_charge=org_id_to_charge,
169+
amount=amount,
170+
description=description,
171+
org_id_for_branding=org_id_for_branding,
172+
disable_email=disable_email,
163173
)
164174
_: CreateInvoiceAndChargeImmediatelyResponse = await self._billing_client.CreateInvoiceAndChargeImmediately(
165175
request, metadata=self._metadata

tests/mocks/services.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,7 @@ def __init__(
13061306
self.curr_month_usage = curr_month_usage
13071307
self.invoices_summary = invoices_summary
13081308
self.billing_info = billing_info
1309+
self.disable_email: bool = False
13091310

13101311
async def GetCurrentMonthUsage(self, stream: Stream[GetCurrentMonthUsageRequest, GetCurrentMonthUsageResponse]) -> None:
13111312
request = await stream.recv_message()
@@ -1342,6 +1343,7 @@ async def CreateInvoiceAndChargeImmediately(
13421343
self.amount = request.amount
13431344
self.description = request.description
13441345
self.org_id_for_branding = request.org_id_for_branding
1346+
self.disable_email = request.disable_email
13451347
await stream.send_message(CreateInvoiceAndChargeImmediatelyResponse())
13461348

13471349

@@ -1937,11 +1939,7 @@ async def list_uuids(
19371939
return [b"uuid1", b"uuid2", b"uuid3"]
19381940

19391941
async def get_transform(
1940-
self,
1941-
uuid: bytes,
1942-
*,
1943-
extra: Optional[Mapping[str, Any]] = None,
1944-
timeout: Optional[float] = None,
1942+
self, uuid: bytes, *, extra: Optional[Mapping[str, Any]] = None, timeout: Optional[float] = None
19451943
) -> "Transform":
19461944
self.uuid = uuid
19471945
self.extra = extra
@@ -1955,10 +1953,7 @@ async def get_transform(
19551953
)
19561954

19571955
async def stream_transform_changes(
1958-
self,
1959-
*,
1960-
extra: Optional[Mapping[str, Any]] = None,
1961-
timeout: Optional[float] = None,
1956+
self, *, extra: Optional[Mapping[str, Any]] = None, timeout: Optional[float] = None
19621957
) -> AsyncGenerator[StreamTransformChangesResponse, None]:
19631958
self.extra = extra
19641959
self.timeout = timeout

tests/test_billing_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,16 @@ async def test_create_invoice_and_charge_immediately(self, service: MockBilling)
113113
org_id = "foo"
114114
description = "A short description"
115115
org_id_for_branding = "bar"
116+
disable_email = True
116117
_: CreateInvoiceAndChargeImmediatelyResponse = await client.create_invoice_and_charge_immediately(
117118
org_id_to_charge=org_id,
118119
amount=OUTSTANDING_BALANCE,
119120
description=description,
120121
org_id_for_branding=org_id_for_branding,
122+
disable_email=disable_email,
121123
)
122124
assert service.org_id_to_charge == org_id
123125
assert service.description == description
124126
assert service.org_id_for_branding == org_id_for_branding
125127
assert service.amount == OUTSTANDING_BALANCE
128+
assert service.disable_email == disable_email

0 commit comments

Comments
 (0)