reichelt/image.go

20 lines
497 B
Go
Raw Permalink Normal View History

2017-03-12 14:47:59 +01:00
package reichelt
import (
"io"
"strconv"
)
// gets the product image of a reichelt article using the internal Part number
// the reader will return a image/jpg file
2017-03-31 14:43:47 +02:00
// NOTE: the Reader must be closed
2017-03-12 14:47:59 +01:00
func (c *Connection) GetImage(p Part, w, h uint) (io.ReadCloser, error) {
resp, err := c.client.Get("https://www.reichelt.de/artimage/resize_" + strconv.Itoa(int(w)) + "x" + strconv.Itoa(int(h)) + "/" + strconv.Itoa(p.Number))
if err != nil {
return nil, err
}
return resp.Body, nil
}