# 证书

# 证书列表

# 接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/v1/certificates

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('certificates');

# 响应document

# 200 OK 状态码
{
    "data": [
        {
            "type": "certificate",
            "id": 1,
            "attributes": {
                "title": "证书标题XXX",
                "code_fixed": "LEXIANG",
                "code_weight": 5,
                "total_num": 1000,
                "period": 0,
                "created_at": "2020-06-10 19:50:40",
                "updated_at": "2020-06-29 09:56:52",
                "preview": "https://lexiangla.com/assets/977ddbbcab1011eaa04f6a8434ce557c",
                "valid_num": 998
            },
            "relationships": {
                "owner": {
                    "data": {
                        "type": "staff",
                        "id": "ThreeZhang"
                    }
                }
            }
        }
    ],
    "links": {
        "first": "https://lxapi.lexiangla.com/cgi-bin/v1/certificates?page=1",
        "last": "https://lxapi.lexiangla.com/cgi-bin/v1/certificates?page=10",
        "prev": null,
        "next": "https://lxapi.lexiangla.com/cgi-bin/v1/certificates?page=2"
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 10,
        "path": "https://lxapi.lexiangla.com/cgi-bin/v1/certificates",
        "per_page": 20,
        "to": 20,
        "total": 184
    },
    "included": [
        {
            "type": "staff",
            "id": "ThreeZhang",
            "attributes": {
                "name": "ThreeZhang",
                "english_name": null,
                "organization": "乐享平台中心"
            }
        }
    ]
}

# 参数说明:

参数 说明
title 证书标题
code_fixed 证书固定编号
code_weight 证书编号位数
total_num 证书颁发总数
valid_num 证书有效数量
period 证书有效期
preview 证书预览图

# 证书颁发详情

# 接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/v1/certificates/{CertificateID}/rewards

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('certificates/10/rewards');

# 响应document

# 200 OK 状态码
{
    "data": [
        {
            "type": "certificate_reward",
            "id": "c1fd844ec4c211e99cf30a58ac1304e4",
            "attributes": {
                "cer_id": 10,
                "title": "2019十佳销售精英",
                "code": "LEXIANG1000001",
                "image": "https://lexiangla.com/assets/c34d4a46c4c211e9bde60a58ac1304e4",
                "created_by": "ThreeZhang",
                "deleted_at": null,
                "created_at": "2019-08-22 17:53:56",
                "updated_at": "2019-08-22 17:53:59",
                "status": "有效",
                "expired_at": "2024-04-22",
                "source_text": "管理后台"
            },
            "relationships": {
                "owner": {
                    "data": {
                        "type": "staff",
                        "id": "ThreeZhang"
                    }
                }
            }
        }
    ],
    "links": {
        "first": "https://lxapi.lexiangla.com/cgi-bin/v1/certificates/10/rewards?page=1",
        "last": "https://lxapi.lexiangla.com/cgi-bin/v1/certificates/10/rewards?page=155",
        "prev": null,
        "next": "https://lxapi.lexiangla.com/cgi-bin/v1/certificates/10/rewards?page=2"
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 155,
        "path": "https://lxapi.lexiangla.com/cgi-bin/v1/certificates/10/rewards",
        "per_page": 20,
        "to": 20,
        "total": 3095
    },
    "included": [
        {
            "type": "staff",
            "id": "ThreeZhang",
            "attributes": {
                "name": "ThreeZhang",
                "english_name": null,
                "organization": "开发组 "
            }
        }
    ]
}

# 参数说明:

参数 说明
title 证书标题
cer_id 证书ID
code 证书完整编号
image 证书图片
status 证书状态
expired_at 证书有效期
source 证书颁发来源 admin:管理后台 class:课堂应用 learning:学习地图应用 exam:考试应用
source_text 证书颁发来源中文标识

# 证书颁发

# 接口调用说明:

POST https://lxapi.lexiangla.com/cgi-bin/v1/certificates/{CertificateID}/rewards

# 请求document

{
    "data": {
        "type": "certificate_reward",
        "attributes": {
            "is_notify": true
        },
        "relationships":{
            "recipient":{
                "data":{
                    "type":"staff",
                    "id":"ThreeZhang"
                }
            }
        }
    }
}

# 参数说明:

参数 是否必须 默认值 说明
CertificateID 资源对象类型为 certificate_reward 的资源对象 ID,即证书模板的 ID
type 资源对象类型,必须为 certificate_reward,表示问题
certificate_reward.is_notify false 是否发送通知; true 是 false 否
certificate_reward.recipient 关联的资源对象,类型为staff,表示被颁发证书的员工

# SDK封装方法使用示例:

$attributes = [
    "is_notify" => true,
    "staff_id" => 'ThreeZhang',
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->postCertificateReward(StaffID, CertificateID, $attributes);

# 响应document

# 204 No Content 状态码

证书颁发是异步任务,接口调用成功会立即返回 204 状态码,没有具体响应内容。

# 证书收回

# 接口调用说明:

DELETE https://lxapi.lexiangla.com/cgi-bin/v1/certificates/{CertificateID}/rewards?code={code}

# 参数说明:

参数 是否必须 默认值 说明
CertificateID 资源对象类型为 certificate_reward 的资源对象 ID,即证书模板的 ID
code 颁发证书的编号

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->deleteCertificateReward(StaffID, CertificateID, '51Npuf');

# 响应document

# 204 No Content 状态码

接口调用成功会立即返回 204 状态码,没有具体响应内容。