lib/whats/actions/send_hsm_message.rb in whatsapp-0.1.5 vs lib/whats/actions/send_hsm_message.rb in whatsapp-1.0.0
- old
+ new
@@ -3,39 +3,44 @@
module Whats
module Actions
class SendHsmMessage
PATH = "/v1/messages"
- def initialize(client, wa_id, namespace, element_name, params)
+ def initialize(client, wa_id, namespace, element_name, language, params)
@client = client
@wa_id = wa_id
@namespace = namespace
@element_name = element_name
+ @language = language
@params = params
end
def call
client.request PATH, payload
end
private
- attr_reader :client, :wa_id, :namespace, :element_name, :params
+ attr_reader :client, :wa_id, :namespace, :element_name, :language, :params
def payload
{
hsm: {
element_name: element_name,
- language: {
- code: :pt_BR,
- policy: :deterministic
- },
+ language: language.is_a?(Hash) ? language : language_options(language),
localizable_params: params,
namespace: namespace
},
recipient_type: :individual,
to: wa_id,
type: :hsm
+ }
+ end
+
+ def language_options(language)
+ {
+ code: language,
+ policy: :deterministic
}
end
end
end
end