File size: 1,223 Bytes
04f1444
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package apps

import (
	"context"

	"github.com/openmeterio/openmeter/openmeter/app"
	appstripe "github.com/openmeterio/openmeter/openmeter/app/stripe"
	"github.com/openmeterio/openmeter/openmeter/billing"
	"github.com/openmeterio/openmeter/pkg/framework/transport/httptransport"
)

type Handler interface {
	// App handlers
	ListApps() ListAppsHandler
	GetApp() GetAppHandler

	CatalogHandler
}

type CatalogHandler interface {
	ListAppCatalog() ListAppCatalogHandler
	GetAppCatalog() GetAppCatalogHandler
	InstallApp() InstallAppHandler
}

var _ Handler = (*handler)(nil)

type handler struct {
	resolveNamespace func(ctx context.Context) (string, error)
	appService       app.Service
	billingService   billing.Service
	stripeAppService appstripe.Service
	options          []httptransport.HandlerOption
}

func New(
	resolveNamespace func(ctx context.Context) (string, error),
	appService app.Service,
	billingService billing.Service,
	stripeAppService appstripe.Service,
	options ...httptransport.HandlerOption,
) Handler {
	return &handler{
		resolveNamespace: resolveNamespace,
		appService:       appService,
		billingService:   billingService,
		stripeAppService: stripeAppService,
		options:          options,
	}
}