This repository has been archived by the owner on Jun 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maxim Lebedev
committed
Dec 28, 2016
1 parent
ebc352c
commit ad9acdc
Showing
56 changed files
with
843 additions
and
821 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package hitGox | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"github.com/valyala/fasthttp" | ||
"strconv" | ||
) | ||
|
||
// AcceptTeamInvite accept an invite from teamName. | ||
func (account *Account) AcceptTeamInvite(teamName string, groupID interface{}) (*Status, error) { | ||
var args fasthttp.Args | ||
args.Add("authToken", account.AuthToken) | ||
switch id := groupID.(type) { | ||
case int: | ||
args.Add("group_id", strconv.Itoa(id)) | ||
case string: | ||
args.Add("group_id", id) | ||
default: | ||
return nil, errors.New("groupid can be only as string or int") | ||
} | ||
|
||
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("/team/", teamName, "/", account.UserName)) | ||
resp, err := update(url, &args) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return fixStatus(resp), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package hitGox | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
func GetChatServers() ([]string, error) { | ||
url := fmt.Sprintf(APIEndpoint, "chat/servers") | ||
resp, err := get(url, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var obj = []struct { | ||
ServerIP string `json:"server_ip"` | ||
}{} | ||
json.NewDecoder(bytes.NewReader(resp)).Decode(&obj) | ||
|
||
var servers []string | ||
for i := range obj { | ||
servers = append(servers, obj[i].ServerIP) | ||
} | ||
|
||
return servers, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package hitGox | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"github.com/valyala/fasthttp" | ||
) | ||
|
||
// SubscriptionInfo is about user subscription status. | ||
type SubscriptionInfo struct { | ||
SubID string `json:"sub_id"` | ||
SubDateAdded string `json:"sub_date_added"` | ||
SubDateValid string `json:"sub_date_valid"` | ||
SubPlanID string `json:"sub_plan_id"` | ||
SubPaymentMethod string `json:"sub_payment_method"` | ||
PlanCharge string `json:"plan_charge"` | ||
PlanCurrency string `json:"plan_currency"` | ||
PlanRecurring string `json:"plan_recurring"` | ||
UserName string `json:"user_name"` | ||
UserID string `json:"user_id"` | ||
UserLogo string `json:"user_logo"` | ||
UserLogoSmall string `json:"user_logo_small"` | ||
Cancel string `json:"cancel"` | ||
Benefits []string `json:"benefits"` | ||
Resub bool `json:"resub"` | ||
} | ||
|
||
// CheckSubscriptionInfo retruns subscription information between :channel and :user | ||
func (account *Account) CheckSubscriptionInfo(user string) (*SubscriptionInfo, error) { | ||
var args fasthttp.Args | ||
args.Add("authToken", account.AuthToken) | ||
|
||
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("subscription/", account.UserName, "/", user)) | ||
resp, err := get(url, &args) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var obj SubscriptionInfo | ||
json.NewDecoder(bytes.NewReader(resp)).Decode(&obj) | ||
|
||
return &obj, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package hitGox | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
// CheckSubscriptionStatus rReturns subscription relationship between channel and auth. | ||
func (account *Account) CheckSubscriptionStatus(channel string) (bool, error) { | ||
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("user/subscription/", channel, "/", account.AuthToken)) | ||
resp, err := get(url, nil) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
var obj = struct { | ||
IsSubscriber bool `json:"isSubscriber"` | ||
}{} | ||
json.NewDecoder(bytes.NewReader(resp)).Decode(&obj) | ||
|
||
return obj.IsSubscriber, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package hitGox | ||
|
||
import ( | ||
"fmt" | ||
"github.com/valyala/fasthttp" | ||
) | ||
|
||
// CheckToken checks if the Token is valid. | ||
func (app *OAuthApplication) CheckToken(authToken string) (*Status, error) { | ||
var args fasthttp.Args | ||
args.Add("token", authToken) | ||
|
||
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("auth/valid/", app.Name)) | ||
resp, err := get(url, &args) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return fixStatus(resp), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.