Completed
Push — master ( d8c62f...b859cd )
by Albert
01:56
created
src/Repositories/CustomerRepository.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -9,47 +9,47 @@
 block discarded – undo
9 9
  */
10 10
 class CustomersRepository
11 11
 {
12
-    /**
13
-     * Customer Model instance.
14
-     *
15
-     * @var mixed
16
-     **/
17
-    public $customer;
18
-
19
-    /**
20
-     * Create a new instance of the CustomerRepository::class.
21
-     **/
22
-    public function __construct(Customer $customer)
23
-    {
24
-        $this->customer = $customer;
25
-    }
12
+	/**
13
+	 * Customer Model instance.
14
+	 *
15
+	 * @var mixed
16
+	 **/
17
+	public $customer;
18
+
19
+	/**
20
+	 * Create a new instance of the CustomerRepository::class.
21
+	 **/
22
+	public function __construct(Customer $customer)
23
+	{
24
+		$this->customer = $customer;
25
+	}
26 26
 
27 27
 //end __construct()
28 28
 
29
-    /**
30
-     * Find a customer by a field.
31
-     *
32
-     * @return mixid $this
33
-     **/
34
-    public function findCustomer($key, $value)
35
-    {
36
-        return $this->customer->where($key, $value)->first();
37
-    }
29
+	/**
30
+	 * Find a customer by a field.
31
+	 *
32
+	 * @return mixid $this
33
+	 **/
34
+	public function findCustomer($key, $value)
35
+	{
36
+		return $this->customer->where($key, $value)->first();
37
+	}
38 38
 
39 39
 //end findCustomer()
40 40
 
41
-    /**
42
-     * Create Customer with the received response.
43
-     *
44
-     * @return Customer
45
-     *
46
-     * @param array $data
47
-     **/
48
-    public function createCustomer($data)
49
-    {
50
-        // TODO: Perform basic validation on the customer object before saving
51
-        return $this->customer->create($data);
52
-    }
41
+	/**
42
+	 * Create Customer with the received response.
43
+	 *
44
+	 * @return Customer
45
+	 *
46
+	 * @param array $data
47
+	 **/
48
+	public function createCustomer($data)
49
+	{
50
+		// TODO: Perform basic validation on the customer object before saving
51
+		return $this->customer->create($data);
52
+	}
53 53
 
54 54
 //end createCustomer()
55 55
 }//end class
Please login to merge, or discard this patch.
src/EnvatoApi.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -4,105 +4,105 @@
 block discarded – undo
4 4
 
5 5
 class EnvatoApi
