Skip to content

Commit

Permalink
inital
Browse files Browse the repository at this point in the history
  • Loading branch information
LasseRafn committed Nov 28, 2016
0 parents commit 3c8b657
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
composer.lock
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The MIT License (MIT)

Copyright (c) 2016 Lasse Rafn <[email protected]>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "lasserafn/laravel-pipedrive-signup",
"description": "",
"keywords": ["laravel", "pipedrive", "signup"],
"license": "MIT",
"authors": [
{
"name": "Lasse Rafn",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "5.1.*|5.2.*|5.3.*",
"guzzlehttp/guzzle": "^6.2"
},
"require-dev": {
},
"autoload": {
"psr-4": {
"LasseRafn\\PipedriveSignup\\": "src"
}
}
}
14 changes: 14 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Laravel Pipedrive Signup

#Installation

1. Require using composer
````
composer require lasserafn/laravel-pipedrive-signup
````
2. Add the PipedriveSignupServiceProvider to your ````config/app.php```` providers array.
````
'providers' => [
\LasseRafn\PipedriveSignup\PipedriveSignupServiceProvider::class,
]
````
46 changes: 46 additions & 0 deletions src/PipedriveSignup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php namespace LasseRafn\PipedriveSignup;

use GuzzleHttp\Client;

class PipedriveSignup
{
protected $endpoint = 'https://secure.e-conomic.com';
private $referralKey;

function __construct()
{
$this->referralKey = config( 'pipedrive-signup.referral_key' );

$this->client = new Client( [
'base_uri' => $this->endpoint,
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded'
]
] );
}

public function signup( $userName, $userEmail, $companyName )
{
try
{
$this->client->post( '/secure/signup/partnertrial/', [
'form_params' => [
'UserEmail' => $userEmail,
'UserName' => $userName,
'CompanyName' => $companyName,
'PartnerAgreementNo' => $this->partnerAgreementNo,
'PartnerKey' => $this->partnerKey
],
'Content-Type' => 'application/x-www-form-urlencoded'
] );

// todo check if redirected to welcome page!

return true;
} catch ( \Exception $exception )
{
throw new \Exception( $exception->getMessage(), $exception->getCode(), $exception->getPrevious() );
}

}
}
32 changes: 32 additions & 0 deletions src/PipedriveSignupServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php namespace LasseRafn\PipedriveSignup;

use Illuminate\Support\ServiceProvider;

class PipedriveSignupServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;

/**
* Boot
*/
public function boot()
{
$configPath = __DIR__ . '/config/pipedrive-signup.php';
$this->mergeConfigFrom($configPath, 'pipedrive-signup');

$configPath = __DIR__ . '/config/pipedrive-signup.php';

if (function_exists('config_path')) {
$publishPath = config_path('pipedrive-signup.php');
} else {
$publishPath = base_path('config/pipedrive-signup.php');
}

$this->publishes([$configPath => $publishPath], 'config');
}
}
4 changes: 4 additions & 0 deletions src/config/pipedrive-signup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
return [
'referral_key' => '' // In case you want to referr people too
];

0 comments on commit 3c8b657

Please sign in to comment.