Skip to content
This repository was archived by the owner on Jun 8, 2018. It is now read-only.

Commit adb5f32

Browse files
author
Maxim Lebedev
committed
👥 Massive update of chat features
chipzel - Disco Descent (1-1 Remix)
1 parent e9e9cdd commit adb5f32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1783
-313
lines changed

AcceptTeamInvite.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
package hitGox
22

33
import (
4-
"errors"
54
"fmt"
6-
"github.com/valyala/fasthttp"
75
"strconv"
6+
7+
just "github.com/toby3d/hitGox/tools"
8+
f "github.com/valyala/fasthttp"
89
)
910

1011
// AcceptTeamInvite accept an invite from teamName.
11-
func (account *Account) AcceptTeamInvite(teamName string, groupID interface{}) (*Status, error) {
12-
var args fasthttp.Args
12+
func (account *Account) AcceptTeamInvite(teamName string, groupID interface{}) (*just.Status, error) {
13+
var args f.Args
1314
args.Add("authToken", account.AuthToken)
1415
switch id := groupID.(type) {
1516
case int:
1617
args.Add("group_id", strconv.Itoa(id))
1718
case string:
1819
args.Add("group_id", id)
1920
default:
20-
return nil, errors.New("groupid can be only as string or int")
21+
return nil, fmt.Errorf("groupid can be only as string or int")
2122
}
2223

23-
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("/team/", teamName, "/", account.UserName))
24-
resp, err := update(url, &args)
24+
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("team/", teamName, "/", account.UserName))
25+
resp, err := just.UPDATE(url, &args)
2526
if err != nil {
2627
return nil, err
2728
}
2829

29-
return fixStatus(resp), nil
30+
return just.FixStatus(resp), nil
3031
}

ChatConnection.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

ChatSettings.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"github.com/valyala/fasthttp"
7+
8+
just "github.com/toby3d/hitGox/tools"
9+
f "github.com/valyala/fasthttp"
810
)
911

1012
// ChatSettings containing information about channel chat.
@@ -19,11 +21,11 @@ type ChatSettings struct {
1921
//
2022
// Moderators and Editors can view this API.
2123
func (account *Account) GetChatSettings(channel string) (*ChatSettings, error) {
22-
var args fasthttp.Args
24+
var args f.Args
2325
args.Add("authToken", account.AuthToken)
2426

2527
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("chat/settings/", channel))
26-
resp, err := get(url, &args)
28+
resp, err := just.GET(url, &args)
2729
if err != nil {
2830
return nil, err
2931
}

CheckFollowingStatus.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"github.com/valyala/fasthttp"
7+
8+
just "github.com/toby3d/hitGox/tools"
9+
f "github.com/valyala/fasthttp"
810
)
911

1012
// FollowingStatus is about follower relationship.
@@ -18,11 +20,11 @@ type FollowingStatus struct {
1820

1921
// CheckFollowingStatus returns follower relationship from userName to channel.
2022
func CheckFollowingStatus(channel string, userName string) (*FollowingStatus, error) {
21-
var args fasthttp.Args
23+
var args f.Args
2224
args.Add("user_name", userName)
2325

2426
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("following/user/", channel))
25-
resp, err := get(url, &args)
27+
resp, err := just.GET(url, &args)
2628
if err != nil {
2729
return nil, err
2830
}

CheckSubscriptionInfo.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"github.com/valyala/fasthttp"
7+
8+
just "github.com/toby3d/hitGox/tools"
9+
f "github.com/valyala/fasthttp"
810
)
911

1012
// SubscriptionInfo is about user subscription status.
@@ -28,11 +30,11 @@ type SubscriptionInfo struct {
2830

2931
// CheckSubscriptionInfo retruns subscription information between :channel and :user
3032
func (account *Account) CheckSubscriptionInfo(user string) (*SubscriptionInfo, error) {
31-
var args fasthttp.Args
33+
var args f.Args
3234
args.Add("authToken", account.AuthToken)
3335

3436
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("subscription/", account.UserName, "/", user))
35-
resp, err := get(url, &args)
37+
resp, err := just.GET(url, &args)
3638
if err != nil {
3739
return nil, err
3840
}

CheckSubscriptionStatus.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7+
8+
just "github.com/toby3d/hitGox/tools"
79
)
810

