Complete refactor to new grpc control plane and only http proxy for carts (#4)
Co-authored-by: matst80 <mats.tornberg@gmail.com> Reviewed-on: https://git.tornberg.me/mats/go-cart-actor/pulls/4 Co-authored-by: Mats Törnberg <mats@tornberg.me> Co-committed-by: Mats Törnberg <mats@tornberg.me>
This commit was merged in pull request #4.
This commit is contained in:
39
pkg/voucher/service.go
Normal file
39
pkg/voucher/service.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package voucher
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.tornberg.me/go-cart-actor/pkg/messages"
|
||||
)
|
||||
|
||||
type Rule struct {
|
||||
Type string `json:"type"`
|
||||
Value int64 `json:"value"`
|
||||
}
|
||||
|
||||
type Voucher struct {
|
||||
Code string `json:"code"`
|
||||
Value int64 `json:"discount"`
|
||||
TaxValue int64 `json:"taxValue"`
|
||||
TaxRate int `json:"taxRate"`
|
||||
rules []Rule `json:"rules"`
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
// Add fields here
|
||||
|
||||
}
|
||||
|
||||
var ErrInvalidCode = errors.New("invalid vouchercode")
|
||||
|
||||
func (s *Service) GetVoucher(code string) (*messages.AddVoucher, error) {
|
||||
if code == "" {
|
||||
return nil, ErrInvalidCode
|
||||
}
|
||||
value := int64(250_00)
|
||||
return &messages.AddVoucher{
|
||||
Code: code,
|
||||
Value: value,
|
||||
VoucherRules: make([]*messages.VoucherRule, 0),
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user