Ë
    ö%9jöV  ã                   óN  — d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	Z	ddl	m
Z
 ddl	mZ ddl	mZ ddl	mZ dd	l	mZ dd
l	mZ dZg d¢Zej$                  Zej&                  Zej(                  Zej*                  Zej,                  Zej.                  Zej0                  Zej2                  Zej4                  Zej6                  Zej8                  Zej:                  Zej<                  Zej>                  Zej@                  Z ejB                  Z!ejD                  Z"ejF                  Z#ejH                  Z$ejJ                  Z%ejL                  Z&ejN                  Z'd„ Z(dd„Z)dd„Z*dd„Z+dd„Z,dd„Z-d d„Z.d d„Z/ G d„ d«      Z0 G d„ d«      Z1 G d„ d«      Z2 G d„ d«      Z3 G d„ d«      Z4y)!z Firebase Cloud Messaging module.é    N)Úhttp)Ú_auth)Ú_http_client)Ú_messaging_encoder)Ú_messaging_utils)Ú_gapic_utils)Ú_utils)Ú
exceptionsÚ
_messaging)!ÚAndroidConfigÚAndroidFCMOptionsÚAndroidNotificationÚ
APNSConfigÚAPNSFCMOptionsÚAPNSPayloadÚApsÚApsAlertÚBatchResponseÚCriticalSoundÚ	ErrorInfoÚ
FCMOptionsÚLightSettingsÚMessageÚMulticastMessageÚNotificationÚQuotaExceededErrorÚSenderIdMismatchErrorÚSendResponseÚThirdPartyAuthErrorÚTopicManagementResponseÚUnregisteredErrorÚWebpushConfigÚWebpushFCMOptionsÚWebpushNotificationÚWebpushNotificationActionÚsendÚsend_allÚsend_multicastÚ	send_eachÚsend_each_for_multicastÚsubscribe_to_topicÚunsubscribe_from_topicc                 ó@   — t        j                  | t        t        «      S ©N)r	   Úget_app_serviceÚ_MESSAGING_ATTRIBUTEÚ_MessagingService)Úapps    úT/var/www/html/truck-me/venv/lib/python3.12/site-packages/firebase_admin/messaging.pyÚ_get_messaging_servicer4   d   s   € Ü×!Ñ! #Ô';Ô=NÓOÐOó    c                 ó8   — t        |«      j                  | |«      S )aÀ  Sends the given message via Firebase Cloud Messaging (FCM).

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead FCM performs all the usual validations, and emulates the send operation.

    Args:
        message: An instance of ``messaging.Message``.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        string: A message ID string that uniquely identifies the sent message.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.
    )r4   r&   )ÚmessageÚdry_runr2   s      r3   r&   r&   g   s   € ô$ " #Ó&×+Ñ+¨G°WÓ=Ð=r5   c                 ó8   — t        |«      j                  | |«      S )a½  Sends each message in the given list via Firebase Cloud Messaging.

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead FCM performs all the usual validations, and emulates the send operation.

    Args:
        messages: A list of ``messaging.Message`` instances.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        BatchResponse: A ``messaging.BatchResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.
    )r4   r)   ©Úmessagesr8   r2   s      r3   r)   r)   {   s   € ô$ " #Ó&×0Ñ0°¸7ÓCÐCr5   c                 óB  — t        | t        «      st        d«      ‚| j                  D �cg c]P  }t	        | j
                  | j                  | j                  | j                  | j                  | j                  |¬«      ‘ŒR }}t        |«      j                  ||«      S c c}w )aÛ  Sends the given mutlicast message to each token via Firebase Cloud Messaging (FCM).

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead FCM performs all the usual validations, and emulates the send operation.

    Args:
        multicast_message: An instance of ``messaging.MulticastMessage``.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        BatchResponse: A ``messaging.BatchResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.
    ú@Message must be an instance of messaging.MulticastMessage class.©ÚdataÚnotificationÚandroidÚwebpushÚapnsÚfcm_optionsÚtoken)Ú
