protected static function replaceTemplateVariables(&$html, License $license) { $mapping = ['%_TECH_CONTACT_%' => $license->getTechContactName(), '%_TECH_CONTACT_FIRST_NAME_%' => self::getFirstName($license->getTechContactName()), '%_ADDON_NAME_%' => $license->getAddonName(), '%_ADDON_KEY_%' => $license->getAddonKey(), '%_LICENSE_ID_%' => $license->getLicenseId(), '%_ADDON_URL_%' => self::buildAddonURL($license->getAddonKey()), '%_LICENSE_START_DATE_%' => $license->getStartDate()->format('Y-m-d'), '%_LICENSE_END_DATE_%' => $license->getEndDate()->format('Y-m-d')]; foreach ($mapping as $token => $replacement) { $html = str_replace($token, $replacement, $html); } }
private function add($listId, License $license) { $body = ['email_address' => $license->getTechContactEmail(), 'status' => 'subscribed', 'merge_fields' => ['FNAME' => $license->getTechContactName()]]; $headers = ['auth' => ['', $this->apiKey], 'body' => json_encode($body)]; $url = 'https://' . $this->dc . '.api.mailchimp.com/3.0/lists/' . $listId . '/members'; try { $client = new Client(); $client->post($url, $headers); $this->output->writeln('Added ' . $license->getTechContactEmail() . ' to the ' . $listId); } catch (ClientException $e) { } }
/** * @param DrillSchemaEvent $drillSchemaEvent * @param License $license * * @return \DateTime */ private function calculateSendDate(DrillSchemaEvent $drillSchemaEvent, License $license) { $shift = $drillSchemaEvent->getDateShift(); if ('startDate' == $drillSchemaEvent->getDateField()) { $direction = '+'; $licenseDate = $license->getStartDate(); } else { // endDate, negative shift $direction = '-'; $licenseDate = $license->getEndDate(); } $sendDate = new \DateTime(); $sendDate->setTimestamp($licenseDate->getTimestamp()); $sendDate->modify($direction . $shift . ' days'); return $sendDate; }
private function getRecipients(License $license) { $recipients = []; if ($this->input->getOption('env') == 'prod') { $recipients[] = ['email' => $license->getTechContactEmail(), 'name' => $license->getTechContactName()]; if ($license->getTechContactEmail() != $license->getBillingContactEmail()) { $recipients[] = ['email' => $license->getBillingContactEmail(), 'name' => $license->getBillingContactName()]; } } else { $recipients[] = ['email' => $this->getContainer()->getParameter('vendor_email')]; } return $recipients; }
/** * @param $licenseId * @param $licenseType * @param $organisationName * @param $addonName * @param $addonKey * @param $techContactName * @param $techContactEmail * @param $techContactPhone * @param $startDate * @param $endDate * * @return License */ public static function createLicense($licenseId, $licenseType, $organisationName, $addonName, $addonKey, $techContactName, $techContactEmail, $techContactPhone, $startDate, $endDate) { $license = new License(); $license->setLicenseId($licenseId)->setLicenseType($licenseType)->setOrganisationName($organisationName)->setAddonName($addonName)->setAddonKey($addonKey)->setTechContactName($techContactName)->setTechContactEmail($techContactEmail)->setTechContactPhone($techContactPhone)->setStartDate(new \DateTime($startDate))->setEndDate(new \DateTime($endDate)); return $license; }