mirror of
https://github.com/taigrr/elevenlabs.git
synced 2026-04-02 03:08:57 -07:00
work on user api
This commit is contained in:
@@ -254,7 +254,7 @@ func (c Client) GetHistoryItemList(ctx context.Context) ([]types.HistoryItemList
|
|||||||
if jerr != nil {
|
if jerr != nil {
|
||||||
return []types.HistoryItemList{}, jerr
|
return []types.HistoryItemList{}, jerr
|
||||||
}
|
}
|
||||||
return []types.HistoryItemList{}, err
|
return history.History, err
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return []types.HistoryItemList{}, errors.Join(err, ErrUnspecified)
|
return []types.HistoryItemList{}, errors.Join(err, ErrUnspecified)
|
||||||
|
|||||||
@@ -2,16 +2,57 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
|
"github.com/taigrr/elevenlabs/client/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c Client) GetUserInfoV1UserGet(ctx context.Context) (UserResponseModel, *http.Response, error) {
|
func (c Client) GetUserInfo(ctx context.Context) (types.UserResponseModel, error) {
|
||||||
localVarHttpMethod = strings.ToUpper("Get")
|
url := c.endpoint + "/v1/user"
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/user"
|
client := &http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return types.UserResponseModel{}, err
|
||||||
|
}
|
||||||
|
req.Header.Set("xi-api-key", c.apiKey)
|
||||||
|
req.Header.Set("User-Agent", "github.com/taigrr/elevenlabs")
|
||||||
|
req.Header.Set("accept", "application/json")
|
||||||
|
res, err := client.Do(req)
|
||||||
|
|
||||||
|
switch res.StatusCode {
|
||||||
|
case 422:
|
||||||
|
ve := types.ValidationError{}
|
||||||
|
defer res.Body.Close()
|
||||||
|
jerr := json.NewDecoder(res.Body).Decode(&ve)
|
||||||
|
if jerr != nil {
|
||||||
|
err = errors.Join(err, jerr)
|
||||||
|
} else {
|
||||||
|
err = errors.Join(err, ve)
|
||||||
|
}
|
||||||
|
return types.UserResponseModel{}, err
|
||||||
|
case 401:
|
||||||
|
return types.UserResponseModel{}, ErrUnauthorized
|
||||||
|
case 200:
|
||||||
|
if err != nil {
|
||||||
|
return types.UserResponseModel{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) GetSubscriptionInfo(ctx context.Context) error {
|
var user types.UserResponseModel
|
||||||
localVarHttpMethod = strings.ToUpper("Get")
|
defer res.Body.Close()
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/user/subscription"
|
jerr := json.NewDecoder(res.Body).Decode(&user)
|
||||||
|
if jerr != nil {
|
||||||
|
return types.UserResponseModel{}, jerr
|
||||||
|
}
|
||||||
|
return user, err
|
||||||
|
|
||||||
|
default:
|
||||||
|
return types.UserResponseModel{}, errors.Join(err, ErrUnspecified)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) GetSubscriptionInfo(ctx context.Context) (types.Subscription, error) {
|
||||||
|
info, err := c.GetUserInfo(ctx)
|
||||||
|
return info.Subscription, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,42 +7,42 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c Client) AddVoiceV1VoicesAddPost(ctx context.Context, name string, files []*os.File, description string, labels string, localVarOptionals *VoicesApiAddVoiceV1VoicesAddPostOpts) (AddVoiceResponseModel, *http.Response, error) {
|
func (c Client) CreateVoice(ctx context.Context, name string, files []*os.File, description string, labels string) (AddVoiceResponseModel, *http.Response, error) {
|
||||||
localVarHttpMethod = strings.ToUpper("Post")
|
localVarHttpMethod = strings.ToUpper("Post")
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/voices/add"
|
localVarPath := a.client.cfg.BasePath + "/v1/voices/add"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) DeleteVoiceV1VoicesVoiceIdDelete(ctx context.Context, voiceId string, localVarOptionals *VoicesApiDeleteVoiceV1VoicesVoiceIdDeleteOpts) (Object, *http.Response, error) {
|
func (c Client) DeleteVoice(ctx context.Context, voiceId string) (Object, *http.Response, error) {
|
||||||
localVarHttpMethod = strings.ToUpper("Delete")
|
localVarHttpMethod = strings.ToUpper("Delete")
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/voices/{voice_id}"
|
localVarPath := a.client.cfg.BasePath + "/v1/voices/{voice_id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) EditVoiceSettingsV1VoicesVoiceIdSettingsEditPost(ctx context.Context, body Settings, voiceId string, localVarOptionals *VoicesApiEditVoiceSettingsV1VoicesVoiceIdSettingsEditPostOpts) (Object, *http.Response, error) {
|
func (c Client) EditVoiceSettings(ctx context.Context, body Settings, voiceId string) (Object, *http.Response, error) {
|
||||||
localVarHttpMethod = strings.ToUpper("Post")
|
localVarHttpMethod = strings.ToUpper("Post")
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/voices/{voice_id}/settings/edit"
|
localVarPath := a.client.cfg.BasePath + "/v1/voices/{voice_id}/settings/edit"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) EditVoiceV1VoicesVoiceIdEditPost(ctx context.Context, name string, files []*os.File, description string, labels string, voiceId string, localVarOptionals *VoicesApiEditVoiceV1VoicesVoiceIdEditPostOpts) (Object, *http.Response, error) {
|
func (c Client) EditVoice(ctx context.Context, name string, files []*os.File, description string, labels string, voiceId string) (Object, *http.Response, error) {
|
||||||
localVarHttpMethod = strings.ToUpper("Post")
|
localVarHttpMethod = strings.ToUpper("Post")
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/voices/{voice_id}/edit"
|
localVarPath := a.client.cfg.BasePath + "/v1/voices/{voice_id}/edit"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) GetDefaultVoiceSettingsV1VoicesSettingsDefaultGet(ctx context.Context) (VoiceSettingsResponseModel, *http.Response, error) {
|
func (c Client) DefaultVoiceSettings(ctx context.Context) (VoiceSettingsResponseModel, *http.Response, error) {
|
||||||
localVarHttpMethod = strings.ToUpper("Get")
|
localVarHttpMethod = strings.ToUpper("Get")
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/voices/settings/default"
|
localVarPath := a.client.cfg.BasePath + "/v1/voices/settings/default"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) GetVoiceSettingsV1VoicesVoiceIdSettingsGet(ctx context.Context, voiceId string, localVarOptionals *VoicesApiGetVoiceSettingsV1VoicesVoiceIdSettingsGetOpts) (VoiceSettingsResponseModel, *http.Response, error) {
|
func (c Client) GetVoiceSettings(ctx context.Context, voiceId string) (VoiceSettingsResponseModel, *http.Response, error) {
|
||||||
localVarHttpMethod = strings.ToUpper("Get")
|
localVarHttpMethod = strings.ToUpper("Get")
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/voices/{voice_id}/settings"
|
localVarPath := a.client.cfg.BasePath + "/v1/voices/{voice_id}/settings"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) GetVoiceV1VoicesVoiceIdGet(ctx context.Context, voiceId string, localVarOptionals *VoicesApiGetVoiceV1VoicesVoiceIdGetOpts) (VoiceResponseModel, *http.Response, error) {
|
func (c Client) GetVoice(ctx context.Context, voiceId string) (VoiceResponseModel, *http.Response, error) {
|
||||||
localVarHttpMethod = strings.ToUpper("Get")
|
localVarHttpMethod = strings.ToUpper("Get")
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/voices/{voice_id}"
|
localVarPath := a.client.cfg.BasePath + "/v1/voices/{voice_id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) GetVoicesV1VoicesGet(ctx context.Context, localVarOptionals *VoicesApiGetVoicesV1VoicesGetOpts) (GetVoicesResponseModel, *http.Response, error) {
|
func (c Client) GetVoices(ctx context.Context) (GetVoicesResponseModel, *http.Response, error) {
|
||||||
localVarHttpMethod = strings.ToUpper("Get")
|
localVarHttpMethod = strings.ToUpper("Get")
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/voices"
|
localVarPath := a.client.cfg.BasePath + "/v1/voices"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user