| package router |
|
|
| import ( |
| "net/http" |
|
|
| "github.com/samber/lo" |
|
|
| "github.com/openmeterio/openmeter/api" |
| "github.com/openmeterio/openmeter/openmeter/billing/httpdriver" |
| ) |
|
|
| |
| |
| func (a *Router) ListBillingProfileCustomerOverrides(w http.ResponseWriter, r *http.Request, params api.ListBillingProfileCustomerOverridesParams) { |
| a.billingHandler.ListCustomerOverrides().With(params).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) DeleteBillingProfileCustomerOverride(w http.ResponseWriter, r *http.Request, customerId string) { |
| a.billingHandler.DeleteCustomerOverride().With(httpdriver.DeleteCustomerOverrideParams{ |
| CustomerId: customerId, |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) GetBillingProfileCustomerOverride(w http.ResponseWriter, r *http.Request, customerId string, params api.GetBillingProfileCustomerOverrideParams) { |
| a.billingHandler.GetCustomerOverride().With(httpdriver.GetCustomerOverrideParams{ |
| CustomerId: customerId, |
| Expand: params.Expand, |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) UpsertBillingProfileCustomerOverride(w http.ResponseWriter, r *http.Request, customerId string) { |
| a.billingHandler.UpsertCustomerOverride().With(httpdriver.UpsertCustomerOverrideParams{ |
| CustomerId: customerId, |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) ListInvoices(w http.ResponseWriter, r *http.Request, params api.ListInvoicesParams) { |
| a.billingHandler.ListInvoices().With(params).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) InvoicePendingLinesAction(w http.ResponseWriter, r *http.Request) { |
| a.billingHandler.InvoicePendingLinesAction().ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) DeleteInvoice(w http.ResponseWriter, r *http.Request, invoiceId string) { |
| a.billingHandler.DeleteInvoice().With(httpdriver.DeleteInvoiceParams{ |
| InvoiceID: invoiceId, |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) GetInvoice(w http.ResponseWriter, r *http.Request, invoiceId string, params api.GetInvoiceParams) { |
| a.billingHandler.GetInvoice().With(httpdriver.GetInvoiceParams{ |
| InvoiceID: invoiceId, |
| Expand: lo.FromPtr(params.Expand), |
| IncludeDeletedLines: lo.FromPtr(params.IncludeDeletedLines), |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) SnapshotQuantitiesInvoiceAction(w http.ResponseWriter, r *http.Request, invoiceId string) { |
| a.billingHandler.ProgressInvoice(httpdriver.InvoiceProgressActionSnapshotQuantities). |
| With(httpdriver.ProgressInvoiceParams{ |
| InvoiceID: invoiceId, |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) AdvanceInvoiceAction(w http.ResponseWriter, r *http.Request, invoiceId string) { |
| a.billingHandler.ProgressInvoice(httpdriver.InvoiceProgressActionAdvance). |
| With(httpdriver.ProgressInvoiceParams{ |
| InvoiceID: invoiceId, |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) ApproveInvoiceAction(w http.ResponseWriter, r *http.Request, invoiceId string) { |
| a.billingHandler.ProgressInvoice(httpdriver.InvoiceProgressActionApprove). |
| With(httpdriver.ProgressInvoiceParams{ |
| InvoiceID: invoiceId, |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) SimulateInvoice(w http.ResponseWriter, r *http.Request, customerId string) { |
| a.billingHandler.SimulateInvoice().With(httpdriver.SimulateInvoiceParams{ |
| CustomerID: customerId, |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) UpdateInvoice(w http.ResponseWriter, r *http.Request, invoiceId string) { |
| a.billingHandler.UpdateInvoice().With(httpdriver.UpdateInvoiceParams{ |
| InvoiceID: invoiceId, |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) RetryInvoiceAction(w http.ResponseWriter, r *http.Request, invoiceId string) { |
| a.billingHandler.ProgressInvoice(httpdriver.InvoiceProgressActionRetry). |
| With(httpdriver.ProgressInvoiceParams{ |
| InvoiceID: invoiceId, |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) RecalculateInvoiceTaxAction(w http.ResponseWriter, r *http.Request, invoiceId string) { |
| w.WriteHeader(http.StatusNotImplemented) |
| } |
|
|
| |
| |
| func (a *Router) VoidInvoiceAction(w http.ResponseWriter, r *http.Request, invoiceId string) { |
| w.WriteHeader(http.StatusNotImplemented) |
| } |
|
|
| |
| |
| func (a *Router) CreatePendingInvoiceLine(w http.ResponseWriter, r *http.Request, customerId string) { |
| a.billingHandler.CreatePendingLine().With(httpdriver.CreatePendingLineParams{ |
| CustomerID: customerId, |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| func (a *Router) ListBillingProfiles(w http.ResponseWriter, r *http.Request, params api.ListBillingProfilesParams) { |
| a.billingHandler.ListProfiles().With(params).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) CreateBillingProfile(w http.ResponseWriter, r *http.Request) { |
| a.billingHandler.CreateProfile().ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) DeleteBillingProfile(w http.ResponseWriter, r *http.Request, id string) { |
| a.billingHandler.DeleteProfile().With(id).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) GetBillingProfile(w http.ResponseWriter, r *http.Request, id string, params api.GetBillingProfileParams) { |
| a.billingHandler.GetProfile().With(httpdriver.GetProfileParams{ |
| ID: id, |
| Expand: lo.FromPtr(params.Expand), |
| }).ServeHTTP(w, r) |
| } |
|
|
| |
| |
| func (a *Router) UpdateBillingProfile(w http.ResponseWriter, r *http.Request, id string) { |
| a.billingHandler.UpdateProfile().With(id).ServeHTTP(w, r) |
| } |
|
|