isinstancer   Ú
ValueErrorÚtokensr   r?   r@   rA   rB   rC   rD   r4   r)   ©Úmulticast_messager8   r2   rE   r;   s        r3   r*   r*   �   s    € ô$ Ð'Ô)9Ô:ÜÐ[Ó\Ð\ð %×+Ñ+ö-ð ô Ø×#Ñ#Ø&×3Ñ3Ø!×)Ñ)Ø!×)Ñ)Ø×#Ñ#Ø%×1Ñ1Øöð -€Hð -ô " #Ó&×0Ñ0°¸7ÓCÐCùò-s   ªABc                 ól   — t        j                  dt        «       t        |«      j	                  | |«      S )a  Sends the given list of messages via Firebase Cloud Messaging as a single batch.

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead FCM performs all the usual validations, and emulates the send operation.

    Args:
        messages: A list of ``messaging.Message`` instances.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        BatchResponse: A ``messaging.BatchResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.

    send_all() is deprecated. Use send_each() instead.
    z2send_all() is deprecated. Use send_each() instead.)ÚwarningsÚwarnÚDeprecationWarningr4   r'   r:   s      r3   r'   r'   ®   s,   € ô( ‡M�MÐFÔHZÔ[Ü! #Ó&×/Ñ/°¸'ÓBÐBr5   c                 óv  — t        j                  dt        «       t        | t        «      st        d«      ‚| j                  D �cg c]P  }t        | j                  | j                  | j                  | j                  | j                  | j                  |¬«      ‘ŒR }}t        |«      j                  ||«      S c c}w )a'  Sends the given mutlicast message to all tokens via Firebase Cloud Messaging (FCM).

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead FCM performs all the usual validations, and emulates the send operation.

    Args:
        multicast_message: An instance of ``messaging.MulticastMessage``.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        BatchResponse: A ``messaging.BatchResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.

    send_multicast() is deprecated. Use send_each_for_multicast() instead.
    zFsend_multicast() is deprecated. Use send_each_for_multicast() instead.r=   r>   )rL   rM   rN   rF   r   rG   rH   r   r?   r@   rA   rB   rC   rD   r4   r'   rI   s        r3   r(   r(   Å   s²   € ô( ‡M�MÐZÜ$ô&äÐ'Ô)9Ô:ÜÐ[Ó\Ð\ð %×+Ñ+ö-ð ô Ø×#Ñ#Ø&×3Ñ3Ø!×)Ñ)Ø!×)Ñ)Ø×#Ñ#Ø%×1Ñ1Øöð -€Hð -ô " #Ó&×/Ñ/°¸'ÓBÐBùò-s   ÁAB6c                 ó:   — t        |«      j                  | |d«      S )a4  Subscribes a list of registration tokens to an FCM topic.

    Args:
        tokens: A non-empty list of device registration tokens. List may not have more than 1000
            elements.
        topic: Name of the topic to subscribe to. May contain the ``/topics/`` prefix.
        app: An App instance (optional).

    Returns:
        TopicManagementResponse: A ``TopicManagementResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while communicating with instance ID service.
        ValueError: If the input arguments are invalid.
    ziid/v1:batchAdd©r4   Úmake_topic_management_request©rH   Útopicr2   s      r3   r+   r+   è   s$   € ô  " #Ó&×DÑDØ�Ð(ó*ð *r5   c                 ó:   — t        |«      j                  | |d«      S )a<  Unsubscribes a list of registration tokens from an FCM topic.

    Args:
        tokens: A non-empty list of device registration tokens. List may not have more than 1000
            elements.
        topic: Name of the topic to unsubscribe from. May contain the ``/topics/`` prefix.
        app: An App instance (optional).

    Returns:
        TopicManagementResponse: A ``TopicManagementResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while communicating with instance ID service.
        ValueError: If the input arguments are invalid.
    ziid/v1:batchRemoverQ   rS   s      r3   r,   r,   û   s$   € ô  " #Ó&×DÑDØ�Ð+ó-ð -r5   c                   ó6   — e Zd ZdZd„ Zed„ «       Zed„ «       Zy)r   zBAn error encountered when performing a topic management operation.c                 ó    — || _         || _        y r.   )Ú_indexÚ_reason)ÚselfÚindexÚreasons      r3   Ú__init__zErrorInfo.__init__  s   € ØˆŒØˆ�r5   c                 ó   — | j                   S )zBIndex of the registration token to which this error is related to.)rX   ©rZ   s    r3   r[   zErrorInfo.index  s   € ð �{‰{Ðr5   c                 ó   — | j                   S )z*String describing the nature of the error.)rY   r_   s    r3   r\   zErrorInfo.reason  ó   € ð �|‰|Ðr5   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r]   Úpropertyr[   r\   © r5   r3   r   r     s2   „ ÙLòð ñó ðð ñó ñr5   r   c                   óF   — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zy)r    z8The response received from a topic management operation.c                 ód  — t        |t        «      rd|vrt        dj                  |«      «      ‚d| _        d| _        g | _        t        |d   «      D ]\  \  }}d|v r>| xj
                  dz  c_        | j                  j                  t        ||d   «      «       ŒH| xj                  dz  c_        Œ^ y )NÚresultsz*Unexpected topic management response: {0}.r   Úerroré   )
