Skip to content

Commit

Permalink
update workflow, payment controller
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanM007 committed Oct 22, 2023
1 parent fc63ec6 commit 9f31eeb
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Mombo Goals CI
name: Lipa CI

# 1
# Controls when the workflow will run
Expand All @@ -15,8 +15,8 @@ on:
required: true
# 2
env:
# REGISTRY: "AllanMombo/goal-accounts"
IMAGE_NAME: "goal-accounts"
# REGISTRY: "Allan/lipa"
IMAGE_NAME: "lipa"
TOKEN: ${{ secrets.GITHUB_TOKEN }} # it's needed for GH CLI

#3
Expand Down
59 changes: 59 additions & 0 deletions controllers/payment_controller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package controllers

import (
"time"

"golang.org/x/exp/constraints"
)

type Channel struct {
Id uint `json:"id"`
Identifier string `json:"identifier"`
Name string `json:"name"`
}

type Currency struct {
Id uint `json:"id"`
Name string `json:"name"`
Active bool `json:"active"`
}

type Payment struct {
UID string `json:"uid" binding:"required"`
Source Channel `json:"source" binding:"required"`
Amount float64 `json:"amount" binding:"amount"`
Currency Currency `json:"currency" binding:"currency"`
Recipient Channel `json:"recipient" binding:"recipient"`
Timestamp time.Time `json:"timeStamp" binding:"timestamp"`
Remarks string `json:"remarks" binding:"remarks"`
}

func Add[T constraints.Ordered](a , b T) T {
return a + b
}

func Subtract[T constraints.Ordered](a , b T) T {
return a + b
}

func Multiply[T constraints.Ordered](a , b T) T {
return a + b
}

func Divide[T constraints.Ordered](a , b T) T {
return a + b
}

func Min[T constraints.Ordered](a , b T) T {
if a > b {
return b
}
return a
}

func Max[T constraints.Ordered](a , b T) T {
if a > b {
return a
}
return b
}
25 changes: 25 additions & 0 deletions controllers/payment_controller_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package controllers

import (
"testing"
)

func TestAdd(t *testing.T) {
got := Add[int](1, 3)

want := 4

if got != want {
t.Errorf("got %q, wanted %q", got, want)
}
}

func TestMinus(t *testing.T) {
got := Subtract[int](10, 4)

want := 6

if got != want {
t.Errorf("got %q, wanted %q", got, want)
}
}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ require (
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/tdewolff/parse/v2 v2.6.5 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gorm.io/gorm v1.25.5 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down Expand Up @@ -319,6 +321,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
6 changes: 3 additions & 3 deletions service.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

service ProductManagement {
rpc GetProduct(ProductRequest) returns (ProductResponse);
rpc UpdateStock(StockUpdateRequest) returns (StockUpdateResponse);
service PaymentManagement {
rpc GetPayments(PaymentRequest) returns (PaymentResponse);
rpc UpdatePayment(PaymentUpdateRequest) returns (PaymentUpdateResponse);
}

0 comments on commit 9f31eeb

Please sign in to comment.