Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
563e6baeda | ||
|
|
e1f7e99027 | ||
|
|
36ca8d6f83 |
3
go.mod
3
go.mod
@@ -1,8 +1,9 @@
|
|||||||
module github.com/debyltech/go-snipcart
|
module github.com/debyltech/go-snipcart
|
||||||
|
|
||||||
go 1.20
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/debyltech/go-helpers v1.1.0
|
github.com/debyltech/go-helpers v1.1.0
|
||||||
|
github.com/debyltech/go-shippr v0.1.0
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -50,22 +50,25 @@ type SnipcartOrder struct {
|
|||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Invoice string `json:"invoiceNumber"`
|
Invoice string `json:"invoiceNumber"`
|
||||||
Subtotal float64 `json:"subtotal,omitempty"`
|
Subtotal float64 `json:"subtotal,omitempty"`
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
Total float64 `json:"grandTotal,omitempty"`
|
Total float64 `json:"grandTotal,omitempty"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
TotalWeight float64 `json:"totalWeight"`
|
TotalWeight float64 `json:"totalWeight"`
|
||||||
Email string `json:"email"`
|
|
||||||
Name string `json:"shippingAddressName"`
|
Name string `json:"shippingAddressName"`
|
||||||
|
Company string `json:"shippingAddressCompanyName"`
|
||||||
Address1 string `json:"shippingAddressAddress1"`
|
Address1 string `json:"shippingAddressAddress1"`
|
||||||
Address2 string `json:"shippingAddressAddress2"`
|
Address2 string `json:"shippingAddressAddress2"`
|
||||||
City string `json:"shippingAddressCity"`
|
City string `json:"shippingAddressCity"`
|
||||||
Province string `json:"shippingAddressProvince"`
|
Province string `json:"shippingAddressProvince"`
|
||||||
Country string `json:"shippingAddressCountry"`
|
Country string `json:"shippingAddressCountry"`
|
||||||
PostalCode string `json:"shippingAddressPostalCode"`
|
PostalCode string `json:"shippingAddressPostalCode"`
|
||||||
Phone string `json:"shippingAddressPhone"`
|
Phone string `json:"shippingAddressPhone,omitempty"`
|
||||||
|
Email string `json:"email,omitempty"`
|
||||||
TrackingNumber string `json:"trackingNumber"`
|
TrackingNumber string `json:"trackingNumber"`
|
||||||
TrackingUrl string `json:"trackingUrl"`
|
TrackingUrl string `json:"trackingUrl"`
|
||||||
ShippingCost float64 `json:"shippingFees"`
|
ShippingCost float64 `json:"shippingFees"`
|
||||||
Items []SnipcartItem `json:"items"`
|
Items []SnipcartItem `json:"items"`
|
||||||
|
Metadata any `json:"metadata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SnipcartOrderUpdate struct {
|
type SnipcartOrderUpdate struct {
|
||||||
|
|||||||
33
snipcart/webhook/config.go
Normal file
33
snipcart/webhook/config.go
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package webhook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/debyltech/go-shippr/shippo"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
ShippoApiKey string `json:"shippo_api_key"`
|
||||||
|
WeightUnit string `json:"weight_unit"`
|
||||||
|
DimensionUnit string `json:"dimension_unit"`
|
||||||
|
ManufactureCountry string `json:"manufacture_country"`
|
||||||
|
SenderAddress shippo.Address `json:"sender_address"`
|
||||||
|
DefaultParcel shippo.Parcel `json:"default_parcel"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewConfigFromFile(filePath string) (*Config, error) {
|
||||||
|
configBytes, err := ioutil.ReadFile(filePath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var config Config
|
||||||
|
err = json.NewDecoder(bytes.NewBuffer(configBytes)).Decode(&config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &config, nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user