示例#1
0
 def __init__(self):
     super().__init__()
     self.base = BaseUtil()
示例#2
0
class Login(SendPostRequests):
    def __init__(self):
        super().__init__()
        self.base = BaseUtil()

    def get_mi_login_url(self, mi_base_url):
        '''
        定义mi登录的URL
        :return:
        '''
        url = mi_base_url + LOGIN_URL + "?&timeStamp=%s&lang=en" % (
            self.base.getTimeStamp())
        return url

    def get_mi_login_Android_email_password_data(self, email, password):
        '''
         定义mi安卓邮箱密码登录的body
        :param email:
        :param password:
        :return:
        '''
        data = {
            "auth_type": "email_password",
            "auto": False,
            "client_id": "0778a347853545c08d496566e0d0180c",
            "client_secret": "a0b5ca0e003a398fc4793514b0b3f754",
            "device_name": "HUAWEI EVA-AL10",
            "email": email,
            "grant_type": "password",
            "imei": "a000006d937c5f",
            "password": self.base.MD5(password),
            "product_line_id": "4f975dc1a43d4117a6f3eb83b2cbc778",
            "scope": "all"
        }
        return data

    def get_mi_refresh_token_url(self, mi_base_url):
        '''
        定义mi刷新token的URL
        :return:
        '''
        url = mi_base_url + REFRESH_TOKEN_URL + "?&timeStamp=%s&lang=en" % (
            self.base.getTimeStamp())
        return url

    def get_mi_refresh_token_data(self, refresh_token):
        '''
         定义mi安卓刷新token的body
        :param access_token:
        :return:
        '''
        data = {
            "client_id": "0778a347853545c08d496566e0d0180c",
            "client_secret": "a0b5ca0e003a398fc4793514b0b3f754",
            "grant_type": "refresh_token",
            "refresh_token": refresh_token,
            "scope": "all"
        }
        return data

    def get_mi_login_auth_data(self):
        '''
         定义mi安卓鉴权登录的body
        :return:
        '''
        data = {
            "client_id": "0778a347853545c08d496566e0d0180c",
            "client_secret": "a0b5ca0e003a398fc4793514b0b3f754",
            "grant_type": "client_credentials",
            "scope": "all"
        }
        return data

    def get_iot_login_url(self, iot_base_url):
        '''
        定义iot登录的URL
        :return:
        '''
        url = iot_base_url + LOGIN_URL + "?&timeStamp=%s&lang=en" % (
            self.base.getTimeStamp())
        return url

    def get_iot_login_data(self, station):
        '''
         定义iot的body
        :param station:
        :return:
        '''
        data = {
            "client_id": "9c33e08830c243c597246c71e3c2f458",
            "client_secret": "237e61fdc48a46908736c499685e9f34",
            "scope": "all",
            "grant_type": "password",
            "sn": station,
            "auth_type": "sn_password"
        }
        return data
