Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b93afeec2f | ||
|
|
bc56b4d16a | ||
|
|
b08b64f5b2 | ||
|
|
ad93704f41 | ||
|
|
b97ee3132b | ||
|
|
cfdde462f4 | ||
|
|
e039b583e2 | ||
|
|
26571a41fa | ||
|
|
559a100e90 | ||
|
|
6ff851823e | ||
|
|
db6e320b7f | ||
|
|
563e6baeda |
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
helper "github.com/debyltech/go-helpers/json"
|
helper "github.com/debyltech/go-helpers/json"
|
||||||
"github.com/skip2/go-qrcode"
|
"github.com/skip2/go-qrcode"
|
||||||
@@ -47,27 +48,34 @@ type SnipcartItem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SnipcartOrder struct {
|
type SnipcartOrder struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Invoice string `json:"invoiceNumber"`
|
Created time.Time `json:"creationDate"`
|
||||||
Subtotal float64 `json:"subtotal,omitempty"`
|
Modified time.Time `json:"modificationDate"`
|
||||||
Currency string `json:"currency,omitempty"`
|
Invoice string `json:"invoiceNumber"`
|
||||||
Total float64 `json:"grandTotal,omitempty"`
|
Subtotal float64 `json:"subtotal,omitempty"`
|
||||||
Status string `json:"status"`
|
Currency string `json:"currency,omitempty"`
|
||||||
TotalWeight float64 `json:"totalWeight"`
|
Total float64 `json:"grandTotal,omitempty"`
|
||||||
Name string `json:"shippingAddressName"`
|
Status string `json:"status"`
|
||||||
Company string `json:"shippingAddressCompanyName"`
|
TotalWeight float64 `json:"totalWeight"`
|
||||||
Address1 string `json:"shippingAddressAddress1"`
|
ShippingAddress SnipcartShippingAddress `json:"shippingAddress,omitempty"`
|
||||||
Address2 string `json:"shippingAddressAddress2"`
|
Name string `json:"shippingAddressName,omitempty"`
|
||||||
City string `json:"shippingAddressCity"`
|
Company string `json:"shippingAddressCompanyName,omitempty"`
|
||||||
Province string `json:"shippingAddressProvince"`
|
Address1 string `json:"shippingAddressAddress1,omitempty"`
|
||||||
Country string `json:"shippingAddressCountry"`
|
Address2 string `json:"shippingAddressAddress2,omitempty"`
|
||||||
PostalCode string `json:"shippingAddressPostalCode"`
|
City string `json:"shippingAddressCity,omitempty"`
|
||||||
Phone string `json:"shippingAddressPhone,omitempty"`
|
Province string `json:"shippingAddressProvince,omitempty"`
|
||||||
Email string `json:"email,omitempty"`
|
Country string `json:"shippingAddressCountry,omitempty"`
|
||||||
TrackingNumber string `json:"trackingNumber"`
|
PostalCode string `json:"shippingAddressPostalCode,omitempty"`
|
||||||
TrackingUrl string `json:"trackingUrl"`
|
Phone string `json:"shippingAddressPhone,omitempty"`
|
||||||
ShippingCost float64 `json:"shippingFees"`
|
Email string `json:"email,omitempty"`
|
||||||
Items []SnipcartItem `json:"items"`
|
TrackingNumber string `json:"trackingNumber"`
|
||||||
|
TrackingUrl string `json:"trackingUrl"`
|
||||||
|
ShippingCost float64 `json:"shippingFees"`
|
||||||
|
ShippingProvider string `json:"shippingProvider,omitempty"`
|
||||||
|
ShippingMethod string `json:"shippingMethod,omitempty"`
|
||||||
|
ShippingRateId string `json:"shippingRateUserDefinedId,omitempty"`
|
||||||
|
Items []SnipcartItem `json:"items"`
|
||||||
|
Metadata any `json:"metadata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SnipcartOrderUpdate struct {
|
type SnipcartOrderUpdate struct {
|
||||||
@@ -83,6 +91,13 @@ type SnipcartOrders struct {
|
|||||||
Items []SnipcartOrder
|
Items []SnipcartOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SnipcartTax struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Amount float64 `json:"amount"`
|
||||||
|
NumberForInvoice string `json:"numberForInvoice"`
|
||||||
|
Rate float64 `json:"rate"`
|
||||||
|
}
|
||||||
|
|
||||||
func NewClient(snipcartApiKey string) Client {
|
func NewClient(snipcartApiKey string) Client {
|
||||||
return Client{
|
return Client{
|
||||||
SnipcartKey: snipcartApiKey,
|
SnipcartKey: snipcartApiKey,
|
||||||
|
|||||||
21
snipcart/webhook.go
Normal file
21
snipcart/webhook.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
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 SnipcartWebhookTaxResponse struct {
|
||||||
|
Taxes []SnipcartTax `json:"taxes"`
|
||||||
|
}
|
||||||
@@ -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