2021-10-05 18:05:06 +00:00
|
|
|
FactoryBot.define do
|
|
|
|
factory :channel_whatsapp, class: 'Channel::Whatsapp' do
|
|
|
|
sequence(:phone_number) { |n| "+123456789#{n}1" }
|
|
|
|
account
|
|
|
|
provider_config { { 'api_key' => 'test_key' } }
|
2021-11-30 15:20:35 +00:00
|
|
|
message_templates do
|
|
|
|
[{ 'name' => 'sample_shipping_confirmation',
|
|
|
|
'status' => 'approved',
|
|
|
|
'category' => 'SHIPPING_UPDATE',
|
|
|
|
'language' => 'id',
|
|
|
|
'namespace' => '2342384942_32423423_23423fdsdaf',
|
|
|
|
'components' =>
|
|
|
|
[{ 'text' => 'Paket Anda sudah dikirim. Paket akan sampai dalam {{1}} hari kerja.', 'type' => 'BODY' },
|
|
|
|
{ 'text' => 'Pesan ini berasal dari bisnis yang tidak terverifikasi.', 'type' => 'FOOTER' }],
|
|
|
|
'rejected_reason' => 'NONE' },
|
2022-01-13 01:41:42 +00:00
|
|
|
{ 'name' => 'customer_yes_no',
|
|
|
|
'status' => 'approved',
|
|
|
|
'category' => 'SHIPPING_UPDATE',
|
|
|
|
'language' => 'ar',
|
|
|
|
'namespace' => '2342384942_32423423_23423fdsdaf23',
|
|
|
|
'components' =>
|
|
|
|
[{ 'text' => 'عميلنا العزيز الرجاء الرد على هذه الرسالة بكلمة *نعم* للرد على إستفساركم من قبل خدمة العملاء.',
|
|
|
|
'type' => 'BODY' }],
|
|
|
|
'rejected_reason' => 'NONE' },
|
2021-11-30 15:20:35 +00:00
|
|
|
{ 'name' => 'sample_shipping_confirmation',
|
|
|
|
'status' => 'approved',
|
|
|
|
'category' => 'SHIPPING_UPDATE',
|
|
|
|
'language' => 'en_US',
|
|
|
|
'namespace' => '23423423_2342423_324234234_2343224',
|
|
|
|
'components' =>
|
|
|
|
[{ 'text' => 'Your package has been shipped. It will be delivered in {{1}} business days.', 'type' => 'BODY' },
|
|
|
|
{ 'text' => 'This message is from an unverified business.', 'type' => 'FOOTER' }],
|
|
|
|
'rejected_reason' => 'NONE' }]
|
|
|
|
end
|
|
|
|
message_templates_last_updated { Time.now.utc }
|
2021-10-05 18:05:06 +00:00
|
|
|
|
2022-06-14 18:16:36 +00:00
|
|
|
transient do
|
|
|
|
sync_templates { true }
|
2022-07-06 19:45:03 +00:00
|
|
|
validate_provider_config { true }
|
2022-06-14 18:16:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
before(:create) do |channel_whatsapp, options|
|
|
|
|
# since factory already has the required message templates, we just need to bypass it getting updated
|
|
|
|
channel_whatsapp.define_singleton_method(:sync_templates) { return } unless options.sync_templates
|
2022-07-06 19:45:03 +00:00
|
|
|
channel_whatsapp.define_singleton_method(:validate_provider_config) { return } unless options.validate_provider_config
|
|
|
|
if channel_whatsapp.provider == 'whatsapp_cloud'
|
2022-10-12 00:32:31 +00:00
|
|
|
channel_whatsapp.provider_config = channel_whatsapp.provider_config.merge({ 'api_key' => 'test_key', 'phone_number_id' => '123456789',
|
|
|
|
'business_account_id' => '123456789' })
|
2022-07-06 19:45:03 +00:00
|
|
|
end
|
2022-06-14 18:16:36 +00:00
|
|
|
end
|
|
|
|
|
2021-10-05 18:05:06 +00:00
|
|
|
after(:create) do |channel_whatsapp|
|
|
|
|
create(:inbox, channel: channel_whatsapp, account: channel_whatsapp.account)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|