示例#3
0
class Station(SendPostRequests):
    def __init__(self):
        super().__init__()
        self.base = BaseUtil()

    def get_check_bind_status_url(self, access_token):
        '''
        定义校验基站绑定状态的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + CHECK_IN_BIND_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_check_bind_status_data(self, stationSn):
        '''
        定义校验基站绑定状态的body
        :param stationSn:
        :return:
        '''
        data = {"stationSn": stationSn}
        return data

    # def get_station_login_url(self):
    #     '''
    #     定义基站登录URL
    #     :return:
    #     '''
    #     url = "https://iot-api-test.sunvalleycloud.com/oauth/login"
    #     return url
    #
    # def get_station_login_data(self,stationSn):
    #     '''
    #     定义基站登录body
    #     :param stationSn:
    #     :return:
    #     '''
    #     data = {
    #             "client_id": "9c33e08830c243c597246c71e3c2f458",
    #             "client_secret": "237e61fdc48a46908736c499685e9f34",
    #             "scope": "all",
    #             "grant_type": "password",
    #             "sn": stationSn,
    #             "auth_type": "sn_password"
    #             }
    #     return data

    def get_lock_url(self, access_token):
        '''
        定义基站进入配对模式【基站】的URL
        :param access_token:
        :return:
        '''
        url = "https://iot-api-test.sunvalleycloud.com" + LOCK_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_lock_data(self):
        '''
        定义基站进入配对模式【基站】的data
        :return:
        '''
        data = {}
        return data

    def get_add_url(self, access_token):
        '''
        定义添加基站的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + ADD_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_add_data(self, stationSn):
        '''
         定义添加基站的body
        :param stationSn:
        :return:
        '''
        data = {"stationName": "", "stationSn": stationSn}
        return data

    def get_remove_url(self, access_token):
        '''
        定义移除基站的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + REMOVE_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_remove_data(self, stationSn):
        '''
         定义移除基站的body
        :param stationSn:
        :return:
        '''
        data = {"stationSn": stationSn}
        return data

    def get_set_url(self, access_token):
        '''
        定义设置基站的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + SET_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_set_data(self, stationSn, stationName):
        '''
         定义设置基站的body
        :param stationSn:
        :return:
        '''
        data = {"stationSn": stationSn, "stationName": stationName}
        return data

    def get_report_status_url(self, access_token):
        '''
        定义上报状态【基站】的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + REPORT_STATUS_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_report_status_data(self):
        '''
         定义上报状态【基站】的body
        :param stationSn:
        :return:
        '''
        data = {
            "stationStatusObject": {
                "xxxxxx": "xxxxxx",
                "yyyyyy": "yyyyyy"
            },
            "cameraStatusObjectList": [{
                "cameraSn": "P020101000101020000000001",
                "powerLever": 66
            }]
        }

        return data

    def get_report_attr_url(self, access_token):
        '''
        定义上报属性【基站】的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + REPORT_ATTR_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_report_attr_data(self):
        '''
         定义上报属性【基站】的body
        :param stationSn:
        :return:
        '''
        data = {
            "stationAttrObject": {
                "aaaaaa": "mock1",
                "bbbbbb": "mock"
            },
            "cameraAttrObject": {
                "cameraSn": "P020101000101020000000001",
                "xxxxxx": "mock1",
                "yyyyyy": "mock"
            }
        }
        return data

    def get_report_monitor_url(self, access_token):
        '''
        定义上报布防【基站】的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + REPORT_MONITOR_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_report_monitor_data(self):
        '''
         定义上报布防【基站】的body
        :param stationSn:
        :return:
        '''
        data = {
            "cameraMonitorObject": [{
                "cameraSn":
                "P020101000101020000000001",
                "arminglist": [{
                    "days": "0123456",
                    "endtime": "235959",
                    "starttime": "000000"
                }, {
                    "days": "0246",
                    "endtime": "020000",
                    "starttime": "013000"
                }],
                "channel":
                1,
                "type":
                2
            }]
        }
        return data
