forked from revdotcom/revai-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccount.go
35 lines (28 loc) · 809 Bytes
/
account.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package revai
import (
"context"
"fmt"
"net/http"
)
// AccountService provides access to the account related functions
// in the Rev.ai API.
type AccountService service
// Account is the developer's account information
type Account struct {
Email string `json:"email"`
BalanceSeconds int `json:"balance_seconds"`
}
// Get the developer's account information
// https://www.rev.ai/docs#operation/GetAccount
func (s *AccountService) Get(ctx context.Context) (*Account, error) {
urlPath := "/speechtotext/v1/account"
req, err := s.client.newRequest(http.MethodGet, urlPath, nil)
if err != nil {
return nil, fmt.Errorf("failed creating request %w", err)
}
var account Account
if err := s.client.doJSON(ctx, req, &account); err != nil {
return nil, err
}
return &account, nil
}