Skip to content

Commit

Permalink
Merge pull request #83 from luigel/analysis-JGr9xv
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
luigel authored Dec 15, 2022
2 parents 7262630 + cdc4322 commit d218190
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/Models/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Luigel\Paymongo\Models;

use Luigel\Paymongo\Paymongo;
use Illuminate\Support\Collection;
use Luigel\Paymongo\Paymongo;

class Customer extends BaseModel
{
Expand Down
12 changes: 6 additions & 6 deletions src/Paymongo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace Luigel\Paymongo;

use Luigel\Paymongo\Models\Customer;
use Luigel\Paymongo\Models\Link;
use Luigel\Paymongo\Models\Token;
use Luigel\Paymongo\Models\Refund;
use Luigel\Paymongo\Models\Source;
use Luigel\Paymongo\Models\Payment;
use Luigel\Paymongo\Models\Webhook;
use Luigel\Paymongo\Traits\Request;
use Luigel\Paymongo\Models\Customer;
use Luigel\Paymongo\Models\PaymentIntent;
use Luigel\Paymongo\Models\PaymentMethod;
use Luigel\Paymongo\Models\Refund;
use Luigel\Paymongo\Models\Source;
use Luigel\Paymongo\Models\Token;
use Luigel\Paymongo\Models\Webhook;
use Luigel\Paymongo\Traits\HasToggleWebhook;
use Luigel\Paymongo\Traits\Request;

class Paymongo
{
Expand Down
49 changes: 27 additions & 22 deletions src/Traits/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

use Exception;
use GuzzleHttp\Client;
use Luigel\Paymongo\Models\Link;
use Illuminate\Support\Collection;
use Luigel\Paymongo\Models\Webhook;
use Luigel\Paymongo\Models\Customer;
use Luigel\Paymongo\Models\BaseModel;
use GuzzleHttp\Exception\ClientException;
use Luigel\Paymongo\Models\PaymentIntent;
use Luigel\Paymongo\Exceptions\NotFoundException;
use Illuminate\Support\Collection;
use Luigel\Paymongo\Exceptions\AmountTypeNotSupportedException;
use Luigel\Paymongo\Exceptions\BadRequestException;
use Luigel\Paymongo\Exceptions\NotFoundException;
use Luigel\Paymongo\Exceptions\PaymentErrorException;
use Luigel\Paymongo\Exceptions\UnauthorizedException;
use Luigel\Paymongo\Exceptions\AmountTypeNotSupportedException;
use Luigel\Paymongo\Models\BaseModel;
use Luigel\Paymongo\Models\Customer;
use Luigel\Paymongo\Models\Link;
use Luigel\Paymongo\Models\PaymentIntent;
use Luigel\Paymongo\Models\Webhook;

trait Request
{
Expand Down Expand Up @@ -146,9 +146,10 @@ public function attach(PaymentIntent $intent, string $paymentMethodId, string|nu
}

/**
* Archives the link
* Archives the link.
*/
public function archive(Link $link){
public function archive(Link $link)
{
$this->method = 'POST';
$this->apiUrl = $this->apiUrl.$link->id.'/archive';

Expand All @@ -163,11 +164,12 @@ public function archive(Link $link){
}

/**
* Unarchives the link
* Unarchives the link.
*/
public function unarchive(Link $link){
public function unarchive(Link $link)
{
$this->method = 'POST';
$this->apiUrl = $this->apiUrl . $link->id . '/unarchive';
$this->apiUrl = $this->apiUrl.$link->id.'/unarchive';

$this->setOptions([
'headers' => [
Expand All @@ -180,11 +182,12 @@ public function unarchive(Link $link){
}

/**
* Update the customer information
* Update the customer information.
*/
public function updateCustomer(Customer $customer, array $payload){
public function updateCustomer(Customer $customer, array $payload)
{
$this->method = 'PATCH';
$this->apiUrl = $this->apiUrl . $customer->id;
$this->apiUrl = $this->apiUrl.$customer->id;
$this->payload = $payload;

$this->formRequestData();
Expand All @@ -200,11 +203,12 @@ public function updateCustomer(Customer $customer, array $payload){
}

/**
* Delete the customer
* Delete the customer.
*/
public function deleteCustomer(Customer $customer){
public function deleteCustomer(Customer $customer)
{
$this->method = 'DELETE';
$this->apiUrl = $this->apiUrl . $customer->id;
$this->apiUrl = $this->apiUrl.$customer->id;

$this->setOptions([
'headers' => [
Expand All @@ -217,11 +221,12 @@ public function deleteCustomer(Customer $customer){
}

/**
* Get Customer's Payment Methods
* Get Customer's Payment Methods.
*/
public function getPaymentMethods(Customer $customer){
public function getPaymentMethods(Customer $customer)
{
$this->method = 'GET';
$this->apiUrl = $this->apiUrl . $customer->id . '/payment_methods';
$this->apiUrl = $this->apiUrl.$customer->id.'/payment_methods';

$this->setOptions([
'headers' => [
Expand Down
10 changes: 5 additions & 5 deletions tests/CustomerTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

use Illuminate\Support\Collection;
use Luigel\Paymongo\Models\Customer;
use Luigel\Paymongo\Facades\Paymongo;
use Luigel\Paymongo\Exceptions\NotFoundException;
use Luigel\Paymongo\Facades\Paymongo;
use Luigel\Paymongo\Models\Customer;

it('can create a customer', function () {
$customer = createCustomer();
Expand All @@ -13,7 +13,7 @@

it('can not retrieve a customer with invalid id', function () {
$this->expectException(NotFoundException::class);

Paymongo::customer()
->find('test');
});
Expand All @@ -33,7 +33,7 @@
expect($customer->last_name)->toBe('Felix');

$updatedCustomer = $customer->update([
'last_name' => 'Mongo'
'last_name' => 'Mongo',
]);

expect($updatedCustomer->last_name)->toBe('Mongo');
Expand All @@ -49,4 +49,4 @@
$customer = createCustomer()->paymentMethods();

expect($customer)->toBeInstanceOf(Collection::class);
});
});
8 changes: 4 additions & 4 deletions tests/LinkTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Luigel\Paymongo\Models\Link;
use Luigel\Paymongo\Facades\Paymongo;
use Luigel\Paymongo\Exceptions\NotFoundException;
use Luigel\Paymongo\Facades\Paymongo;
use Luigel\Paymongo\Models\Link;

it('can create a link', function () {
$link = createLink();
Expand All @@ -12,7 +12,7 @@

it('can not retrieve a link with invalid id', function () {
$this->expectException(NotFoundException::class);

Paymongo::link()
->find('test');
});
Expand Down Expand Up @@ -46,4 +46,4 @@
$unarchivedLink = $archivedLink->unarchive();

expect($unarchivedLink->archived)->toBe(false);
});
});
2 changes: 1 addition & 1 deletion tests/PaymentMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
->toBeInstanceOf(PaymentMethod::class)
->type->toBe('payment_method')
->payment_method_type->toBe('paymaya');
});
});
3 changes: 1 addition & 2 deletions tests/PaymentTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Illuminate\Support\Collection;
use Luigel\Paymongo\Exceptions\BadRequestException;
use Luigel\Paymongo\Exceptions\NotFoundException;
use Luigel\Paymongo\Facades\Paymongo;
use Luigel\Paymongo\Models\Payment;
Expand Down Expand Up @@ -37,4 +36,4 @@
->currency->toBe('PHP')
->statement_descriptor->toBe('LUIGEL STORE')
->status->toBe('paid');
});
});
20 changes: 10 additions & 10 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

use Illuminate\Support\Str;
use Luigel\Paymongo\Facades\Paymongo;
use Luigel\Paymongo\Models\Customer;
use Luigel\Paymongo\Models\Link;
use Luigel\Paymongo\Models\Token;
use Luigel\Paymongo\Models\Source;
use Luigel\Paymongo\Models\Payment;
use Luigel\Paymongo\Traits\Request;
use Luigel\Paymongo\Models\Customer;
use Luigel\Paymongo\Facades\Paymongo;
use Luigel\Paymongo\Tests\BaseTestCase;
use Luigel\Paymongo\Models\PaymentIntent;
use Luigel\Paymongo\Models\PaymentMethod;
use Luigel\Paymongo\Models\Source;
use Luigel\Paymongo\Models\Token;
use Luigel\Paymongo\Tests\BaseTestCase;
use Luigel\Paymongo\Traits\Request;

uses(BaseTestCase::class, Request::class)
->in(__DIR__);
Expand Down Expand Up @@ -145,7 +145,7 @@ function createLink(): Link
return Paymongo::link()->create([
'amount' => 100.00,
'description' => 'Link Test',
'remarks' => 'laravel-paymongo'
'remarks' => 'laravel-paymongo',
]);
}

Expand All @@ -154,9 +154,9 @@ function createCustomer(): Customer
return Paymongo::customer()->create([
'first_name' => 'Gringiemar',
'last_name' => 'Felix',
'phone' => '+6391234' . rand(10000, 99999),
'email' => 'customer' . Str::random(8) . rand(0, 100) . '@email.com',
'default_device' => 'phone'
'phone' => '+6391234'.rand(10000, 99999),
'email' => 'customer'.Str::random(8).rand(0, 100).'@email.com',
'default_device' => 'phone',
]);
}

Expand Down

1 comment on commit d218190

@vercel
Copy link

@vercel vercel bot commented on d218190 Dec 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please # to comment.