This commit is contained in:
scheibling
2025-04-08 19:24:11 +02:00
commit 30fb57f4f7
92 changed files with 6196 additions and 0 deletions

36
shipping_method.go Normal file
View File

@@ -0,0 +1,36 @@
package woogo
import (
"fmt"
"git.cloudyne.io/go/woogo/entity"
jsoniter "github.com/json-iterator/go"
)
type shippingMethodService service
// All list all shipping methods
func (s shippingMethodService) All() (items []entity.ShippingMethod, err error) {
resp, err := s.httpClient.R().Get("/shipping_methods")
if err != nil {
return
}
if resp.IsSuccess() {
err = jsoniter.Unmarshal(resp.Body(), &items)
}
return
}
// One retrieve a shipping method
func (s shippingMethodService) One(id int) (item entity.ShippingMethod, err error) {
resp, err := s.httpClient.R().Get(fmt.Sprintf("/shipping_methods/%d", id))
if err != nil {
return
}
if resp.IsSuccess() {
err = jsoniter.Unmarshal(resp.Body(), &item)
}
return
}