diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b67c34 --- /dev/null +++ b/.gitignore @@ -0,0 +1,110 @@ +### Composer template +composer.phar +vendor/ + +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +# User-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# .idea/dictionaries + +# Sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml +# .idea/uiDesigner.xml + +# Gradle: +# .idea/gradle.xml +# .idea/libraries + +# Mongo Explorer plugin: +# .idea/mongoSettings.xml + +## File-based project format: +*.ipr +*.iws + +# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +# composer.lock + + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +### Linux template +*~ + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* +### Windows template +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk +### OSX template +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Created by .ignore support plugin (hsz.mobi) diff --git a/Contract/Formatable.php b/Contract/Formatable.php new file mode 100644 index 0000000..eb078df --- /dev/null +++ b/Contract/Formatable.php @@ -0,0 +1,11 @@ +message = $message; + } + + public function setSource($name) + { + $this->source = $name; + } + public function getSource() + { + return !empty($this->source) ? $this->source : gethostname(); + } + + + /** + * @return string + */ + public function format() + { + $out = array( + 'brand' => $this->getSource(), + 'event_name' => $this->message->getEvent(), + 'to' => array( + 'client_id' => $this->message->getClientId(), + 'email' => $this->message->getEmail(), + 'first_name' => $this->message->getFirstName(), + 'last_name' => $this->message->getLastName(), + 'lang' => $this->message->getLang(), + ), + 'vars' => $this->message->getExtras(), + ); + return json_encode($out); + } + +} \ No newline at end of file diff --git a/Messages/Simple.php b/Messages/Simple.php new file mode 100644 index 0000000..e3cba8f --- /dev/null +++ b/Messages/Simple.php @@ -0,0 +1,156 @@ +clientId; + } + + /** + * @param int $clientId + */ + public function setClientId($clientId) + { + $this->clientId = $clientId; + } + + /** + * @return null + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param null $email + */ + public function setEmail($email) + { + $this->email = $email; + } + + /** + * @return string + */ + public function getFirstName() + { + return $this->first_name; + } + + /** + * @param string $first_name + */ + public function setFirstName($first_name) + { + $this->first_name = $first_name; + } + + /** + * @return string + */ + public function getLastName() + { + return $this->last_name; + } + + /** + * @param string $last_name + */ + public function setLastName($last_name) + { + $this->last_name = $last_name; + } + + /** + * @return string + */ + public function getLang() + { + return $this->lang; + } + + /** + * @param string $lang + */ + public function setLang($lang = 'en') + { + $this->lang = $lang; + } + + /** + * @return array + */ + public function getExtras() + { + return $this->extras; + } + + /** + * @param array $vars + */ + public function setExtras(array $extras) + { + $this->extras = $extras; + } + + /** + * @return string + */ + public function getEvent() + { + return $this->event; + } + + /** + * @param string $event + */ + public function setEvent($event) + { + $this->event = $event; + } + + +} diff --git a/Notification.php b/Notification.php new file mode 100644 index 0000000..9d4b718 --- /dev/null +++ b/Notification.php @@ -0,0 +1,44 @@ +source = $name; + } + + /** + * @param MessageFormatter $formatter + */ + public function setFormatter(MessageFormatter $formatter) + { + $this->formatter = $formatter; + } + + /** + * @param Messageable $message + * @return string + */ + public function getFormatted(Messageable $message) + { + $this->formatter->setSource($this->source); + $this->formatter->setMessage($message); + return $this->formatter->format(); + } + + +}