forked from jherman3/zencoder
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccounts.go
64 lines (51 loc) · 1.66 KB
/
accounts.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package zencoder
type AccountDetails struct {
AccountState string `json:"account_state,omitempty"`
Plan string `json:"plan,omitempty"`
MinutesUsed int32 `json:"minutes_used,omitempty"`
MinutesIncluded int32 `json:"minutes_included,omitempty"`
BillingState string `json:"billing_state,omitempty"`
IntegrationMode bool `json:"integration_mode,omitempty"`
}
type CreateAccountRequest struct {
Email string `json:"email,omitempty"`
TermsOfService string `json:"terms_of_service,omitempty"`
Password *string `json:"password,omitempty,omitempty"`
PasswordConfirmation *string `json:"password_confirmation,omitempty,omitempty"`
}
type CreateAccountResponse struct {
ApiKey string `json:"api_key,omitempty"`
Password string `json:"password,omitempty"`
}
// Create an account
func (z *Zencoder) CreateAccount(email, password string) (*CreateAccountResponse, error) {
request := &CreateAccountRequest{
Email: email,
TermsOfService: "1",
}
if len(password) > 0 {
request.Password = &password
request.PasswordConfirmation = &password
}
var result CreateAccountResponse
if err := z.post("account", request, &result); err != nil {
return nil, err
}
return &result, nil
}
// Get Account Details
func (z *Zencoder) GetAccount() (*AccountDetails, error) {
var details AccountDetails
if err := z.getBody("account", &details); err != nil {
return nil, err
}
return &details, nil
}
// Set Integration Mode
func (z *Zencoder) SetIntegrationMode() error {
return z.putNoContent("account/integration")
}
// Set Live Mode
func (z *Zencoder) SetLiveMode() error {
return z.putNoContent("account/live")
}