9-
// CheckSubscriptionStatus rReturns subscription relationship between channel and auth.
11+
// CheckSubscriptionStatus returns subscription relationship between channel and auth.
1012
func (account *Account) CheckSubscriptionStatus(channel string) (bool, error) {
1113
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("user/subscription/", channel, "/", account.AuthToken))
12-
resp, err := get(url, nil)
14+
resp, err := just.GET(url, nil)
1315
if err != nil {
1416
return false, err
1517
}

CheckToken.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ package hitGox
22

33
import (
44
"fmt"
5-
"github.com/valyala/fasthttp"
5+
6+
just "github.com/toby3d/hitGox/tools"
7+
f "github.com/valyala/fasthttp"
68
)
79

810
// CheckToken checks if the Token is valid.
9-
func (app *OAuthApplication) CheckToken(authToken string) (*Status, error) {
10-
var args fasthttp.Args
11+
func (app *OAuthApplication) CheckToken(authToken string) (*just.Status, error) {
12+
var args f.Args
1113
args.Add("token", authToken)
1214

1315
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("auth/valid/", app.Name))
14-
resp, err := get(url, &args)
16+
resp, err := just.GET(url, &args)
1517
if err != nil {
1618
return nil, err
1719
}
1820

19-
return fixStatus(resp), nil
21+
return just.FixStatus(resp), nil
2022
}

CheckVerifiedEmail.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7+
8+
just "github.com/toby3d/hitGox/tools"
79
)
810

911
// VerifiedStatus is about validated user email address.
@@ -21,7 +23,7 @@ type VerifiedStatus struct {
2123
// CheckVerifiedEmail check if user has validated their email address.
2224
func CheckVerifiedEmail(userName string) (*VerifiedStatus, error) {
2325
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("user/checkVerifiedEmail/", userName))
24-
resp, err := get(url, nil)
26+
resp, err := just.GET(url, nil)
2527
if err != nil {
2628
return nil, err
2729
}

CreateOAuthApplication.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ package hitGox
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/valyala/fasthttp"
6+
7+
just "github.com/toby3d/hitGox/tools"
8+
f "github.com/valyala/fasthttp"
79
)
810

911
// CreateOAuthApplication creates a OAuth Application.
10-
func (account *Account) CreateOAuthApplication(name string, redirectURI string) (*Status, error) {
12+
func (account *Account) CreateOAuthApplication(name string, redirectURI string) (*just.Status, error) {
1113
var changes = struct {
1214
AuthToken string `json:"authToken"`
1315
UserName string `json:"user_name"`
@@ -27,14 +29,14 @@ func (account *Account) CreateOAuthApplication(name string, redirectURI string)
2729
return nil, err
2830
}
2931

30-
var args fasthttp.Args
32+
var args f.Args
3133
args.Add("authToken", account.AuthToken)
3234

3335
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("oauthapps/", account.UserName))
34-
resp, err := post(dst, url, &args)
36+
resp, err := just.POST(dst, url, &args)
3537
if err != nil {
3638
return nil, err
3739
}
3840

39-
return fixStatus(resp), nil
41+
return just.FixStatus(resp), nil
4042
}

CreateTeam.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package hitGox
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/valyala/fasthttp"
6+
7+
just "github.com/toby3d/hitGox/tools"
8+
f "github.com/valyala/fasthttp"
79
)
810

911
// CreateTeam creates a team object.
1012
//
1113
// displayName must match dame except casing.
12-
func (account *Account) CreateTeam(name string, displayName string, text string) (*Status, error) {
14+
func (account *Account) CreateTeam(name string, displayName string, text string) (*just.Status, error) {
1315
var changes = struct {
1416
AuthToken string `json:"authToken"`
1517
GroupUserName string `json:"group_user_name"`
@@ -23,14 +25,14 @@ func (account *Account) CreateTeam(name string, displayName string, text string)
2325
return nil, err
2426
}
2527

26-
var args fasthttp.Args
28+
var args f.Args
2729
args.Add("authToken", account.AuthToken)
2830

2931
url := fmt.Sprintf(APIEndpoint, "team")
30-
resp, err := post(dst, url, &args)
32+
resp, err := just.POST(dst, url, &args)
3133
if err != nil {
3234
return nil, err
3335
}
3436

35-
return fixStatus(resp), nil
37+
return just.FixStatus(resp), nil
3638
}

0 commit comments

Comments
 (0)