-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support get delivery metric by current month
- Loading branch information
Showing
29 changed files
with
672 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package fortress | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/dwarvesf/fortress-discord/pkg/model" | ||
) | ||
|
||
func (f *Fortress) CheckWithdrawCondition(discordID string) (rs *model.AdapterCheckWithdrawCondition, err error) { | ||
req, err := f.makeReq(fmt.Sprintf("/api/v1/discords/withdraw/check?discordID=%v", discordID), http.MethodGet, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resp, err := http.DefaultClient.Do(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
defer resp.Body.Close() | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
return nil, fmt.Errorf("invalid call, code %v", resp.StatusCode) | ||
} | ||
|
||
if err := json.NewDecoder(resp.Body).Decode(&rs); err != nil { | ||
return nil, fmt.Errorf("invalid decoded, error %v", err.Error()) | ||
} | ||
|
||
return rs, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package withdraw | ||
|
||
import ( | ||
"github.com/dwarvesf/fortress-discord/pkg/model" | ||
) | ||
|
||
func (e *Withdraw) Prefix() []string { | ||
return []string{"withdraw"} | ||
} | ||
|
||
// Execute is where we handle logic for each command | ||
func (e *Withdraw) Execute(message *model.DiscordMessage) error { | ||
if len(message.ContentArgs) == 1 { | ||
return e.DefaultCommand(message) | ||
} | ||
|
||
//switch message.ContentArgs[1] { | ||
//case "with": | ||
// return e.Home(message) | ||
//} | ||
|
||
return nil | ||
} | ||
|
||
func (e *Withdraw) Name() string { | ||
return "Home Command" | ||
} | ||
|
||
func (e *Withdraw) Help(message *model.DiscordMessage) error { | ||
return nil | ||
} | ||
|
||
func (e *Withdraw) DefaultCommand(message *model.DiscordMessage) error { | ||
return e.Withdraw(message) | ||
} | ||
|
||
func (e *Withdraw) PermissionCheck(message *model.DiscordMessage) (bool, []string) { | ||
return true, []string{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package withdraw | ||
|
||
import ( | ||
"github.com/dwarvesf/fortress-discord/pkg/discord/base" | ||
"github.com/dwarvesf/fortress-discord/pkg/model" | ||
) | ||
|
||
type Commander interface { | ||
base.TextCommander | ||
|
||
Withdraw(message *model.DiscordMessage) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package withdraw | ||
|
||
import ( | ||
"github.com/dwarvesf/fortress-discord/pkg/discord/service" | ||
"github.com/dwarvesf/fortress-discord/pkg/discord/view" | ||
"github.com/dwarvesf/fortress-discord/pkg/logger" | ||
"github.com/dwarvesf/fortress-discord/pkg/model" | ||
) | ||
|
||
type Withdraw struct { | ||
L logger.Logger | ||
svc service.Servicer | ||
view view.Viewer | ||
} | ||
|
||
func New(l logger.Logger, svc service.Servicer, view view.Viewer) Commander { | ||
return &Withdraw{ | ||
L: l, | ||
svc: svc, | ||
view: view, | ||
} | ||
} | ||
|
||
func (e *Withdraw) Withdraw(message *model.DiscordMessage) error { | ||
cond, err := e.svc.Withdrawal().CheckWithdrawCondition(message.Author.ID) | ||
if err != nil { | ||
e.L.Error(err, "failed to check withdraw condition") | ||
return e.view.Withdraw().ErrorWithdraw(message, err) | ||
} | ||
|
||
banks, err := e.svc.Withdrawal().GetBanks("", "", "") | ||
if err != nil { | ||
e.L.Error(err, "failed to get banks") | ||
return e.view.Withdraw().ErrorWithdraw(message, err) | ||
} | ||
|
||
in := &model.WithdrawInput{ | ||
ICYAmount: cond.ICYAmount, | ||
VNDAmount: cond.VNDAmount, | ||
ICYVNDRate: cond.ICYVNDRate, | ||
} | ||
return e.view.Withdraw().Home(message, in, banks) | ||
} |
Oops, something went wrong.