- Introduced a new test file for setting up an in-memory SQLite database for testing purposes. - Added helper functions for seeding test data, including users, plans, subscriptions, and wallet transactions. - Implemented usage helpers to load user video counts and storage usage. - Created user payload struct and functions to build user payloads with preferences and wallet balance. - Refactored gRPC server setup to include new services and handlers. - Updated proto files to simplify service definitions by removing redundant service prefixes.
236 lines
9.2 KiB
Go
236 lines
9.2 KiB
Go
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
// versions:
|
|
// - protoc-gen-go-grpc v1.6.1
|
|
// - protoc (unknown)
|
|
// source: app/v1/payments.proto
|
|
|
|
package appv1
|
|
|
|
import (
|
|
context "context"
|
|
grpc "google.golang.org/grpc"
|
|
codes "google.golang.org/grpc/codes"
|
|
status "google.golang.org/grpc/status"
|
|
)
|
|
|
|
// This is a compile-time assertion to ensure that this generated file
|
|
// is compatible with the grpc package it is being compiled against.
|
|
// Requires gRPC-Go v1.64.0 or later.
|
|
const _ = grpc.SupportPackageIsVersion9
|
|
|
|
const (
|
|
Payments_CreatePayment_FullMethodName = "/stream.app.v1.Payments/CreatePayment"
|
|
Payments_ListPaymentHistory_FullMethodName = "/stream.app.v1.Payments/ListPaymentHistory"
|
|
Payments_TopupWallet_FullMethodName = "/stream.app.v1.Payments/TopupWallet"
|
|
Payments_DownloadInvoice_FullMethodName = "/stream.app.v1.Payments/DownloadInvoice"
|
|
)
|
|
|
|
// PaymentsClient is the client API for Payments service.
|
|
//
|
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
type PaymentsClient interface {
|
|
CreatePayment(ctx context.Context, in *CreatePaymentRequest, opts ...grpc.CallOption) (*CreatePaymentResponse, error)
|
|
ListPaymentHistory(ctx context.Context, in *ListPaymentHistoryRequest, opts ...grpc.CallOption) (*ListPaymentHistoryResponse, error)
|
|
TopupWallet(ctx context.Context, in *TopupWalletRequest, opts ...grpc.CallOption) (*TopupWalletResponse, error)
|
|
DownloadInvoice(ctx context.Context, in *DownloadInvoiceRequest, opts ...grpc.CallOption) (*DownloadInvoiceResponse, error)
|
|
}
|
|
|
|
type paymentsClient struct {
|
|
cc grpc.ClientConnInterface
|
|
}
|
|
|
|
func NewPaymentsClient(cc grpc.ClientConnInterface) PaymentsClient {
|
|
return &paymentsClient{cc}
|
|
}
|
|
|
|
func (c *paymentsClient) CreatePayment(ctx context.Context, in *CreatePaymentRequest, opts ...grpc.CallOption) (*CreatePaymentResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(CreatePaymentResponse)
|
|
err := c.cc.Invoke(ctx, Payments_CreatePayment_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *paymentsClient) ListPaymentHistory(ctx context.Context, in *ListPaymentHistoryRequest, opts ...grpc.CallOption) (*ListPaymentHistoryResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(ListPaymentHistoryResponse)
|
|
err := c.cc.Invoke(ctx, Payments_ListPaymentHistory_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *paymentsClient) TopupWallet(ctx context.Context, in *TopupWalletRequest, opts ...grpc.CallOption) (*TopupWalletResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(TopupWalletResponse)
|
|
err := c.cc.Invoke(ctx, Payments_TopupWallet_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *paymentsClient) DownloadInvoice(ctx context.Context, in *DownloadInvoiceRequest, opts ...grpc.CallOption) (*DownloadInvoiceResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(DownloadInvoiceResponse)
|
|
err := c.cc.Invoke(ctx, Payments_DownloadInvoice_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
// PaymentsServer is the server API for Payments service.
|
|
// All implementations must embed UnimplementedPaymentsServer
|
|
// for forward compatibility.
|
|
type PaymentsServer interface {
|
|
CreatePayment(context.Context, *CreatePaymentRequest) (*CreatePaymentResponse, error)
|
|
ListPaymentHistory(context.Context, *ListPaymentHistoryRequest) (*ListPaymentHistoryResponse, error)
|
|
TopupWallet(context.Context, *TopupWalletRequest) (*TopupWalletResponse, error)
|
|
DownloadInvoice(context.Context, *DownloadInvoiceRequest) (*DownloadInvoiceResponse, error)
|
|
mustEmbedUnimplementedPaymentsServer()
|
|
}
|
|
|
|
// UnimplementedPaymentsServer must be embedded to have
|
|
// forward compatible implementations.
|
|
//
|
|
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
// pointer dereference when methods are called.
|
|
type UnimplementedPaymentsServer struct{}
|
|
|
|
func (UnimplementedPaymentsServer) CreatePayment(context.Context, *CreatePaymentRequest) (*CreatePaymentResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method CreatePayment not implemented")
|
|
}
|
|
func (UnimplementedPaymentsServer) ListPaymentHistory(context.Context, *ListPaymentHistoryRequest) (*ListPaymentHistoryResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method ListPaymentHistory not implemented")
|
|
}
|
|
func (UnimplementedPaymentsServer) TopupWallet(context.Context, *TopupWalletRequest) (*TopupWalletResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method TopupWallet not implemented")
|
|
}
|
|
func (UnimplementedPaymentsServer) DownloadInvoice(context.Context, *DownloadInvoiceRequest) (*DownloadInvoiceResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method DownloadInvoice not implemented")
|
|
}
|
|
func (UnimplementedPaymentsServer) mustEmbedUnimplementedPaymentsServer() {}
|
|
func (UnimplementedPaymentsServer) testEmbeddedByValue() {}
|
|
|
|
// UnsafePaymentsServer may be embedded to opt out of forward compatibility for this service.
|
|
// Use of this interface is not recommended, as added methods to PaymentsServer will
|
|
// result in compilation errors.
|
|
type UnsafePaymentsServer interface {
|
|
mustEmbedUnimplementedPaymentsServer()
|
|
}
|
|
|
|
func RegisterPaymentsServer(s grpc.ServiceRegistrar, srv PaymentsServer) {
|
|
// If the following call panics, it indicates UnimplementedPaymentsServer was
|
|
// embedded by pointer and is nil. This will cause panics if an
|
|
// unimplemented method is ever invoked, so we test this at initialization
|
|
// time to prevent it from happening at runtime later due to I/O.
|
|
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
t.testEmbeddedByValue()
|
|
}
|
|
s.RegisterService(&Payments_ServiceDesc, srv)
|
|
}
|
|
|
|
func _Payments_CreatePayment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(CreatePaymentRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(PaymentsServer).CreatePayment(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Payments_CreatePayment_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(PaymentsServer).CreatePayment(ctx, req.(*CreatePaymentRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Payments_ListPaymentHistory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(ListPaymentHistoryRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(PaymentsServer).ListPaymentHistory(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Payments_ListPaymentHistory_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(PaymentsServer).ListPaymentHistory(ctx, req.(*ListPaymentHistoryRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Payments_TopupWallet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(TopupWalletRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(PaymentsServer).TopupWallet(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Payments_TopupWallet_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(PaymentsServer).TopupWallet(ctx, req.(*TopupWalletRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Payments_DownloadInvoice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(DownloadInvoiceRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(PaymentsServer).DownloadInvoice(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Payments_DownloadInvoice_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(PaymentsServer).DownloadInvoice(ctx, req.(*DownloadInvoiceRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
// Payments_ServiceDesc is the grpc.ServiceDesc for Payments service.
|
|
// It's only intended for direct use with grpc.RegisterService,
|
|
// and not to be introspected or modified (even as a copy)
|
|
var Payments_ServiceDesc = grpc.ServiceDesc{
|
|
ServiceName: "stream.app.v1.Payments",
|
|
HandlerType: (*PaymentsServer)(nil),
|
|
Methods: []grpc.MethodDesc{
|
|
{
|
|
MethodName: "CreatePayment",
|
|
Handler: _Payments_CreatePayment_Handler,
|
|
},
|
|
{
|
|
MethodName: "ListPaymentHistory",
|
|
Handler: _Payments_ListPaymentHistory_Handler,
|
|
},
|
|
{
|
|
MethodName: "TopupWallet",
|
|
Handler: _Payments_TopupWallet_Handler,
|
|
},
|
|
{
|
|
MethodName: "DownloadInvoice",
|
|
Handler: _Payments_DownloadInvoice_Handler,
|
|
},
|
|
},
|
|
Streams: []grpc.StreamDesc{},
|
|
Metadata: "app/v1/payments.proto",
|
|
}
|