# -*- coding: utf-8 -*-
# 更新图片
# 作者: 陈磊
# 时间: 2019-10-23
from WorkUtils.UtilsRequest import UtilsRequest
from WorkUtils.UtilsLog import UtilsLog


class Update(object):
    def __init__(self, host, imageid=None, name=None, imagetype=None, image=None):
        """
        :param host: 域名
        :param imageid: 图片ID
        :param name: 图片名称
        :param imagetype: 图片类型
        :param image: 图片Base64字符串
        :return:
        """
        self.log = UtilsLog()
        self.log.info("调用更新图片接口")
        self.log.info(self.__class__)

        self.host = host
        self.headers = {}
        self.path = "/image/update"
        self.url = self.host + self.path
        self.params = {}
        self.json = {}
        self.response = ""

        self.imageid = imageid
        self.name = name
        self.imagetype = imagetype
        self.image = image

        self.api = UtilsRequest()

    def get_response(self):
        self.json = {
            "imageid": self.imageid,
            "name": self.name,
            "imagetype": self.imagetype,
            "image": self.image,
        }
        self.response = self.api.post(url=self.url, json=self.json)
