本文整理汇总了Golang中github.com/135yshr/goracom/config.MakeUrl函数的典型用法代码示例。如果您正苦于以下问题:Golang MakeUrl函数的具体用法?Golang MakeUrl怎么用?Golang MakeUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakeUrl函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Tags
func (self *Client) Tags(imsi string, tags []map[string]string) (*Subscriber, error) {
u := config.MakeUrl("/subscribers/%s/tags", imsi)
body, err := json.Marshal(tags)
if err != nil {
return nil, err
}
return self.put(u, body)
}
开发者ID:Nagitch,项目名称:goracom,代码行数:8,代码来源:subscriber.go
示例2: Register
func (self *Client) Register(imsi string, regsub map[string]string) (*Subscriber, error) {
u := config.MakeUrl("/subscribers/%s/register", imsi)
body, err := json.Marshal(regsub)
if err != nil {
return nil, err
}
return self.post(u, body)
}
开发者ID:Nagitch,项目名称:goracom,代码行数:8,代码来源:subscriber.go
示例3: SetExpiryTime
func (self *Client) SetExpiryTime(imsi string, expiryTime int64) (*Subscriber, error) {
u := config.MakeUrl("/subscribers/%s/set_expiry_time", imsi)
body, err := json.Marshal(map[string]int64{"expiryTime": expiryTime})
if err != nil {
return nil, err
}
return self.post(u, body)
}
开发者ID:Nagitch,项目名称:goracom,代码行数:8,代码来源:subscriber.go
示例4: UpdateSpeedClass
func (self *Client) UpdateSpeedClass(imsi, speed string) (*Subscriber, error) {
u := config.MakeUrl("/subscribers/%s/update_speed_class", imsi)
body, err := json.Marshal(map[string]string{"speedClass": speed})
if err != nil {
return nil, err
}
return self.post(u, body)
}
开发者ID:Nagitch,项目名称:goracom,代码行数:8,代码来源:subscriber.go
示例5: CreateOperator
func (self *Client) CreateOperator(param map[string]string) error {
u := config.MakeUrl("/operators")
body, _ := json.Marshal(param)
c := http.NewClient(self.apiKey, self.token)
if _, err := c.Post(u, body); err != nil {
return err
}
return nil
}
开发者ID:135yshr,项目名称:goracom,代码行数:9,代码来源:operators.go
示例6: reports
func (self *Client) reports(mode, imsi string, from, to int64, period string, v interface{}) error {
url := config.MakeUrl("/stats/%s/subscribers/%s?from=%d&to=%d&period=%s", mode, imsi, from, to, period)
c := http.NewClient(self.ApiKey, self.Token)
data, err := c.Get(url)
if err != nil {
return err
}
if err := json.Unmarshal(data, v); err != nil {
return err
}
return nil
}
开发者ID:135yshr,项目名称:goracom,代码行数:12,代码来源:stats.go
示例7: FindId
func (self *Client) FindId(id string) (*Operator, error) {
u := config.MakeUrl("/operators/%s", id)
c := http.NewClient(self.apiKey, self.token)
data, err := c.Get(u)
if err != nil {
return nil, err
}
s := Operator{}
if err := json.Unmarshal(data, &s); err != nil {
return nil, err
}
return &s, nil
}
开发者ID:135yshr,项目名称:goracom,代码行数:13,代码来源:operators.go
示例8: Sim
func (self *Client) Sim(imsi string) (*Subscriber, error) {
u := config.MakeUrl("/subscribers/%s", imsi)
c := http.NewClient(self.apiKey, self.token)
data, err := c.Get(u)
if err != nil {
return nil, err
}
s := Subscriber{}
if err := json.Unmarshal(data, &s); err != nil {
return nil, err
}
return &s, nil
}
开发者ID:135yshr,项目名称:goracom,代码行数:13,代码来源:subscriber.go
示例9: Find
func (self *Client) Find(q map[string]string) (*Subscribers, error) {
val := url.Values{}
for k, v := range q {
val.Set(k, v)
}
u := config.MakeUrl("/subscribers?%s", val.Encode())
c := http.NewClient(self.apiKey, self.token)
data, err := c.Get(u)
if err != nil {
return nil, err
}
ss := Subscribers{}
if err := json.Unmarshal(data, &ss); err != nil {
return nil, err
}
return &ss, nil
}
开发者ID:135yshr,项目名称:goracom,代码行数:17,代码来源:subscriber.go
示例10: ExportReport
func (self *Client) ExportReport(mode, operatorId string, from, to int64) (string, error) {
url := config.MakeUrl("/stats/%s/operators/%s/export", mode, operatorId)
m := map[string]interface{}{
"period": "month",
"from": from,
"to": to,
}
body, err := json.Marshal(m)
c := http.NewClient(self.ApiKey, self.Token)
data, err := c.Post(url, body)
if err != nil {
return "", err
}
v := make(map[string]string)
if err := json.Unmarshal(data, &v); err != nil {
return "", err
}
return v["url"], nil
}
开发者ID:135yshr,项目名称:goracom,代码行数:19,代码来源:stats.go
示例11: Authenticate
func Authenticate(email, passwd string) (map[string]string, error) {
auth := map[string]interface{}{
"email": email,
"password": passwd,
"tokenTimeoutSeconds": 0,
}
buf, _ := json.Marshal(auth)
body := bytes.NewReader(buf)
url := config.MakeUrl("/auth")
resp, err := http.Post(url, "application/json", body)
if err != nil {
return nil, err
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
if resp.StatusCode != 200 {
return nil, errors.NewError(data)
}
return parseAuthenticate(data)
}
开发者ID:135yshr,项目名称:goracom,代码行数:24,代码来源:auth.go
示例12: Authenticate
func Authenticate(email, passwd string) (map[string]string, error) {
auth := map[string]interface{}{
"email": email,
"password": passwd,
"tokenTimeoutSeconds": 0,
}
buf, err := json.Marshal(auth)
if err != nil {
return nil, err
}
body := bytes.NewReader(buf)
url := config.MakeUrl("/auth")
resp, err := http.Post(url, "application/json", body)
if err != nil {
return nil, err
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
if resp.StatusCode != 200 {
m := map[string]string{}
if err := json.Unmarshal(data, &m); err != nil {
return nil, err
}
return nil, fmt.Errorf("[%s] %s", m["code"], m["message"])
}
ret := make(map[string]string)
if err := json.Unmarshal(data, &ret); err != nil {
return nil, err
}
return ret, nil
}
开发者ID:Nagitch,项目名称:goracom,代码行数:36,代码来源:auth.go
示例13: DeleteTag
func (self *Client) DeleteTag(imsi, tag string) error {
u := config.MakeUrl("/subscribers/%s/tags/%s", imsi, tag)
return self.delete(u)
}
开发者ID:135yshr,项目名称:goracom,代码行数:4,代码来源:subscriber.go
示例14: UnsetExpiryTime
func (self *Client) UnsetExpiryTime(imsi string) (*Subscriber, error) {
u := config.MakeUrl("/subscribers/%s/unset_expiry_time", imsi)
return self.post(u, nil)
}
开发者ID:135yshr,项目名称:goracom,代码行数:4,代码来源:subscriber.go
示例15: DisableTerminate
func (self *Client) DisableTerminate(imsi string) (*Subscriber, error) {
u := config.MakeUrl("/subscribers/%s/disable_termination", imsi)
return self.post(u, nil)
}
开发者ID:135yshr,项目名称:goracom,代码行数:4,代码来源:subscriber.go
示例16: Deactivate
func (self *Client) Deactivate(imsi string) (*Subscriber, error) {
u := config.MakeUrl("/subscribers/%s/deactivate", imsi)
return self.post(u, nil)
}
开发者ID:135yshr,项目名称:goracom,代码行数:4,代码来源:subscriber.go
示例17:
Expect(err).ToNot(BeNil())
})
})
Context("認証が完了していないとき", func() {
handler := func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("X-Soracom-API-Key") != "apiKey" {
err_body := makeErrorCode("SEM0035", "API Token is missing")
http.Error(w, err_body, http.StatusInternalServerError)
return
}
}
BeforeEach(func() {
s = httptest.NewServer(http.HandlerFunc(handler))
config.BaseURL = s.URL
c := NewClient("", "")
sut, err = c.Get(config.MakeUrl("subscribers"))
})
AfterEach(func() {
s.Close()
})
It("エラーが返ってくること", func() {
Expect(err).ToNot(BeNil())
})
It("エラーメッセージ[SEM0035] API Token is missingが返ってくること", func() {
Expect(err.Error()).To(Equal("[SEM0035] API Token is missing"))
})
})
Context("認証が完了していないとき", func() {
handler := func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "exeption message", http.StatusInternalServerError)
}
开发者ID:Nagitch,项目名称:goracom,代码行数:31,代码来源:client_test.go
注:本文中的github.com/135yshr/goracom/config.MakeUrl函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论