Skip to content

Commit

Permalink
Release 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Heinz committed Apr 30, 2018
0 parents commit 56bde8d
Show file tree
Hide file tree
Showing 22 changed files with 893 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# CSS-Files
[*.css]
indent_style = tab
indent_size = 4

# HTML-Files
[*.html]
indent_style = tab
indent_size = 2

# TMPL-Files
[*.tmpl]
indent_style = tab
indent_size = 4

# SCSS-Files
[*.scss]
indent_style = space
indent_size = 4

# JS-Files
[*.js]
indent_style = space
indent_size = 2

# JSON-Files
[*.json]
indent_style = tab
indent_size = 4

# PHP-Files
[*.php]
indent_style = space
indent_size = 4

# ReST-Files
[*.rst]
indent_style = space
indent_size = 3

# MD-Files
[*.md]
indent_style = space
indent_size = 4

# YAML-Files
[{*.yaml,*.yml}]
indent_style = space
indent_size = 2

# package.json
# .travis.yml
# bower.json
[{package.json,.travis.yml,bower.json}]
indent_style = space
indent_size = 2

# TypoScript
[*.ts]
indent_style = space
indent_size = 2
[*.typoscript]
indent_style = space
indent_size = 2

# XLF-Files
[*.xlf]
indent_style = tab
indent_size = 4

# SQL-Files
[*.sql]
indent_style = tab
indent_size = 2
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*~
*.bak
*.swp
.DS_Store
Thumbs.db
nbproject
*.idea
*.project
.buildpath
.settings
.TemporaryItems
.webprj
.cache
.php_cs.cache
.sass-cache
.session
composer.lock
60 changes: 60 additions & 0 deletions Classes/CleverReach/Api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
namespace T3premium\FemanagerCleverreach\CleverReach;

use T3premium\FemanagerCleverreach\Tools\Rest;

class Api
{
/**
* @var \T3premium\FemanagerCleverreach\Service\ConfigurationService
* @inject
*/
protected $configurationService;

/**
* @var Rest
*/
protected $rest;

public function connect()
{

if ($this->rest !== null) {
return;
}

$this->rest = new Rest($this->configurationService->getRestUrl());

// Get CleverReach connection data of typoscript
$token = $this->rest->post('/login',
[
'client_id' => $this->configurationService->getClientId(),
'login' => $this->configurationService->getClientLogin(),
'password' => $this->configurationService->getClientPassword()
]
);
$this->rest->setAuthMode('bearer', $token);
}

/**
* Adds new receiver CleverReach. Ignores, if already in list.
*
* @param array $receivers
* @param int $groupId
* @return mixed
*/
public function addReceiversToGroup($receivers, $groupId = null)
{
// Connect to CleverReach REST API
$this->connect();

if ($groupId === null || $groupId === '') {
$groupId = $this->configurationService->getGroupId();
}

$return = $this->rest->post('/groups/' . $groupId . '/receivers',
$receivers
);
}

}
50 changes: 50 additions & 0 deletions Classes/Finisher/CleverReachFinisher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
namespace T3premium\FemanagerCleverreach\Finisher;

use In2code\Femanager\Domain\Model\User;
use In2code\Femanager\Finisher\AbstractFinisher;

/**
* Class CleverReachFinisher
*
* @package T3premium\FemanagerCleverreach\Finisher
*/
class CleverReachFinisher extends AbstractFinisher
{

/**
* @var \T3premium\FemanagerCleverreach\CleverReach\Api
* @inject
*/
protected $api;

/**
* @var User
*/
protected $user;

/**
* @var array
*/
protected $configuration;

/**
* CrFinisher
*
* @return void
*/
public function crFinisher()
{

$receivers[] = array(
"email" => $this->user->getEmail(),
"firstname" => $this->user->getFirstName(),
"lastname" => $this->user->getLastName(),
"registered" => strtotime("now"),
"activated" => strtotime("now"),
);

// Add new receiver to CleverReach
$this->api->addReceiversToGroup($receivers,$groupId);
}
}
73 changes: 73 additions & 0 deletions Classes/Service/ConfigurationService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
namespace T3premium\FemanagerCleverreach\Service;

/**
* Class ConfigurationService
*/
class ConfigurationService {


/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
* @inject
*/
protected $objectManager;


public function getConfiguration() {
/**
* @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
* $configurationManager
*/
$configurationManager = $this->objectManager->get('TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface');
$settings = $configurationManager->getConfiguration(
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT,
'femanager'
);
return $settings['plugin.']['tx_femanager.']['settings.']['finishers.']['100.']['config.'];
}

/**
* @return string
*/
public function getRestUrl() {

$config = $this->getConfiguration();
return $config['restUrl'];

}

/**
* @return int
*/
public function getClientId() {

$config = $this->getConfiguration();
return (int)$config['clientId'];

}

/**
* @return string
*/
public function getClientLogin() {
$config = $this->getConfiguration();
return $config['clientLogin'];
}

/**
* @return string
*/
public function getClientPassword() {
$config = $this->getConfiguration();
return $config['clientPassword'];
}

/**
* @return int
*/
public function getGroupId() {
$config = $this->getConfiguration();
return (int)$config['groupId'];
}
}
Loading

0 comments on commit 56bde8d

Please sign in to comment.