123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- # coding=utf-8
- from Service.VivoPushService.push_admin.APIConstants import Constants
- class MessageDict(dict):
- def __getattr__(self, item):
- try:
- return self[item]
- except KeyError:
- raise AttributeError(r"'message' object has no attribute %s'" % item)
- def __setattr__(self, key, value):
- self[key] = value
- class PushMessage(object):
- tag_expression={}
- def __init__(self):
- self.__message_dict = MessageDict()
- def or_tags(self,or_tags):
- PushMessage.tag_expression[Constants.http_param_or_tags]=or_tags
- self.__message_dict[Constants.http_param_tag_expression] = PushMessage.tag_expression
- return self
- def and_tags(self,and_tags):
- PushMessage.tag_expression[Constants.http_param_and_tags]=and_tags
- self.__message_dict[Constants.http_param_tag_expression] = PushMessage.tag_expression
- return self
- def not_tags(self,not_tags):
- PushMessage.tag_expression[Constants.http_param_not_tags]=not_tags
- self.__message_dict[Constants.http_param_tag_expression] = PushMessage.tag_expression
- return self
- def segment_name(self, segment_name):
- self.__message_dict[Constants.http_param_segment_name] = segment_name
- self.__message_dict[Constants.http_param_tag_expression] = PushMessage.tag_expression
- return self
- def reg_id(self, reg_id):
- self.__message_dict[Constants.http_param_reg_id] = reg_id
- return self
- def ali_as(self, ali_as):
- self.__message_dict[Constants.http_param_ali_as] = ali_as
- return self
- def content(self, content):
- self.__message_dict[Constants.http_param_content] = content
- return self
- def title(self, title):
- self.__message_dict[Constants.http_param_title] = title
- return self
- def notify_type(self, notify_type):
- self.__message_dict[Constants.http_param_notify_type] = notify_type
- return self
- def time_to_live(self, time_to_live):
- self.__message_dict[Constants.http_param_time_to_live] = time_to_live
- return self
- def skip_type(self, skip_type):
- self.__message_dict[Constants.http_param_skip_type] = skip_type
- return self
- def skip_content(self, skip_content):
- self.__message_dict[Constants.http_param_skip_content] = skip_content
- return self
- def network_type(self, network_type=-1):
- self.__message_dict[Constants.http_param_network_type] = network_type
- return self
- def request_id(self, request_id):
- self.__message_dict[Constants.http_param_request_id] = request_id
- return self
- def classification(self, classification):
- self.__message_dict[Constants.http_param_classification] = classification
- return self
- def push_mode(self, push_mode):
- self.__message_dict[Constants.http_param_push_mode] = push_mode
- return self
- def client_custom_map(self, **client_custom_map):
- self.__message_dict[Constants.http_param_client_custom_map] = client_custom_map
- return self
- def extra(self, value1, value2):
- extra = {Constants.http_param_callback: value1, Constants.http_param_callback_param: value2}
- self.__message_dict[Constants.http_param_extra] = extra
- return self
- '''
- message params build method
- '''
- def message_dict(self):
- return self.__message_dict
|