Exemple #1
0
    /**
     * @return int
     */
    public function execute()
    {
        /*$campaignContact = new CampaignContact();
            $campaignContact->campaignId = rand(1,9);
            $campaignContact->language = array_rand(
              ["en" => "en", "es" => "es", "de" => "de",]
            );
            $campaignContact->contactId = rand(1,9);
            $campaignContact->saveChanges();
        
        
            return 0;*/
        $contact = new Contact();
        $contact->name = "John Smith";
        $contact->description = "John the test monkey";
        $contact->email = "*****@*****.**";
        $contact->jobTitle = "Test Monkey";
        $contact->reference = "johnsmith";
        $contact->signature = '
Kind Regards

John Smith
Test Monkey
Cubex Tester
0123-456-789';
        $contact->saveChanges();
        $campaign = new Campaign();
        $campaign->reference = "testcampaign:" . FileSystem::readRandomCharacters(3);
        $campaign->name = "Test Campaign";
        $campaign->description = "A test created with sample data";
        $campaign->active = true;
        $campaign->contactId = $contact->id();
        $campaign->type = CampaignType::ACTION;
        $campaign->saveChanges();
        $message = $campaign->message();
        $message->setLanguage('en');
        $message->subject = "This is my subject";
        $message->plainText = "Hello {{name}}. how are you today?";
        $message->saveAsNew();
        $message->setLanguage('es');
        $message->subject = "Este es mi tema";
        $message->plainText = "Hola {{name}}. ¿Cómo estás hoy?";
        $message->saveAsNew();
        $message->setLanguage('de');
        $message->subject = "Dies ist mein Thema";
        $message->plainText = "Hallo {{name}}. Wie geht es Ihnen heute?";
        $message->saveAsNew();
    }
Exemple #2
0
 public function add()
 {
     $this->_throwIfNotSet("reference");
     $this->_throwIfNotSet("description");
     $this->_throwIfNotSet("name");
     $this->_throwIfNotSet("email");
     $contact = new Contact();
     $contact->reference = $this->reference;
     $contact->description = $this->description;
     $contact->name = $this->name;
     $contact->email = $this->email;
     $contact->jobTitle = $this->jobTitle;
     $contact->signature = $this->signature;
     $contact->saveChanges();
     echo "Added contact id {$contact->id()} ({$contact->name})";
 }
Exemple #3
0
 private static function _tryGetMapperUrl($query)
 {
     if (preg_match("/^(?:.* |)(?<tag>[CcP][0-9]+)(?:.* |)\$/", $query, $matches)) {
         $tag = $matches['tag'];
         $id = substr($tag, 1);
         $map = null;
         $ep = null;
         switch (substr($tag, 0, 1)) {
             case 'C':
                 $ep = "/campaigns/%d";
                 $map = new Campaign($id);
                 break;
             case 'c':
                 $ep = "/contacts/%d";
                 $map = new Contact($id);
                 break;
         }
         if ($map instanceof RecordMapper) {
             if ($map->exists()) {
                 return sprintf($ep, $map->id());
             }
         }
     }
     return null;
 }