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 c0b3ae2
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 81 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
147 changes: 75 additions & 72 deletions lib/whatsapp_sdk/resource/languages.rb
Original file line number Diff line number Diff line change
@@ -1,79 +1,82 @@
# typed: false
# frozen_string_literal: true

module WhatsappSdk
module Resource
class Languages
AVAILABLE_LANGUAGES = Set.new([
"af", # Afrikaans
"sq", # Albanian
"ar", # Arabic
"az", # Azerbaijani
"bn", # Bengali
"bg", # Bulgarian
"ca", # Catalan
"zh_CN", # Chinese (CHN)
"zh_HK", # Chinese (HKG)
"zh_TW", # Chinese (TAI)
"hr", # Croatian
"cs", # Czech
"da", # Danish
"nl", # Dutch
"en", # English
"en_GB", # English (UK)
"en_US", # English (US)
"et", # Estonian
"fil", # Filipino
"fi", # Finnish
"fr", # French
"ka", # Georgian
"de", # German
"el", # Greek
"gu", # Gujarati
"ha", # Hausa
"he", # Hebrew
"hi", # Hindi
"hu", # Hungarian
"id", # Indonesian
"ga", # Irish
"it", # Italian
"ja", #Japanese
"kn", #Kannada
"kk", #Kazakh
"rw_RW", #Kinyarwanda
"ko", #Korean
"ky_KG", #Kyrgyz (Kyrgyzstan)
"lo", #Lao
"lv", #Latvian
"lt", #Lithuanian
"mk", # Macedonian
"ms", # Malay
"ml", # Malayalam
"mr", # Marathi
"nb", # Norwegian
"fa", # Persian
"pl", # Polish
"pt_BR", # Portuguese (BR)
"pt_PT", # Portuguese (POR)
"pa", # Punjabi
"ro", # Romanian
"ru", # Russian
"sr", # Serbian
"sk", # Slovak
"sl", # Slovenian
"es", # Spanish
"es_AR", # Spanish (ARG)
"es_ES", # Spanish (SPA)
"es_MX", # Spanish (MEX)
"sw", # Swahili
"sv", # Swedish
"ta", # Tamil
"te", # Telugu
"th", # Thai
"tr", # Turkish
"uk", # Ukrainian
"ur", # Urdu
"uz", # Uzbek
"vi", # Vietnamese
"zu", # Zulu
])
"af", # Afrikaans
"sq", # Albanian
"ar", # Arabic
"az", # Azerbaijani
"bn", # Bengali
"bg", # Bulgarian
"ca", # Catalan
"zh_CN", # Chinese (CHN)
"zh_HK", # Chinese (HKG)
"zh_TW", # Chinese (TAI)
"hr", # Croatian
"cs", # Czech
"da", # Danish
"nl", # Dutch
"en", # English
"en_GB", # English (UK)
"en_US", # English (US)
"et", # Estonian
"fil", # Filipino
"fi", # Finnish
"fr", # French
"ka", # Georgian
"de", # German
"el", # Greek
"gu", # Gujarati
"ha", # Hausa
"he", # Hebrew
"hi", # Hindi
"hu", # Hungarian
"id", # Indonesian
"ga", # Irish
"it", # Italian
"ja", # Japanese
"kn", # Kannada
"kk", # Kazakh
"rw_RW", # Kinyarwanda
"ko", # Korean
"ky_KG", # Kyrgyz (Kyrgyzstan)
"lo", # Lao
"lv", # Latvian
"lt", # Lithuanian
"mk", # Macedonian
"ms", # Malay
"ml", # Malayalam
"mr", # Marathi
"nb", # Norwegian
"fa", # Persian
"pl", # Polish
"pt_BR", # Portuguese (BR)
"pt_PT", # Portuguese (POR)
"pa", # Punjabi
"ro", # Romanian
"ru", # Russian
"sr", # Serbian
"sk", # Slovak
"sl", # Slovenian
"es", # Spanish
"es_AR", # Spanish (ARG)
"es_ES", # Spanish (SPA)
"es_MX", # Spanish (MEX)
"sw", # Swahili
"sv", # Swedish
"ta", # Tamil
"te", # Telugu
"th", # Thai
"tr", # Turkish
"uk", # Ukrainian
"ur", # Urdu
"uz", # Uzbek
"vi", # Vietnamese
"zu" # Zulu
])

def self.available?(language)
AVAILABLE_LANGUAGES.include?(language)
Expand Down

0 comments on commit c0b3ae2

Please sign in to comment.