这有两个步骤:
-
business-hours-rule
获取调用处理规则API
获取当前标准和自定义规则的列表。
-
更新问候API
具有
type
设置为
HoldMusic
和
answeringRuleId
设置为要更新的id,例如。
营业时间规则
-
multipart/form-data
有单独的弦乐部分。在这种方法中,单独的部分与名称一起发送
类型
,
,和
binary
-
多部分/表单数据
json
发送的有效载荷如下:
{"type": "HoldMusic", "answeringRule": { "id": "12345678" }}
-
multipart/mixed
多部分/表单数据
因为它很容易与cURL和许多HTTP客户端等工具一起使用。
package main
import(
"log"
"net/http"
"net/url"
"os"
"github.com/grokify/gotilla/mime/multipartutil"
"github.com/grokify/oauth2more/ringcentral"
)
func main() {
// Get the Client (*http.Client):
client, err = ringcentral.NewClientPassword(
ringcentral.ApplicationCredentials{
ClientID: os.Getenv("RINGCENTRAL_CLIENT_ID"),
ClientSecret: os.Getenv("RINGCENTRAL_CLIENT_SECRET"),
ServerURL: os.Getenv("RINGCENTRAL_SERVER_URL")},
ringcentral.PasswordCredentials{
Username: os.Getenv("RINGCENTRAL_USERNAME"),
Extension: os.Getenv("RINGCENTRAL_EXTENSION"),
Password: os.Getenv("RINGCENTRAL_PASSWORD")})
if err!=nil {
log.Fatal(err)
}
// Create the HTTP Request (*http.Request)
params := url.Values{}
params.Set("type", "HoldMusic")
params.Set("answeringRuleId", "business-hours-rule")
req, err := multipartutil.NewRequest(
http.MethodPost,
"https://platform.ringcenral.com/restapi/v1.0/account/~/extension/~/greeting",
params,
[]multipartutil.FileInfo{
{
MIMEPartName: "binary",
Filepath: "mygreeting.wav",
},
},
)
// Send the request
resp, err = client.Do(req)
if err != nil {
log.Fatal(err)
}
fmt.Printf("STATUS: %v\n", resp.StatusCode)
}