-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
af4246d
commit 4e7865d
Showing
3 changed files
with
75 additions
and
0 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,27 @@ | ||
package test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
"github.com/HiWay-Media/tiktok-go-sdk/tiktok" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
c, err := GetTikTok() | ||
if err != nil { | ||
t.Fatalf(err.Error()) | ||
} | ||
c.IsDebug() | ||
} | ||
|
||
|
||
func GetTikTok() (tiktok.ITiktok, error) { | ||
clientKey := os.GetEnv("clientKey") | ||
clientSecret := os.GetEnv("clientSecret") | ||
// | ||
c, err := tiktok.NewTikTok(clientKey, clientSecret, false) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return c, 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,44 @@ | ||
package tiktok | ||
|
||
|
||
|
||
func (o *tiktok) HealthCheck() error { | ||
resp, err := o.restyPost("/", nil) | ||
if err != nil { | ||
return err | ||
} | ||
if resp.IsError() { | ||
return fmt.Errorf("healthcheck error") | ||
Check failure on line 11 in tiktok/resty.go GitHub Actions / build (1.19.x)
Check failure on line 11 in tiktok/resty.go GitHub Actions / build (1.20.x)
|
||
} | ||
return nil | ||
} | ||
|
||
func (o *tiktok) IsDebug() bool { | ||
return o.debug | ||
} | ||
|
||
// Resty Methods | ||
|
||
func (o *tiktok) restyPost(url string, body interface{}) (*resty.Response, error) { | ||
Check failure on line 22 in tiktok/resty.go GitHub Actions / build (1.19.x)
Check failure on line 22 in tiktok/resty.go GitHub Actions / build (1.20.x)
|
||
resp, err := o.restClient.R(). | ||
SetHeader("Accept", "application/json"). | ||
SetHeader("Content-Type", "application/json"). | ||
SetBody(body). | ||
Post(url) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
return resp, nil | ||
} | ||
|
||
func (o *tiktok) restyGet(url string, queryParams map[string]string) (*resty.Response, error) { | ||
Check failure on line 35 in tiktok/resty.go GitHub Actions / build (1.19.x)
Check failure on line 35 in tiktok/resty.go GitHub Actions / build (1.20.x)
|
||
resp, err := o.restClient.R(). | ||
SetQueryParams(queryParams). | ||
Get(url) | ||
// | ||
if err != nil { | ||
return nil, err | ||
} | ||
return 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