fix saving and project improvments

This commit is contained in:
Aleksandr Trushkin
2024-01-25 16:42:08 +03:00
parent f94d39b124
commit a1e767217b
16 changed files with 680 additions and 438 deletions

View File

@ -12,41 +12,51 @@ import (
"strconv"
"strings"
"git.loyso.art/frx/eway/internal/config"
"git.loyso.art/frx/eway/internal/entity"
"github.com/go-resty/resty/v2"
"github.com/rs/zerolog"
)
type Client interface {
}
type client struct {
http *resty.Client
log zerolog.Logger
}
func NewClientWithSession(sessionid, sessionuser string, log zerolog.Logger) client {
type Config config.Eway
func New(cfg Config, log zerolog.Logger) client {
if cfg.Contract == "" {
cfg.Contract = "6101"
}
cookies := []*http.Cookie{
{
Name: "session_id",
Value: sessionid,
Value: cfg.SessionID,
Domain: "eway.elevel.ru",
HttpOnly: true,
},
{
Name: "session_user",
Value: sessionuser,
Value: cfg.SessionUser,
Domain: "eway.elevel.ru",
HttpOnly: true,
},
{
Name: "contract",
Value: "6101",
Value: cfg.Contract,
Domain: "eway.elevel.ru",
HttpOnly: true,
},
}
httpclient := resty.New().
SetDebug(false).
SetDebug(cfg.Debug).
SetCookies(cookies).
SetBaseURL("https://eway.elevel.ru/api")