diff --git a/snipcart/webhook.go b/snipcart/webhook.go new file mode 100644 index 0000000..087c117 --- /dev/null +++ b/snipcart/webhook.go @@ -0,0 +1,23 @@ +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"` + State string `json:"province"` + Phone string `json:"phone"` + VatNumber string `json:"vatNumber,omitempty"` +} + +type SnipcartOrderEventContent struct { + Token string `json:"token"` + Items []SnipcartItem `json:"items"` + ShippingAddress SnipcartShippingAddress `json:"shippingAddress"` +} diff --git a/snipcart/webhook/config.go b/snipcart/webhook/config.go deleted file mode 100644 index 976b9f0..0000000 --- a/snipcart/webhook/config.go +++ /dev/null @@ -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 -}