CreateAddressList
Oleg Zech이(가) 2 년 전에 이 페이지를 수정함
create or replace function api."CreateSMSCampaign"(
    _formset formset -- Formset (a template containing common form properties) to use
, _address_list uuid -- address list created with api."CreateAddressList"
, _send_at timestamptz -- Date and time to send the form
, _sender text -- SMS Sender name (max 11 chars) visible as SMS sender
, _time_end time -- Hour of the day when to stop sending forms
, _time_start time -- Hour of the day when to start sending forms
, _name text -- Campaign name, keep it distinct ("Teachers Limassol", "Students Nicosia")
, _skip_duplicates bool default true -- Skip duplicate mobile numbers
, out campaign forms.campaigns
)
Feature: Create a campaign from a formset and an address list.

    Scenario: Create a campaign
        Given a formset
        And an address list
        And a send_at date (when to send the form)
        And a sender name (max 11 chars) as SMS sender
        And a time_start (hour of the day when to start sending forms)
        And a time_end (hour of the day when to stop sending forms)
        And a campaign name (keep it distinct) i.e. "Teachers Limassol", "Students Nicosia"
        And a skip_duplicates flag (skip duplicate mobile numbers)
        When I create a campaign
        Then I should have a campaign
        And I should have forms
        And I should have a result
[
  {
    "campaign": "34716d44-bcbd-4c77-a51f-b6b9736c2cab",
    "timestamp": "2023-02-04 04:09:15.614080 +00:00",
    "creator": "v35799882090",
    "name": "MySchool Campaign",
    "send_at": "2023-02-04 04:10:15.614080 +00:00",
    "time_start": "08:00:00",
    "time_end": "23:00:00"
  }
]
    Scenario Outline: Start a campaign outside of start/end time
        Given all parameters are valid
        And the send_at date is set to now or past
        And send_at time is outside of time_start and time_end
        When I create a campaign
        Then I should have a campaign
        And I should have forms in sms.queue with status 'pending'
        And I should wait for the next day time_start
        And I should have a result OK

    Scenario Outline: Start a campaign inside of start/end time
        Given all parameters are valid
        And the send_at date is set to now or past
        And send_at time is inside of time_start and time_end
        When I create a campaign
        Then I should have a campaign
        And I should have forms in sms.queue with status 'SENT'
        And I should have a result OK
        
    Scenario Outline: Start a campaign in the future
        Given all parameters are valid
        And the send_at date is set to future
        When I create a campaign
        Then I should have a campaign
        And I should have forms in sms.queue with status 'pending'
        And I should send the forms at first time_start/time_end window after send_at
        And I should have a result O