Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfb6497d25 | ||
|
|
82b88cbaf5 | ||
|
|
994cabc20e |
@@ -7,10 +7,6 @@ import (
|
||||
"github.com/debyltech/go-snipcart/snipcart"
|
||||
)
|
||||
|
||||
const (
|
||||
configFile = "config.json"
|
||||
)
|
||||
|
||||
func main() {
|
||||
snipcartApiKey := flag.String("key", "", "Snipcart API Key")
|
||||
flag.Parse()
|
||||
|
||||
2
go.mod
2
go.mod
@@ -3,6 +3,6 @@ module github.com/debyltech/go-snipcart
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/debyltech/go-helpers v1.0.1
|
||||
github.com/debyltech/go-helpers v1.0.4
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
)
|
||||
|
||||
@@ -61,7 +61,6 @@ type SnipcartOrder struct {
|
||||
}
|
||||
|
||||
type SnipcartOrderUpdate struct {
|
||||
Token string `json:"token"`
|
||||
Status OrderStatus `json:"status"`
|
||||
PaymentStatus string `json:"paymentStatus,omitempty"`
|
||||
TrackingNumber string `json:"trackingNumber,omitempty"`
|
||||
@@ -138,14 +137,15 @@ func (o *SnipcartOrder) TokenPNGBase64() (string, error) {
|
||||
return base64.StdEncoding.EncodeToString(img), nil
|
||||
}
|
||||
|
||||
func (s *SnipcartProvider) UpdateOrder(orderUpdate *SnipcartOrderUpdate) (*SnipcartOrder, error) {
|
||||
response, err := helper.Put(orderUri+"/"+orderUpdate.Token, "Basic", s.AuthBase64, orderUpdate)
|
||||
func (s *SnipcartProvider) UpdateOrder(token string, orderUpdate *SnipcartOrderUpdate) (*SnipcartOrder, error) {
|
||||
response, err := helper.Put(orderUri+"/"+token, "Basic", s.AuthBase64, orderUpdate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.StatusCode < 200 && response.StatusCode >= 300 {
|
||||
return nil, fmt.Errorf("unexpected response received: %s", response.Status)
|
||||
}
|
||||
fmt.Println(response.Status)
|
||||
|
||||
defer response.Body.Close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user