示例#4
0
class Camera(SendPostRequests):
    def __init__(self):
        super().__init__()
        self.base = BaseUtil()

    def get_check_bind_status_url(self, access_token):
        '''
        定义校验摄像头绑定状态的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + CHECK_BIND_STATUS + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_check_data(self, cameraSn, stationSn):
        '''
        定义校验摄像头绑定状态的body
        :param stationSn:
        :return:
        '''
        data = {"cameraSn": cameraSn, "stationSn": stationSn, "channel": 0}
        return data

    def get_add_blind_url(self, access_token):
        '''
        定义盲配添加摄像头【基站】的URL
        :param access_token:
        :return:
        '''
        url = "https://iot-api-test.sunvalleycloud.com" + ADD_BIND_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_add_blind_data(self, cameraSn):
        '''
        定义盲配添加摄像头【基站】的data
        :return:
        '''
        data = {"cameraSn": cameraSn, "cameraName": "", "channel": 0}
        return data

    def get_add_url(self, access_token):
        '''
        定义正常添加摄像头【基站】的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + ADD_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_add_data(self, cameraSn):
        '''
         定义正常添加摄像头【基站】的body
        :param cameraSn:
        :return:
        '''
        data = {"cameraSn": cameraSn, "cameraName": "", "channel": 0}
        return data

    def get_remove_url(self, access_token):
        '''
        定义移除摄像头的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + REMOVE_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_remove_data(self, cameraSn):
        '''
         定义移除摄像头的body
        :param cameraSn:
        :return:
        '''
        data = {"cameraSn": cameraSn}
        return data

    def get_set_url(self, access_token):
        '''
        定义设置摄像头的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + SET_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_set_data(self, cameraSn, shareFlag, cameraName, voiceSwitch,
                     mailSwitch, pushSwitch):
        '''
         定义设置摄像头的body
        :param cameraSn:
        :return:
        '''
        data = {
            "cameraSn": cameraSn,
            "shareFlag": shareFlag,
            "cameraName": cameraName,
            "voiceSwitch": voiceSwitch,
            "mailSwitch": mailSwitch,
            "pushSwitch": pushSwitch
        }
        return data

    def get_list_for_station_url(self, access_token):
        '''
        定义查询摄像头列表【基站】的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + LIST_FOR_STATION_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_list_for_station_data(self):
        '''
         定义查询摄像头列表【基站】的body
        :return:
        '''
        data = {}
        return data

    def get_list_for_index_url(self, access_token):
        '''
        定义查询摄像头列表-首页的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + LIST_FOR_INDEX_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_list_for_index_data(self):
        '''
         定义查询摄像头列表-首页的body
        :return:
        '''
        data = {}
        return data

    def get_list_for_mgt_url(self, access_token):
        '''
        定义查询摄像头列表-管理的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + LIST_FOR_MGT_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_list_for_mgt_data(self):
        '''
         定义查询摄像头列表-管理的body
        :return:
        '''
        data = {}
        return data

    def get_list_for_my_devices_url(self, access_token):
        '''
        定义查询摄像头列表-我的设备的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + LIST_FOR_MY_DEVICES_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_list_for_my_devices_data(self):
        '''
         定义查询摄像头列表-我的设备的body
        :return:
        '''
        data = {}
        return data

    def get_list_for_share_url(self, access_token):
        '''
        定义查询摄像头列表-分享的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + LIST_FOR_SHARE_URL + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_list_for_share_data(self, receiverId=None):
        '''
         定义查询摄像头列表-分享的body
        :return:
        '''
        data = {"receiverId": receiverId}
        return data

    def get_list_sn_status_url(self, access_token):
        '''
        定义查询设备状态的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + LIST_SN_STATUS + "?&access_token=%s&timeStamp=%s&lang=en" % (
            access_token, self.base.getTimeStamp())
        return url

    def get_list_sn_status_data(self, sn):
        '''
         定义查询设备状态的body
        :return:
        '''
        data = {"sn": sn}
        return data
示例#5
0
class Register(SendPostRequests):
    def __init__(self):
        super().__init__()
        self.base = BaseUtil()

    def get_login_auth_url(self, mi_base_url):
        '''
        定义鉴权登录的URL
        :param timestamp:
        :return:
        '''
        url = mi_base_url + REGISTER_AUTH_URL + "?&timeStamp=%s&lang=en" % (
            self.base.getTimeStamp())
        return url

    def get_login_auth_data(self):
        '''
        定义鉴权登录的body
        :return:
        '''
        data = {
            "client_id": "0778a347853545c08d496566e0d0180c",
            "client_secret": "a0b5ca0e003a398fc4793514b0b3f754",
            "grant_type": "client_credentials",
            "scope": "all"
        }
        return data

    def get_email_verify_url(self, access_token):
        '''
        定义邮箱校验接口的URL
        :param timestamp:
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + REGISTER_EMAIL_VERIFY + "?&timeStamp=%s&lang=en&access_token=%s" % (
            self.base.getTimeStamp(), access_token)
        return url

    def get_email_verify_data(self, email):
        '''
        定义邮箱校验接口的body
        :param email:
        :return:
        '''
        data = {"email": email}
        return data

    def get_send_code_url(self, access_token):
        '''
        定义邮箱发送验证码的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + REGISTER_SEND_EMAIL_VERIFY_CODE + "?&timeStamp=%s&lang=en&access_token=%s" % (
            self.base.getTimeStamp(), access_token)
        return url

    def get_send_code_data(self, email):
        '''
        定义发送验证码的body
        :param email:
        :return:
        '''
        data = {"email": email}
        return data

    def get_email_passwd_register_url(self, access_token):
        '''
        定义邮箱密码注册的URL
        :param access_token:
        :return:
        '''
        url = "https://mi-api-test.sunvalleycloud.com" + REGISTER_EMAIL_PASSWORD + "?&timeStamp=%s&lang=en&access_token=%s" % (
            self.base.getTimeStamp(), access_token)
        return url

    def get_email_passwd_register_data(self, email, verifyCode):
        '''
        定义邮箱密码注册的body
        :param email:
        :param verifyCode:
        :return:
        '''

        data = {
            "email": email,
            "firstName": "durant",
            "lastName": "zeng",
            "password": "******",
            "productLineId": "4f975dc1a43d4117a6f3eb83b2cbc778",
            "verifyCode": verifyCode
        }
        return data