Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28f77f63b9 | ||
|
|
2a97bca474 | ||
|
|
2d91d1d122 | ||
|
|
13f482e50a |
33
example_get_order.go
Normal file
33
example_get_order.go
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/debyltech/go-snipcart/snipcart"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
snipcartApiKey := flag.String("key", "", "Snipcart API Key")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if *snipcartApiKey == "" {
|
||||||
|
log.Fatal("missing -key flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
snipcartProvider := snipcart.NewSnipcartProvider(*snipcartApiKey)
|
||||||
|
|
||||||
|
response, err := snipcartProvider.GetOrder("b35990df-c0ca-4014-94de-1caa7bd7bb51")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
byteResponse, err := json.Marshal(response)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(string(byteResponse))
|
||||||
|
}
|
||||||
32
example_update_order.go
Normal file
32
example_update_order.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/debyltech/go-snipcart/snipcart"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
snipcartApiKey := flag.String("key", "", "Snipcart API Key")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if *snipcartApiKey == "" {
|
||||||
|
log.Fatal("missing -key flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
snipcartProvider := snipcart.NewSnipcartProvider(*snipcartApiKey)
|
||||||
|
|
||||||
|
updateOrder := snipcart.SnipcartOrderUpdate{
|
||||||
|
Status: snipcart.Delivered,
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := snipcartProvider.UpdateOrder("b35990df-c0ca-4014-94de-1caa7bd7bb51", &updateOrder)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range response.Items {
|
||||||
|
log.Printf("%v: %v\n", k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
2
go.mod
2
go.mod
@@ -3,6 +3,6 @@ module github.com/debyltech/go-snipcart
|
|||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/debyltech/go-helpers v1.0.4
|
github.com/debyltech/go-helpers v1.0.5
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -26,13 +26,19 @@ type SnipcartProvider struct {
|
|||||||
Limit int
|
Limit int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SnipcartCustomField struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
type SnipcartItem struct {
|
type SnipcartItem struct {
|
||||||
UUID string `json:"uniqueId"`
|
UUID string `json:"uniqueId"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Quantity int `json:"quantity"`
|
Quantity int `json:"quantity"`
|
||||||
TotalWeight float64 `json:"totalWeight,omitempty"`
|
TotalWeight float64 `json:"totalWeight,omitempty"`
|
||||||
CustomFieldsJSON string `json:"customFieldsJson"`
|
TotalPrice string `json:"totalPrice,omitempty"`
|
||||||
|
CustomFields []SnipcartCustomField `json:"customFields"`
|
||||||
Length float64 `json:"length,omitempty"`
|
Length float64 `json:"length,omitempty"`
|
||||||
Width float64 `json:"width,omitempty"`
|
Width float64 `json:"width,omitempty"`
|
||||||
Height float64 `json:"height,omitempty"`
|
Height float64 `json:"height,omitempty"`
|
||||||
@@ -43,6 +49,8 @@ type SnipcartItem struct {
|
|||||||
type SnipcartOrder struct {
|
type SnipcartOrder struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Invoice string `json:"invoiceNumber"`
|
Invoice string `json:"invoiceNumber"`
|
||||||
|
Subtotal string `json:"subtotal,omitempty"`
|
||||||
|
Total string `json:"grandTotal,omitempty"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
TotalWeight float64 `json:"totalWeight"`
|
TotalWeight float64 `json:"totalWeight"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
|
|||||||
Reference in New Issue
Block a user