initial commit

This commit is contained in:
2023-03-13 00:23:59 +01:00
commit 3d61f9b542
21 changed files with 2973 additions and 0 deletions

4
grpc/proto/README.md Normal file
View File

@@ -0,0 +1,4 @@
# Build proto
protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. ./*.proto

View File

@@ -0,0 +1,681 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.19.4
// source: carpool-incentives-service.proto
package proto
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
structpb "google.golang.org/protobuf/types/known/structpb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type GetAvailableIncentivesRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Userid string `protobuf:"bytes,1,opt,name=userid,proto3" json:"userid,omitempty"`
}
func (x *GetAvailableIncentivesRequest) Reset() {
*x = GetAvailableIncentivesRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_carpool_incentives_service_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetAvailableIncentivesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetAvailableIncentivesRequest) ProtoMessage() {}
func (x *GetAvailableIncentivesRequest) ProtoReflect() protoreflect.Message {
mi := &file_carpool_incentives_service_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetAvailableIncentivesRequest.ProtoReflect.Descriptor instead.
func (*GetAvailableIncentivesRequest) Descriptor() ([]byte, []int) {
return file_carpool_incentives_service_proto_rawDescGZIP(), []int{0}
}
func (x *GetAvailableIncentivesRequest) GetUserid() string {
if x != nil {
return x.Userid
}
return ""
}
type GetAvailableIncentivesResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Incentives []*Incentive `protobuf:"bytes,2,rep,name=incentives,proto3" json:"incentives,omitempty"`
}
func (x *GetAvailableIncentivesResponse) Reset() {
*x = GetAvailableIncentivesResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_carpool_incentives_service_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetAvailableIncentivesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetAvailableIncentivesResponse) ProtoMessage() {}
func (x *GetAvailableIncentivesResponse) ProtoReflect() protoreflect.Message {
mi := &file_carpool_incentives_service_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetAvailableIncentivesResponse.ProtoReflect.Descriptor instead.
func (*GetAvailableIncentivesResponse) Descriptor() ([]byte, []int) {
return file_carpool_incentives_service_proto_rawDescGZIP(), []int{1}
}
func (x *GetAvailableIncentivesResponse) GetIncentives() []*Incentive {
if x != nil {
return x.Incentives
}
return nil
}
type GetInitiatedIncentivesRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Userid string `protobuf:"bytes,3,opt,name=userid,proto3" json:"userid,omitempty"`
}
func (x *GetInitiatedIncentivesRequest) Reset() {
*x = GetInitiatedIncentivesRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_carpool_incentives_service_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetInitiatedIncentivesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetInitiatedIncentivesRequest) ProtoMessage() {}
func (x *GetInitiatedIncentivesRequest) ProtoReflect() protoreflect.Message {
mi := &file_carpool_incentives_service_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetInitiatedIncentivesRequest.ProtoReflect.Descriptor instead.
func (*GetInitiatedIncentivesRequest) Descriptor() ([]byte, []int) {
return file_carpool_incentives_service_proto_rawDescGZIP(), []int{2}
}
func (x *GetInitiatedIncentivesRequest) GetUserid() string {
if x != nil {
return x.Userid
}
return ""
}
type GetInitiatedIncentivesResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Incentives []*Incentive `protobuf:"bytes,4,rep,name=incentives,proto3" json:"incentives,omitempty"`
}
func (x *GetInitiatedIncentivesResponse) Reset() {
*x = GetInitiatedIncentivesResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_carpool_incentives_service_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetInitiatedIncentivesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetInitiatedIncentivesResponse) ProtoMessage() {}
func (x *GetInitiatedIncentivesResponse) ProtoReflect() protoreflect.Message {
mi := &file_carpool_incentives_service_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetInitiatedIncentivesResponse.ProtoReflect.Descriptor instead.
func (*GetInitiatedIncentivesResponse) Descriptor() ([]byte, []int) {
return file_carpool_incentives_service_proto_rawDescGZIP(), []int{3}
}
func (x *GetInitiatedIncentivesResponse) GetIncentives() []*Incentive {
if x != nil {
return x.Incentives
}
return nil
}
type GetDeclinedIncentivesRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Userid string `protobuf:"bytes,3,opt,name=userid,proto3" json:"userid,omitempty"`
}
func (x *GetDeclinedIncentivesRequest) Reset() {
*x = GetDeclinedIncentivesRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_carpool_incentives_service_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetDeclinedIncentivesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetDeclinedIncentivesRequest) ProtoMessage() {}
func (x *GetDeclinedIncentivesRequest) ProtoReflect() protoreflect.Message {
mi := &file_carpool_incentives_service_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetDeclinedIncentivesRequest.ProtoReflect.Descriptor instead.
func (*GetDeclinedIncentivesRequest) Descriptor() ([]byte, []int) {
return file_carpool_incentives_service_proto_rawDescGZIP(), []int{4}
}
func (x *GetDeclinedIncentivesRequest) GetUserid() string {
if x != nil {
return x.Userid
}
return ""
}
type GetDeclinedIncentivesResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Incentives []*Incentive `protobuf:"bytes,4,rep,name=incentives,proto3" json:"incentives,omitempty"`
}
func (x *GetDeclinedIncentivesResponse) Reset() {
*x = GetDeclinedIncentivesResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_carpool_incentives_service_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetDeclinedIncentivesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetDeclinedIncentivesResponse) ProtoMessage() {}
func (x *GetDeclinedIncentivesResponse) ProtoReflect() protoreflect.Message {
mi := &file_carpool_incentives_service_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetDeclinedIncentivesResponse.ProtoReflect.Descriptor instead.
func (*GetDeclinedIncentivesResponse) Descriptor() ([]byte, []int) {
return file_carpool_incentives_service_proto_rawDescGZIP(), []int{5}
}
func (x *GetDeclinedIncentivesResponse) GetIncentives() []*Incentive {
if x != nil {
return x.Incentives
}
return nil
}
type SubscribeIncentiveRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Incentiveid string `protobuf:"bytes,5,opt,name=incentiveid,proto3" json:"incentiveid,omitempty"`
Userid string `protobuf:"bytes,6,opt,name=userid,proto3" json:"userid,omitempty"`
IdentityVerificationIds []string `protobuf:"bytes,7,rep,name=identity_verification_ids,json=identityVerificationIds,proto3" json:"identity_verification_ids,omitempty"`
Data *structpb.Struct `protobuf:"bytes,8,opt,name=data,proto3" json:"data,omitempty"`
Declined bool `protobuf:"varint,9,opt,name=declined,proto3" json:"declined,omitempty"`
}
func (x *SubscribeIncentiveRequest) Reset() {
*x = SubscribeIncentiveRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_carpool_incentives_service_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SubscribeIncentiveRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SubscribeIncentiveRequest) ProtoMessage() {}
func (x *SubscribeIncentiveRequest) ProtoReflect() protoreflect.Message {
mi := &file_carpool_incentives_service_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SubscribeIncentiveRequest.ProtoReflect.Descriptor instead.
func (*SubscribeIncentiveRequest) Descriptor() ([]byte, []int) {
return file_carpool_incentives_service_proto_rawDescGZIP(), []int{6}
}
func (x *SubscribeIncentiveRequest) GetIncentiveid() string {
if x != nil {
return x.Incentiveid
}
return ""
}
func (x *SubscribeIncentiveRequest) GetUserid() string {
if x != nil {
return x.Userid
}
return ""
}
func (x *SubscribeIncentiveRequest) GetIdentityVerificationIds() []string {
if x != nil {
return x.IdentityVerificationIds
}
return nil
}
func (x *SubscribeIncentiveRequest) GetData() *structpb.Struct {
if x != nil {
return x.Data
}
return nil
}
func (x *SubscribeIncentiveRequest) GetDeclined() bool {
if x != nil {
return x.Declined
}
return false
}
type SubscribeIncentiveResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Subscriptionid string `protobuf:"bytes,10,opt,name=subscriptionid,proto3" json:"subscriptionid,omitempty"`
}
func (x *SubscribeIncentiveResponse) Reset() {
*x = SubscribeIncentiveResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_carpool_incentives_service_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SubscribeIncentiveResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SubscribeIncentiveResponse) ProtoMessage() {}
func (x *SubscribeIncentiveResponse) ProtoReflect() protoreflect.Message {
mi := &file_carpool_incentives_service_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SubscribeIncentiveResponse.ProtoReflect.Descriptor instead.
func (*SubscribeIncentiveResponse) Descriptor() ([]byte, []int) {
return file_carpool_incentives_service_proto_rawDescGZIP(), []int{7}
}
func (x *SubscribeIncentiveResponse) GetSubscriptionid() string {
if x != nil {
return x.Subscriptionid
}
return ""
}
var File_carpool_incentives_service_proto protoreflect.FileDescriptor
var file_carpool_incentives_service_proto_rawDesc = []byte{
0x0a, 0x20, 0x63, 0x61, 0x72, 0x70, 0x6f, 0x6f, 0x6c, 0x2d, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74,
0x69, 0x76, 0x65, 0x73, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x1a, 0x10, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x22, 0x37, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62,
0x6c, 0x65, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x69, 0x64, 0x22, 0x4c, 0x0a, 0x1e, 0x47,
0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x49, 0x6e, 0x63, 0x65, 0x6e,
0x74, 0x69, 0x76, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a,
0x0a, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x0a, 0x2e, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x52, 0x0a, 0x69,
0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x22, 0x37, 0x0a, 0x1d, 0x47, 0x65, 0x74,
0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x74, 0x65, 0x64, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69,
0x76, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73,
0x65, 0x72, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72,
0x69, 0x64, 0x22, 0x4c, 0x0a, 0x1e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x74,
0x65, 0x64, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x0a, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76,
0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x49, 0x6e, 0x63, 0x65, 0x6e,
0x74, 0x69, 0x76, 0x65, 0x52, 0x0a, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73,
0x22, 0x36, 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x44, 0x65, 0x63, 0x6c, 0x69, 0x6e, 0x65, 0x64, 0x49,
0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x69, 0x64, 0x22, 0x4b, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x44,
0x65, 0x63, 0x6c, 0x69, 0x6e, 0x65, 0x64, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65,
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x0a, 0x69, 0x6e, 0x63,
0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e,
0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x52, 0x0a, 0x69, 0x6e, 0x63, 0x65, 0x6e,
0x74, 0x69, 0x76, 0x65, 0x73, 0x22, 0xda, 0x01, 0x0a, 0x19, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x62, 0x65, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65,
0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74,
0x69, 0x76, 0x65, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x69, 0x64, 0x18,
0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x69, 0x64, 0x12, 0x3a, 0x0a,
0x19, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69,
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09,
0x52, 0x17, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69,
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74,
0x61, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74,
0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x65, 0x63, 0x6c, 0x69, 0x6e,
0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x64, 0x65, 0x63, 0x6c, 0x69, 0x6e,
0x65, 0x64, 0x22, 0x44, 0x0a, 0x1a, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x49,
0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x26, 0x0a, 0x0e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x69, 0x64, 0x32, 0xf8, 0x02, 0x0a, 0x11, 0x43, 0x61, 0x72,
0x70, 0x6f, 0x6f, 0x6c, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x12, 0x5b,
0x0a, 0x16, 0x47, 0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x49, 0x6e,
0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x12, 0x1e, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x76,
0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65,
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x76,
0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65,
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5b, 0x0a, 0x16, 0x47,
0x65, 0x74, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x74, 0x65, 0x64, 0x49, 0x6e, 0x63, 0x65, 0x6e,
0x74, 0x69, 0x76, 0x65, 0x73, 0x12, 0x1e, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x69, 0x74, 0x69,
0x61, 0x74, 0x65, 0x64, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x69, 0x74, 0x69,
0x61, 0x74, 0x65, 0x64, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x44,
0x65, 0x63, 0x6c, 0x69, 0x6e, 0x65, 0x64, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65,
0x73, 0x12, 0x1d, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x65, 0x63, 0x6c, 0x69, 0x6e, 0x65, 0x64, 0x49,
0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x1e, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x65, 0x63, 0x6c, 0x69, 0x6e, 0x65, 0x64, 0x49, 0x6e,
0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x4f, 0x0a, 0x12, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x49,
0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x12, 0x1a, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63,
0x72, 0x69, 0x62, 0x65, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65,
0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67,
0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61, 0x74,
0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x63, 0x61, 0x72, 0x70, 0x6f, 0x6f, 0x6c, 0x2d, 0x69, 0x6e, 0x63,
0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_carpool_incentives_service_proto_rawDescOnce sync.Once
file_carpool_incentives_service_proto_rawDescData = file_carpool_incentives_service_proto_rawDesc
)
func file_carpool_incentives_service_proto_rawDescGZIP() []byte {
file_carpool_incentives_service_proto_rawDescOnce.Do(func() {
file_carpool_incentives_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_carpool_incentives_service_proto_rawDescData)
})
return file_carpool_incentives_service_proto_rawDescData
}
var file_carpool_incentives_service_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_carpool_incentives_service_proto_goTypes = []interface{}{
(*GetAvailableIncentivesRequest)(nil), // 0: GetAvailableIncentivesRequest
(*GetAvailableIncentivesResponse)(nil), // 1: GetAvailableIncentivesResponse
(*GetInitiatedIncentivesRequest)(nil), // 2: GetInitiatedIncentivesRequest
(*GetInitiatedIncentivesResponse)(nil), // 3: GetInitiatedIncentivesResponse
(*GetDeclinedIncentivesRequest)(nil), // 4: GetDeclinedIncentivesRequest
(*GetDeclinedIncentivesResponse)(nil), // 5: GetDeclinedIncentivesResponse
(*SubscribeIncentiveRequest)(nil), // 6: SubscribeIncentiveRequest
(*SubscribeIncentiveResponse)(nil), // 7: SubscribeIncentiveResponse
(*Incentive)(nil), // 8: Incentive
(*structpb.Struct)(nil), // 9: google.protobuf.Struct
}
var file_carpool_incentives_service_proto_depIdxs = []int32{
8, // 0: GetAvailableIncentivesResponse.incentives:type_name -> Incentive
8, // 1: GetInitiatedIncentivesResponse.incentives:type_name -> Incentive
8, // 2: GetDeclinedIncentivesResponse.incentives:type_name -> Incentive
9, // 3: SubscribeIncentiveRequest.data:type_name -> google.protobuf.Struct
0, // 4: CarpoolIncentives.GetAvailableIncentives:input_type -> GetAvailableIncentivesRequest
2, // 5: CarpoolIncentives.GetInitiatedIncentives:input_type -> GetInitiatedIncentivesRequest
4, // 6: CarpoolIncentives.GetDeclinedIncentives:input_type -> GetDeclinedIncentivesRequest
6, // 7: CarpoolIncentives.SubscribeIncentive:input_type -> SubscribeIncentiveRequest
1, // 8: CarpoolIncentives.GetAvailableIncentives:output_type -> GetAvailableIncentivesResponse
3, // 9: CarpoolIncentives.GetInitiatedIncentives:output_type -> GetInitiatedIncentivesResponse
5, // 10: CarpoolIncentives.GetDeclinedIncentives:output_type -> GetDeclinedIncentivesResponse
7, // 11: CarpoolIncentives.SubscribeIncentive:output_type -> SubscribeIncentiveResponse
8, // [8:12] is the sub-list for method output_type
4, // [4:8] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_carpool_incentives_service_proto_init() }
func file_carpool_incentives_service_proto_init() {
if File_carpool_incentives_service_proto != nil {
return
}
file_incentives_proto_init()
if !protoimpl.UnsafeEnabled {
file_carpool_incentives_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetAvailableIncentivesRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_carpool_incentives_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetAvailableIncentivesResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_carpool_incentives_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetInitiatedIncentivesRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_carpool_incentives_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetInitiatedIncentivesResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_carpool_incentives_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetDeclinedIncentivesRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_carpool_incentives_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetDeclinedIncentivesResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_carpool_incentives_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SubscribeIncentiveRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_carpool_incentives_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SubscribeIncentiveResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_carpool_incentives_service_proto_rawDesc,
NumEnums: 0,
NumMessages: 8,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_carpool_incentives_service_proto_goTypes,
DependencyIndexes: file_carpool_incentives_service_proto_depIdxs,
MessageInfos: file_carpool_incentives_service_proto_msgTypes,
}.Build()
File_carpool_incentives_service_proto = out.File
file_carpool_incentives_service_proto_rawDesc = nil
file_carpool_incentives_service_proto_goTypes = nil
file_carpool_incentives_service_proto_depIdxs = nil
}

View File

@@ -0,0 +1,51 @@
syntax = "proto3";
option go_package = "git.coopgo.io/coopgo-platform/carpool-incentives/grpc/proto";
import "google/protobuf/struct.proto";
import "incentives.proto";
service CarpoolIncentives {
// rpc XXXX(Request) returns (Response) {}
rpc GetAvailableIncentives(GetAvailableIncentivesRequest) returns (GetAvailableIncentivesResponse) {}
rpc GetInitiatedIncentives(GetInitiatedIncentivesRequest) returns (GetInitiatedIncentivesResponse) {}
rpc GetDeclinedIncentives(GetDeclinedIncentivesRequest) returns (GetDeclinedIncentivesResponse) {}
rpc SubscribeIncentive(SubscribeIncentiveRequest) returns (SubscribeIncentiveResponse) {}
}
message GetAvailableIncentivesRequest {
string userid = 1;
}
message GetAvailableIncentivesResponse {
repeated Incentive incentives = 2;
}
message GetInitiatedIncentivesRequest {
string userid = 3;
}
message GetInitiatedIncentivesResponse {
repeated Incentive incentives = 4;
}
message GetDeclinedIncentivesRequest {
string userid = 3;
}
message GetDeclinedIncentivesResponse {
repeated Incentive incentives = 4;
}
message SubscribeIncentiveRequest {
string incentiveid = 5;
string userid = 6;
repeated string identity_verification_ids = 7;
google.protobuf.Struct data = 8;
bool declined = 9;
}
message SubscribeIncentiveResponse {
string subscriptionid = 10;
}

View File

@@ -0,0 +1,215 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.19.4
// source: carpool-incentives-service.proto
package proto
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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// CarpoolIncentivesClient is the client API for CarpoolIncentives 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 CarpoolIncentivesClient interface {
// rpc XXXX(Request) returns (Response) {}
GetAvailableIncentives(ctx context.Context, in *GetAvailableIncentivesRequest, opts ...grpc.CallOption) (*GetAvailableIncentivesResponse, error)
GetInitiatedIncentives(ctx context.Context, in *GetInitiatedIncentivesRequest, opts ...grpc.CallOption) (*GetInitiatedIncentivesResponse, error)
GetDeclinedIncentives(ctx context.Context, in *GetDeclinedIncentivesRequest, opts ...grpc.CallOption) (*GetDeclinedIncentivesResponse, error)
SubscribeIncentive(ctx context.Context, in *SubscribeIncentiveRequest, opts ...grpc.CallOption) (*SubscribeIncentiveResponse, error)
}
type carpoolIncentivesClient struct {
cc grpc.ClientConnInterface
}
func NewCarpoolIncentivesClient(cc grpc.ClientConnInterface) CarpoolIncentivesClient {
return &carpoolIncentivesClient{cc}
}
func (c *carpoolIncentivesClient) GetAvailableIncentives(ctx context.Context, in *GetAvailableIncentivesRequest, opts ...grpc.CallOption) (*GetAvailableIncentivesResponse, error) {
out := new(GetAvailableIncentivesResponse)
err := c.cc.Invoke(ctx, "/CarpoolIncentives/GetAvailableIncentives", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *carpoolIncentivesClient) GetInitiatedIncentives(ctx context.Context, in *GetInitiatedIncentivesRequest, opts ...grpc.CallOption) (*GetInitiatedIncentivesResponse, error) {
out := new(GetInitiatedIncentivesResponse)
err := c.cc.Invoke(ctx, "/CarpoolIncentives/GetInitiatedIncentives", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *carpoolIncentivesClient) GetDeclinedIncentives(ctx context.Context, in *GetDeclinedIncentivesRequest, opts ...grpc.CallOption) (*GetDeclinedIncentivesResponse, error) {
out := new(GetDeclinedIncentivesResponse)
err := c.cc.Invoke(ctx, "/CarpoolIncentives/GetDeclinedIncentives", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *carpoolIncentivesClient) SubscribeIncentive(ctx context.Context, in *SubscribeIncentiveRequest, opts ...grpc.CallOption) (*SubscribeIncentiveResponse, error) {
out := new(SubscribeIncentiveResponse)
err := c.cc.Invoke(ctx, "/CarpoolIncentives/SubscribeIncentive", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// CarpoolIncentivesServer is the server API for CarpoolIncentives service.
// All implementations must embed UnimplementedCarpoolIncentivesServer
// for forward compatibility
type CarpoolIncentivesServer interface {
// rpc XXXX(Request) returns (Response) {}
GetAvailableIncentives(context.Context, *GetAvailableIncentivesRequest) (*GetAvailableIncentivesResponse, error)
GetInitiatedIncentives(context.Context, *GetInitiatedIncentivesRequest) (*GetInitiatedIncentivesResponse, error)
GetDeclinedIncentives(context.Context, *GetDeclinedIncentivesRequest) (*GetDeclinedIncentivesResponse, error)
SubscribeIncentive(context.Context, *SubscribeIncentiveRequest) (*SubscribeIncentiveResponse, error)
mustEmbedUnimplementedCarpoolIncentivesServer()
}
// UnimplementedCarpoolIncentivesServer must be embedded to have forward compatible implementations.
type UnimplementedCarpoolIncentivesServer struct {
}
func (UnimplementedCarpoolIncentivesServer) GetAvailableIncentives(context.Context, *GetAvailableIncentivesRequest) (*GetAvailableIncentivesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetAvailableIncentives not implemented")
}
func (UnimplementedCarpoolIncentivesServer) GetInitiatedIncentives(context.Context, *GetInitiatedIncentivesRequest) (*GetInitiatedIncentivesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetInitiatedIncentives not implemented")
}
func (UnimplementedCarpoolIncentivesServer) GetDeclinedIncentives(context.Context, *GetDeclinedIncentivesRequest) (*GetDeclinedIncentivesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetDeclinedIncentives not implemented")
}
func (UnimplementedCarpoolIncentivesServer) SubscribeIncentive(context.Context, *SubscribeIncentiveRequest) (*SubscribeIncentiveResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SubscribeIncentive not implemented")
}
func (UnimplementedCarpoolIncentivesServer) mustEmbedUnimplementedCarpoolIncentivesServer() {}
// UnsafeCarpoolIncentivesServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to CarpoolIncentivesServer will
// result in compilation errors.
type UnsafeCarpoolIncentivesServer interface {
mustEmbedUnimplementedCarpoolIncentivesServer()
}
func RegisterCarpoolIncentivesServer(s grpc.ServiceRegistrar, srv CarpoolIncentivesServer) {
s.RegisterService(&CarpoolIncentives_ServiceDesc, srv)
}
func _CarpoolIncentives_GetAvailableIncentives_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetAvailableIncentivesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CarpoolIncentivesServer).GetAvailableIncentives(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CarpoolIncentives/GetAvailableIncentives",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CarpoolIncentivesServer).GetAvailableIncentives(ctx, req.(*GetAvailableIncentivesRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CarpoolIncentives_GetInitiatedIncentives_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetInitiatedIncentivesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CarpoolIncentivesServer).GetInitiatedIncentives(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CarpoolIncentives/GetInitiatedIncentives",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CarpoolIncentivesServer).GetInitiatedIncentives(ctx, req.(*GetInitiatedIncentivesRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CarpoolIncentives_GetDeclinedIncentives_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetDeclinedIncentivesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CarpoolIncentivesServer).GetDeclinedIncentives(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CarpoolIncentives/GetDeclinedIncentives",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CarpoolIncentivesServer).GetDeclinedIncentives(ctx, req.(*GetDeclinedIncentivesRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CarpoolIncentives_SubscribeIncentive_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SubscribeIncentiveRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CarpoolIncentivesServer).SubscribeIncentive(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CarpoolIncentives/SubscribeIncentive",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CarpoolIncentivesServer).SubscribeIncentive(ctx, req.(*SubscribeIncentiveRequest))
}
return interceptor(ctx, in, info, handler)
}
// CarpoolIncentives_ServiceDesc is the grpc.ServiceDesc for CarpoolIncentives service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var CarpoolIncentives_ServiceDesc = grpc.ServiceDesc{
ServiceName: "CarpoolIncentives",
HandlerType: (*CarpoolIncentivesServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetAvailableIncentives",
Handler: _CarpoolIncentives_GetAvailableIncentives_Handler,
},
{
MethodName: "GetInitiatedIncentives",
Handler: _CarpoolIncentives_GetInitiatedIncentives_Handler,
},
{
MethodName: "GetDeclinedIncentives",
Handler: _CarpoolIncentives_GetDeclinedIncentives_Handler,
},
{
MethodName: "SubscribeIncentive",
Handler: _CarpoolIncentives_SubscribeIncentive_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "carpool-incentives-service.proto",
}

261
grpc/proto/incentives.pb.go Normal file
View File

@@ -0,0 +1,261 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.19.4
// source: incentives.proto
package proto
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
structpb "google.golang.org/protobuf/types/known/structpb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Incentive struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
}
func (x *Incentive) Reset() {
*x = Incentive{}
if protoimpl.UnsafeEnabled {
mi := &file_incentives_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Incentive) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Incentive) ProtoMessage() {}
func (x *Incentive) ProtoReflect() protoreflect.Message {
mi := &file_incentives_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Incentive.ProtoReflect.Descriptor instead.
func (*Incentive) Descriptor() ([]byte, []int) {
return file_incentives_proto_rawDescGZIP(), []int{0}
}
func (x *Incentive) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Incentive) GetName() string {
if x != nil {
return x.Name
}
return ""
}
type IncentiveSubscription struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,10,opt,name=id,proto3" json:"id,omitempty"`
Userid string `protobuf:"bytes,11,opt,name=userid,proto3" json:"userid,omitempty"`
Incentiveid string `protobuf:"bytes,12,opt,name=incentiveid,proto3" json:"incentiveid,omitempty"`
Data *structpb.Struct `protobuf:"bytes,13,opt,name=data,proto3" json:"data,omitempty"`
Declined bool `protobuf:"varint,14,opt,name=declined,proto3" json:"declined,omitempty"`
}
func (x *IncentiveSubscription) Reset() {
*x = IncentiveSubscription{}
if protoimpl.UnsafeEnabled {
mi := &file_incentives_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *IncentiveSubscription) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*IncentiveSubscription) ProtoMessage() {}
func (x *IncentiveSubscription) ProtoReflect() protoreflect.Message {
mi := &file_incentives_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use IncentiveSubscription.ProtoReflect.Descriptor instead.
func (*IncentiveSubscription) Descriptor() ([]byte, []int) {
return file_incentives_proto_rawDescGZIP(), []int{1}
}
func (x *IncentiveSubscription) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *IncentiveSubscription) GetUserid() string {
if x != nil {
return x.Userid
}
return ""
}
func (x *IncentiveSubscription) GetIncentiveid() string {
if x != nil {
return x.Incentiveid
}
return ""
}
func (x *IncentiveSubscription) GetData() *structpb.Struct {
if x != nil {
return x.Data
}
return nil
}
func (x *IncentiveSubscription) GetDeclined() bool {
if x != nil {
return x.Declined
}
return false
}
var File_incentives_proto protoreflect.FileDescriptor
var file_incentives_proto_rawDesc = []byte{
0x0a, 0x10, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x22, 0x2f, 0x0a, 0x09, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x22, 0xaa, 0x01, 0x0a, 0x15, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x53,
0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69,
0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75,
0x73, 0x65, 0x72, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65,
0x72, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65,
0x69, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74,
0x69, 0x76, 0x65, 0x69, 0x64, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0d, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x64, 0x61,
0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x65, 0x63, 0x6c, 0x69, 0x6e, 0x65, 0x64, 0x18, 0x0e,
0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x64, 0x65, 0x63, 0x6c, 0x69, 0x6e, 0x65, 0x64, 0x42, 0x3d,
0x5a, 0x3b, 0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f,
0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f,
0x63, 0x61, 0x72, 0x70, 0x6f, 0x6f, 0x6c, 0x2d, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76,
0x65, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_incentives_proto_rawDescOnce sync.Once
file_incentives_proto_rawDescData = file_incentives_proto_rawDesc
)
func file_incentives_proto_rawDescGZIP() []byte {
file_incentives_proto_rawDescOnce.Do(func() {
file_incentives_proto_rawDescData = protoimpl.X.CompressGZIP(file_incentives_proto_rawDescData)
})
return file_incentives_proto_rawDescData
}
var file_incentives_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_incentives_proto_goTypes = []interface{}{
(*Incentive)(nil), // 0: Incentive
(*IncentiveSubscription)(nil), // 1: IncentiveSubscription
(*structpb.Struct)(nil), // 2: google.protobuf.Struct
}
var file_incentives_proto_depIdxs = []int32{
2, // 0: IncentiveSubscription.data:type_name -> google.protobuf.Struct
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_incentives_proto_init() }
func file_incentives_proto_init() {
if File_incentives_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_incentives_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Incentive); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_incentives_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*IncentiveSubscription); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_incentives_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_incentives_proto_goTypes,
DependencyIndexes: file_incentives_proto_depIdxs,
MessageInfos: file_incentives_proto_msgTypes,
}.Build()
File_incentives_proto = out.File
file_incentives_proto_rawDesc = nil
file_incentives_proto_goTypes = nil
file_incentives_proto_depIdxs = nil
}

View File

@@ -0,0 +1,18 @@
syntax = "proto3";
option go_package = "git.coopgo.io/coopgo-platform/carpool-incentives/grpc/proto";
import "google/protobuf/struct.proto";
message Incentive{
string id = 1;
string name = 2;
}
message IncentiveSubscription {
string id = 10;
string userid = 11;
string incentiveid = 12;
google.protobuf.Struct data = 13;
bool declined = 14;
}

13
grpc/server/incentives.go Normal file
View File

@@ -0,0 +1,13 @@
package grpcserver
import (
"git.coopgo.io/coopgo-platform/carpool-incentives/grpc/proto"
"git.coopgo.io/coopgo-platform/carpool-incentives/storage"
)
func IncentiveFromStorage(incentive storage.Incentive) proto.Incentive {
return proto.Incentive{
Id: incentive.ID,
Name: incentive.Name,
}
}

98
grpc/server/server.go Normal file
View File

@@ -0,0 +1,98 @@
package grpcserver
import (
"context"
"fmt"
"log"
"net"
"git.coopgo.io/coopgo-platform/carpool-incentives/grpc/proto"
"git.coopgo.io/coopgo-platform/carpool-incentives/handlers/incentives"
"github.com/spf13/viper"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/reflection"
"google.golang.org/grpc/status"
)
type CarpoolIncentivesServerImpl struct {
IncentivesHandler *incentives.IncentivesHandler
proto.UnimplementedCarpoolIncentivesServer
}
func NewCarpoolIncentivesServer(incentivesHandler *incentives.IncentivesHandler) *CarpoolIncentivesServerImpl {
return &CarpoolIncentivesServerImpl{
IncentivesHandler: incentivesHandler,
}
}
func (s CarpoolIncentivesServerImpl) GetAvailableIncentives(ctx context.Context, req *proto.GetAvailableIncentivesRequest) (*proto.GetAvailableIncentivesResponse, error) {
results := []*proto.Incentive{}
incentives, err := s.IncentivesHandler.GetAvailableIncentives(req.Userid)
if err != nil {
return nil, status.Errorf(codes.Internal, "error in GetAvailableIncentives : ", err)
}
for _, i := range incentives {
incentive := IncentiveFromStorage(i)
results = append(results, &incentive)
}
return &proto.GetAvailableIncentivesResponse{
Incentives: results,
}, nil
}
func (s CarpoolIncentivesServerImpl) GetInitiatedIncentives(ctx context.Context, req *proto.GetInitiatedIncentivesRequest) (*proto.GetInitiatedIncentivesResponse, error) {
results := []*proto.Incentive{}
incentives, err := s.IncentivesHandler.GetInitiatedIncentives(req.Userid)
if err != nil {
return nil, status.Errorf(codes.Internal, "error in GetInitiatedIncentives : ", err)
}
for _, i := range incentives {
incentive := IncentiveFromStorage(i)
results = append(results, &incentive)
}
return &proto.GetInitiatedIncentivesResponse{
Incentives: results,
}, nil
}
func (s CarpoolIncentivesServerImpl) SubscribeIncentive(ctx context.Context, req *proto.SubscribeIncentiveRequest) (*proto.SubscribeIncentiveResponse, error) {
data := req.Data.AsMap()
res, err := s.IncentivesHandler.SubscribeIncentive(req.Incentiveid, req.Userid, req.IdentityVerificationIds, data, req.Declined)
if err != nil {
return nil, err
}
return &proto.SubscribeIncentiveResponse{
Subscriptionid: res.ID,
}, nil
}
func Run(done chan error, cfg *viper.Viper, incentivesHandler *incentives.IncentivesHandler) {
var (
dev_env = cfg.GetBool("dev_env")
address = ":" + cfg.GetString("services.grpc.port")
)
//fmt.Println("-> GRPC server on", address)
server := grpc.NewServer()
proto.RegisterCarpoolIncentivesServer(server, NewCarpoolIncentivesServer(incentivesHandler))
l, err := net.Listen("tcp", address)
if err != nil {
log.Fatal(err)
}
if dev_env {
reflection.Register(server)
}
if err := server.Serve(l); err != nil {
fmt.Println("gRPC service ended")
done <- err
}
}