From 2426db0f7625668434fbcc1722cc13a1bdf67e1b Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 11 Dec 2015 02:48:57 +0100 Subject: added RemovCart and AddCut commands diff --git a/src/helsinki.at/rhimport/importer.go b/src/helsinki.at/rhimport/importer.go index c7b1a66..8995717 100644 --- a/src/helsinki.at/rhimport/importer.go +++ b/src/helsinki.at/rhimport/importer.go @@ -137,6 +137,7 @@ func send_post_request(url string, b *bytes.Buffer, contenttype string) (err err return } + func add_cart(ctx *ImportContext) (err error) { var b bytes.Buffer w := multipart.NewWriter(&b) @@ -165,6 +166,47 @@ func add_cart(ctx *ImportContext) (err error) { return send_post_request(ctx.Config.RDXportEndpoint, &b, w.FormDataContentType()) } +func add_cut(ctx *ImportContext) (err error) { + var b bytes.Buffer + w := multipart.NewWriter(&b) + + if err = w.WriteField("COMMAND", "10"); err != nil { + return + } + if err = w.WriteField("LOGIN_NAME", ctx.UserName); err != nil { + return + } + if err = w.WriteField("PASSWORD", ctx.Password); err != nil { + return + } + if err = w.WriteField("CART_NUMBER", fmt.Sprintf("%d", ctx.Cart)); err != nil { + return + } + w.Close() + return send_post_request(ctx.Config.RDXportEndpoint, &b, w.FormDataContentType()) +} + +func remove_cart(ctx *ImportContext) (err error) { + var b bytes.Buffer + w := multipart.NewWriter(&b) + + if err = w.WriteField("COMMAND", "13"); err != nil { + return + } + if err = w.WriteField("LOGIN_NAME", ctx.UserName); err != nil { + return + } + if err = w.WriteField("PASSWORD", ctx.Password); err != nil { + return + } + if err = w.WriteField("CART_NUMBER", fmt.Sprintf("%d", ctx.Cart)); err != nil { + return + } + w.Close() + return send_post_request(ctx.Config.RDXportEndpoint, &b, w.FormDataContentType()) +} + + func import_audio(ctx *ImportContext) (err error) { var b bytes.Buffer w := multipart.NewWriter(&b) -- cgit v0.10.2