Skip to content

Commit

Permalink
[docs,template] adding docs
Browse files Browse the repository at this point in the history
  • Loading branch information
david-lev committed Aug 20, 2023
1 parent 0b46a86 commit 47745d2
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 13 deletions.
31 changes: 23 additions & 8 deletions docs/source/content/client/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,26 @@ Client Reference

.. currentmodule:: pywa.client

.. autoclass:: WhatsApp()
:members: send_message, send_image, send_video, send_audio, send_document,
send_location, send_contact, send_sticker, send_catalog,
send_product, send_products, send_reaction, remove_reaction,
mark_message_as_read, upload_media, download_media,
get_media_url, get_business_profile, update_business_profile,
get_commerce_settings, update_commerce_settings
:member-order: bysource
.. automethod:: WhatsApp.send_message
.. automethod:: WhatsApp.send_image
.. automethod:: WhatsApp.send_video
.. automethod:: WhatsApp.send_audio
.. automethod:: WhatsApp.send_document
.. automethod:: WhatsApp.send_location
.. automethod:: WhatsApp.send_contact
.. automethod:: WhatsApp.send_sticker
.. automethod:: WhatsApp.send_catalog
.. automethod:: WhatsApp.send_template
.. automethod:: WhatsApp.send_product
.. automethod:: WhatsApp.send_products
.. automethod:: WhatsApp.send_reaction
.. automethod:: WhatsApp.remove_reaction
.. automethod:: WhatsApp.mark_message_as_read
.. automethod:: WhatsApp.upload_media
.. automethod:: WhatsApp.download_media
.. automethod:: WhatsApp.get_media_url
.. automethod:: WhatsApp.get_business_profile
.. automethod:: WhatsApp.update_business_profile
.. automethod:: WhatsApp.get_commerce_settings
.. automethod:: WhatsApp.update_commerce_settings
.. automethod:: WhatsApp.create_template
4 changes: 3 additions & 1 deletion docs/source/content/client/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The available methods are:
:meth:`~WhatsApp.send_location`,
:meth:`~WhatsApp.send_contact`,
:meth:`~WhatsApp.send_sticker`,
:meth:`~WhatsApp.send_template`,
:meth:`~WhatsApp.send_catalog`,
:meth:`~WhatsApp.send_product`,
:meth:`~WhatsApp.send_products`,
Expand All @@ -41,7 +42,8 @@ The available methods are:
:meth:`~WhatsApp.download_media`,
:meth:`~WhatsApp.get_media_url`
* - Business profile
- :meth:`~WhatsApp.get_business_profile`,
- :meth:`~WhatsApp.create_template`,
:meth:`~WhatsApp.get_business_profile`,
:meth:`~WhatsApp.update_business_profile`
* - Commerce
- :meth:`~WhatsApp.get_commerce_settings`,
Expand Down
23 changes: 23 additions & 0 deletions docs/source/content/errors/sending_messages_errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,26 @@ Sending Messages Errors
.. autoclass:: InvalidParameter()
:show-inheritance:
.. autoclass:: MissingRequiredParameter()
:show-inheritance:
.. autoclass:: MediaDownloadError()
:show-inheritance:
.. autoclass:: MediaUploadError()
:show-inheritance:
.. autoclass:: TemplateParamCountMismatch()
:show-inheritance:
.. autoclass:: TemplateNotExists()
:show-inheritance:
.. autoclass:: TemplateTextTooLong()
:show-inheritance:
.. autoclass:: GenericError()
:show-inheritance:
.. autoclass:: UnknownError()
:show-inheritance:
.. autoclass:: AccessDenied()
:show-inheritance:
.. autoclass:: ServiceUnavailable()
:show-inheritance:
.. autoclass:: RecipientCannotBeSender()
:show-inheritance:
.. autoclass:: BusinessPaymentIssue()
:show-inheritance:
1 change: 1 addition & 0 deletions docs/source/content/types/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.. toctree::
media
keyboard
template
update_fields
others
enums
20 changes: 20 additions & 0 deletions docs/source/content/types/template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Enums
=====

.. currentmodule:: pywa.types.template

.. autoclass:: NewTemplate()
:members:
:undoc-members:

--------------------

.. autoclass:: Template()
:members:
:undoc-members:

--------------------

.. autoclass:: TemplateResponse()
:members:
:undoc-members:
11 changes: 8 additions & 3 deletions pywa/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,11 +1231,14 @@ def create_template(
`\`Create Templates\` on developers.facebook.com
<https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates>`_.
- To send a template, use :py:func:`~pywa.client.WhatsApp.send_template`.
ATTENTION: In case of an errors, WhatsApp does not return a proper error message, instead, it returns a message
of `invalid parameter` with error code of 100. You need to pay attention to the following:
- The template name must be unique.
- The limitiations of the characters in every field (all documented).
- The order of the buttons.
- The template name must be unique.
- The limitiations of the characters in every field (all documented).
- The order of the buttons.
Templates can be created and managed in the
Expand Down Expand Up @@ -1308,6 +1311,8 @@ def send_template(
"""
Send a template to a WhatsApp user.
- To create a template, use :py:func:`~pywa.client.WhatsApp.create_template`.
Example:
>>> from pywa.types import Template as Temp
Expand Down
2 changes: 1 addition & 1 deletion pywa/types/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ class OTPButton(NewButtonABC):
package_name: Android package name of your app. Required if ``otp_type`` is ``OtpType.ONE_TAP``.
signature_hash: Your app signing key hash. See `App Signing Key Hash
<https://developers.facebook.com/docs/whatsapp/business-management-api/authentication-templates#app-signing-key-hash>`_
for more information. Required if ``otp_type`` is ``OtpType.ONE_TAP``.
for more information. Required if ``otp_type`` is ``OtpType.ONE_TAP``.
"""
type: ComponentType = field(default=ButtonType.OTP, init=False)
otp_type: OtpType
Expand Down

0 comments on commit 47745d2

Please sign in to comment.