Completed
Pull Request — develop (#284)
by
unknown
01:30
created

BaseCardCheckEvent   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 3
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 0
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
3 15
import six
4 15
from werobot.messages.entries import StringEntry, IntEntry, FloatEntry
5
from werobot.messages.base import WeRoBotMetaClass
6 15
7
8
class EventMetaClass(WeRoBotMetaClass):
9 15
    pass
10 15
11 15
12
@six.add_metaclass(EventMetaClass)
13 15
class WeChatEvent(object):
14 15
    target = StringEntry('ToUserName')
15 15
    source = StringEntry('FromUserName')
16
    time = IntEntry('CreateTime')
17
    message_id = IntEntry('MsgID', 0)
18
19 15
    def __init__(self, message):
20 15
        self.__dict__.update(message)
21
22
23 15
class SimpleEvent(WeChatEvent):
24 15
    key = StringEntry('EventKey')
25 15
26 15
27 15
class TicketEvent(WeChatEvent):
28
    key = StringEntry('EventKey')
29 15
    ticket = StringEntry('Ticket')
30 15
31
32
class SubscribeEvent(TicketEvent):
33 15
    __type__ = 'subscribe_event'
34 15
35 15
36
class UnSubscribeEvent(WeChatEvent):
37
    __type__ = 'unsubscribe_event'
38 15
39 15
40
class ScanEvent(TicketEvent):
41
    __type__ = 'scan_event'
42 15
43 15
44
class ScanCodePushEvent(SimpleEvent):
45
    __type__ = 'scancode_push_event'
46 15
    scan_type = StringEntry('ScanCodeInfo.ScanType')
47 15
    scan_result = StringEntry('ScanCodeInfo.ScanResult')
48
49
50 15
class ScanCodeWaitMsgEvent(ScanCodePushEvent):
51 15
    __type__ = 'scancode_waitmsg_event'
52
    scan_type = StringEntry('ScanCodeInfo.ScanType')
53
    scan_result = StringEntry('ScanCodeInfo.ScanResult')
54 15
55 15
56
class BasePicEvent(SimpleEvent):
57
    count = IntEntry('SendPicsInfo.Count')
58 15
59 15
    def __init__(self, message):
60
        super(BasePicEvent, self).__init__(message)
61
        self.pic_list = list()
62 15
        if self.count > 1:
63 15
            for item in message['SendPicsInfo']['PicList'].pop('item'):
64 15
                self.pic_list.append({'pic_md5_sum': item['PicMd5Sum']})
65 15
        else:
66 15
            self.pic_list.append(
67
                {'pic_md5_sum': message['SendPicsInfo']['PicList'].pop('item')['PicMd5Sum']}
68
            )
69 15
70 15
71
class PicSysphotoEvent(BasePicEvent):
72
    __type__ = 'pic_sysphoto_event'
73
74
75
class PicPhotoOrAlbumEvent(BasePicEvent):
76
    __type__ = 'pic_photo_or_album_event'
77
78
79
class PicWeixinEvent(BasePicEvent):
80
    __type__ = 'pic_weixin_event'
81
82
83
class LocationSelectEvent(SimpleEvent):
84
    __type__ = 'location_select_event'
85
    location_x = StringEntry('SendLocationInfo.Location_X')
86
    location_y = StringEntry('SendLocationInfo.Location_Y')
87
    scale = StringEntry('SendLocationInfo.Scale')
88
    label = StringEntry('SendLocationInfo.Label')
89
    poi_name = StringEntry('SendLocationInfo.Poiname')
90
91
92
class ClickEvent(SimpleEvent):
93
    __type__ = 'click_event'
94
95
96
class ViewEvent(SimpleEvent):
97
    __type__ = 'view_event'
98
99
100
class LocationEvent(WeChatEvent):
101
    __type__ = 'location_event'
102
    latitude = FloatEntry('Latitude')
103
    longitude = FloatEntry('Longitude')
104
    precision = FloatEntry('Precision')
105
106
107
class TemplateSendJobFinishEvent(WeChatEvent):
108
    __type__ = 'templatesendjobfinish_event'
109
    status = StringEntry('Status')
110
111
112
class BaseProductEvent(WeChatEvent):
113
    key_standard = StringEntry('KeyStandard')
114
    key_str = StringEntry('KeyStr')
115
    ext_info = StringEntry('ExtInfo')
116
117
118
class UserScanProductEvent(BaseProductEvent):
119
    __type__ = 'user_scan_product_event'
120
    country = StringEntry('Country')
121
    province = StringEntry('Province')
122
    city = StringEntry('City')
123
    sex = IntEntry('Sex')
124
    scene = IntEntry('Scene')
125
126
127
class UserScanProductEnterSessionEvent(BaseProductEvent):
128
    __type__ = 'user_scan_product_enter_session_event'
129
130
131
class UserScanProductAsyncEvent(BaseProductEvent):
132
    __type__ = 'user_scan_product_async_event'
133
    region_code = StringEntry('RegionCode')
134
135
136
class UserScanProductVerifyActionEvent(WeChatEvent):
137
    __type__ = 'user_scan_product_verify_action_event'
138
    key_standard = StringEntry('KeyStandard')
139
    key_str = StringEntry('KeyStr')
140
    result = StringEntry('Result')
141
    reason_msg = StringEntry('ReasonMsg')
142
143
144
class BaseCardCheckEvent(WeChatEvent):
145
    card_id = StringEntry('CardId')
146
    refuse_reason = StringEntry('RefuseReason')
147
148
149
class CardPassCheckEvent(BaseCardCheckEvent):
150
    __type__ = 'card_pass_check_event'
151
152
153
class CardNotPassCheckEvent(BaseCardCheckEvent):
154
    __type__ = 'card_not_pass_check_event'
155
156
157
class BaseCardEvent(WeChatEvent):
158
    card_id = StringEntry('CardId')
159
    user_card_code = StringEntry('UserCardCode')
160
161
162
class UserGetCardEvent(BaseCardEvent):
163
    __type__ = 'user_get_card_event'
164
    is_give_by_friend = IntEntry('IsGiveByFriend')
165
    friend_user_name = StringEntry('FriendUserName')
166
    outer_id = IntEntry('OuterId')
167
    old_user_card_code = StringEntry('OldUserCardCode')
168
    outer_str = StringEntry('OuterStr')
169
    is_restore_member_card = IntEntry('IsRestoreMemberCard')
170
    is_recommend_by_friend = IntEntry('IsRecommendByFriend')
171
172
173
class UserGiftingCardEvent(BaseCardEvent):
174
    __type__ = 'user_gifting_card_event'
175
    is_return_back = IntEntry('IsReturnBack')
176
    friend_user_name = StringEntry('FriendUserName')
177
    is_chat_room = IntEntry('IsChatRoom')
178
179
180
class UserDelCardEvent(BaseCardEvent):
181
    __type__ = 'user_del_card_event'
182
183
184
class UserConsumeCardEvent(BaseCardEvent):
185
    __type__ = 'user_consume_card_event'
186
    consume_source = StringEntry('ConsumeSource')
187
    location_name = StringEntry('LocationName')
188
    staff_open_id = StringEntry('StaffOpenId')
189
    verify_code = StringEntry('VerifyCode')
190
    remark_amount = StringEntry('RemarkAmount')
191
    outer_str = StringEntry('OuterStr')
192
193
194
class UserPayFromPayCellEvent(BaseCardEvent):
195
    __type__ = 'user_pay_from_pay_cell_event'
196
    trans_id = StringEntry('TransId')
197
    location_id = IntEntry('LocationId')
198
    fee = StringEntry('Fee')
199
    original_fee = StringEntry('OriginalFee')
200
201
202
class UserViewCardEvent(BaseCardEvent):
203
    __type__ = 'user_view_card_event'
204
    outer_str = StringEntry('OuterStr')
205
206
207
class UserEnterSessionFromCardEvent(BaseCardEvent):
208
    __type__ = 'user_enter_session_from_card_event'
209
210
211
class UpdateMemberCardEvent(BaseCardEvent):
212
    __type__ = 'update_member_card_event'
213
    modify_bonus = IntEntry('ModifyBonus')
214
    modify_balance = IntEntry('ModifyBalance')
215
216
217
class CardSkuRemindEvent(WeChatEvent):
218
    __type__ = 'card_sku_remind_event'
219
    card_id = StringEntry('CardId')
220
    detail = StringEntry('Detail')
221
222
223
class CardPayOrderEvent(WeChatEvent):
224
    __type__ = 'card_pay_order_event'
225
    order_id = StringEntry('OrderId')
226
    status = StringEntry('Status')
227
    create_order_time = IntEntry('CreateOrderTime')
228
    pay_finish_time = IntEntry('PayFinishTime')
229
    desc = StringEntry('Desc')
230
    free_coin_count = StringEntry('FreeCoinCount')
231
    pay_coin_count = StringEntry('PayCoinCount')
232
    refund_free_coin_count = StringEntry('RefundFreeCoinCount')
233
    refund_pay_coin_count = StringEntry('RefundPayCoinCount')
234
    order_type = StringEntry('OrderType')
235
    memo = StringEntry('Memo')
236
    receipt_info = StringEntry('ReceiptInfo')
237
238
239
class SubmitMembercardUserInfoEvent(BaseCardEvent):
240
    __type__ = 'submit_membercard_user_info_event'
241
242
243
class UnknownEvent(WeChatEvent):
244
    __type__ = 'unknown_event'
245