rF   ÚdictrG   ÚformatÚ_success_countÚ_failure_countÚ_errorsÚ	enumerateÚappendr   )rZ   Úrespr[   Úresults       r3   r]   z TopicManagementResponse.__init__$  s¥   € Ü˜$¤Ô%¨¸$Ñ)>ÜÐI×PÑPÐQUÓVÓWÐWØˆÔØˆÔØˆŒÜ& t¨I¡Ó7ò 	)‰MˆE�6Ø˜&Ñ Ø×#Ò# qÑ(Õ#Ø—‘×#Ñ#¤I¨e°V¸G±_Ó$EÕFà×#Ò# qÑ(Ö#ñ	)r5   c                 ó   — | j                   S )zCNumber of tokens that were successfully subscribed or unsubscribed.©ro   r_   s    r3   Úsuccess_countz%TopicManagementResponse.success_count1  ó   € ð ×"Ñ"Ð"r5   c                 ó   — | j                   S )zLNumber of tokens that could not be subscribed or unsubscribed due to errors.)rp   r_   s    r3   Úfailure_countz%TopicManagementResponse.failure_count6  ry   r5   c                 ó   — | j                   S )z;A list of ``messaging.ErrorInfo`` objects (possibly empty).)rq   r_   s    r3   ÚerrorszTopicManagementResponse.errors;  ra   r5   N)	rb   rc   rd   re   r]   rf   rx   r{   r}   rg   r5   r3   r    r    !  sF   „ ÙBò)ð ñ#ó ð#ð ñ#ó ð#ð ñó ñr5   r    c                   óF   — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zy)r   z:The response received from a batch request to the FCM API.c                 ór   — || _         t        |D �cg c]  }|j                  sŒ|‘Œ c}«      | _        y c c}w r.   )Ú
_responsesÚlenÚsuccessro   )rZ   Ú	responsesrt   s      r3   r]   zBatchResponse.__init__D  s*   € Ø#ˆŒÜ!°IÖ"N¨DÀÇÃ¢4Ò"NÓOˆÕùÒ"Ns   ‘4£4c                 ó   — | j                   S )z>A list of ``messaging.SendResponse`` objects (possibly empty).)r€   r_   s    r3   rƒ   zBatchResponse.responsesH  ó   € ð �‰Ðr5   c                 ó   — | j                   S r.   rw   r_   s    r3   rx   zBatchResponse.success_countM  s   € à×"Ñ"Ð"r5   c                 óF   — t        | j                  «      | j                  z
  S r.   )r�   rƒ   rx   r_   s    r3   r{   zBatchResponse.failure_countQ  s   € ä�4—>‘>Ó" T×%7Ñ%7Ñ7Ð7r5   N)	rb   rc   rd   re   r]   rf   rƒ   rx   r{   rg   r5   r3   r   r   A  sG   „ ÙDòPð ñó ðð ñ#ó ð#ð ñ8ó ñ8r5   r   c                   óF   — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zy)r   zHThe response received from an individual batched request to the FCM API.c                 óT   — || _         d | _        |r|j                  dd «      | _        y y )NÚname)Ú
_exceptionÚ_message_idÚget)rZ   rt   Ú	exceptions      r3   r]   zSendResponse.__init__Y  s,   € Ø#ˆŒØˆÔÙØ#Ÿx™x¨°Ó5ˆDÕð r5   c                 ó   — | j                   S )z9A message ID string that uniquely identifies the message.)rŒ   r_   s    r3   Ú
message_idzSendResponse.message_id_  s   € ð ×ÑÐr5   c                 ó<   — | j                   duxr | j                   S )z3A boolean indicating if the request was successful.N)rŒ   r‹   r_   s    r3   r‚   zSendResponse.successd  s!   € ð ×Ñ tÐ+ÒC°D·O±OÐ0CÐCr5   c                 ó   — | j                   S )zTA ``FirebaseError`` if an error occurs while sending the message to the FCM service.)r‹   r_   s    r3   rŽ   zSendResponse.exceptioni  r…   r5   N)	rb   rc   rd   re   r]   rf   r�   r‚   rŽ   rg   r5   r3   r   r   V  sH   „ ÙRò6ð ñ ó ð ð ñDó ðDð ñó ñr5   r   c                   óØ   — e Zd ZdZdZdZdZddiZ ej                  «       Z
eeeeedœZd„ Zed	„ «       Zdd
„Zdd„Zdd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ «       Zed„ «       Zed„ «       Zy)r1   zKService class that implements Firebase Cloud Messaging (FCM) functionality.z8https://fcm.googleapis.com/v1/projects/{0}/messages:sendz https://fcm.googleapis.com/batchzhttps://iid.googleapis.comÚaccess_token_authÚtrue)ÚAPNS_AUTH_ERRORÚQUOTA_EXCEEDEDÚSENDER_ID_MISMATCHÚTHIRD_PARTY_AUTH_ERRORÚUNREGISTEREDc                 óÔ  — |j                   }|st        d«      ‚t        j                  j	                  |«      | _        ddj	                  t        j                  «      dœ| _        |j                  j                  dt        j                  «      }|j                  j                  «       | _        t        j                   | j                  |¬«      | _        t$        j&                  | _        y )NzÀProject ID is required to access Cloud Messaging service. Either set the projectId option, or use service account credentials. Alternatively, set the GOOGLE_CLOUD_PROJECT environment variable.Ú2zfire-admin-python/{0})zX-GOOG-API-FORMAT-VERSIONzX-FIREBASE-CLIENTÚhttpTimeout)Ú
credentialÚtimeout)Ú
project_idrG   r1   ÚFCM_URLrn   Ú_fcm_urlÚfirebase_adminÚ__version__Ú_fcm_headersÚoptionsr�   r   ÚDEFAULT_TIMEOUT_SECONDSrž   Úget_credentialÚ_credentialÚJsonHttpClientÚ_clientr   Úauthorized_httpÚ_build_transport)rZ   r2   r    rŸ   s       r3   r]   z_MessagingService.__init__€  sµ   € Ø—^‘^ˆ
ÙÜð=ó>ð >ô *×1Ñ1×8Ñ8¸ÓDˆŒà),Ø!8×!?Ñ!?Ä×@ZÑ@ZÓ![ñ
ˆÔð —+‘+—/‘/ -´×1UÑ1UÓVˆØŸ>™>×8Ñ8Ó:ˆÔÜ#×2Ñ2¸d×>NÑ>NÐX_Ô`ˆŒÜ %× 5Ñ 5ˆÕr5   c                 ón   — t        |t        «      st        d«      ‚| j                  j	                  |«      S )Nz7Message must be an instance of messaging.Message class.)rF   r   rG   ÚJSON_ENCODERÚdefault)Úclsr7   s     r3   Úencode_messagez _MessagingService.encode_message‘  s/   € ä˜'¤7Ô+ÜÐVÓWÐWØ×Ñ×'Ñ'¨Ó0Ð0r5   c                 ó  — | j                  ||«      }	 | j                  j                  d| j                  | j                  |¬«      }|d   S # t
        j                  j                  $ r}| j                  |«      ‚d}~ww xY w)z2Sends the given message to FCM via the FCM v1 API.Úpost©ÚurlÚheadersÚjsonrŠ   N)	Ú_message_datar«   Úbodyr¢   r¥   Úrequestsr
   ÚRequestExceptionÚ_handle_fcm_error)rZ   r7   r8   r?   rt   rk   s         r3   r&   z_MessagingService.send—  sƒ   € à×!Ñ! '¨7Ó3ˆð
	 Ø—<‘<×$Ñ$ØØ—M‘MØ×)Ñ)Øð	 %ó ˆDð ˜‘<Ðøô ×"Ñ"×3Ñ3ò 	0Ø×(Ñ(¨Ó/Ð/ûð	0ús   ”3A ÁA?Á)A:Á:A?c                 ó
  ‡ — t        |t        «      st        d«      ‚t        |«      dkD  rt        d«      ‚ˆ fd„}|D �cg c]  }‰ j	                  ||«      ‘Œ }}	 t
        j                  j                  t        |«      ¬«      5 }|j                  ||«      D �cg c]  }|‘Œ }}t        |«      cddd«       S c c}w c c}w # 1 sw Y   yxY w# t        $ r+}	t        j                  dj                  |	«      |	¬«      ‚d}	~	ww xY w)	z3Sends the given messages to FCM via the FCM v1 API.ú7messages must be a list of messaging.Message instances.éô  ú1messages must not contain more than 500 elements.c                 ó  •— 	 ‰j                   j                  d‰j                  ‰j                  | ¬«      }t	        |d ¬«      S # t
        j                  j                  $ r&}t	        d ‰j                  |«      ¬«      cY d }~S d }~ww xY w)Nr´   rµ   )rŽ   )rt   rŽ   )	r«   rº   r¢   r¥   r   r»   r
   r¼   r½   )r?   rt   rŽ   rZ   s      €r3   Ú	send_dataz._MessagingService.send_each.<locals>.send_data­  s   ø€ ð	:Ø—|‘|×(Ñ(ØØŸ™Ø ×-Ñ-Øð	 )ó �ô $ D°DÔ9Ð9øô ×&Ñ&×7Ñ7ò \Ü#¨¸×9OÑ9OÐPYÓ9ZÔ[Õ[ûð\ús   ƒ3A ÁBÁ BÁ;BÂB)Úmax_workersNz4Unknown error while making remote service calls: {0})r7   Úcause)rF   ÚlistrG   r�   r¹   Ú
concurrentÚfuturesÚThreadPoolExecutorÚmapr   Ú	Exceptionr
   ÚUnknownErrorrn   )
