diff options
author | Christian Pointner <equinox@helsinki.at> | 2017-01-28 01:38:38 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2017-01-28 01:38:38 (GMT) |
commit | 20366f869beaa6b3332b2fe49d20cf01f5082a5d (patch) | |
tree | e600e2f8e780397a15d4cb50e25fec65e6d9599e /rhimport | |
parent | f8b3c8c2ca2a51100c7b7649acf5aa90a47623bc (diff) |
added simple Function to remove carts
Diffstat (limited to 'rhimport')
-rw-r--r-- | rhimport/core.go | 19 |
1 files changed, 19 insertions, 0 deletions
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 +} |