Generates the payload expected by the API.

@param string    $type
@param string    $to
@param string    $templateId
@param array     $personalisation
@param string    $reference

@return array
498185
private function buildPayload( $type, $to, $templateId, array $personalisation, $reference ){

        $payload = [
            'template_id'=> $templateId
        ];

        if ( $type == 'sms' ) {
            $payload['phone_number'] = $to;
        } else if ( $type == 'email' ) {
            $payload['email_address'] = $to;
        }

        if ( count($personalisation) > 0 ) {
            $payload['personalisation'] = $personalisation;
        }

        if ( isset($reference) && $reference != '' ) {
            $payload['reference'] = $reference;
        }

        return $payload;

    }
777575
public function getMailRendered($template, array $variables = [], $type = MailTypes::TYPE_ALL)
    {
        $id = $this->getCacheId($template, $variables, $type);

        if (!isset($this->cache[$template][$id])) {
            $this->cache[$template][$id] = $this->getTemplater()->render($template, $variables, $type);
        }

        return $this->cache[$template][$id];
    }
347720
public function newAuthorizeRequest($type, $typeId, $authParams = [])
    {
        if ($this->authorizationServer->hasGrantType('authorization_code')) {
            /** @var AuthCodeGrant $authGrant */
            $authGrant = $this->authorizationServer->getGrantType('authorization_code');
            return $authGrant->newAuthorizeRequest($type, $typeId, $authParams);
        }

        return '';
    }
872055
public function render(string $templateID, string $language, \Swift_Mime_SimpleMessage &$message)
    {
        // Find Template
        $template = $this->entityManager
            ->getRepository(MailTemplate::class)
            ->findOneBy(['templateId' => $templateID, 'status' => true, 'language' => $language]);

        if ((null === $template) && ($language !== $this->defaultLanguage)) {
            return $this->render($templateID, $this->defaultLanguage, $message);
        }

        // Render Template
        if (null !== $template) {
            // Render Body
            try {
                $message->setBody(
                    $this->twig->createTemplate($template->getTemplate())->render(unserialize($message->getBody())),
                    $message->getContentType(),
                    $message->getCharset());
            } catch (\Exception $e) {
            }

            // Set Header
            if (!empty($template->getFromName()) && !empty($template->getFromEmail())) {
                $message->setFrom($template->getFromEmail(), $template->getFromName());
            }

            // Set Subject
            if (!empty($template->getSubject())) {
                $message->setSubject($template->getSubject());
            }

            return true;
        }

        return false;
    }
1198504
public function setToType($to_type)
    {
        if ($to_type == $this->to_type) return $this;
        $to_type = strtoupper($to_type);
        if (!isset(self::getAddressTypes()[$to_type])) {
            throw new \InvalidArgumentException(sprintf('The "%s" to_type is not a valid address type.', $to_type));
        }
        $this->to_type = $to_type;
        return $this;
    }
359526
private function loadTemplate($templateId)
    {
        $template = $this->templateFactory->create();
        $this->templateResource->load($template, $templateId);

        return $template;
    }
432291
public function template($type, $options) {
		if (isset($options[$type])) {
			return $options[$type];
		}
		return isset($options['template']) ? $options['template'] : '';
	}
828933
public static function data_for_template_competencies_page($templateid, $pagecontext) {
        global $PAGE;
        $params = self::validate_parameters(self::data_for_template_competencies_page_parameters(), array(
            'templateid' => $templateid,
            'pagecontext' => $pagecontext
        ));

        $context = self::get_context_from_params($params['pagecontext']);
        self::validate_context($context);

        $template = api::read_template($params['templateid']);
        $renderable = new output\template_competencies_page($template, $context);
        $renderer = $PAGE->get_renderer('tool_lp');

        $data = $renderable->export_for_template($renderer);

        return $data;
    }
793986
def get_reference_template(self, ref_type):
        
        template = self._zotero_lib.item_template(ref_type)
        return OrderedDict(sorted(template.items(), key=lambda x: x[0]))
157838
public function sendTemplateMessageByType($touser, $type, $data, $url = null) {
		return isset($this->templates[$type]) && $this->sendTemplateMessage($touser, $this->templates[$type], $data, $url);
	}