rZ   r;   r8   rÃ   r7   Úmessage_dataÚexecutorrt   rƒ   rk   s
   `         r3   r)   z_MessagingService.send_each¦  s   ø€ ä˜(¤DÔ)ÜÐVÓWÐWÜˆx‹=˜3ÒÜÐPÓQÐQô
	:ð MUÖUÀ˜×*Ñ*¨7°GÕ<ÐUˆÐUð	Ü×#Ñ#×6Ñ6Ä3À|ÓCTÐ6ÓUð 0ÐYaØ.6¯l©l¸9ÀlÓ.SÖT dšTÐT�	ÐTÜ$ YÓ/÷0ñ 0ùò Vùò U÷0ð 0ûô ò 	Ü×)Ñ)ØN×UÑUÐV[Ó\Øôð ûð	úsM   ¿B8Á)C ÂCÂ	B=Â"CÂ.	C Â=CÃCÃC ÃC Ã	DÃ&C=Ã=Dc           	      óf  ‡ ‡
— t        |t        «      st        d«      ‚t        |«      dkD  rt        d«      ‚g Š
ˆ
ˆ fd„}t	        j
                  |t        j                  ¬«      }‰ j                  ‰ j                  «      }|D ]q  }t        j                  ‰ j                  ||«      «      }t	        j                  |‰ j                  ‰ j                  d|‰ j                   ¬«      }|j#                  |«       Œs 	 |j%                  «        t'        ‰
«      S # t(        $ r}	‰ j+                  |	«      ‚d}	~	ww xY w)	z2Sends the given messages to FCM via the batch API.r¿   rÀ   rÁ   c                 ój   •— d }|r‰j                  |«      }t        ||«      }‰j                  |«       y r.   )Ú_handle_batch_errorr   rs   )Ú_Úresponserk   rŽ   Úsend_responserƒ   rZ   s        €€r3   Úbatch_callbackz2_MessagingService.send_all.<locals>.batch_callbackÌ  s5   ø€ ØˆIÙØ ×4Ñ4°UÓ;�	Ü(¨°9Ó=ˆMØ×Ñ˜]Õ+r5   )ÚcallbackÚ	batch_uriÚPOST)r   ÚpostprocÚuriÚmethodrº   r·   N)rF   rÆ   rG   r�   r   ÚBatchHttpRequestr1   ÚFCM_BATCH_URLr­   r©   r¸   Údumpsr¹   ÚHttpRequestÚ	_postprocr¢   r¥   ÚaddÚexecuter   rË   rÑ   )rZ   r;   r8   rÕ   ÚbatchÚ	transportr7   rº   Úreqrk   rƒ   s   `         @r3   r'   z_MessagingService.send_allÃ  s  ù€ ä˜(¤DÔ)ÜÐVÓWÐWÜˆx‹=˜3ÒÜÐPÓQÐQàˆ	õ	,ô ×%Ñ%Ø#Ô/@×/NÑ/NôPˆà×)Ñ)¨$×*:Ñ*:Ó;ˆ	Øò 
	ˆGÜ—:‘:˜d×0Ñ0°¸'ÓBÓCˆDÜ×"Ñ"ØØŸ™Ø—M‘MØØØ×)Ñ)ôˆCð �I‰I�c�Nð
	ð	,Ø�M‰MŒOô ! Ó+Ð+øô ò 	2Ø×*Ñ*¨5Ó1Ð1ûð	2ús   Ã6D Ä	D0ÄD+Ä+D0c                 óp  — t        |t        «      r|g}t        |t        «      r|st        d«      ‚|D �cg c]  }t        |t        «      r|rŒ|‘Œ }}|rt        d«      ‚t        |t        «      r|st        d«      ‚|j	                  d«      sdj                  |«      }||dœ}dj                  t        j                  |«      }	 | j                  j                  d||t        j                  ¬	«      }t        |«      S c c}w # t        j                  j                  $ r}	| j                  |	«      ‚d
}	~	ww xY w)z;Invokes the IID service for topic management functionality.z7Tokens must be a string or a non-empty list of strings.z!Tokens must be non-empty strings.z!Topic must be a non-empty string.z/topics/z/topics/{0})ÚtoÚregistration_tokensz{0}/{1}r´   )r¶   r¸   r·   N)rF   ÚstrrÆ   rG   Ú
startswithrn   r1   ÚIID_URLr«   rº   ÚIID_HEADERSr    r»   r
   r¼   Ú_handle_iid_error)
