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


class Create(object):
    def __init__(self, host, name=None, imagetype=None, image=None):
        """
        :param host: 域名
        :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/create"
        self.url = self.host + self.path
        self.params = {}
        self.json = {}
        self.response = ""

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

        self.api = UtilsRequest()

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