How to use the wechatpy.fields.StringField function in wechatpy

To help you get started, we’ve selected a few wechatpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jxtech / wechatpy / tests / test_fields.py View on Github external
def test_string_field_to_xml(self):
        from wechatpy.fields import StringField

        name = 'Content'
        value = 'test'
        expected = '<{name}>'.format(
            name=name,
            value=value
        )

        field = StringField(name)
        self.assertEqual(expected, field.to_xml(value))
github jxtech / wechatpy / wechatpy / events.py View on Github external
success_order_id = StringField('SuccOrderId')  # 授权成功的订单号
    fail_order_id = StringField('FailOrderId')  # 授权失败的订单号
    app_id = StringField('AppId')  # 用于接收事件推送的公众号的AppId
    auth_source = StringField('Source')  # 授权来源,web表示来自微信内H5,app标识来自app


@register_event('update_invoice_status')
class UpdateInvoiceStatusEvent(BaseEvent):
    """
    发票状态更新事件

    详情请参考
    https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2
    """
    event = 'update_invoice_status'
    status = StringField('Status')  # 发票报销状态
    card_id = StringField('CardId')  # 发票 Card ID
    code = StringField('Code')  # 发票 Code


@register_event('submit_invoice_title')
class SubmitInvoiceTitleEvent(BaseEvent):
    """
    用户提交发票抬头事件

    详情请参考
    https://mp.weixin.qq.com/wiki?id=mp1496554912_vfWU0
    """
    event = 'submit_invoice_title'
    title = StringField('title')  # 抬头
    phone = StringField('phone')  # 联系方式
    tax_no = StringField('tax_no')  # 税号
github jxtech / wechatpy / wechatpy / events.py View on Github external
event = 'user_del_card'
    card_id = StringField('CardId')
    code = StringField('UserCardCode')


@register_event('submit_membercard_user_info')
class SubmitMembercardUserInfo(BaseEvent):
    """
    接收会员信息事件通知

    详情请参阅
    https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025274
    """
    event = 'submit_membercard_user_info'
    card_id = StringField('CardId')
    card_code = StringField('UserCardCode')


@register_event('user_view_card')
class User_View_Card(BaseEvent):
    """
    进入会员卡事件推送

    详情请参阅
    https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025274
    """
    event = 'user_view_card'
    card_id = StringField('CardId')
    card_code = StringField('UserCardCode')


@register_event('user_consume_card')
github jxtech / wechatpy / wechatpy / events.py View on Github external
card_id = StringField('CardId')
    card_code = StringField('UserCardCode')


@register_event('user_consume_card')
class UserConsumeCardEvent(BaseEvent):
    """
    卡券核销事件推送

    详情请参阅
    https://mp.weixin.qq.com/wiki?id=mp1451025274
    """
    event = 'user_consume_card'
    card_id = StringField('CardId')
    code = StringField('UserCardCode')
    consume_source = StringField('ConsumeSource')
    location_id = StringField('LocationId')
    staff = StringField('StaffOpenId')


@register_event('merchant_order')
class MerchantOrderEvent(BaseEvent):
    event = 'merchant_order'
    order_id = StringField('OrderId')
    order_status = IntegerField('OrderStatus')
    product_id = StringField('ProductId')
    sku_info = StringField('SkuInfo')


@register_event('kf_create_session')
class KfCreateSessionEvent(BaseEvent):
    event = 'kf_create_session'