rZ   rH   rT   Ú	operationÚtÚinvalid_strr?   r¶   rt   rk   s
             r3   rR   z/_MessagingService.make_topic_management_requesté  s(  € ä�fœcÔ"Ø�XˆFÜ˜&¤$Ô'©vÜÐVÓWÐWØ"(ÖL˜Q´
¸1¼cÔ0BÊ!’qÐLˆÐLÙÜÐ@ÓAÐAä˜%¤Ô%©UÜÐ@ÓAÐAØ×Ñ 
Ô+Ø!×(Ñ(¨Ó/ˆEàØ#)ñ
ˆð ×ÑÔ0×8Ñ8¸)ÓDˆð
	1Ø—<‘<×$Ñ$ØØØÜ)×5Ñ5ð	 %ó ˆDô +¨4Ó0Ð0ùò/ Møô( ×"Ñ"×3Ñ3ò 	0Ø×(Ñ(¨Ó/Ð/ûð	0ús#   µC=ÁC=Ã-D ÄD5ÄD0Ä0D5c                 óB   — dt         j                  |«      i}|rd|d<   |S )Nr7   TÚvalidate_only)r1   r²   )rZ   r7   r8   r?   s       r3   r¹   z_MessagingService._message_data  s*   € ØÔ,×;Ñ;¸GÓDÐEˆÙØ$(ˆD�Ñ!Øˆr5   c                 óH   — t        j                  |j                  «       «      S )z'Handle response from batch API request.)r¸   ÚloadsÚdecode)rZ   rÒ   rº   s      r3   rà   z_MessagingService._postproc  s   € ô �z‰z˜$Ÿ+™+›-Ó(Ð(r5   c                 óJ   — t        j                  |t        j                  «      S )z)Handles errors received from the FCM API.)r	   Ú#handle_platform_error_from_requestsr1   Ú_build_fcm_error_requests©rZ   rk   s     r3   r½   z#_MessagingService._handle_fcm_error  s#   € ä×9Ñ9ØÔ$×>Ñ>ó@ð 	@r5   c                 óÊ  — |j                   €t        j                  |«      ‚i }	 |j                   j                  «       }t	        |t
        «      r|}|j                  d«      }d}|rdj                  |«      }nHdj                  |j                   j                  |j                   j                  j                  «       «      }t        j                  ||«      S # t        $ r Y Œ�w xY w)z1Handles errors received from the Instance ID API.Nrk   z(Error while calling the IID service: {0}z4Unexpected HTTP response with status: {0}; body: {1})rÓ   r	   Úhandle_requests_errorr¸   rF   rm   rG   r�   rn   Ústatus_codeÚcontentrõ   )rZ   rk   r?   Úparsed_bodyÚcodeÚmsgs         r3   rí   z#_MessagingService._handle_iid_error  sÌ   € à�>‰>Ð!Ü×.Ñ.¨uÓ5Ð5àˆð	ØŸ.™.×-Ñ-Ó/ˆKÜ˜+¤tÔ,Ø"�ð
 �x‰x˜Ó ˆØˆÙØ<×CÑCÀDÓI‰CàH×OÑOØ—‘×*Ñ*¨E¯N©N×,BÑ,B×,IÑ,IÓ,KóMˆCô ×+Ñ+¨E°3Ó7Ð7øô ò 	Ùð	ús   ¥,C Ã	C"Ã!C"c                 óJ   — t        j                  |t        j                  «      S )zMHandles errors received from the googleapiclient while making batch requests.)r   Ú*handle_platform_error_from_googleapiclientr1   Ú _build_fcm_error_googleapiclientrù   s     r3   rÑ   z%_MessagingService._handle_batch_error0  s#   € ä×FÑFØÔ$×EÑEóGð 	Gr5   c                 óV   — | j                  |«      }|r ||||j                  ¬«      S dS ©zfParses an error response from the FCM API and creates a FCM-specific exception if
        appropriate.)rÅ   Úhttp_responseN)Ú_build_fcm_errorrÓ   )r±   rk   r7   Ú