6 6
 {
7
-    /**
8
-     * Envanto API bearer token.
9
-     *
10
-     * @var string
11
-     **/
12
-    private $bearer;
13
-
14
-    /**
15
-     * Purchase verification endpoint.
16
-     *
17
-     * @var string
18
-     **/
19
-    protected $url = 'https://api.envato.com/v3/market/author/sale?code=';
20
-
21
-    /**
22
-     * Request headers.
23
-     *
24
-     * @var array
25
-     **/
26
-    private $headers;
27
-
28
-    /**
29
-     * Create EnvantoApi Instance.
30
-     **/
31
-    public function __construct($bearer)
32
-    {
33
-        $this->bearer = $bearer;
34
-        $this->buildHeaders();
35
-    }
7
+	/**
8
+	 * Envanto API bearer token.
9
+	 *
10
+	 * @var string
11
+	 **/
12
+	private $bearer;
13
+
14
+	/**
15
+	 * Purchase verification endpoint.
16
+	 *
17
+	 * @var string
18
+	 **/
19
+	protected $url = 'https://api.envato.com/v3/market/author/sale?code=';
20
+
21
+	/**
22
+	 * Request headers.
23
+	 *
24
+	 * @var array
25
+	 **/
26
+	private $headers;
27
+
28
+	/**
29
+	 * Create EnvantoApi Instance.
30
+	 **/
31
+	public function __construct($bearer)
32
+	{
33
+		$this->bearer = $bearer;
34
+		$this->buildHeaders();
35
+	}
36 36
 
37 37
 //end __construct()
38 38
 
39
-    /**
40
-     * Make a call to the Envato API to verify purchase.
41
-     *
42
-     * @return mixed Guzzle\Response::getBody()
43
-     *
44
-     * @param string $code
45
-     **/
46
-    public function getPurchaseData($code)
47
-    {
48
-        $ch_verify = curl_init($this->url.$code);
49
-        curl_setopt($ch_verify, CURLOPT_HTTPHEADER, $this->headers);
50
-        curl_setopt($ch_verify, CURLOPT_SSL_VERIFYPEER, false);
51
-        curl_setopt($ch_verify, CURLOPT_RETURNTRANSFER, 1);
52
-        curl_setopt($ch_verify, CURLOPT_CONNECTTIMEOUT, 5);
53
-        curl_setopt($ch_verify, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
54
-
55
-        $cinit_verify_data = curl_exec($ch_verify);
56
-        curl_close($ch_verify);
57
-
58
-        if ($cinit_verify_data != '') {
59
-            return json_decode($cinit_verify_data, true);
60
-        }
61
-
62
-        return [
63
-                  'error' => 'exception',
64
-                  'description' => 'A server error was encountered please notify us if you see this',
65
-                 ];
66
-    }
39
+	/**
40
+	 * Make a call to the Envato API to verify purchase.
41
+	 *
42
+	 * @return mixed Guzzle\Response::getBody()
43
+	 *
44
+	 * @param string $code
45
+	 **/
46
+	public function getPurchaseData($code)
47
+	{
48
+		$ch_verify = curl_init($this->url.$code);
49
+		curl_setopt($ch_verify, CURLOPT_HTTPHEADER, $this->headers);
50
+		curl_setopt($ch_verify, CURLOPT_SSL_VERIFYPEER, false);
51
+		curl_setopt($ch_verify, CURLOPT_RETURNTRANSFER, 1);
52
+		curl_setopt($ch_verify, CURLOPT_CONNECTTIMEOUT, 5);
53
+		curl_setopt($ch_verify, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
54
+
55
+		$cinit_verify_data = curl_exec($ch_verify);
56
+		curl_close($ch_verify);
57
+
58
+		if ($cinit_verify_data != '') {
59
+			return json_decode($cinit_verify_data, true);
60
+		}
61
+
62
+		return [
63
+				  'error' => 'exception',
64
+				  'description' => 'A server error was encountered please notify us if you see this',
65
+				 ];
66
+	}
67 67
 
68 68
 //end getPurchaseData()
69 69
 
70
-    /**
71
-     * Verify purchase.
72
-     *
73
-     * @return string Array
74
-     *
75
-     * @param string $code Purchase Code
76
-     **/
77
-    public function verifyPurchase(string $code)
78
-    {
79
-        $purchase = [];
80
-        $purchase['response'] = (object) $this->getPurchaseData($code);
81
-        if ($purchase->error) {
82
-            return $purchase['status'] = 'error';
83
-        } else {
84
-            return $purchase['status'] = 'success';
85
-        }
86
-    }
70
+	/**
71
+	 * Verify purchase.
72
+	 *
73
+	 * @return string Array
74
+	 *
75
+	 * @param string $code Purchase Code
76
+	 **/
77
+	public function verifyPurchase(string $code)
78
+	{
79
+		$purchase = [];
80
+		$purchase['response'] = (object) $this->getPurchaseData($code);
81
+		if ($purchase->error) {
82
+			return $purchase['status'] = 'error';
83
+		} else {
84
+			return $purchase['status'] = 'success';
85
+		}
86
+	}
87 87
 
88 88
 //end verifyPurchase()
89 89
 
90
-    /**
91
-     * setting the header for the rest of the api.
92
-     **/
93
-    protected function buildHeaders()
94
-    {
95
-        $headers = [
96
-                    'Content-type' => 'application/json',
97
-                    'Authorization' => 'Bearer '.$this->bearer,
98
-                   ];
99
-        $h = [];
100
-        foreach ($headers as $key => $value) {
101
-            $h[] = $key.':'.$value;
102
-        }
103
-
104
-        $this->headers = $h;
105
-    }
90
+	/**
91
+	 * setting the header for the rest of the api.
92
+	 **/
93
+	protected function buildHeaders()
94
+	{
95
+		$headers = [
96
+					'Content-type' => 'application/json',
97
+					'Authorization' => 'Bearer '.$this->bearer,
98
+				   ];
99
+		$h = [];
100
+		foreach ($headers as $key => $value) {
101
+			$h[] = $key.':'.$value;
102
+		}
103
+
104
+		$this->headers = $h;
105
+	}
106 106
 
107 107
 //end buildHeaders()
108 108
 }//end class
Please login to merge, or discard this patch.
src/Traits/VerifiesPurchase.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -4,68 +4,68 @@
 block discarded – undo
4 4
 
5 5
 trait VerifiesPurchase
6 6
 {
7
-    /**
8
-     * Customer Entity.
9
-     *
10
-     * @var mixed
11
-     **/
12
-    protected $customer;
7
+	/**
8
+	 * Customer Entity.
9
+	 *
10
+	 * @var mixed
11
+	 **/
12
+	protected $customer;
13 13
 
14
-    /**
15
-     * Verify validity of the purchase key and if valid create customer.
16
-     **/
17
-    public function verifyPurchase()
18
-    {
19
-        $this->getCustomer();
20
-        if (null != $this->customer) {
21
-            return $this->validKeyResponse();
22
-        }
14
+	/**
15
+	 * Verify validity of the purchase key and if valid create customer.
16
+	 **/
17
+	public function verifyPurchase()
18
+	{
19
+		$this->getCustomer();
20
+		if (null != $this->customer) {
21
+			return $this->validKeyResponse();
22
+		}
23 23
 
24
-        $response = app()->envatoapi->verifyPurchase(request('code'));
25
-        if ('error' == $response['status']) {
26
-            return $this->invalidKeyResponse();
27
-        }
24
+		$response = app()->envatoapi->verifyPurchase(request('code'));
25
+		if ('error' == $response['status']) {
26
+			return $this->invalidKeyResponse();
27
+		}
28 28
 
29
-        // If we are here then the key is valid
30
-        // We now create a new customer record from the envato api response
31
-        $this->customer = $this->customers->createCustomer($response['response']);
32
-        // After creation of customer details return the response back to the user
33
-        return $this->validKeyResponse();
34
-    }
29
+		// If we are here then the key is valid
30
+		// We now create a new customer record from the envato api response
31
+		$this->customer = $this->customers->createCustomer($response['response']);
32
+		// After creation of customer details return the response back to the user
33
+		return $this->validKeyResponse();
34
+	}
35 35
 
36 36
 //end verifyPurchase()
37 37
 
38
-    /**
39
-     * Return invalid key response.
40
-     *
41
-     * @return Illuminate\Http\Response
42
-     **/
43
-    protected function invalidKeyResponse()
44
-    {
45
-        return response()->json(['status' => 'error', 'description' => 'Invalid purchase key'], 403);
46
-    }
38
+	/**
39
+	 * Return invalid key response.
40
+	 *
41
+	 * @return Illuminate\Http\Response
42
+	 **/
43
+	protected function invalidKeyResponse()
44
+	{
45
+		return response()->json(['status' => 'error', 'description' => 'Invalid purchase key'], 403);
46
+	}
47 47
 
48 48
 //end invalidKeyResponse()
49 49
 
50
-    /**
51
-     * Set the customer object.
52
-     **/
53
-    protected function getCustomer()
54
-    {
55
-        $this->customer = $this->customers->findCustomer('purchaseKey', request()->get('code'));
56
-    }
50
+	/**
51
+	 * Set the customer object.
52
+	 **/
53
+	protected function getCustomer()
54
+	{
55
+		$this->customer = $this->customers->findCustomer('purchaseKey', request()->get('code'));
56
+	}
57 57
 
58 58
 //end getCustomer()
59 59
 
60
-    /**
61
-     * Return a success response if the purchase key is valid.
62
-     *
63
-     * @return Illuminate\Http\Response json object response
64
-     **/
65
-    protected function validKeyResponse()
66
-    {
67
-        return response()->json(['status' => 'success', 'description' => $this->customer->tojson()]);
68
-    }
60
+	/**
61
+	 * Return a success response if the purchase key is valid.
62
+	 *
63
+	 * @return Illuminate\Http\Response json object response
64
+	 **/
65
+	protected function validKeyResponse()
66
+	{
67
+		return response()->json(['status' => 'success', 'description' => $this->customer->tojson()]);
68
+	}
69 69
 
70 70
 //end validKeyResponse()
71 71
 }
Please login to merge, or discard this patch.
src/ElimuswiftCoreServiceProvider.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -6,51 +6,51 @@
 block discarded – undo
6 6
 
7 7
 class ElimuswiftCoreServiceProvider extends ServiceProvider
8 8
 {
9
-    /**
10
-     * Bootstrap the application services.
11
-     */
12
-    public function boot()
13
-    {
14
-        $this->loadFiles();
15
-    }
9
+	/**
10
+	 * Bootstrap the application services.
11
+	 */
12
+	public function boot()
13
+	{
14
+		$this->loadFiles();
15
+	}
16 16
 
17 17
 //end boot()
18 18
 
19
-    /**
20
-     * Register the application services.
21
-     */
22
-    public function register()
23
-    {
24
-        $this->mergeConfigFrom(
25
-            __DIR__.'/config/core.php',
26
-            'core'
27
-        );
28
-
29
-        $this->app->singleton(
30
-            'envatoapi',
31
-            function () {
32
-                return new EnvatoApi(env('ENVATO_SECRET'));
33
-            }
34
-        );
35
-
36
-        $this->app->bind('Elimuswift\Core\Repositories\Contracts\RepositoryContract', 'Elimuswift\Core\Repositories\UpdatesRepository');
37
-    }
19
+	/**
20
+	 * Register the application services.
21
+	 */
22
+	public function register()
23
+	{
24
+		$this->mergeConfigFrom(
25
+			__DIR__.'/config/core.php',
26
+			'core'
27
+		);
28
+
29
+		$this->app->singleton(
30
+			'envatoapi',
31
+			function () {
32
+				return new EnvatoApi(env('ENVATO_SECRET'));
33
+			}
34
+		);
35
+
36
+		$this->app->bind('Elimuswift\Core\Repositories\Contracts\RepositoryContract', 'Elimuswift\Core\Repositories\UpdatesRepository');
37
+	}
38 38
 
39 39
 //end register()
40 40
 
41
-    /**
42
-     * Load and publish app migration files.
43
-     **/
44
-    protected function loadFiles()
45
-    {
46
-        $this->publishes(
47
-             [
48
-              __DIR__.'config/core.php' => config_path('core.php'),
49
-             ]
50
-         );
51
-        // $this->loadMigrationsFrom(__DIR__.'/Migrations');
52
-        $this->loadRoutesFrom(__DIR__.'/routes.php');
53
-    }
41
+	/**
42
+	 * Load and publish app migration files.
43
+	 **/
44
+	protected function loadFiles()
45
+	{
46
+		$this->publishes(
47
+			 [
48
+			  __DIR__.'config/core.php' => config_path('core.php'),
49
+			 ]
50
+		 );
51
+		// $this->loadMigrationsFrom(__DIR__.'/Migrations');
52
+		$this->loadRoutesFrom(__DIR__.'/routes.php');
53
+	}
54 54
 
55 55
 //end loadFiles()
56 56
 }//end class
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 
29 29
         $this->app->singleton(
30 30
             'envatoapi',
31
-            function () {
31
+            function() {
32 32
                 return new EnvatoApi(env('ENVATO_SECRET'));
33 33
             }
34 34
         );
Please login to merge, or discard this patch.