Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e039b583e2 | ||
|
|
26571a41fa | ||
|
|
559a100e90 | ||
|
|
6ff851823e | ||
|
|
db6e320b7f |
30
snipcart/webhook.go
Normal file
30
snipcart/webhook.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package snipcart
|
||||
|
||||
type SnipcartShippingAddress struct {
|
||||
FullName string `json:"fullName"`
|
||||
FirstName string `json:"firstName"`
|
||||
Name string `json:"name"`
|
||||
Company string `json:"company"`
|
||||
Address1 string `json:"address1"`
|
||||
Address2 string `json:"address2"`
|
||||
FullAddress string `json:"fullAddress"`
|
||||
City string `json:"city"`
|
||||
Country string `json:"country"`
|
||||
PostalCode string `json:"postalCode"`
|
||||
Province string `json:"province"`
|
||||
Phone string `json:"phone"`
|
||||
VatNumber string `json:"vatNumber,omitempty"`
|
||||
}
|
||||
|
||||
type SnipcartOrderEventContent struct {
|
||||
Token string `json:"token"`
|
||||
Invoice string `json:"invoiceNumber"`
|
||||
Status string `json:"status"`
|
||||
PaymentStatus string `json:"paymentStatus"`
|
||||
Email string `json:"email"`
|
||||
Currency string `json:"currency"`
|
||||
TotalWeight float64 `json:"totalWeight"`
|
||||
Items []SnipcartItem `json:"items"`
|
||||
ShippingAddress SnipcartShippingAddress `json:"shippingAddress"`
|
||||
Metadata string `json:"metadata"`
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
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