# -*-coding:utf-8-*-
import requests
import io
import json
import string
import time

class Api:
    host = "http://149.129.219.36:9898"
    
    #查询发布记录
    def select_log_info(self,config):
        url = self.host+"/gp/package/info"
        params = {'corpId': config['corpId']}
        result = requests.get(url, params)
        return result
    
    #新 插入发布记录
    def insert_log_v2(self,config):
        url = self.host+"/gp/package/insert_info"
        params = {'corpId': config['corpId'],'pkgName':config['pkgName'],'level':config['level'],\
            'developer':config['developer'],'action':config['action'],'accountSource':config['accountSource'],'pkgType':config['pkgType']}
        result = requests.get(url, params)
        return result

    #旧 插入发布记录
    def insert_log_v1(self,config):
        url = "http://34.92.238.50:5021/refreshGPInfo"
        seconds = int(time.time())
        params = {'corpid': config['corpId'], 'level': config['level'], 'developer': config['developer'], 'pkg_name': config['pkgName'], 'action': config['action'], 'update_time': seconds}
        result = requests.get(url, params)
        return result

    #更新记录
    def update_log(self,config):
        url = self.host+"/gp/package/insert_info"
        params = {'corpId': config['corpId'],'pkgName':config['pkgName'],'level':config['level'],\
            'developer':config['developer'],'action':config['action'],'accountSource':config['accountSource'],'pkgType':config['pkgType']}
        result = requests.get(url, params)
        return result