Add testable request builder (#162)

* Add testable request builder

* improve tests
This commit is contained in:
sashabaranov
2023-03-15 13:16:33 +04:00
committed by GitHub
parent 53d195cf5a
commit c34bc77f1a
13 changed files with 205 additions and 152 deletions

View File

@@ -45,14 +45,8 @@ type ImageResponseDataInner struct {
// CreateImage - API call to create an image. This is the main endpoint of the DALL-E API.
func (c *Client) CreateImage(ctx context.Context, request ImageRequest) (response ImageResponse, err error) {
var reqBytes []byte
reqBytes, err = c.marshaller.marshal(request)
if err != nil {
return
}
urlSuffix := "/images/generations"
req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.fullURL(urlSuffix), bytes.NewBuffer(reqBytes))
req, err := c.requestBuilder.build(ctx, http.MethodPost, c.fullURL(urlSuffix), request)
if err != nil {
return
}