#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json

from alipay.aop.api.constant.ParamConstants import *
from alipay.aop.api.domain.SignContentParams import SignContentParams


class AlipayCommerceCommonAgreementSignModel(object):

    def __init__(self):
        self._agreement_code = None
        self._biz_date = None
        self._open_id = None
        self._out_sign_no = None
        self._sign_content = None
        self._user_id = None

    @property
    def agreement_code(self):
        return self._agreement_code

    @agreement_code.setter
    def agreement_code(self, value):
        self._agreement_code = value
    @property
    def biz_date(self):
        return self._biz_date

    @biz_date.setter
    def biz_date(self, value):
        self._biz_date = value
    @property
    def open_id(self):
        return self._open_id

    @open_id.setter
    def open_id(self, value):
        self._open_id = value
    @property
    def out_sign_no(self):
        return self._out_sign_no

    @out_sign_no.setter
    def out_sign_no(self, value):
        self._out_sign_no = value
    @property
    def sign_content(self):
        return self._sign_content

    @sign_content.setter
    def sign_content(self, value):
        if isinstance(value, SignContentParams):
            self._sign_content = value
        else:
            self._sign_content = SignContentParams.from_alipay_dict(value)
    @property
    def user_id(self):
        return self._user_id

    @user_id.setter
    def user_id(self, value):
        self._user_id = value


    def to_alipay_dict(self):
        params = dict()
        if self.agreement_code:
            if hasattr(self.agreement_code, 'to_alipay_dict'):
                params['agreement_code'] = self.agreement_code.to_alipay_dict()
            else:
                params['agreement_code'] = self.agreement_code
        if self.biz_date:
            if hasattr(self.biz_date, 'to_alipay_dict'):
                params['biz_date'] = self.biz_date.to_alipay_dict()
            else:
                params['biz_date'] = self.biz_date
        if self.open_id:
            if hasattr(self.open_id, 'to_alipay_dict'):
                params['open_id'] = self.open_id.to_alipay_dict()
            else:
                params['open_id'] = self.open_id
        if self.out_sign_no:
            if hasattr(self.out_sign_no, 'to_alipay_dict'):
                params['out_sign_no'] = self.out_sign_no.to_alipay_dict()
            else:
                params['out_sign_no'] = self.out_sign_no
        if self.sign_content:
            if hasattr(self.sign_content, 'to_alipay_dict'):
                params['sign_content'] = self.sign_content.to_alipay_dict()
            else:
                params['sign_content'] = self.sign_content
        if self.user_id:
            if hasattr(self.user_id, 'to_alipay_dict'):
                params['user_id'] = self.user_id.to_alipay_dict()
            else:
                params['user_id'] = self.user_id
        return params

    @staticmethod
    def from_alipay_dict(d):
        if not d:
            return None
        o = AlipayCommerceCommonAgreementSignModel()
        if 'agreement_code' in d:
            o.agreement_code = d['agreement_code']
        if 'biz_date' in d:
            o.biz_date = d['biz_date']
        if 'open_id' in d:
            o.open_id = d['open_id']
        if 'out_sign_no' in d:
            o.out_sign_no = d['out_sign_no']
        if 'sign_content' in d:
            o.sign_content = d['sign_content']
        if 'user_id' in d:
            o.user_id = d['user_id']
        return o


