Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b70e95ac5c | ||
| ac4f4670bb | |||
| 4a8b5cf0c5 |
@@ -8,11 +8,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) executeRequest(ctx context.Context, request FiscalRequest, response interface{}) error {
|
func (c *Client) executeRequest(ctx context.Context, request FiscalRequest, response interface{}) error {
|
||||||
|
//execute request with json body in request
|
||||||
reqJson, err := json.Marshal(request)
|
reqJson, err := json.Marshal(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to marshal request: %w", err)
|
return fmt.Errorf("failed to marshal request: %w", err)
|
||||||
}
|
}
|
||||||
fmt.Println(string(reqJson))
|
|
||||||
|
|
||||||
resp, err := c.resty.R().
|
resp, err := c.resty.R().
|
||||||
SetContext(ctx).
|
SetContext(ctx).
|
||||||
@@ -101,12 +101,6 @@ func (c *Client) Sell(ctx context.Context, params SellParams) (*SellResponse, er
|
|||||||
request.Userinfo = *params.Userinfo
|
request.Userinfo = *params.Userinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
reqJson, err := json.Marshal(request)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
fmt.Println(string(reqJson))
|
|
||||||
|
|
||||||
var response SellResponse
|
var response SellResponse
|
||||||
if err := c.executeRequest(ctx, request, &response); err != nil {
|
if err := c.executeRequest(ctx, request, &response); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
20
vchasno.go
20
vchasno.go
@@ -274,3 +274,23 @@ func (c *Client) QuickSellNamed(ctx context.Context, name string, price float64)
|
|||||||
Price: price,
|
Price: price,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) ZeroReceipt(ctx context.Context) (*api.SellResponse, error) {
|
||||||
|
return c.api.Sell(ctx, api.SellParams{
|
||||||
|
Cashier: c.cashier,
|
||||||
|
Source: c.source,
|
||||||
|
Rows: []api.ReceiptRow{},
|
||||||
|
Pays: []api.ReceiptPay{},
|
||||||
|
CommentUP: "Нульовий чек",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) ZeroReceiptWithTimeout(timeout time.Duration) (*api.SellResponse, error) {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
|
defer cancel()
|
||||||
|
return c.ZeroReceipt(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) ZeroReceiptDefault() (*api.SellResponse, error) {
|
||||||
|
return c.ZeroReceiptWithTimeout(c.defaults.DefaultTimeout)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user