telnyx-porting-out-go
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
Telnyx Porting Out - Go
Telnyx 号码端口转出 - Go
Installation
安装
bash
go get github.com/team-telnyx/telnyx-gobash
go get github.com/team-telnyx/telnyx-goSetup
设置
go
import (
"context"
"fmt"
"os"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
client := telnyx.NewClient(
option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)All examples below assume is already initialized as shown above.
clientgo
import (
"context"
"fmt"
"os"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
client := telnyx.NewClient(
option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)以下所有示例均假设已按照上述方式完成初始化。
clientList portout requests
列出端口转出请求
Returns the portout requests according to filters
GET /portoutsgo
page, err := client.Portouts.List(context.TODO(), telnyx.PortoutListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)根据筛选条件返回端口转出请求
GET /portoutsgo
page, err := client.Portouts.List(context.TODO(), telnyx.PortoutListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)Get a portout request
获取单个端口转出请求
Returns the portout request based on the ID provided
GET /portouts/{id}go
portout, err := client.Portouts.Get(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", portout.Data)根据提供的ID返回对应的端口转出请求
GET /portouts/{id}go
portout, err := client.Portouts.Get(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", portout.Data)List all comments for a portout request
列出端口转出请求的所有评论
Returns a list of comments for a portout request.
GET /portouts/{id}/commentsgo
comments, err := client.Portouts.Comments.List(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", comments.Data)返回指定端口转出请求的评论列表
GET /portouts/{id}/commentsgo
comments, err := client.Portouts.Comments.List(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", comments.Data)Create a comment on a portout request
为端口转出请求添加评论
Creates a comment on a portout request.
POST /portouts/{id}/commentsOptional: (string)
bodygo
comment, err := client.Portouts.Comments.New(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortoutCommentNewParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", comment.Data)为指定端口转出请求创建一条评论
POST /portouts/{id}/comments可选参数: (字符串)
bodygo
comment, err := client.Portouts.Comments.New(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortoutCommentNewParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", comment.Data)List supporting documents on a portout request
列出端口转出请求的证明文件
List every supporting documents for a portout request.
GET /portouts/{id}/supporting_documentsgo
supportingDocuments, err := client.Portouts.SupportingDocuments.List(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", supportingDocuments.Data)返回指定端口转出请求的所有证明文件
GET /portouts/{id}/supporting_documentsgo
supportingDocuments, err := client.Portouts.SupportingDocuments.List(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", supportingDocuments.Data)Create a list of supporting documents on a portout request
为端口转出请求添加证明文件列表
Creates a list of supporting documents on a portout request.
POST /portouts/{id}/supporting_documentsOptional: (array[object])
documentsgo
supportingDocument, err := client.Portouts.SupportingDocuments.New(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortoutSupportingDocumentNewParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", supportingDocument.Data)为指定端口转出请求创建证明文件列表
POST /portouts/{id}/supporting_documents可选参数: (对象数组)
documentsgo
supportingDocument, err := client.Portouts.SupportingDocuments.New(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortoutSupportingDocumentNewParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", supportingDocument.Data)Update Status
更新状态
Authorize or reject portout request
PATCH /portouts/{id}/{status}reasonOptional: (boolean)
host_messaginggo
response, err := client.Portouts.UpdateStatus(
context.TODO(),
telnyx.PortoutUpdateStatusParamsStatusAuthorized,
telnyx.PortoutUpdateStatusParams{
ID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
Reason: "I do not recognize this transaction",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)批准或拒绝端口转出请求
PATCH /portouts/{id}/{status}reason可选参数: (布尔值)
host_messaginggo
response, err := client.Portouts.UpdateStatus(
context.TODO(),
telnyx.PortoutUpdateStatusParamsStatusAuthorized,
telnyx.PortoutUpdateStatusParams{
ID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
Reason: "I do not recognize this transaction",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)List all port-out events
列出所有端口转出事件
Returns a list of all port-out events.
GET /portouts/eventsgo
page, err := client.Portouts.Events.List(context.TODO(), telnyx.PortoutEventListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)返回所有端口转出事件的列表
GET /portouts/eventsgo
page, err := client.Portouts.Events.List(context.TODO(), telnyx.PortoutEventListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)Show a port-out event
查看单个端口转出事件
Show a specific port-out event.
GET /portouts/events/{id}go
event, err := client.Portouts.Events.Get(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", event.Data)查看指定的端口转出事件详情
GET /portouts/events/{id}go
event, err := client.Portouts.Events.Get(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", event.Data)Republish a port-out event
重新发布端口转出事件
Republish a specific port-out event.
POST /portouts/events/{id}/republishgo
err := client.Portouts.Events.Republish(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}重新发布指定的端口转出事件
POST /portouts/events/{id}/republishgo
err := client.Portouts.Events.Republish(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}List eligible port-out rejection codes for a specific order
列出指定订单的合格端口转出拒绝码
Given a port-out ID, list rejection codes that are eligible for that port-out
GET /portouts/rejections/{portout_id}go
response, err := client.Portouts.ListRejectionCodes(
context.TODO(),
"329d6658-8f93-405d-862f-648776e8afd7",
telnyx.PortoutListRejectionCodesParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)根据端口转出ID,列出该端口转出请求可使用的合格拒绝码
GET /portouts/rejections/{portout_id}go
response, err := client.Portouts.ListRejectionCodes(
context.TODO(),
"329d6658-8f93-405d-862f-648776e8afd7",
telnyx.PortoutListRejectionCodesParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)List port-out related reports
列出端口转出相关报告
List the reports generated about port-out operations.
GET /portouts/reportsgo
page, err := client.Portouts.Reports.List(context.TODO(), telnyx.PortoutReportListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)列出所有端口转出操作生成的报告
GET /portouts/reportsgo
page, err := client.Portouts.Reports.List(context.TODO(), telnyx.PortoutReportListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)Create a port-out related report
生成端口转出相关报告
Generate reports about port-out operations.
POST /portouts/reportsgo
report, err := client.Portouts.Reports.New(context.TODO(), telnyx.PortoutReportNewParams{
Params: telnyx.ExportPortoutsCsvReportParam{
Filters: telnyx.ExportPortoutsCsvReportFiltersParam{},
},
ReportType: telnyx.PortoutReportNewParamsReportTypeExportPortoutsCsv,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", report.Data)生成端口转出操作的相关报告
POST /portouts/reportsgo
report, err := client.Portouts.Reports.New(context.TODO(), telnyx.PortoutReportNewParams{
Params: telnyx.ExportPortoutsCsvReportParam{
Filters: telnyx.ExportPortoutsCsvReportFiltersParam{},
},
ReportType: telnyx.PortoutReportNewParamsReportTypeExportPortoutsCsv,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", report.Data)Retrieve a report
获取报告详情
Retrieve a specific report generated.
GET /portouts/reports/{id}go
report, err := client.Portouts.Reports.Get(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", report.Data)获取指定的已生成报告
GET /portouts/reports/{id}go
report, err := client.Portouts.Reports.Get(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", report.Data)