Ejemplo n.º 1
0
 def find_ayah(cls):
     ayah_repo = AyahRepo()
     find_translation = TranslationFactory.find_translation()
     find_surah = SurahFactory.find_surah()
     find_edition = EditionFactory.find_edition()
     find_audio = AudioFactory.find_audio()
     find_image = ImageFactory.find_image()
     return FindAyah(ayah_repo, find_translation, find_surah, find_edition,
                     find_audio, find_image)
Ejemplo n.º 2
0
    def FindSurahByEnglishNameTranslation(self, request, context):
        find_surah = SurahFactory.find_surah()
        res = find_surah.by_english_name_translation(request.name)

        if res is None:
            return surah_proto.SurahSingleResponse(code=404,
                                                   status='Not Found')

        surah_entity = entity_proto.SurahEntity(**res.surah.to_dict())
        surah_data = surah_proto.SurahSingleData(surah=surah_entity,
                                                 number_of_results=1)
        return surah_proto.SurahSingleResponse(code=200,
                                               status='OK',
                                               data=surah_data)
Ejemplo n.º 3
0
    def FindSurahByNumber(self, request, context):
        find_surah = SurahFactory.find_surah()
        res = find_surah.by_number(request.number)

        if res is None:
            return surah_proto.SurahSingleResponse(code=404,
                                                   status='Not Found')

        surah_entity = entity_proto.SurahEntity(**res.surah.to_dict())
        surah_data = surah_proto.SurahSingleData(
            surah=surah_entity, number_of_results=res.number_of_results)
        return surah_proto.SurahSingleResponse(code=200,
                                               status='OK',
                                               data=surah_data)
Ejemplo n.º 4
0
    def GetAll(self, request, context):
        find_surah = SurahFactory.find_surah()
        surah_stream = find_surah.get_all(request.limit, request.cursor)
        surah_list = []
        for surah in surah_stream.surah_list:
            surah_list.append(entity_proto.SurahEntity(**surah.to_dict()))

        if len(surah_list) == 0:
            return surah_proto.SurahMultiResponse(code=404, status='Not Found')

        surah_data = surah_proto.SurahMultiData(
            surah=surah_list,
            number_of_results=surah_stream.number_of_results,
            cursor=surah_stream.cursor)
        return surah_proto.SurahMultiResponse(code=200,
                                              status='OK',
                                              data=surah_data)