Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5936f24c7c |
@@ -30,14 +30,10 @@ 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 float64 `json:"quantity"`
|
||||||
TotalWeight float64 `json:"totalWeight,omitempty"`
|
Weight string `json:"weight"`
|
||||||
|
TotalWeight float64 `json:"totalWeight"`
|
||||||
CustomFieldsJSON string `json:"customFieldsJson"`
|
CustomFieldsJSON string `json:"customFieldsJson"`
|
||||||
Length float64 `json:"length,omitempty"`
|
|
||||||
Width float64 `json:"width,omitempty"`
|
|
||||||
Height float64 `json:"height,omitempty"`
|
|
||||||
Weight float64 `json:"weight,omitempty"`
|
|
||||||
Shippable bool `json:"shippable,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SnipcartOrder struct {
|
type SnipcartOrder struct {
|
||||||
@@ -56,7 +52,6 @@ type SnipcartOrder struct {
|
|||||||
Phone string `json:"shippingAddressPhone"`
|
Phone string `json:"shippingAddressPhone"`
|
||||||
TrackingNumber string `json:"trackingNumber"`
|
TrackingNumber string `json:"trackingNumber"`
|
||||||
TrackingUrl string `json:"trackingUrl"`
|
TrackingUrl string `json:"trackingUrl"`
|
||||||
ShippingCost string `json:"shippingFees"`
|
|
||||||
Items []SnipcartItem `json:"items"`
|
Items []SnipcartItem `json:"items"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,26 +67,6 @@ func NewSnipcartProvider(snipcartApiKey string) SnipcartProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SnipcartProvider) GetOrder(token string) (*SnipcartOrder, error) {
|
|
||||||
response, err := helper.Get(orderUri+"/"+token, "Basic", s.AuthBase64, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if response.Status != "200 OK" {
|
|
||||||
return nil, fmt.Errorf("unexpected response received: %s", response.Status)
|
|
||||||
}
|
|
||||||
|
|
||||||
defer response.Body.Close()
|
|
||||||
|
|
||||||
var order SnipcartOrder
|
|
||||||
err = json.NewDecoder(response.Body).Decode(&order)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &order, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SnipcartProvider) GetOrders(queries map[string]string) (*SnipcartOrders, error) {
|
func (s *SnipcartProvider) GetOrders(queries map[string]string) (*SnipcartOrders, error) {
|
||||||
response, err := helper.Get(orderUri, "Basic", s.AuthBase64, queries)
|
response, err := helper.Get(orderUri, "Basic", s.AuthBase64, queries)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -121,10 +96,10 @@ func (s *SnipcartProvider) GetOrdersByStatus(status OrderStatus) (*SnipcartOrder
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *SnipcartOrder) TokenPNGBase64() (string, error) {
|
func (o *SnipcartOrder) TokenPNGBase64() (string, error) {
|
||||||
img, err := qrcode.Encode("order:"+o.Token, qrcode.Medium, 128)
|
img, err := qrcode.Encode(o.Token, qrcode.Medium, 128)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return base64.StdEncoding.EncodeToString(img), nil
|
return "order:" + base64.StdEncoding.EncodeToString(img), nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user