提供服务管理功能的类,支持创建、详情、上线、搜索和下线、删除服务。
构造函数
包含代理地址和区块地址信息的配置选项
const providerOption = { proxy: 'http://proxy.example.com', blockAddress: { identifier: 'example-did', privateKey: 'example-private-key' } }const serviceProvider = new ServiceProvider(providerOption) Copy
const providerOption = { proxy: 'http://proxy.example.com', blockAddress: { identifier: 'example-did', privateKey: 'example-private-key' } }const serviceProvider = new ServiceProvider(providerOption)
创建服务
服务元数据对象
返回创建服务的响应体
const serviceMetadata = { did: 'example-did', name: 'example-service', description: 'This is a service' }serviceProvider.create(serviceMetadata) .then(response => console.log(response)) .catch(err => console.error(err)) Copy
const serviceMetadata = { did: 'example-did', name: 'example-service', description: 'This is a service' }serviceProvider.create(serviceMetadata) .then(response => console.log(response)) .catch(err => console.error(err))
根据服务的 DID 和版本号发送删除元数据请求
服务的 DID
服务的版本号
返回删除服务的响应体
服务详情
DetailServiceResponseBody
根据条件和分页参数查询服务列表
当前页码
每页显示的条目数
Optional
搜索条件(部分 SearchServiceCondition 对象)
SearchServiceCondition
返回搜索服务的响应体
const condition = { code: 'example-code', owner: 'example-owner', name: 'example-name' }serviceProvider.search(condition, 1, 10) .then(response => console.log(response)) .catch(err => console.error(err)) Copy
const condition = { code: 'example-code', owner: 'example-owner', name: 'example-name' }serviceProvider.search(condition, 1, 10) .then(response => console.log(response)) .catch(err => console.error(err))
提供服务管理功能的类,支持创建、详情、上线、搜索和下线、删除服务。