Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing traits and attributes #301

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
39 changes: 34 additions & 5 deletions src/Picqer/Financials/Moneybird/Entities/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Picqer\Financials\Moneybird\Entities;

use JsonException;
use Picqer\Financials\Moneybird\Actions\Filterable;
use Picqer\Financials\Moneybird\Actions\FindAll;
use Picqer\Financials\Moneybird\Actions\FindOne;
Expand Down Expand Up @@ -91,13 +92,13 @@ class Contact extends Model
* @var array
*/
protected $multipleNestedEntities = [
'custom_fields' => [
'custom_fields' => [
'entity' => ContactCustomField::class,
'type' => self::NESTING_TYPE_NESTED_OBJECTS,
'type' => self::NESTING_TYPE_NESTED_OBJECTS,
],
'contact_people' => [
'entity' => ContactPeople::class,
'type' => self::NESTING_TYPE_NESTED_OBJECTS,
'type' => self::NESTING_TYPE_NESTED_OBJECTS,
],
];

Expand All @@ -109,7 +110,7 @@ class Contact extends Model
*/
public function findByCustomerId($customerId)
{
$result = $this->connection()->get($this->getEndpoint() . '/customer_id/' . urlencode($customerId));
$result = $this->connection()->get($this->getEndpoint().'/customer_id/'.urlencode($customerId));

return $this->makeFromResponse($result);
}
Expand All @@ -120,10 +121,38 @@ public function findByCustomerId($customerId)
public function getPaymentsMandate(): array
{
return $this->connection()->get(
$this->getEndpoint() . '/' . $this->id . '/moneybird_payments_mandate'
$this->getEndpoint().'/'.$this->id.'/moneybird_payments_mandate'
);
}


/**
* @throws ApiException
* @throws JsonException
*/
public function getPaymentsMandateUrl(array $attributes = []): array
{
return $this->connection()->post(
$this->getEndpoint().'/'.$this->id.'/moneybird_payments_mandate/url',
json_encode($attributes, JSON_THROW_ON_ERROR)
);
}

/**
* @throws ApiException
* @throws JsonException
*/
public function requestNewPaymentsMandate(array $attributes = [])
{
return $this->connection()->post(
$this->getEndpoint().'/'.$this->id.'/moneybird_payments_mandate',
json_encode($attributes, JSON_THROW_ON_ERROR)
);
}

/**
* @throws ApiException
*/
public function addContactPerson(array $attributes): ContactPeople
{
$attributes['contact_id'] = $this->id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Picqer\Financials\Moneybird\Actions\Filterable;
use Picqer\Financials\Moneybird\Actions\FindAll;
use Picqer\Financials\Moneybird\Actions\FindOne;
use Picqer\Financials\Moneybird\Actions\Synchronizable;
use Picqer\Financials\Moneybird\Exceptions\ApiException;
use Picqer\Financials\Moneybird\Model;
Expand All @@ -15,7 +16,7 @@
*/
class FinancialMutation extends Model
{
use FindAll, Filterable, Synchronizable;
use FindAll, Filterable, Synchronizable, FindOne;

/**
* @see https://developer.moneybird.com/api/financial_mutations/#patch_financial_mutations_id_link_booking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
use Picqer\Financials\Moneybird\Actions\Noteable;
use Picqer\Financials\Moneybird\Actions\Removable;
use Picqer\Financials\Moneybird\Actions\Storable;
use Picqer\Financials\Moneybird\Actions\Synchronizable;
use Picqer\Financials\Moneybird\Model;

/**
* Class GeneralJournalDocument.
*/
class GeneralJournalDocument extends Model
{
use Filterable, FindAll, FindOne, Storable, Removable, Noteable;
use Filterable, FindAll, FindOne, Storable, Removable, Noteable, Synchronizable;

/**
* @var array
Expand All @@ -28,6 +29,7 @@ class GeneralJournalDocument extends Model
'updated_at',
'general_journal_document_entries',
'notes',
'version',
'attachments',
];

Expand Down
2 changes: 2 additions & 0 deletions src/Picqer/Financials/Moneybird/Entities/LedgerAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class LedgerAccount extends Model
'account_id',
'parent_id',
'allowed_document_types',
'taxonomy_item',
'financial_account_id',
'created_at',
'updated_at',
];
Expand Down
50 changes: 50 additions & 0 deletions src/Picqer/Financials/Moneybird/Entities/PurchaseTransaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Picqer\Financials\Moneybird\Entities;

use Picqer\Financials\Moneybird\Actions\FindAll;
use Picqer\Financials\Moneybird\Actions\FindOne;
use Picqer\Financials\Moneybird\Actions\Removable;
use Picqer\Financials\Moneybird\Model;

/**
* Class PurchaseInvoice.
*/
class PurchaseTransaction extends Model
{
use FindAll, FindOne, Removable;

/**
* @var array
*/
protected $fillable = [
'id',
'financial_account_id',
'payment_instrument_id',
'state',
'sepa_iban',
'sepa_iban_account_name',
'sepa_bic',
'source_sepa_iban',
'source_sepa_iban_account_name',
'date',
'description',
'end_to_end_id',
'amount',
'created_at',
'updated_at',
'payable_type',
'payable_id',
'payment_method',
];

/**
* @var string
*/
protected $endpoint = 'purchase_transactions';

/**
* @var string
*/
protected $namespace = 'purchase_transaction';
}
10 changes: 10 additions & 0 deletions src/Picqer/Financials/Moneybird/Moneybird.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Picqer\Financials\Moneybird\Entities\PurchaseInvoice;
use Picqer\Financials\Moneybird\Entities\PurchaseInvoiceDetail;
use Picqer\Financials\Moneybird\Entities\PurchaseInvoicePayment;
use Picqer\Financials\Moneybird\Entities\PurchaseTransaction;
use Picqer\Financials\Moneybird\Entities\Receipt;
use Picqer\Financials\Moneybird\Entities\ReceiptDetail;
use Picqer\Financials\Moneybird\Entities\ReceiptPayment;
Expand Down Expand Up @@ -303,6 +304,15 @@ public function purchaseInvoicePayment($attributes = [])
return new PurchaseInvoicePayment($this->connection, $attributes);
}

/**
* @param array $attributes
* @return \Picqer\Financials\Moneybird\Entities\PurchaseTransaction
*/
public function purchaseTransaction($attributes = [])
{
return new PurchaseTransaction($this->connection, $attributes);
}

/**
* @param array $attributes
* @return \Picqer\Financials\Moneybird\Entities\Receipt
Expand Down