def get_impl(Model, Message, itemId): return ferris3.ToolChain(itemId) \ .ndb.get() \ .raise_if(None, ferris3.NotFoundException()) \ .ndb.check_kind(Model) \ .messages.serialize(Message) \ .value()
def by_channel(delf, request, channelid=(str, )): cha_msgs = PushMessage.query(PushMessage.channel_id == channelid) if cha_msgs is not None: return f3.messages.serialize_list(MultiMessage, cha_msgs) else: raise f3.NotFoundException()
def resend_sms_verification(delf,request,objectId=(str,)): subscriber_value= Subscriber.get_by_obj_id(objectId).get() if subscriber_value is not None: client = TwilioRestClient(twilio_acc, twilio_tkn) message = client.messages.create(to="+"+subscriber_value.phone_number, from_="+12057915054", body="You verification code is: "+subscriber_value.sms_verification_code); else: raise f3.NotFoundException()
def remove_channel(delf,request,channelid=(str,),objectId=(str,)): subscriber_value= Subscriber.get_by_obj_id(objectId).get() if subscriber_value is not None: subscriber_value.channels.remove(channelid) subscriber_value.put() else: raise f3.NotFoundException() return f3.messages.serialize(SubMsg, subscriber_value)
def by_ids(self, request, channels=(str, )): selected_channels = channels.split(",") cha_msgs = Channel.query(Channel.short_id.IN(selected_channels)) if cha_msgs is not None: return f3.messages.serialize_list(MultiMessage, cha_msgs) else: raise f3.NotFoundException()
def by_latest(delf, request): cha_msgs = PushMessage.query().order(-PushMessage.date) if cha_msgs is not None: return f3.messages.serialize_list(MultiMessage, cha_msgs) else: raise f3.NotFoundException()
def verify_sms(delf,request,objectId=(str,), verification_code=(str,)): subscriber_value= Subscriber.get_by_obj_id(objectId).get() if subscriber_value is not None: if subscriber_value.sms_verification_code == verification_code: subscriber_value.sms_verified=True subscriber_value.put() else: raise f3.NotFoundException() return f3.messages.serialize(SubMsg, subscriber_value)
def by_city(self, request, city=(str, ), country=(str, )): parsed_city_key = (city + "-" + country).lower() city_key = ndb.Key(City, parsed_city_key) if (city_key): cha_msgs = Channel.query(Channel.city == city_key) if cha_msgs is not None: return f3.messages.serialize_list(MultiMessage, cha_msgs) else: raise f3.NotFoundException()
def by_channels( self, request, ): cha_msgs = Channel.query(Channel.is_featured == True) if cha_msgs is not None: return f3.messages.serialize_list(MultiMessage, cha_msgs) else: raise f3.NotFoundException()
def update_impl(Model, Message, itemId, request): item = ferris3.ToolChain(itemId) \ .ndb.get() \ .raise_if(None, ferris3.NotFoundException()) \ .ndb.check_kind(Model) \ .value() return ferris3.ToolChain(request) \ .messages.deserialize(item) \ .ndb.put() \ .messages.serialize(Message) \ .value()
def validate(delf,request,objectId=(str,), password=(str,)): subscriber_value= Subscriber.get_by_obj_id(objectId).get(); if SHA256.new(password).hexdigest() == subscriber_value.password : return f3.messages.serialize(SubMsg, subscriber_value) else: raise f3.NotFoundException()