-
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
0 parents
commit fcf024a
Showing
17 changed files
with
1,623 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 @@ | ||
.idea |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Birjemin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,65 @@ | ||
## wxgameod-微信小游戏开放数据后台接口 | ||
|
||
[![Build Status](https://travis-ci.com/Birjemin/wxgameod.svg?branch=master)](https://travis-ci.com/Birjemin/wxgameod) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/birjemin/wxgameod)](https://goreportcard.com/report/github.com/birjemin/wxgameod) | ||
[![codecov](https://codecov.io/gh/Birjemin/wxgameod/branch/master/graph/badge.svg)](https://codecov.io/gh/Birjemin/wxgameod) | ||
|
||
|
||
[开发者中心](https://developers.weixin.qq.com/minigame/dev/api-backend/open-api/data/storage.removeUserStorage.html) | ||
|
||
### 引入方式 | ||
``` | ||
go get github.com/birjemin/wxgameod | ||
``` | ||
|
||
### 接口列表 | ||
|
||
- [removeUserStorage](https://developers.weixin.qq.com/minigame/dev/api-backend/open-api/data/storage.removeUserStorage.html) ✅ | ||
- [setUserInteractiveData](https://developers.weixin.qq.com/minigame/dev/api-backend/open-api/data/storage.setUserInteractiveData.html) ✅ | ||
- [setUserStorage](https://developers.weixin.qq.com/minigame/dev/api-backend/open-api/data/storage.setUserStorage.html) ✅ | ||
|
||
### 使用方式 | ||
|
||
- 示例 | ||
|
||
```golang | ||
httpClient := &utils.HTTPClient{ | ||
Client: &http.Client{ | ||
Timeout: 5 * time.Second, | ||
}, | ||
} | ||
var m = SetUserStorage{ | ||
AccessToken: "ACCESS_TOKEN", | ||
SessionKey: "SESSION_KEY", | ||
OpenID: "OPEN_ID", | ||
KvList: "{\"kv_list\":[{\"key\":\"1\",\"value\":\"0\"}]}", | ||
HTTPRequest: httpClient, | ||
} | ||
|
||
if ret, err := m.doSetUserStorage(ts.URL); err != nil { | ||
t.Error(err) | ||
} else { | ||
if ret.ErrCode != 0 { | ||
t.Error(errors.New("msg: " + ret.ErrMsg)) | ||
} | ||
} | ||
``` | ||
|
||
### 测试 | ||
- 测试 | ||
``` | ||
go test | ||
``` | ||
- 格式化代码 | ||
``` | ||
golint | ||
``` | ||
- 覆盖率 | ||
``` | ||
go test -cover | ||
go test -coverprofile=coverage.out | ||
go tool cover -html=coverage.out | ||
``` | ||
### 备注 | ||
无 |
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 @@ | ||
package socialite |
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,41 @@ | ||
package socialite | ||
|
||
type Default struct{} | ||
|
||
// RespToken struct | ||
type RespToken struct { | ||
Code int `json:"code"` | ||
Msg string `json:"msg"` | ||
AccessToken string `json:"access_token"` | ||
ExpiresIn int `json:"expires_in"` | ||
RefreshToken string `json:"refresh_token"` | ||
OpenID string `json:"openid"` | ||
} | ||
|
||
// RespUserInfo user info | ||
type RespUserInfo struct { | ||
Code int `json:"code"` | ||
Msg string `json:"msg"` | ||
OpenID string `json:"open_id"` | ||
Nickname string `json:"nickname"` | ||
Gender int `json:"gender"` | ||
Country string `json:"country"` | ||
Province string `json:"province"` | ||
City string `json:"city"` | ||
Avatar string `json:"avatar"` | ||
} | ||
|
||
// ISocialite interface | ||
type ISocialite interface { | ||
// GetAuthorizeURL get authorize url | ||
GetAuthorizeURL(args string) string | ||
|
||
// Token get token | ||
Token(code string) (*RespToken, error) | ||
|
||
// RefreshToken refresh token | ||
RefreshToken(refreshToken string) (*RespToken, error) | ||
|
||
// GetUserInfo get user info | ||
GetUserInfo(accessToken, openID string) (*RespUserInfo, error) | ||
} |
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,8 @@ | ||
module socialite | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/json-iterator/go v1.1.10 | ||
github.com/stretchr/testify v1.6.1 | ||
) |
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 @@ | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= | ||
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= | ||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= | ||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= | ||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= | ||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= | ||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | ||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= | ||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
Oops, something went wrong.