add webclient with wishlist func
This commit is contained in:
parent
37fad282e6
commit
8510e7fbe0
|
@ -269,3 +269,72 @@ func ExportNewOrders(client *http.Client, lastOrder int) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type paxanWebClient struct {
|
||||||
|
client *http.Client
|
||||||
|
baseUrl string
|
||||||
|
}
|
||||||
|
|
||||||
|
func Connect(user string, password string) (paxanWebClient, error) {
|
||||||
|
var pwc paxanWebClient
|
||||||
|
// New http client with cookie
|
||||||
|
cookieJar, _ := cookiejar.New(nil)
|
||||||
|
pwc.client = &http.Client{
|
||||||
|
Jar: cookieJar,
|
||||||
|
}
|
||||||
|
|
||||||
|
pwc.baseUrl = "https://www.hakopaxan-shop.de/html"
|
||||||
|
|
||||||
|
loginvalues := make(url.Values)
|
||||||
|
loginvalues.Set("performAction", "processLogin")
|
||||||
|
loginvalues.Set("personlogin", user)
|
||||||
|
loginvalues.Set("personpwd", password)
|
||||||
|
loginvalues.Set("firma", "paxan")
|
||||||
|
_, err := pwc.client.PostForm("https://www.hakopaxan-shop.de/html/login.html", loginvalues)
|
||||||
|
if err != nil {
|
||||||
|
return paxanWebClient{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pwc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *paxanWebClient) Disconnect() error {
|
||||||
|
_, err := w.client.Get("https://www.hakopaxan-shop.de/html/logout-performAction-processLogout.html")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *paxanWebClient) selectWishlist(id string) error {
|
||||||
|
_, err := w.client.Get("https://www.hakopaxan-shop.de/html/wishlist-wishlist__switch-" + id + ".html")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *paxanWebClient) AddToWishlist(artnr string, wishlist string) error {
|
||||||
|
//w.getWishList()
|
||||||
|
w.selectWishlist("10")
|
||||||
|
//w.client.PostForm()
|
||||||
|
|
||||||
|
formvalues := make(url.Values)
|
||||||
|
//formvalues.Set("x", "10")
|
||||||
|
//formvalues.Set("y", "8")
|
||||||
|
formvalues.Set("itemId", artnr)
|
||||||
|
formvalues.Set("wishlist_add_position", "true")
|
||||||
|
formvalues.Set("wvarid", artnr)
|
||||||
|
formvalues.Set("qty", "1")
|
||||||
|
formvalues.Set("me", "0")
|
||||||
|
_, err := w.client.PostForm("https://www.hakopaxan-shop.de/html/item.html", formvalues)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
//set to old wishlist
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue