From 76d9eda074a507f29c3b0fec1515af5a92b4b80d Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 20 Jan 2019 20:33:47 +0800 Subject: [PATCH] update --- go.mod | 2 +- go.sum | 2 -- modules/apiact/line.go | 33 +++++++++++++++++++++++++++++++++ modules/apiact/tcgplayer.go | 4 +++- modules/lineobj/lineobj.go | 5 ++++- 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 modules/apiact/line.go diff --git a/go.mod b/go.mod index 71f7402..44df2ed 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/gin-gonic/gin v1.3.0 github.com/golang/protobuf v1.2.0 // indirect github.com/jmoiron/sqlx v1.2.0 - github.com/json-iterator/go v1.1.5 // indirect + github.com/json-iterator/go v1.1.5 github.com/lib/pq v1.0.0 github.com/mattn/go-isatty v0.0.4 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect diff --git a/go.sum b/go.sum index e1d98f9..0e1ac3c 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -git.trj.tw/golang/utils v0.0.0-20181219032659-b1a8bce04189 h1:KHFlWRVFd5NIsnnFSy090+k6kT7KRotxUPTsho6F9lk= -git.trj.tw/golang/utils v0.0.0-20181219032659-b1a8bce04189/go.mod h1:yE+qbsUsijCTdwsaQRkPT1CXYk7ftMzXsCaaYx/0QI0= git.trj.tw/golang/utils v0.0.0-20190116070516-b266ebeb2d82 h1:to19C8t9z6z4b1EMnMm8JIB4qDBCkBjEAhHH5yopSZ0= git.trj.tw/golang/utils v0.0.0-20190116070516-b266ebeb2d82/go.mod h1:yE+qbsUsijCTdwsaQRkPT1CXYk7ftMzXsCaaYx/0QI0= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/modules/apiact/line.go b/modules/apiact/line.go new file mode 100644 index 0000000..c78f9f2 --- /dev/null +++ b/modules/apiact/line.go @@ -0,0 +1,33 @@ +package apiact + +import "net/url" + +// Line - +type Line struct { + URL string + APIVersion string + AccessToken string +} + +// NewLineApi - +func NewLineApi(apiVersion string) (line *Line, err error) { + if len(apiVersion) == 0 { + apiVersion = "v2" + } + line = &Line{} + line.URL = "https://api.line.me" + line.APIVersion = apiVersion + return +} + +func (p *Line) getAPIURL(urlPath string) (apiURL string, err error) { + u, err := url.Parse(p.URL) + if err != nil { + return "", err + } + u, err = u.Parse("/v2") + if err != nil { + return "", err + } + return +} diff --git a/modules/apiact/tcgplayer.go b/modules/apiact/tcgplayer.go index 0d10f09..6b98aec 100644 --- a/modules/apiact/tcgplayer.go +++ b/modules/apiact/tcgplayer.go @@ -1,7 +1,6 @@ package apiact import ( - "encoding/json" "errors" "fmt" "io/ioutil" @@ -13,8 +12,11 @@ import ( "time" "git.trj.tw/golang/mtgbot/modules/config" + jsoniter "github.com/json-iterator/go" ) +var json = jsoniter.ConfigCompatibleWithStandardLibrary + // TCGPlayer - type TCGPlayer struct { URL string diff --git a/modules/lineobj/lineobj.go b/modules/lineobj/lineobj.go index 9f55e19..01eb8d0 100644 --- a/modules/lineobj/lineobj.go +++ b/modules/lineobj/lineobj.go @@ -1,10 +1,13 @@ package lineobj import ( - "encoding/json" "fmt" + + jsoniter "github.com/json-iterator/go" ) +var json = jsoniter.ConfigCompatibleWithStandardLibrary + // SourceObject - type SourceObject struct { Type string `json:"type" cc:"type"`