error_dictÚexc_types        r3   rø   z+_MessagingService._build_fcm_error_requests5  s/   € ð ×'Ñ'¨
Ó3ˆÙOW‰x˜ u¸E¿N¹NÔKÐaÐ]aÐar5   c                 óB   — | j                  |«      }|r ||||¬«      S dS r  )r  )r±   rk   r7   r  r  r	  s         r3   r  z2_MessagingService._build_fcm_error_googleapiclient<  s+   € ð ×'Ñ'¨
Ó3ˆÙNV‰x˜ u¸MÔJÐ`Ð\`Ð`r5   c                 óÆ   — |sy d }|j                  dg «      D ])  }|j                  d«      dk(  sŒ|j                  d«      } n t        j                  j                  |«      S )NÚdetailsz@typez3type.googleapis.com/google.firebase.fcm.v1.FcmErrorÚ	errorCode)r�   r1   ÚFCM_ERROR_TYPES)r±   r  Úfcm_codeÚdetails       r3   r  z"_MessagingService._build_fcm_errorC  sc   € áØØˆØ —n‘n Y°Ó3ò 	ˆFØ�z‰z˜'Ó"Ð&[Ó[Ø!Ÿ:™: kÓ2�Ùð	ô !×0Ñ0×4Ñ4°XÓ>Ð>r5   N)F)rb   rc   rd   re   r¡   rÝ   rë   rì   r   ÚMessageEncoderr¯   r   r   r   r!   r  r]   Úclassmethodr²   r&   r)   r'   rR   r¹   rà   r½   rí   rÑ   rø   r  r  rg   r5   r3   r1   r1   o  sÐ   „ ÙUàH€GØ6€MØ*€GØ&¨Ð/€KØ4Ð%×4Ñ4Ó6€Lð /Ø,Ø3Ø"5Ø)ñ€Oò6ð" ñ1ó ð1ó
 óó:$,òL1ò>ò)ò