github jxtech / wechatpy / wechatpy / events.py View on Github external
小程序用户进入客服消息
    详情请参阅
    https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/receive.html
    """
    event = 'user_enter_tempsession'
    session_from = StringField('SessionFrom')


@register_event('view_miniprogram')
class ViewMiniProgramEvent(BaseEvent):
    """
    从菜单进入小程序事件
    """
    event = 'view_miniprogram'
    page_path = StringField('EventKey')  # 小程序路径
    menu_id = StringField('MenuId')  # 菜单ID
github JoneXiong / oejia_wx / ext_libs / wechatpy / messages.py View on Github external
cls = super(MessageMetaClass, cls).__new__(cls, name, bases, attrs)
        cls._fields = {}

        for name, field in cls.__dict__.items():
            if isinstance(field, BaseField):
                field.add_to_class(cls, name)
        return cls


class BaseMessage(six.with_metaclass(MessageMetaClass)):
    """Base class for all messages and events"""
    type = 'unknown'
    id = IntegerField('MsgId', 0)
    source = StringField('FromUserName')
    target = StringField('ToUserName')
    create_time = DateTimeField('CreateTime')
    time = IntegerField('CreateTime')

    def __init__(self, message):
        self._data = message

    def __repr__(self):
        _repr = "{klass}({msg})".format(
            klass=self.__class__.__name__,
            msg=repr(self._data)
        )
        if six.PY2:
            return to_binary(_repr)
        else:
            return to_text(_repr)
github jxtech / wechatpy / wechatpy / messages.py View on Github external
cls = super(MessageMetaClass, cls).__new__(cls, name, bases, attrs)
        cls._fields = {}

        for name, field in cls.__dict__.items():
            if isinstance(field, BaseField):
                field.add_to_class(cls, name)
        return cls


class BaseMessage(six.with_metaclass(MessageMetaClass)):
    """Base class for all messages and events"""
    type = 'unknown'
    id = IntegerField('MsgId', 0)
    source = StringField('FromUserName')
    target = StringField('ToUserName')
    time = IntegerField('CreateTime', 0)

    def __init__(self, message):
        self._data = message

    def __repr__(self):
        _repr = "{klass}({msg})".format(
            klass=self.__class__.__name__,
            msg=repr(self._data)
        )
        if six.PY2:
            return to_binary(_repr)
        else:
            return to_text(_repr)

    @property
github jxtech / wechatpy / wechatpy / replies.py View on Github external
@register_reply('transfer_customer_service')
class TransferCustomerServiceReply(BaseReply):
    """
    将消息转发到多客服
    详情请参阅
    http://mp.weixin.qq.com/wiki/5/ae230189c9bd07a6b221f48619aeef35.html
    """
    type = 'transfer_customer_service'


@register_reply('device_text')
class DeviceTextReply(BaseReply):
    type = 'device_text'
    device_type = StringField('DeviceType')
    device_id = StringField('DeviceID')
    session_id = StringField('SessionID')
    content = Base64EncodeField('Content')


@register_reply('device_event')
class DeviceEventReply(BaseReply):
    type = 'device_event'
    event = StringField('Event')
    device_type = StringField('DeviceType')
    device_id = StringField('DeviceID')
    session_id = StringField('SessionID')
    content = Base64EncodeField('Content')


@register_reply('device_status')
class DeviceStatusReply(BaseReply):
    type = 'device_status'
github jxtech / wechatpy / wechatpy / events.py View on Github external
event = 'card_not_pass_check'
    card_id = StringField('CardId')


@register_event('user_get_card')
class UserGetCardEvent(BaseEvent):
    """
    领取事件推送

    详情请参阅
    https://mp.weixin.qq.com/wiki?id=mp1451025274
    """
    event = 'user_get_card'
    card_id = StringField('CardId')
    is_given_by_friend = IntegerField('IsGiveByFriend')
    friend = StringField('FriendUserName')
    code = StringField('UserCardCode')
    old_code = StringField('OldUserCardCode')
    outer_id = StringField('OuterId')
    outer_str = StringField('OuterStr')


@register_event('user_del_card')
class UserDeleteCardEvent(BaseEvent):
    """
    卡券删除事件推送

    详情请参阅
    https://mp.weixin.qq.com/wiki?id=mp1451025274
    """
    event = 'user_del_card'
    card_id = StringField('CardId')
github JoneXiong / oejia_wx / ext_libs / wechatpy / messages.py View on Github external
)
        if six.PY2:
            return to_binary(_repr)
        else:
            return to_text(_repr)


@register_message('text')
class TextMessage(BaseMessage):
    """
    文本消息
    详情请参阅
    http://mp.weixin.qq.com/wiki/10/79502792eef98d6e0c6e1739da387346.html
    """
    type = 'text'
    content = StringField('Content')


@register_message('image')
class ImageMessage(BaseMessage):
    """
    图片消息
    详情请参阅
    http://mp.weixin.qq.com/wiki/10/79502792eef98d6e0c6e1739da387346.html
    """
    type = 'image'
    media_id = StringField('MediaId')
    image = StringField('PicUrl')


@register_message('voice')
class VoiceMessage(BaseMessage):