875129
public function sendPrecompiledLetter( $reference, $pdf_data, $postage = NULL ){
        $payload = [
          'reference' => $reference,
          'content' => base64_encode($pdf_data)
        ];

        if ($postage != NULL) {
          $payload['postage'] = $postage;
        }

        return $this->httpPost(
            self::PATH_NOTIFICATION_SEND_LETTER,
            $payload
        );

    }
1268571
public function send($touser, $template_id, $url, $data = [])
    {
        if (!is_string($touser) || !is_string($template_id) || !is_array($data) || empty($data)) {
            $this->setError('参数错误');

            return false;
        }

        $queryStr = [
            'touser'      => $touser,
            'template_id' => $template_id,
            'url'         => $url,
            'data'        => $data,
        ];

        $this->module = 'message';

        $res = $this->_post('template/send', $queryStr);

        return $res;
    }
1040219
public function loadReverseRelations($toContentId, $relationType = null)
    {
        $query = $this->queryBuilder->createRelationFindQuery();
        $query->where(
            $query->expr->eq(
                $this->dbHandler->quoteColumn('to_contentobject_id', 'ezcontentobject_link'),
                $query->bindValue($toContentId, null, \PDO::PARAM_INT)
            )
        );

        // ezcontentobject join
        $query->from(
            $this->dbHandler->quoteTable('ezcontentobject')
        )->where(
            $query->expr->lAnd(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('id', 'ezcontentobject'),
                    $this->dbHandler->quoteColumn('from_contentobject_id', 'ezcontentobject_link')
                ),
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('current_version', 'ezcontentobject'),
                    $this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link')
                ),
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('status', 'ezcontentobject'),
                    $query->bindValue(1, null, \PDO::PARAM_INT)
                )
            )
        );

        // relation type
        if (isset($relationType)) {
            $query->where(
                $query->expr->gt(
                    $query->expr->bitAnd(
                        $this->dbHandler->quoteColumn('relation_type', 'ezcontentobject_link'),
                        $query->bindValue($relationType, null, \PDO::PARAM_INT)
                    ),
                    0
                )
            );
        }

        $statement = $query->prepare();

        $statement->execute();

        return $statement->fetchAll(\PDO::FETCH_ASSOC);
    }
76267
public function getTemplateById($template_id)
		{
			$form_data = array(
				'template_id' => $template_id
			);
			$xml = $this->call('gettemplatebyid', $form_data);

			$template = new Template;
			$template
				->setFolderId((int)$xml->folder_id)
				->setTemplateId((int)$xml->template_id)
				->setName((string)$xml->template_name)
				->setSubject((string)$xml->template_subject)
				->setBodyPlain((string)$xml->body_plain)
				->setBodyHtml((string)$xml->body_html)
				->setDescription((string)$xml->template_description);

			return $template;
		}
1318682
public function privilegeKeyCreate(
        $type = Teamspeak::TOKEN_SERVERGROUP,
        $id1,
        $id2 = 0,
        $description = null,
        $customset = null
    ) {
        $token = $this->execute(
            "privilegekeyadd",
            array(
                "tokentype" => $type,
                "tokenid1" => $id1,
                "tokenid2" => $id2,
                "tokendescription" => $description,
                "tokencustomset" => $customset
            )
        )->toList();

        Signal::getInstance()->emit("notifyTokencreated", $this, $token["token"]);

        return $token["token"];
    }
90316
public function determineActions(Type $fromType, Type $toType)
    {
        $actions = array();
        foreach ($fromType->fieldDefinitions as $fieldDef) {
            if (!$this->hasFieldDefinition($toType, $fieldDef)) {
                $actions[] = new ContentUpdater\Action\RemoveField(
                    $this->contentGateway,
                    $fieldDef,
                    $this->storageHandler,
                    $this->contentMapper
                );
            }
        }
        foreach ($toType->fieldDefinitions as $fieldDef) {
            if (!$this->hasFieldDefinition($fromType, $fieldDef)) {
                $actions[] = new ContentUpdater\Action\AddField(
                    $this->contentGateway,
                    $fieldDef,
                    $this->converterRegistry->getConverter(
                        $fieldDef->fieldType
                    ),
                    $this->storageHandler,
                    $this->contentMapper
                );
            }
        }

        return $actions;
    }
879228
public function previewTemplate( $templateId, $personalisation){
        $path = sprintf( self::PATH_TEMPLATE_PREVIEW, $templateId );
        $payload = [
          'personalisation'=>$personalisation
        ];
        return $this->httpPost( $path, $payload );
    }