@ò
8ò0Gð
 ñbó ðbð ñaó ðað ñ?ó ñ?r5   r1   )FNr.   )5re   Úconcurrent.futuresrÇ   r¸   rL   r»   Úgoogleapiclientr   r   r£   r   r   r   r   r	   r
   r0   Ú__all__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r#   r$   r%   r   r   r   r!   r4   r&   r)   r*   r'   r(   r+   r,   r   r    r   r   r1   rg   r5   r3   ú<module>r     s¢  ðñ 'ã Û Û Û å  Ý !ã Ý 'Ý -Ý +Ý 'Ý !Ý %ð $Ð ò#€ðL !×.Ñ.€Ø$×6Ñ6Ð Ø&×:Ñ:Ð Ø×(Ñ(€
Ø!×0Ñ0€Ø×*Ñ*€Ø×Ñ€Ø×$Ñ$€Ø ×.Ñ.€Ø×(Ñ(€
Ø ×.Ñ.€Ø
×
$Ñ
$€Ø%×6Ñ6Ð Ø×,Ñ,€Ø ×.Ñ.€Ø$×6Ñ6Ð Ø&×:Ñ:Ð Ø,×FÑFÐ à%×8Ñ8Ð Ø(×>Ñ>Ð Ø&×:Ñ:Ð Ø$×6Ñ6Ð òPó>ó(Dó(Dó>Có.!CóF*ó&-÷(ñ ÷$ñ ÷@8ñ 8÷*ñ ÷2]?ò ]?r5   