Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
ignacio-chiazzo committed Dec 3, 2023
1 parent e808c50 commit 4219efd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,31 @@ messages_api = WhatsappSdk::Api::Messages.new
phone_numbers_api = WhatsappSdk::Api::PhoneNumbers.new
medias_api = WhatsappSdk::Api::Medias.new
business_profile_api = WhatsappSdk::Api::BusinessProfile.new
templates_api = WhatsappSdk::Api::Templates.new
```

Note: Remember to initialize the client first!

## APIs

### Templates
<details>

```ruby
# Get list of templates
templates_api.templates(business_id: BUSINESS_ID)

# Create a template
new_template = templates_api.create(
business_id: BUSINESS_ID, name: "seasonal_promotion", language: "en_US", category: "MARKETING",
components_json: components_json, allow_category_change: true
)

# Delete a template
templates_api.delete(business_id: BUSINESS_ID, name: "my_name") # delete by name
```
</details>

### Business Profile API
<details>

Expand Down
19 changes: 10 additions & 9 deletions lib/whatsapp_sdk/api/templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ def initialize(category:)

# Create a template
#
# @param business_id [Integer] Business Id.
# @param name [String] the template's name.
# @param category [String] the template's category. Possible values: AUTHENTICATION, MARKETING, UTILITY.
# @param language [String] Template language and locale cod (e.g. en_US).
# @param language [String] Template language and locale code (e.g. en_US).
# See the list of possible languages https://developers.facebook.com/docs/whatsapp/api/messages/message-templates
# @param components_json [Component] Components that make up the template. See the list of possible components:
# https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/components
# @param allow_category_change [Boolean] Optional Allow category change.
# Set to true to allow us to assign a category
# based on the template guidelines and the template's contents. This can prevent your template
# from being rejected for miscategorization.
# Set to true to allow us to assign a category based on the template guidelines and the template's contents.
# This can prevent your template from being rejected for miscategorization.
# @return [WhatsappSdk::Api::Response] Response object.
sig do
params(
Expand Down Expand Up @@ -99,7 +100,7 @@ def templates(business_id:, limit: 100)
http_method: "get",
params: params
)
# TODO: Parse response

WhatsappSdk::Api::Response.new(
response: response,
data_class_type: WhatsappSdk::Api::Responses::TemplatesDataResponse,
Expand All @@ -111,7 +112,6 @@ def templates(business_id:, limit: 100)
# The message template namespace is required to send messages using the message templates.
#
# @param business_id [Integer] The business ID.
#
# @return [WhatsappSdk::Api::Response] Response object.
sig { params(business_id: Integer).returns(WhatsappSdk::Api::Response) }
def get_message_template_namespace(business_id:)
Expand All @@ -135,7 +135,7 @@ def get_message_template_namespace(business_id:)
#
# Message templates can only be edited when in an Approved, Rejected, or Paused state.
#
# @param id [String] Required The message_template-id.
# @param id [String] Required. The message_template-id.
# @param components_json [Json] Components that make up the template..
# return [WhatsappSdk::Api::Response] Response object.
def update(template_id:, category: nil, components_json: nil)
Expand Down Expand Up @@ -168,8 +168,9 @@ def update(template_id:, category: nil, components_json: nil)
# To delete a template by ID, include the template's ID along with its name in your request;
# only the template with the matching template ID will be deleted.
#
# @param name [String] Required The template's name.
# @param hsm_id [String] Optional The template's id.
# @param business_id [Integer] Required. The business ID.
# @param name [String] Required. The template's name.
# @param hsm_id [String] Optional. The template's id.
#
# @return [WhatsappSdk::Api::Response] Response object.
sig do
Expand Down

0 comments on commit 4219efd

Please sign in to comment.