simpler rules
This commit is contained in:
@@ -92,10 +92,10 @@ type CartGrain struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Voucher struct {
|
type Voucher struct {
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Rules []*messages.VoucherRule `json:"rules"`
|
Rules []string `json:"rules"`
|
||||||
Id uint32 `json:"id"`
|
Id uint32 `json:"id"`
|
||||||
Value int64 `json:"value"`
|
Value int64 `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Voucher) AppliesTo(cart *CartGrain) ([]*CartItem, bool) {
|
func (v *Voucher) AppliesTo(cart *CartGrain) ([]*CartItem, bool) {
|
||||||
@@ -127,8 +127,8 @@ func (v *Voucher) AppliesTo(cart *CartGrain) ([]*CartItem, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All voucher rules must pass (logical AND)
|
// All voucher rules must pass (logical AND)
|
||||||
for _, rule := range v.Rules {
|
for _, expr := range v.Rules {
|
||||||
expr := rule.GetCondition()
|
|
||||||
if expr == "" {
|
if expr == "" {
|
||||||
// Empty condition treated as pass (acts like a comment / placeholder)
|
// Empty condition treated as pass (acts like a comment / placeholder)
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -926,86 +926,18 @@ func (x *InitializeCheckout) GetPaymentInProgress() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
type VoucherRule struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
|
|
||||||
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
|
|
||||||
Condition string `protobuf:"bytes,4,opt,name=condition,proto3" json:"condition,omitempty"`
|
|
||||||
Action string `protobuf:"bytes,5,opt,name=action,proto3" json:"action,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *VoucherRule) Reset() {
|
|
||||||
*x = VoucherRule{}
|
|
||||||
mi := &file_messages_proto_msgTypes[12]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *VoucherRule) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*VoucherRule) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *VoucherRule) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_messages_proto_msgTypes[12]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use VoucherRule.ProtoReflect.Descriptor instead.
|
|
||||||
func (*VoucherRule) Descriptor() ([]byte, []int) {
|
|
||||||
return file_messages_proto_rawDescGZIP(), []int{12}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *VoucherRule) GetType() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Type
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *VoucherRule) GetDescription() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Description
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *VoucherRule) GetCondition() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Condition
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *VoucherRule) GetAction() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Action
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type AddVoucher struct {
|
type AddVoucher struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
|
Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
|
||||||
Value int64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
|
Value int64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
VoucherRules []*VoucherRule `protobuf:"bytes,3,rep,name=voucherRules,proto3" json:"voucherRules,omitempty"`
|
VoucherRules []string `protobuf:"bytes,3,rep,name=voucherRules,proto3" json:"voucherRules,omitempty"`
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AddVoucher) Reset() {
|
func (x *AddVoucher) Reset() {
|
||||||
*x = AddVoucher{}
|
*x = AddVoucher{}
|
||||||
mi := &file_messages_proto_msgTypes[13]
|
mi := &file_messages_proto_msgTypes[12]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -1017,7 +949,7 @@ func (x *AddVoucher) String() string {
|
|||||||
func (*AddVoucher) ProtoMessage() {}
|
func (*AddVoucher) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *AddVoucher) ProtoReflect() protoreflect.Message {
|
func (x *AddVoucher) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_messages_proto_msgTypes[13]
|
mi := &file_messages_proto_msgTypes[12]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -1030,7 +962,7 @@ func (x *AddVoucher) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use AddVoucher.ProtoReflect.Descriptor instead.
|
// Deprecated: Use AddVoucher.ProtoReflect.Descriptor instead.
|
||||||
func (*AddVoucher) Descriptor() ([]byte, []int) {
|
func (*AddVoucher) Descriptor() ([]byte, []int) {
|
||||||
return file_messages_proto_rawDescGZIP(), []int{13}
|
return file_messages_proto_rawDescGZIP(), []int{12}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AddVoucher) GetCode() string {
|
func (x *AddVoucher) GetCode() string {
|
||||||
@@ -1047,7 +979,7 @@ func (x *AddVoucher) GetValue() int64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AddVoucher) GetVoucherRules() []*VoucherRule {
|
func (x *AddVoucher) GetVoucherRules() []string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.VoucherRules
|
return x.VoucherRules
|
||||||
}
|
}
|
||||||
@@ -1063,7 +995,7 @@ type RemoveVoucher struct {
|
|||||||
|
|
||||||
func (x *RemoveVoucher) Reset() {
|
func (x *RemoveVoucher) Reset() {
|
||||||
*x = RemoveVoucher{}
|
*x = RemoveVoucher{}
|
||||||
mi := &file_messages_proto_msgTypes[14]
|
mi := &file_messages_proto_msgTypes[13]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -1075,7 +1007,7 @@ func (x *RemoveVoucher) String() string {
|
|||||||
func (*RemoveVoucher) ProtoMessage() {}
|
func (*RemoveVoucher) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *RemoveVoucher) ProtoReflect() protoreflect.Message {
|
func (x *RemoveVoucher) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_messages_proto_msgTypes[14]
|
mi := &file_messages_proto_msgTypes[13]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -1088,7 +1020,7 @@ func (x *RemoveVoucher) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use RemoveVoucher.ProtoReflect.Descriptor instead.
|
// Deprecated: Use RemoveVoucher.ProtoReflect.Descriptor instead.
|
||||||
func (*RemoveVoucher) Descriptor() ([]byte, []int) {
|
func (*RemoveVoucher) Descriptor() ([]byte, []int) {
|
||||||
return file_messages_proto_rawDescGZIP(), []int{14}
|
return file_messages_proto_rawDescGZIP(), []int{13}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *RemoveVoucher) GetId() uint32 {
|
func (x *RemoveVoucher) GetId() uint32 {
|
||||||
@@ -1110,7 +1042,7 @@ type UpsertSubscriptionDetails struct {
|
|||||||
|
|
||||||
func (x *UpsertSubscriptionDetails) Reset() {
|
func (x *UpsertSubscriptionDetails) Reset() {
|
||||||
*x = UpsertSubscriptionDetails{}
|
*x = UpsertSubscriptionDetails{}
|
||||||
mi := &file_messages_proto_msgTypes[15]
|
mi := &file_messages_proto_msgTypes[14]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -1122,7 +1054,7 @@ func (x *UpsertSubscriptionDetails) String() string {
|
|||||||
func (*UpsertSubscriptionDetails) ProtoMessage() {}
|
func (*UpsertSubscriptionDetails) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *UpsertSubscriptionDetails) ProtoReflect() protoreflect.Message {
|
func (x *UpsertSubscriptionDetails) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_messages_proto_msgTypes[15]
|
mi := &file_messages_proto_msgTypes[14]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -1135,7 +1067,7 @@ func (x *UpsertSubscriptionDetails) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use UpsertSubscriptionDetails.ProtoReflect.Descriptor instead.
|
// Deprecated: Use UpsertSubscriptionDetails.ProtoReflect.Descriptor instead.
|
||||||
func (*UpsertSubscriptionDetails) Descriptor() ([]byte, []int) {
|
func (*UpsertSubscriptionDetails) Descriptor() ([]byte, []int) {
|
||||||
return file_messages_proto_rawDescGZIP(), []int{15}
|
return file_messages_proto_rawDescGZIP(), []int{14}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *UpsertSubscriptionDetails) GetId() string {
|
func (x *UpsertSubscriptionDetails) GetId() string {
|
||||||
@@ -1177,7 +1109,7 @@ type PreConditionFailed struct {
|
|||||||
|
|
||||||
func (x *PreConditionFailed) Reset() {
|
func (x *PreConditionFailed) Reset() {
|
||||||
*x = PreConditionFailed{}
|
*x = PreConditionFailed{}
|
||||||
mi := &file_messages_proto_msgTypes[16]
|
mi := &file_messages_proto_msgTypes[15]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -1189,7 +1121,7 @@ func (x *PreConditionFailed) String() string {
|
|||||||
func (*PreConditionFailed) ProtoMessage() {}
|
func (*PreConditionFailed) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *PreConditionFailed) ProtoReflect() protoreflect.Message {
|
func (x *PreConditionFailed) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_messages_proto_msgTypes[16]
|
mi := &file_messages_proto_msgTypes[15]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -1202,7 +1134,7 @@ func (x *PreConditionFailed) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use PreConditionFailed.ProtoReflect.Descriptor instead.
|
// Deprecated: Use PreConditionFailed.ProtoReflect.Descriptor instead.
|
||||||
func (*PreConditionFailed) Descriptor() ([]byte, []int) {
|
func (*PreConditionFailed) Descriptor() ([]byte, []int) {
|
||||||
return file_messages_proto_rawDescGZIP(), []int{16}
|
return file_messages_proto_rawDescGZIP(), []int{15}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PreConditionFailed) GetOperation() string {
|
func (x *PreConditionFailed) GetOperation() string {
|
||||||
@@ -1335,17 +1267,12 @@ const file_messages_proto_rawDesc = "" +
|
|||||||
"\x12InitializeCheckout\x12\x18\n" +
|
"\x12InitializeCheckout\x12\x18\n" +
|
||||||
"\aorderId\x18\x01 \x01(\tR\aorderId\x12\x16\n" +
|
"\aorderId\x18\x01 \x01(\tR\aorderId\x12\x16\n" +
|
||||||
"\x06status\x18\x02 \x01(\tR\x06status\x12,\n" +
|
"\x06status\x18\x02 \x01(\tR\x06status\x12,\n" +
|
||||||
"\x11paymentInProgress\x18\x03 \x01(\bR\x11paymentInProgress\"y\n" +
|
"\x11paymentInProgress\x18\x03 \x01(\bR\x11paymentInProgress\"Z\n" +
|
||||||
"\vVoucherRule\x12\x12\n" +
|
|
||||||
"\x04type\x18\x02 \x01(\tR\x04type\x12 \n" +
|
|
||||||
"\vdescription\x18\x03 \x01(\tR\vdescription\x12\x1c\n" +
|
|
||||||
"\tcondition\x18\x04 \x01(\tR\tcondition\x12\x16\n" +
|
|
||||||
"\x06action\x18\x05 \x01(\tR\x06action\"q\n" +
|
|
||||||
"\n" +
|
"\n" +
|
||||||
"AddVoucher\x12\x12\n" +
|
"AddVoucher\x12\x12\n" +
|
||||||
"\x04code\x18\x01 \x01(\tR\x04code\x12\x14\n" +
|
"\x04code\x18\x01 \x01(\tR\x04code\x12\x14\n" +
|
||||||
"\x05value\x18\x02 \x01(\x03R\x05value\x129\n" +
|
"\x05value\x18\x02 \x01(\x03R\x05value\x12\"\n" +
|
||||||
"\fvoucherRules\x18\x03 \x03(\v2\x15.messages.VoucherRuleR\fvoucherRules\"\x1f\n" +
|
"\fvoucherRules\x18\x03 \x03(\tR\fvoucherRules\"\x1f\n" +
|
||||||
"\rRemoveVoucher\x12\x0e\n" +
|
"\rRemoveVoucher\x12\x0e\n" +
|
||||||
"\x02id\x18\x01 \x01(\rR\x02id\"\xa7\x01\n" +
|
"\x02id\x18\x01 \x01(\rR\x02id\"\xa7\x01\n" +
|
||||||
"\x19UpsertSubscriptionDetails\x12\x13\n" +
|
"\x19UpsertSubscriptionDetails\x12\x13\n" +
|
||||||
@@ -1371,7 +1298,7 @@ func file_messages_proto_rawDescGZIP() []byte {
|
|||||||
return file_messages_proto_rawDescData
|
return file_messages_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 17)
|
var file_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 16)
|
||||||
var file_messages_proto_goTypes = []any{
|
var file_messages_proto_goTypes = []any{
|
||||||
(*ClearCartRequest)(nil), // 0: messages.ClearCartRequest
|
(*ClearCartRequest)(nil), // 0: messages.ClearCartRequest
|
||||||
(*AddItem)(nil), // 1: messages.AddItem
|
(*AddItem)(nil), // 1: messages.AddItem
|
||||||
@@ -1385,23 +1312,21 @@ var file_messages_proto_goTypes = []any{
|
|||||||
(*OrderCreated)(nil), // 9: messages.OrderCreated
|
(*OrderCreated)(nil), // 9: messages.OrderCreated
|
||||||
(*Noop)(nil), // 10: messages.Noop
|
(*Noop)(nil), // 10: messages.Noop
|
||||||
(*InitializeCheckout)(nil), // 11: messages.InitializeCheckout
|
(*InitializeCheckout)(nil), // 11: messages.InitializeCheckout
|
||||||
(*VoucherRule)(nil), // 12: messages.VoucherRule
|
(*AddVoucher)(nil), // 12: messages.AddVoucher
|
||||||
(*AddVoucher)(nil), // 13: messages.AddVoucher
|
(*RemoveVoucher)(nil), // 13: messages.RemoveVoucher
|
||||||
(*RemoveVoucher)(nil), // 14: messages.RemoveVoucher
|
(*UpsertSubscriptionDetails)(nil), // 14: messages.UpsertSubscriptionDetails
|
||||||
(*UpsertSubscriptionDetails)(nil), // 15: messages.UpsertSubscriptionDetails
|
(*PreConditionFailed)(nil), // 15: messages.PreConditionFailed
|
||||||
(*PreConditionFailed)(nil), // 16: messages.PreConditionFailed
|
(*anypb.Any)(nil), // 16: google.protobuf.Any
|
||||||
(*anypb.Any)(nil), // 17: google.protobuf.Any
|
|
||||||
}
|
}
|
||||||
var file_messages_proto_depIdxs = []int32{
|
var file_messages_proto_depIdxs = []int32{
|
||||||
6, // 0: messages.SetDelivery.pickupPoint:type_name -> messages.PickupPoint
|
6, // 0: messages.SetDelivery.pickupPoint:type_name -> messages.PickupPoint
|
||||||
12, // 1: messages.AddVoucher.voucherRules:type_name -> messages.VoucherRule
|
16, // 1: messages.UpsertSubscriptionDetails.data:type_name -> google.protobuf.Any
|
||||||
17, // 2: messages.UpsertSubscriptionDetails.data:type_name -> google.protobuf.Any
|
16, // 2: messages.PreConditionFailed.input:type_name -> google.protobuf.Any
|
||||||
17, // 3: messages.PreConditionFailed.input:type_name -> google.protobuf.Any
|
3, // [3:3] is the sub-list for method output_type
|
||||||
4, // [4:4] is the sub-list for method output_type
|
3, // [3:3] is the sub-list for method input_type
|
||||||
4, // [4:4] is the sub-list for method input_type
|
3, // [3:3] is the sub-list for extension type_name
|
||||||
4, // [4:4] is the sub-list for extension type_name
|
3, // [3:3] is the sub-list for extension extendee
|
||||||
4, // [4:4] is the sub-list for extension extendee
|
0, // [0:3] is the sub-list for field type_name
|
||||||
0, // [0:4] is the sub-list for field type_name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_messages_proto_init() }
|
func init() { file_messages_proto_init() }
|
||||||
@@ -1413,14 +1338,14 @@ func file_messages_proto_init() {
|
|||||||
file_messages_proto_msgTypes[4].OneofWrappers = []any{}
|
file_messages_proto_msgTypes[4].OneofWrappers = []any{}
|
||||||
file_messages_proto_msgTypes[5].OneofWrappers = []any{}
|
file_messages_proto_msgTypes[5].OneofWrappers = []any{}
|
||||||
file_messages_proto_msgTypes[6].OneofWrappers = []any{}
|
file_messages_proto_msgTypes[6].OneofWrappers = []any{}
|
||||||
file_messages_proto_msgTypes[15].OneofWrappers = []any{}
|
file_messages_proto_msgTypes[14].OneofWrappers = []any{}
|
||||||
type x struct{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_messages_proto_rawDesc), len(file_messages_proto_rawDesc)),
|
RawDescriptor: unsafe.Slice(unsafe.StringData(file_messages_proto_rawDesc), len(file_messages_proto_rawDesc)),
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 17,
|
NumMessages: 16,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type Rule struct {
|
|||||||
type Voucher struct {
|
type Voucher struct {
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Value int64 `json:"value"`
|
Value int64 `json:"value"`
|
||||||
rules string `json:"rules"`
|
Rules string `json:"rules"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
@@ -42,13 +42,8 @@ func (s *Service) GetVoucher(code string) (*messages.AddVoucher, error) {
|
|||||||
return &messages.AddVoucher{
|
return &messages.AddVoucher{
|
||||||
Code: code,
|
Code: code,
|
||||||
Value: v.Value,
|
Value: v.Value,
|
||||||
VoucherRules: []*messages.VoucherRule{
|
VoucherRules: []string{
|
||||||
{
|
v.Rules,
|
||||||
Condition: v.rules,
|
|
||||||
Type: "",
|
|
||||||
Description: "",
|
|
||||||
Action: "",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@@ -59,7 +54,7 @@ type State struct {
|
|||||||
|
|
||||||
type StateFile struct {
|
type StateFile struct {
|
||||||
State State `json:"state"`
|
State State `json:"state"`
|
||||||
Vercion int `json:"version"`
|
Version int `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sf *StateFile) GetVoucher(code string) (*Voucher, bool) {
|
func (sf *StateFile) GetVoucher(code string) (*Voucher, bool) {
|
||||||
|
|||||||
@@ -4,129 +4,114 @@ option go_package = "git.tornberg.me/go-cart-actor/proto;messages";
|
|||||||
|
|
||||||
import "google/protobuf/any.proto";
|
import "google/protobuf/any.proto";
|
||||||
|
|
||||||
message ClearCartRequest {
|
message ClearCartRequest {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message AddItem {
|
message AddItem {
|
||||||
uint32 item_id = 1;
|
uint32 item_id = 1;
|
||||||
int32 quantity = 2;
|
int32 quantity = 2;
|
||||||
int64 price = 3;
|
int64 price = 3;
|
||||||
int64 orgPrice = 9;
|
int64 orgPrice = 9;
|
||||||
string sku = 4;
|
string sku = 4;
|
||||||
string name = 5;
|
string name = 5;
|
||||||
string image = 6;
|
string image = 6;
|
||||||
int32 stock = 7;
|
int32 stock = 7;
|
||||||
int32 tax = 8;
|
int32 tax = 8;
|
||||||
string brand = 13;
|
string brand = 13;
|
||||||
string category = 14;
|
string category = 14;
|
||||||
string category2 = 15;
|
string category2 = 15;
|
||||||
string category3 = 16;
|
string category3 = 16;
|
||||||
string category4 = 17;
|
string category4 = 17;
|
||||||
string category5 = 18;
|
string category5 = 18;
|
||||||
string disclaimer = 10;
|
string disclaimer = 10;
|
||||||
string articleType = 11;
|
string articleType = 11;
|
||||||
string sellerId = 19;
|
string sellerId = 19;
|
||||||
string sellerName = 20;
|
string sellerName = 20;
|
||||||
string country = 21;
|
string country = 21;
|
||||||
string saleStatus = 24;
|
string saleStatus = 24;
|
||||||
optional string outlet = 12;
|
optional string outlet = 12;
|
||||||
optional string storeId = 22;
|
optional string storeId = 22;
|
||||||
optional uint32 parentId = 23;
|
optional uint32 parentId = 23;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RemoveItem {
|
message RemoveItem { uint32 Id = 1; }
|
||||||
uint32 Id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ChangeQuantity {
|
message ChangeQuantity {
|
||||||
uint32 Id = 1;
|
uint32 Id = 1;
|
||||||
int32 quantity = 2;
|
int32 quantity = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SetDelivery {
|
message SetDelivery {
|
||||||
string provider = 1;
|
string provider = 1;
|
||||||
repeated uint32 items = 2;
|
repeated uint32 items = 2;
|
||||||
optional PickupPoint pickupPoint = 3;
|
optional PickupPoint pickupPoint = 3;
|
||||||
string country = 4;
|
string country = 4;
|
||||||
string zip = 5;
|
string zip = 5;
|
||||||
optional string address = 6;
|
optional string address = 6;
|
||||||
optional string city = 7;
|
optional string city = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SetPickupPoint {
|
message SetPickupPoint {
|
||||||
uint32 deliveryId = 1;
|
uint32 deliveryId = 1;
|
||||||
string id = 2;
|
string id = 2;
|
||||||
optional string name = 3;
|
optional string name = 3;
|
||||||
optional string address = 4;
|
optional string address = 4;
|
||||||
optional string city = 5;
|
optional string city = 5;
|
||||||
optional string zip = 6;
|
optional string zip = 6;
|
||||||
optional string country = 7;
|
optional string country = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PickupPoint {
|
message PickupPoint {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
optional string name = 2;
|
optional string name = 2;
|
||||||
optional string address = 3;
|
optional string address = 3;
|
||||||
optional string city = 4;
|
optional string city = 4;
|
||||||
optional string zip = 5;
|
optional string zip = 5;
|
||||||
optional string country = 6;
|
optional string country = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RemoveDelivery {
|
message RemoveDelivery { uint32 id = 1; }
|
||||||
uint32 id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message CreateCheckoutOrder {
|
message CreateCheckoutOrder {
|
||||||
string terms = 1;
|
string terms = 1;
|
||||||
string checkout = 2;
|
string checkout = 2;
|
||||||
string confirmation = 3;
|
string confirmation = 3;
|
||||||
string push = 4;
|
string push = 4;
|
||||||
string validation = 5;
|
string validation = 5;
|
||||||
string country = 6;
|
string country = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message OrderCreated {
|
message OrderCreated {
|
||||||
string orderId = 1;
|
string orderId = 1;
|
||||||
string status = 2;
|
string status = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Noop {
|
message Noop {
|
||||||
// Intentionally empty - used for ownership acquisition or health pings
|
// Intentionally empty - used for ownership acquisition or health pings
|
||||||
}
|
}
|
||||||
|
|
||||||
message InitializeCheckout {
|
message InitializeCheckout {
|
||||||
string orderId = 1;
|
string orderId = 1;
|
||||||
string status = 2;
|
string status = 2;
|
||||||
bool paymentInProgress = 3;
|
bool paymentInProgress = 3;
|
||||||
}
|
|
||||||
|
|
||||||
message VoucherRule {
|
|
||||||
string type = 2;
|
|
||||||
string description = 3;
|
|
||||||
string condition = 4;
|
|
||||||
string action = 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message AddVoucher {
|
message AddVoucher {
|
||||||
string code = 1;
|
string code = 1;
|
||||||
int64 value = 2;
|
int64 value = 2;
|
||||||
repeated VoucherRule voucherRules = 3;
|
repeated string voucherRules = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RemoveVoucher {
|
message RemoveVoucher { uint32 id = 1; }
|
||||||
uint32 id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UpsertSubscriptionDetails {
|
message UpsertSubscriptionDetails {
|
||||||
optional string id = 1;
|
optional string id = 1;
|
||||||
string offeringCode = 2;
|
string offeringCode = 2;
|
||||||
string signingType = 3;
|
string signingType = 3;
|
||||||
google.protobuf.Any data = 4;
|
google.protobuf.Any data = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PreConditionFailed {
|
message PreConditionFailed {
|
||||||
string operation = 1;
|
string operation = 1;
|
||||||
string error = 2;
|
string error = 2;
|
||||||
google.protobuf.Any input = 3;
|
google.protobuf.Any input = 3;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user