From 20366f869beaa6b3332b2fe49d20cf01f5082a5d Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 28 Jan 2017 02:38:38 +0100 Subject: added simple Function to remove carts diff --git a/rhimport/core.go b/rhimport/core.go index 25a4090..1b2423b 100644 --- a/rhimport/core.go +++ b/rhimport/core.go @@ -28,6 +28,7 @@ import ( "fmt" "io/ioutil" "log" + "net/http" "os" "path" @@ -321,3 +322,21 @@ func (ctx *Context) reportProgress(step int, stepName string, current, total flo func (ctx *Context) isCanceled() bool { return ctx.Cancel != nil && len(ctx.Cancel) > 0 } + +func RemoveCart(cart uint, rdxportEndpoint, username, password string) (err error) { + conf := &Config{} + conf.RDXportEndpoint = rdxportEndpoint + ctx := NewContext(conf, nil, nil, nil) + ctx.Cart = cart + ctx.UserName = username + ctx.Password = password + + res := &Result{ResponseCode: http.StatusOK} + if err = removeCart(ctx, res); err != nil { + return err + } + if res.ResponseCode != http.StatusOK { + return fmt.Errorf("Error removing cart %d: %s", cart, res.ErrorString) + } + return nil +} -- cgit v0.10.2