Interface BillingDatabaseClient
-
- All Known Implementing Classes:
BillingDatabaseClientMock
public interface BillingDatabaseClientInterface that talks about bills in the billing API. It is a layer on top of the SQL database where we store data about bills.- Author:
- olaa, ogronnesby
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringaddLineItem(com.yahoo.config.provision.TenantName tenantName, Bill.LineItem lineItem, Optional<Bill.Id> billId)Add a line item to an open billvoidcommitLineItems(com.yahoo.config.provision.TenantName tenantName, Bill.Id billId)Associate all uncommitted line items to a given bill This is only allowed if the line item has not already been associated with an billBill.IdcreateBill(com.yahoo.config.provision.TenantName tenant, ZonedDateTime startTime, ZonedDateTime endTime, String agent)Create a completely new Bill in the open state with no LineItems.voiddeactivateDefaultPaymentInstrument(com.yahoo.config.provision.TenantName tenant)Deactivates the default payment instrument for a tenant, if it exists.voiddeleteLineItem(String lineItemId)Delete a line item This is only allowed if the line item has not yet been associated with an billOptional<CollectionMethod>getCollectionMethod(com.yahoo.config.provision.TenantName tenantName)Get the current collection method for the tenant - if one has persistedOptional<InstrumentOwner>getDefaultPaymentInstrumentForTenant(com.yahoo.config.provision.TenantName from)Optional<Plan>getPlan(com.yahoo.config.provision.TenantName tenantName)Return the plan for the given tenantMap<com.yahoo.config.provision.TenantName,Optional<Plan>>getPlans(List<com.yahoo.config.provision.TenantName> tenants)Return the plan for the given tenants if present.List<Bill.LineItem>getUnusedLineItems(com.yahoo.config.provision.TenantName tenantName)Optional<Bill>readBill(Bill.Id billId)Read the given bill from the data sourceList<Bill>readBills()Read all bills, ordered by dateList<Bill>readBillsForTenant(com.yahoo.config.provision.TenantName tenant)Get all bills for a given tenant, ordered by datebooleansetActivePaymentInstrument(InstrumentOwner paymentInstrument)voidsetCollectionMethod(com.yahoo.config.provision.TenantName tenantName, CollectionMethod collectionMethod)Set the collection method for the tenantvoidsetPlan(com.yahoo.config.provision.TenantName tenantName, Plan plan)Set the current plan for the given tenantvoidsetStatus(Bill.Id billId, String agent, String status)Set status for the given bill
-
-
-
Method Detail
-
setActivePaymentInstrument
boolean setActivePaymentInstrument(InstrumentOwner paymentInstrument)
-
getDefaultPaymentInstrumentForTenant
Optional<InstrumentOwner> getDefaultPaymentInstrumentForTenant(com.yahoo.config.provision.TenantName from)
-
createBill
Bill.Id createBill(com.yahoo.config.provision.TenantName tenant, ZonedDateTime startTime, ZonedDateTime endTime, String agent)
Create a completely new Bill in the open state with no LineItems.- Parameters:
tenant- The name of the tenant the bill is foragent- The agent that created the bill- Returns:
- The Id of the new bill
-
readBill
Optional<Bill> readBill(Bill.Id billId)
Read the given bill from the data source- Parameters:
billId- The Id of the bill to retrieve- Returns:
- The Bill if it exists, Optional.empty() if not.
-
readBillsForTenant
List<Bill> readBillsForTenant(com.yahoo.config.provision.TenantName tenant)
Get all bills for a given tenant, ordered by date- Parameters:
tenant- The name of the tenant- Returns:
- List of all bills ordered by date
-
readBills
List<Bill> readBills()
Read all bills, ordered by date- Returns:
- List of all bills ordered by date
-
addLineItem
String addLineItem(com.yahoo.config.provision.TenantName tenantName, Bill.LineItem lineItem, Optional<Bill.Id> billId)
Add a line item to an open bill- Parameters:
lineItem-billId- The optional ID of the bill this line item is for- Returns:
- The Id of the new line item
- Throws:
RuntimeException- if the bill is not in OPEN state
-
setStatus
void setStatus(Bill.Id billId, String agent, String status)
Set status for the given bill- Parameters:
billId- The ID of the bill this status is foragent- The agent that added the statusstatus- The new status of the bill
-
getUnusedLineItems
List<Bill.LineItem> getUnusedLineItems(com.yahoo.config.provision.TenantName tenantName)
-
deleteLineItem
void deleteLineItem(String lineItemId)
Delete a line item This is only allowed if the line item has not yet been associated with an bill- Parameters:
lineItemId- The ID of the line item- Throws:
RuntimeException- if the line item is associated with an bill
-
commitLineItems
void commitLineItems(com.yahoo.config.provision.TenantName tenantName, Bill.Id billId)Associate all uncommitted line items to a given bill This is only allowed if the line item has not already been associated with an bill- Parameters:
tenantName- The tenant we want to commit line items forbillId- The ID of the line item- Throws:
RuntimeException- if the line item is already associated with an bill
-
getPlan
Optional<Plan> getPlan(com.yahoo.config.provision.TenantName tenantName)
Return the plan for the given tenant- Parameters:
tenantName- The tenant to retrieve the plan for- Returns:
- Optional.of the plan if present in DN, else Optional.empty
-
getPlans
Map<com.yahoo.config.provision.TenantName,Optional<Plan>> getPlans(List<com.yahoo.config.provision.TenantName> tenants)
Return the plan for the given tenants if present. If the database does not know of the tenant, the tenant is not included in the result.
-
setPlan
void setPlan(com.yahoo.config.provision.TenantName tenantName, Plan plan)Set the current plan for the given tenant- Parameters:
tenantName- The tenant to set the plan forplan- The plan to use
-
deactivateDefaultPaymentInstrument
void deactivateDefaultPaymentInstrument(com.yahoo.config.provision.TenantName tenant)
Deactivates the default payment instrument for a tenant, if it exists. Used during tenant deletion
-
getCollectionMethod
Optional<CollectionMethod> getCollectionMethod(com.yahoo.config.provision.TenantName tenantName)
Get the current collection method for the tenant - if one has persisted- Returns:
- Optional.empty if no collection method has been persisted for the tenant
-
setCollectionMethod
void setCollectionMethod(com.yahoo.config.provision.TenantName tenantName, CollectionMethod collectionMethod)Set the collection method for the tenant- Parameters:
tenantName- The name of the tenant to set collection method forcollectionMethod- The collection method for the tenant
-
-