├── README.md
├── .gitignore
├── src
├── Argument
│ ├── Invoice
│ │ └── ShareMethodArgument.php
│ ├── IncludeArgument.php
│ ├── SearchArgument.php
│ └── SearchArrayArgument.php
├── Request
│ ├── Data
│ │ ├── Invoice
│ │ │ ├── InvoiceEmailData.php
│ │ │ ├── InvoiceUpdateData.php
│ │ │ ├── InvoiceCreateData.php
│ │ │ ├── SendEmailTrait.php
│ │ │ ├── InvoiceLineData.php
│ │ │ └── WritableInvoiceFieldsTrait.php
│ │ ├── Gateway
│ │ │ └── GatewayTypeEnum.php
│ │ ├── Estimate
│ │ │ └── EstimateData.php
│ │ ├── DateTimeData.php
│ │ ├── Client
│ │ │ └── LatePayment
│ │ │ │ ├── CommonWriteLatePaymentReminders.php
│ │ │ │ ├── ReminderData.php
│ │ │ │ └── FeeData.php
│ │ ├── AmountData.php
│ │ ├── Tax
│ │ │ └── TaxData.php
│ │ ├── Common
│ │ │ └── CommonWritableOnCreateFields.php
│ │ └── Presentation
│ │ │ └── PresentationData.php
│ └── Call
│ │ ├── IAccountIdRequest.php
│ │ ├── Estimate
│ │ ├── Collection
│ │ │ ├── EstimateCollectionRequest.php
│ │ │ └── EstimateCreateRequest.php
│ │ ├── EstimateDeleteRequest.php
│ │ ├── EstimateReadRequest.php
│ │ ├── EstimateResourceRequest.php
│ │ └── EstimateUpdateRequest.php
│ │ ├── Report
│ │ ├── ReportBaseRequest.php
│ │ ├── ReportProfitLossReadRequest.php
│ │ ├── ReportTaxSummaryReadRequest.php
│ │ ├── ReportAccountsAgingReadRequest.php
│ │ ├── ReportExpenseDetailsReadRequest.php
│ │ ├── ReportInvoiceDetailsReadRequest.php
│ │ └── ReportPaymentsCollectedReadRequest.php
│ │ ├── HasAccountIdTrait.php
│ │ ├── Account
│ │ └── OwnAccountRequest.php
│ │ ├── Tax
│ │ ├── Collection
│ │ │ ├── TaxListReadRequest.php
│ │ │ └── TaxCreateRequest.php
│ │ ├── TaxDeleteRequest.php
│ │ ├── TaxReadRequest.php
│ │ └── TaxUpdateRequest.php
│ │ ├── Invoice
│ │ ├── Collection
│ │ │ ├── InvoiceListReadRequest.php
│ │ │ └── InvoiceCreateRequest.php
│ │ ├── Presentations
│ │ │ └── PresentationsReadRequest.php
│ │ ├── InvoiceDeleteRequest.php
│ │ ├── InvoiceReadRequest.php
│ │ ├── InvoiceSendEmailRequest.php
│ │ ├── InvoiceUpdateRequest.php
│ │ └── ShareLink
│ │ │ └── InvoiceShareLinkReadRequest.php
│ │ ├── Clients
│ │ ├── Collection
│ │ │ ├── ClientListReadRequest.php
│ │ │ └── ClientCreateRequest.php
│ │ ├── ClientReadRequest.php
│ │ ├── ClientDeleteRequest.php
│ │ └── ClientUpdateRequest.php
│ │ └── InvoiceProfile
│ │ ├── Collection
│ │ ├── InvoiceProfileListReadRequest.php
│ │ └── InvoiceProfileCreateRequest.php
│ │ ├── InvoiceProfileReadRequest.php
│ │ ├── InvoiceProfileDeleteRequest.php
│ │ └── InvoiceProfileUpdateRequest.php
├── Business
│ ├── Data
│ │ ├── BusinessData.php
│ │ └── BusinessMembership.php
│ ├── Report
│ │ ├── ExpenseDetails
│ │ │ ├── Category.php
│ │ │ ├── Author.php
│ │ │ ├── ExpenseDetailsClient.php
│ │ │ ├── ExpenseDetailsData.php
│ │ │ └── Expense.php
│ │ ├── AccountsAging
│ │ │ └── Account.php
│ │ ├── InvoiceDetails
│ │ │ ├── TaxSummary.php
│ │ │ ├── Summary.php
│ │ │ ├── InvoiceDetailsClient.php
│ │ │ ├── ReportInvoiceLine.php
│ │ │ └── Invoice.php
│ │ ├── ProfitLoss
│ │ │ └── Entry.php
│ │ ├── PaymentsCollected
│ │ │ └── Payment.php
│ │ └── TaxSummary
│ │ │ └── Tax.php
│ ├── Amount.php
│ ├── Enums
│ │ ├── Client
│ │ │ └── Fee
│ │ │ │ └── LatePaymentFeeType.php
│ │ ├── Language
│ │ │ └── LanguageEnum.php
│ │ ├── Estimate
│ │ │ ├── EstimateStatusEnum.php
│ │ │ └── UIEstimateStatusEnum.php
│ │ ├── Invoice
│ │ │ └── InvoiceStatusEnum.php
│ │ └── Payment
│ │ │ └── PaymentMethodEnum.php
│ ├── LatePaymentReminder.php
│ ├── InvoiceLine.php
│ └── LatePaymentFee.php
├── Response
│ ├── ShareLink
│ │ └── ShareLinkResponse.php
│ ├── Tax
│ │ ├── TaxResponse.php
│ │ └── Collection
│ │ │ └── TaxCollectionResponse.php
│ ├── Invoice
│ │ ├── Collection
│ │ │ └── InvoiceCollectionResponse.php
│ │ ├── Presentation
│ │ │ └── PresentationResponse.php
│ │ └── InvoiceResponse.php
│ ├── InvoiceProfile
│ │ ├── Collection
│ │ │ └── InvoiceProfileCollectionResponse.php
│ │ └── InvoiceProfileResponse.php
│ ├── Clients
│ │ ├── Collection
│ │ │ └── ClientCollectionResponse.php
│ │ └── ClientResponse.php
│ ├── Account
│ │ └── OwnAccountResponse.php
│ ├── Report
│ │ ├── ReportTaxSummaryResponse.php
│ │ ├── ReportAccountsAgingResponse.php
│ │ ├── ReportPaymentsCollectedResponse.php
│ │ ├── ReportInvoiceDetailsResponse.php
│ │ ├── ReportProfitLossResponse.php
│ │ └── ReportExpenseDetailsResponse.php
│ └── Estimate
│ │ └── EstimateResponse.php
├── Config
│ └── FreshbooksConfiguration.php
├── Exception
│ └── UnprocessableEntityException.php
├── Helper
│ └── Collection
│ │ └── CollectionHelper.php
└── Middleware
│ ├── AccountIdSetterMiddleware.php
│ └── Error
│ └── UnprocessableEntityMiddleware.php
├── ruleset.xml
├── phpunit.xml
├── tests
└── src
│ ├── Requests
│ ├── Middleware
│ │ └── MiddlewareTest.php
│ ├── Account
│ │ └── AccountTest.php
│ └── Invoice
│ │ └── Presentations
│ │ └── PresentationsTest.php
│ └── Base
│ └── TestAccountRequest.php
├── composer.json
├── LICENSE
├── package.json
├── .travis.yml
└── phpdox.xml
/README.md:
--------------------------------------------------------------------------------
1 | # freshbook-sdk
2 | SDK for freshbook
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | composer.phar
2 | /vendor/
3 | .idea
4 | /node_modules/
5 |
6 | # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
7 | # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
8 | # composer.lock
9 |
--------------------------------------------------------------------------------
/src/Argument/Invoice/ShareMethodArgument.php:
--------------------------------------------------------------------------------
1 | setActionEmail(true);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Request/Data/Invoice/InvoiceUpdateData.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PSR2 style guide + Pear Multiline
5 |
6 |
7 |
8 |
9 | */node_modules/*
10 | */vendor/*
11 |
12 |
13 |
14 |
15 | */node_modules/*
16 | */vendor/*
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Request/Call/IAccountIdRequest.php:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 | ./tests/src
13 |
14 |
15 |
16 |
17 | ./src/
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Request/Data/Gateway/GatewayTypeEnum.php:
--------------------------------------------------------------------------------
1 | data()['code']);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Business/Enums/Client/Fee/LatePaymentFeeType.php:
--------------------------------------------------------------------------------
1 | data['business']);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Argument/SearchArrayArgument.php:
--------------------------------------------------------------------------------
1 | preSuccess([]);
21 | $accountId = uniqid();
22 | $request = new TestAccountRequest();
23 |
24 | $client->getOAuthTestClient()->registerPreRequestMiddleware(new AccountIdSetterMiddleware($accountId))
25 | ->processRequest($request);
26 |
27 | $this->validateUrl($client, [$accountId, 'test']);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Request/Data/Estimate/EstimateData.php:
--------------------------------------------------------------------------------
1 | estimateNumber = $estimateNumber;
34 |
35 | return $this;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Exception/UnprocessableEntityException.php:
--------------------------------------------------------------------------------
1 | rawError = $json;
30 | parent::__construct('Field: ' . $json['field'] . PHP_EOL . $json['message'], $json['errno']);
31 | }
32 |
33 | /**
34 | * @return array
35 | */
36 | public function getRawError(): array
37 | {
38 | return $this->rawError;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Request/Data/DateTimeData.php:
--------------------------------------------------------------------------------
1 | date = $date;
25 | $this->format = $format;
26 | }
27 |
28 | /**
29 | * Return a primitive value for this object.
30 | *
31 | * @return int|float|string|float
32 | */
33 | public function toPrimitive()
34 | {
35 | if (is_null($this->date)) {
36 | return null;
37 | }
38 | return $this->date->format($this->format);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Business/Report/InvoiceDetails/TaxSummary.php:
--------------------------------------------------------------------------------
1 | data['tax_total']);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Business/Enums/Language/LanguageEnum.php:
--------------------------------------------------------------------------------
1 | = 7.4",
18 | "zerospam/oauth2-freshbooks": "^1.6",
19 | "zerospam/sdk-framework": "^v7.0.1"
20 | },
21 | "require-dev": {
22 | "mockery/mockery": "^1.1",
23 | "squizlabs/php_codesniffer": "^3.2",
24 | "phpunit/phpunit": "^9.5.4",
25 | "php-coveralls/php-coveralls": "^2.0",
26 | "phploc/phploc": "^7.0.2",
27 | "dms/phpunit-arraysubset-asserts": "^v0.2.1"
28 | },
29 | "autoload": {
30 | "psr-4": {
31 | "ZEROSPAM\\Freshbooks\\": "src/"
32 | }
33 | },
34 | "autoload-dev": {
35 | "psr-4": {
36 | "ZEROSPAM\\Freshbooks\\Test\\": "tests/src/"
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Request/Call/Report/ReportBaseRequest.php:
--------------------------------------------------------------------------------
1 | addBinding(self::$ACCOUNT_ID, $id);
35 |
36 |
37 | return $this;
38 | }
39 |
40 | /**
41 | * Is account ID set
42 | *
43 | * @return bool
44 | */
45 | public function hasAccountId(): bool
46 | {
47 | return $this->hasBinding(self::$ACCOUNT_ID);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Response/Invoice/Collection/InvoiceCollectionResponse.php:
--------------------------------------------------------------------------------
1 | lateReminders = $lateReminders;
36 |
37 | return $this;
38 | }
39 |
40 | /**
41 | * @param FeeData $lateFee
42 | *
43 | * @return self
44 | */
45 | public function setLateFee(FeeData $lateFee)
46 | {
47 | $this->lateFee = $lateFee;
48 |
49 | return $this;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/Request/Call/Estimate/EstimateDeleteRequest.php:
--------------------------------------------------------------------------------
1 | accountId = $accountId;
31 | }
32 |
33 |
34 | /**
35 | * Handle the request before processing
36 | *
37 | * @param IRequest $request
38 | *
39 | */
40 | public function handle(IRequest $request): void
41 | {
42 | if ($request instanceof IAccountIdRequest && !$request->hasAccountId()) {
43 | $request->setAccountId($this->accountId);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Business/Report/ExpenseDetails/ExpenseDetailsData.php:
--------------------------------------------------------------------------------
1 | data()['total']);
37 | }
38 |
39 | public function getExpensesAttribute(): array
40 | {
41 | return array_map(
42 | function ($data) {
43 | return new Expense($data);
44 | },
45 | $this->data()['expenses']
46 | );
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Response/Clients/Collection/ClientCollectionResponse.php:
--------------------------------------------------------------------------------
1 | data()['total']);
37 | }
38 |
39 | /**
40 | * Children
41 | *
42 | * @return Entry[]
43 | */
44 | public function getChildrenAttribute(): array
45 | {
46 | return array_map(
47 | function ($data) {
48 | return new Entry($data);
49 | },
50 | $this->data()['children']
51 | );
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/Request/Call/Estimate/EstimateReadRequest.php:
--------------------------------------------------------------------------------
1 | amount = $amount;
30 |
31 | return $this;
32 | }
33 |
34 | /**
35 | * @deprecated
36 | *
37 | * @param string $code
38 | *
39 | * @return $this
40 | */
41 | public function setCode(string $code): AmountData
42 | {
43 | $this->code = $code;
44 |
45 | return $this;
46 | }
47 |
48 | /**
49 | * @param CurrencyEnum $currency
50 | *
51 | * @return $this
52 | */
53 | public function setCurrency(CurrencyEnum $currency): AmountData
54 | {
55 | $this->code = $currency->getValue();
56 |
57 | return $this;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/Request/Call/Report/ReportAccountsAgingReadRequest.php:
--------------------------------------------------------------------------------
1 | data['amount']);
44 | }
45 |
46 | /**
47 | * Unit cost mutator
48 | *
49 | * @return Amount
50 | */
51 | public function getUnitCostAttribute(): Amount
52 | {
53 | return new Amount($this->data['unit_cost']);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/Request/Call/Report/ReportExpenseDetailsReadRequest.php:
--------------------------------------------------------------------------------
1 | addBinding('estimateId', $id);
36 |
37 | return $this;
38 | }
39 |
40 | /**
41 | * Base route without binding.
42 | *
43 | * @return string
44 | */
45 | public function baseRoute(): string
46 | {
47 | return 'accounting/account/:accountId/estimates/estimates/:estimateId';
48 | }
49 | }
--------------------------------------------------------------------------------
/src/Business/Report/InvoiceDetails/Summary.php:
--------------------------------------------------------------------------------
1 | data['total']);
35 | }
36 |
37 | /**
38 | * Paid
39 | *
40 | * @return Amount
41 | */
42 | public function getPaidAttribute(): Amount
43 | {
44 | return new Amount($this->data['paid']);
45 | }
46 |
47 | /**
48 | * Outstanding
49 | *
50 | * @return Amount
51 | */
52 | public function getOutstandingAttribute(): Amount
53 | {
54 | return new Amount($this->data['outstanding']);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/Request/Call/Report/ReportPaymentsCollectedReadRequest.php:
--------------------------------------------------------------------------------
1 | data['summary']);
38 | }
39 |
40 | /**
41 | * Invoices
42 | *
43 | * @return Invoice[]
44 | */
45 | public function getInvoicesAttribute(): array
46 | {
47 | return array_map(
48 | function (array $data) {
49 | return new Invoice($data);
50 | },
51 | $this->data['invoices']
52 | );
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Request/Data/Invoice/InvoiceCreateData.php:
--------------------------------------------------------------------------------
1 | presentation = PresentationData::fromResponse($presentation);
42 |
43 | return $this;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Business/Enums/Estimate/UIEstimateStatusEnum.php:
--------------------------------------------------------------------------------
1 | emailSubject = $emailSubject;
32 | return $this;
33 | }
34 |
35 | /**
36 | * @param string[] $emailRecipients
37 | * @return $this
38 | */
39 | public function setEmailRecipients(array $emailRecipients)
40 | {
41 | $this->emailRecipients = $emailRecipients;
42 | return $this;
43 | }
44 |
45 | /**
46 | * @param string $emailBody
47 | * @return $this
48 | */
49 | public function setEmailBody(string $emailBody)
50 | {
51 | $this->emailBody = $emailBody;
52 | return $this;
53 | }
54 |
55 | /**
56 | * @param bool $actionEmail
57 | * @return $this
58 | */
59 | public function setActionEmail(bool $actionEmail)
60 | {
61 | $this->actionEmail = $actionEmail;
62 | return $this;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/Request/Data/Tax/TaxData.php:
--------------------------------------------------------------------------------
1 | name = $name;
35 | return $this;
36 | }
37 |
38 | /**
39 | * @param bool $compound
40 | * @return $this
41 | */
42 | public function setCompound(bool $compound): TaxData
43 | {
44 | $this->compound = $compound;
45 | return $this;
46 | }
47 |
48 | /**
49 | * @param null|string $number
50 | * @return $this
51 | */
52 | public function setNumber(?string $number): TaxData
53 | {
54 | $this->nullableChanged();
55 | $this->number = $number;
56 | return $this;
57 | }
58 |
59 | /**
60 | * @param string $amount
61 | * @return $this
62 | */
63 | public function setAmount(string $amount): TaxData
64 | {
65 | $this->amount = $amount;
66 | return $this;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Business/LatePaymentFee.php:
--------------------------------------------------------------------------------
1 | data()['type']);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/Request/Data/Common/CommonWritableOnCreateFields.php:
--------------------------------------------------------------------------------
1 | ownerid = $ownerid;
39 |
40 | return $this;
41 | }
42 |
43 | /**
44 | * @param int $estimateid
45 | *
46 | * @return $this
47 | */
48 | public function setEstimateid(int $estimateid)
49 | {
50 | $this->estimateid = $estimateid;
51 |
52 | return $this;
53 | }
54 |
55 | /**
56 | * Set the allowed gateways used for payments
57 | *
58 | * @param array $gateways
59 | *
60 | * @return $this
61 | */
62 | public function setAllowedGateways(array $gateways)
63 | {
64 | $this->allowedGatewayids = $gateways;
65 |
66 | return $this;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Response/Invoice/Presentation/PresentationResponse.php:
--------------------------------------------------------------------------------
1 | data;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Request/Call/Estimate/EstimateUpdateRequest.php:
--------------------------------------------------------------------------------
1 | estimate = $data;
35 | }
36 |
37 | /**
38 | * Type of request.
39 | *
40 | * @return RequestType
41 | */
42 | public function httpType(): RequestType
43 | {
44 | return RequestType::HTTP_PUT();
45 | }
46 |
47 | /**
48 | * Process the data that is in the response.
49 | *
50 | * @param array $jsonResponse
51 | *
52 | * @return \ZEROSPAM\Framework\SDK\Response\Api\IResponse
53 | */
54 | public function processResponse(array $jsonResponse): IResponse
55 | {
56 | return new EstimateResponse($jsonResponse['response']['result']['estimate']);
57 | }
58 | }
--------------------------------------------------------------------------------
/src/Request/Call/Estimate/Collection/EstimateCreateRequest.php:
--------------------------------------------------------------------------------
1 | estimate = $data;
37 | }
38 |
39 |
40 | /**
41 | * Type of request.
42 | *
43 | * @return RequestType
44 | */
45 | public function httpType(): RequestType
46 | {
47 | return RequestType::HTTP_POST();
48 | }
49 |
50 | /**
51 | * Process the data that is in the response.
52 | *
53 | * @param array $jsonResponse
54 | *
55 | * @return \ZEROSPAM\Framework\SDK\Response\Api\IResponse
56 | */
57 | public function processResponse(array $jsonResponse): IResponse
58 | {
59 | return new EstimateResponse($jsonResponse['response']['result']['estimate']);
60 | }
61 | }
--------------------------------------------------------------------------------
/src/Middleware/Error/UnprocessableEntityMiddleware.php:
--------------------------------------------------------------------------------
1 | client = $client;
35 |
36 | return $this;
37 | }
38 |
39 |
40 | /**
41 | * Which status error code does this middleware manage.
42 | *
43 | * @return array
44 | */
45 | public static function statusCode(): array
46 | {
47 | return [422, 413];
48 | }
49 |
50 | /**
51 | * Handle the request/response.
52 | *
53 | * Return an array with the response data
54 | *
55 | * @param IRequest $request
56 | * @param ResponseInterface $httpResponse
57 | * @param array $parsedData
58 | *
59 | * @return array
60 | */
61 | public function handle(IRequest $request, ResponseInterface $httpResponse, array $parsedData): array
62 | {
63 | throw new UnprocessableEntityException($parsedData['response']['errors'][0]);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/Request/Call/Tax/Collection/TaxListReadRequest.php:
--------------------------------------------------------------------------------
1 | data['business_memberships'][0]['business']['account_id'];
46 | }
47 |
48 | /**
49 | * Business Membership
50 | *
51 | * @return BusinessMembership[]
52 | */
53 | public function getBusinessMembershipsAttribute(): array
54 | {
55 | return array_map(
56 | function (array $data) {
57 | return new BusinessMembership($data);
58 | },
59 | $this->data['business_memberships']
60 | );
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/Request/Call/Invoice/Collection/InvoiceCreateRequest.php:
--------------------------------------------------------------------------------
1 | invoice = $invoiceCreateData;
29 | }
30 |
31 | /**
32 | * Base route without binding.
33 | *
34 | * @return string
35 | */
36 | public function baseRoute(): string
37 | {
38 | return 'accounting/account/:accountId/invoices/invoices';
39 | }
40 |
41 | /**
42 | * Type of request.
43 | *
44 | * @return RequestType
45 | */
46 | public function httpType(): RequestType
47 | {
48 | return RequestType::HTTP_POST();
49 | }
50 |
51 | /**
52 | * Process the data that is in the response.
53 | *
54 | * @param array $jsonResponse
55 | *
56 | * @return IResponse
57 | */
58 | public function processResponse(array $jsonResponse): IResponse
59 | {
60 | return new InvoiceResponse($jsonResponse['response']['result']['invoice']);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/Request/Data/Client/LatePayment/ReminderData.php:
--------------------------------------------------------------------------------
1 | nullableChanged();
37 | $this->body = $body;
38 | return $this;
39 | }
40 |
41 | /**
42 | * @param int $delay
43 | * @return $this
44 | */
45 | public function setDelay(int $delay): ReminderData
46 | {
47 | $this->delay = $delay;
48 | return $this;
49 | }
50 |
51 | /**
52 | * @param bool $enabled
53 | * @return $this
54 | */
55 | public function setEnabled(bool $enabled): ReminderData
56 | {
57 | $this->enabled = $enabled;
58 | return $this;
59 | }
60 |
61 | /**
62 | * @param int $position
63 | * @return $this
64 | */
65 | public function setPosition(int $position): ReminderData
66 | {
67 | $this->position = $position;
68 | return $this;
69 | }
70 |
71 | /**
72 | * @param int $userid
73 | * @return $this
74 | */
75 | public function setUserid(int $userid): ReminderData
76 | {
77 | $this->id = 'userid' . $userid;
78 | return $this;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/Request/Call/Invoice/Presentations/PresentationsReadRequest.php:
--------------------------------------------------------------------------------
1 | data()['amount']);
51 | }
52 |
53 | /**
54 | * @return PaymentMethodEnum
55 | */
56 | public function getMethodAttribute(): PaymentMethodEnum
57 | {
58 | return PaymentMethodEnum::byValueInsensitive($this->data()['method']);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/Response/Report/ReportTaxSummaryResponse.php:
--------------------------------------------------------------------------------
1 | data()['taxes']
52 | );
53 | }
54 |
55 | public function getTotalInvoicedAttribute(): Amount
56 | {
57 | return new Amount($this->data()['total_invoiced']);
58 | }
59 |
60 | /**
61 | * @return CurrencyEnum
62 | */
63 | public function getCurrencyAttribute(): CurrencyEnum
64 | {
65 | return CurrencyEnum::get($this->data['currency_code']);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/Request/Call/Tax/TaxDeleteRequest.php:
--------------------------------------------------------------------------------
1 | addBinding('taxId', $id);
73 |
74 | return $this;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/Request/Call/Tax/Collection/TaxCreateRequest.php:
--------------------------------------------------------------------------------
1 | tax = $data;
38 | }
39 |
40 | /**
41 | * Type of request.
42 | *
43 | * @return RequestType
44 | */
45 | public function httpType(): RequestType
46 | {
47 | return RequestType::HTTP_POST();
48 | }
49 |
50 | /**
51 | * Process the data that is in the response.
52 | *
53 | * @param array $jsonResponse
54 | *
55 | * @return \ZEROSPAM\Framework\SDK\Response\Api\IResponse
56 | */
57 | public function processResponse(array $jsonResponse): IResponse
58 | {
59 | return new TaxResponse($jsonResponse["response"]["result"]["tax"]);
60 | }
61 |
62 | /**
63 | * Base route without binding.
64 | *
65 | * @return string
66 | */
67 | public function baseRoute(): string
68 | {
69 | return 'accounting/account/:accountId/taxes/taxes';
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/Business/Report/ExpenseDetails/Expense.php:
--------------------------------------------------------------------------------
1 | data()['amount']);
52 | }
53 |
54 | /**
55 | * Tax amount 1
56 | *
57 | * @return Amount
58 | */
59 | public function getTaxAmount1Attribute(): Amount
60 | {
61 | return new Amount($this->data()['taxAmount1']);
62 | }
63 |
64 | /**
65 | * Tax amount 2
66 | *
67 | * @return Amount
68 | */
69 | public function getTaxAmount2Attribute(): Amount
70 | {
71 | return new Amount($this->data()['taxAmount2']);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/Request/Call/Tax/TaxReadRequest.php:
--------------------------------------------------------------------------------
1 | addBinding('taxId', $id);
72 |
73 | return $this;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/Request/Call/Invoice/InvoiceDeleteRequest.php:
--------------------------------------------------------------------------------
1 | addBinding('invoiceId', $id);
74 |
75 | return $this;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/Request/Call/Clients/Collection/ClientCreateRequest.php:
--------------------------------------------------------------------------------
1 | client = $data;
38 | }
39 |
40 | /**
41 | * Base route without binding.
42 | *
43 | * @return string
44 | */
45 | public function baseRoute(): string
46 | {
47 | return 'accounting/account/:accountId/users/clients';
48 | }
49 |
50 | /**
51 | * Type of request.
52 | *
53 | * @return RequestType
54 | */
55 | public function httpType(): RequestType
56 | {
57 | return RequestType::HTTP_POST();
58 | }
59 |
60 | /**
61 | * Process the data that is in the response.
62 | *
63 | * @param array $jsonResponse
64 | *
65 | * @return \ZEROSPAM\Framework\SDK\Response\Api\IResponse
66 | */
67 | public function processResponse(array $jsonResponse): IResponse
68 | {
69 | return new ClientResponse($jsonResponse["response"]["result"]["client"]);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/Request/Call/Invoice/InvoiceReadRequest.php:
--------------------------------------------------------------------------------
1 | addBinding('invoiceId', $id);
74 |
75 | return $this;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/Request/Call/Clients/ClientReadRequest.php:
--------------------------------------------------------------------------------
1 | addBinding('clientId', $id);
62 |
63 | return $this;
64 | }
65 |
66 | /**
67 | * Base route without binding.
68 | *
69 | * @return string
70 | */
71 | public function baseRoute(): string
72 | {
73 | return 'accounting/account/:accountId/users/clients/:clientId';
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/Response/Report/ReportAccountsAgingResponse.php:
--------------------------------------------------------------------------------
1 | data()['totals']
51 | );
52 | }
53 |
54 | /**
55 | * Accounts
56 | *
57 | * @return Account[]
58 | */
59 | public function getAccountsAttribute(): array
60 | {
61 | return array_map(
62 | function ($data) {
63 | return new Account($data);
64 | },
65 | $this->data()['accounts']
66 | );
67 | }
68 |
69 | /**
70 | * @return CurrencyEnum
71 | */
72 | public function getCurrencyAttribute(): CurrencyEnum
73 | {
74 | return CurrencyEnum::get($this->data['currency_code']);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/Business/Enums/Payment/PaymentMethodEnum.php:
--------------------------------------------------------------------------------
1 | invoiceProfile = $data;
38 | }
39 |
40 | /**
41 | * Base route without binding.
42 | *
43 | * @return string
44 | */
45 | public function baseRoute(): string
46 | {
47 | return 'accounting/account/:accountId/invoice_profiles/invoice_profiles';
48 | }
49 |
50 | /**
51 | * Type of request.
52 | *
53 | * @return RequestType
54 | */
55 | public function httpType(): RequestType
56 | {
57 | return RequestType::HTTP_POST();
58 | }
59 |
60 | /**
61 | * Process the data that is in the response.
62 | *
63 | * @param array $jsonResponse
64 | *
65 | * @return IResponse
66 | */
67 | public function processResponse(array $jsonResponse): IResponse
68 | {
69 | return new InvoiceProfileResponse($jsonResponse['response']['result']['invoice_profile']);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/Request/Call/Clients/ClientDeleteRequest.php:
--------------------------------------------------------------------------------
1 | client = [
36 | 'vis_state' => 1
37 | ];
38 | }
39 |
40 | /**
41 | * Type of request.
42 | *
43 | * @return RequestType
44 | */
45 | public function httpType(): RequestType
46 | {
47 | return RequestType::HTTP_PUT();
48 | }
49 |
50 | /**
51 | * Process the data that is in the response.
52 | *
53 | * @param array $jsonResponse
54 | *
55 | * @return IResponse
56 | */
57 | public function processResponse(array $jsonResponse): IResponse
58 | {
59 | return new EmptyResponse();
60 | }
61 |
62 | /**
63 | * Set the clientID
64 | *
65 | * @param int $id
66 | *
67 | * @return $this
68 | */
69 | public function setClientId(int $id): ClientDeleteRequest
70 | {
71 | $this->addBinding('clientId', $id);
72 |
73 | return $this;
74 | }
75 |
76 | /**
77 | * Base route without binding.
78 | *
79 | * @return string
80 | */
81 | public function baseRoute(): string
82 | {
83 | return 'accounting/account/:accountId/users/clients/:clientId';
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/Request/Call/Invoice/InvoiceSendEmailRequest.php:
--------------------------------------------------------------------------------
1 | invoice = $data;
29 | }
30 |
31 | /**
32 | * Type of request.
33 | *
34 | * @return RequestType
35 | */
36 | public function httpType(): RequestType
37 | {
38 | return RequestType::HTTP_PUT();
39 | }
40 |
41 | /**
42 | * Process the data that is in the response.
43 | *
44 | * @param array $jsonResponse
45 | *
46 | * @return \ZEROSPAM\Framework\SDK\Response\Api\IResponse
47 | */
48 | public function processResponse(array $jsonResponse): IResponse
49 | {
50 | return new InvoiceResponse($jsonResponse['response']['result']['invoice']);
51 | }
52 |
53 | /**
54 | * Base route without binding.
55 | *
56 | * @return string
57 | */
58 | public function baseRoute(): string
59 | {
60 | return 'accounting/account/:accountId/invoices/invoices/:invoiceId';
61 | }
62 |
63 | /**
64 | * Set the invoice ID in the URL
65 | *
66 | * @param string $id
67 | *
68 | * @return $this
69 | */
70 | public function setInvoiceId(string $id): InvoiceSendEmailRequest
71 | {
72 | $this->addBinding('invoiceId', $id);
73 |
74 | return $this;
75 | }
76 | }
--------------------------------------------------------------------------------
/src/Request/Call/Invoice/InvoiceUpdateRequest.php:
--------------------------------------------------------------------------------
1 | invoice = $data;
29 | }
30 |
31 | /**
32 | * Type of request.
33 | *
34 | * @return RequestType
35 | */
36 | public function httpType(): RequestType
37 | {
38 | return RequestType::HTTP_PUT();
39 | }
40 |
41 | /**
42 | * Process the data that is in the response.
43 | *
44 | * @param array $jsonResponse
45 | *
46 | * @return \ZEROSPAM\Framework\SDK\Response\Api\IResponse
47 | */
48 | public function processResponse(array $jsonResponse): IResponse
49 | {
50 | return new InvoiceResponse($jsonResponse['response']['result']['invoice']);
51 | }
52 |
53 | /**
54 | * Base route without binding.
55 | *
56 | * @return string
57 | */
58 | public function baseRoute(): string
59 | {
60 | return 'accounting/account/:accountId/invoices/invoices/:invoiceId';
61 | }
62 |
63 | /**
64 | * Set the invoice ID in the URL
65 | *
66 | * @param string $id
67 | *
68 | * @return $this
69 | */
70 | public function setInvoiceId(string $id): InvoiceUpdateRequest
71 | {
72 | $this->addBinding('invoiceId', $id);
73 |
74 | return $this;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/Request/Call/Tax/TaxUpdateRequest.php:
--------------------------------------------------------------------------------
1 | tax = $data;
38 | }
39 |
40 | /**
41 | * Type of request.
42 | *
43 | * @return RequestType
44 | */
45 | public function httpType(): RequestType
46 | {
47 | return RequestType::HTTP_PUT();
48 | }
49 |
50 | /**
51 | * Process the data that is in the response.
52 | *
53 | * @param array $jsonResponse
54 | *
55 | * @return IResponse
56 | */
57 | public function processResponse(array $jsonResponse): IResponse
58 | {
59 | return new TaxResponse($jsonResponse["response"]["result"]["tax"]);
60 | }
61 |
62 | /**
63 | * Base route without binding.
64 | *
65 | * @return string
66 | */
67 | public function baseRoute(): string
68 | {
69 | return 'accounting/account/:accountId/taxes/taxes/:taxId';
70 | }
71 |
72 |
73 | /**
74 | * Set the tax id
75 | *
76 | * @param string $id
77 | * @return $this
78 | */
79 | public function setTaxId(string $id): TaxUpdateRequest
80 | {
81 | $this->addBinding('taxId', $id);
82 |
83 | return $this;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/Request/Call/InvoiceProfile/InvoiceProfileReadRequest.php:
--------------------------------------------------------------------------------
1 | addBinding('invoiceProfileId', $id);
73 |
74 | return $this;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/Business/Report/InvoiceDetails/ReportInvoiceLine.php:
--------------------------------------------------------------------------------
1 | data['amount']);
44 | }
45 |
46 | /**
47 | * Tax amount 1
48 | *
49 | * @return Amount
50 | */
51 | public function getTaxAmount1Attribute(): Amount
52 | {
53 | return new Amount($this->data['tax_amount1']);
54 | }
55 |
56 | /**
57 | * Tax amount 2
58 | *
59 | * @return Amount
60 | */
61 | public function getTaxAmount2Attribute(): Amount
62 | {
63 | return new Amount($this->data['tax_amount2']);
64 | }
65 |
66 | /**
67 | * Rate
68 | *
69 | * @return Amount
70 | */
71 | public function getRateAttribute(): Amount
72 | {
73 | return new Amount($this->data['rate']);
74 | }
75 |
76 | /**
77 | * Total
78 | *
79 | * @return Amount
80 | */
81 | public function getTotalAttribute(): Amount
82 | {
83 | return new Amount($this->data['total']);
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/Request/Call/Clients/ClientUpdateRequest.php:
--------------------------------------------------------------------------------
1 | client = $data;
38 | }
39 |
40 | /**
41 | * Type of request.
42 | *
43 | * @return RequestType
44 | */
45 | public function httpType(): RequestType
46 | {
47 | return RequestType::HTTP_PUT();
48 | }
49 |
50 | /**
51 | * Process the data that is in the response.
52 | *
53 | * @param array $jsonResponse
54 | *
55 | * @return IResponse
56 | */
57 | public function processResponse(array $jsonResponse): IResponse
58 | {
59 | return new ClientResponse($jsonResponse['response']['result']['client']);
60 | }
61 |
62 | /**
63 | * Set the clientID
64 | *
65 | * @param int $id
66 | *
67 | * @return $this
68 | */
69 | public function setClientId(int $id): ClientUpdateRequest
70 | {
71 | $this->addBinding('clientId', $id);
72 |
73 | return $this;
74 | }
75 |
76 | /**
77 | * Base route without binding.
78 | *
79 | * @return string
80 | */
81 | public function baseRoute(): string
82 | {
83 | return 'accounting/account/:accountId/users/clients/:clientId';
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/Business/Report/TaxSummary/Tax.php:
--------------------------------------------------------------------------------
1 | data['taxable_amount_paid']);
39 | }
40 |
41 | /**
42 | * Taxable amount collected
43 | *
44 | * @return Amount
45 | */
46 | public function getTaxableAmountCollectedAttribute(): Amount
47 | {
48 | return new Amount($this->data['taxable_amount_collected']);
49 | }
50 |
51 | /**
52 | * Net taxable amount
53 | *
54 | * @return Amount
55 | */
56 | public function getNetTaxableAmountAttribute(): Amount
57 | {
58 | return new Amount($this->data['net_taxable_amount']);
59 | }
60 |
61 | /**
62 | * Tax paid
63 | *
64 | * @return Amount
65 | */
66 | public function getTaxPaidAttribute(): Amount
67 | {
68 | return new Amount($this->data['tax_paid']);
69 | }
70 |
71 | /**
72 | * Tax collected
73 | *
74 | * @return Amount
75 | */
76 | public function getTaxCollectedAttribute(): Amount
77 | {
78 | return new Amount($this->data['tax_collected']);
79 | }
80 |
81 | /**
82 | * Net tax
83 | *
84 | * @return Amount
85 | */
86 | public function getNetTaxAttribute(): Amount
87 | {
88 | return new Amount($this->data['net_tax']);
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/Response/Report/ReportPaymentsCollectedResponse.php:
--------------------------------------------------------------------------------
1 | data()['totals']
53 | );
54 | }
55 |
56 | /**
57 | * Payments
58 | *
59 | * @return Payment[]
60 | */
61 | public function getPaymentsAttribute(): array
62 | {
63 | return array_map(
64 | function ($data) {
65 | return new Payment($data);
66 | },
67 | $this->data()['payments']
68 | );
69 | }
70 |
71 | /**
72 | * @return array|CurrencyEnum[]
73 | */
74 | public function getCurrenciesAttribute(): array
75 | {
76 | return array_map(function ($item) {
77 | CurrencyEnum::get($item);
78 | }, $this->data['currency_codes']);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/Request/Call/InvoiceProfile/InvoiceProfileDeleteRequest.php:
--------------------------------------------------------------------------------
1 | invoiceProfile = [
36 | 'vis_state' => 1
37 | ];
38 | }
39 |
40 | /**
41 | * Type of request.
42 | *
43 | * @return RequestType
44 | */
45 | public function httpType(): RequestType
46 | {
47 | return RequestType::HTTP_PUT();
48 | }
49 |
50 | /**
51 | * Process the data that is in the response.
52 | *
53 | * @param array $jsonResponse
54 | *
55 | * @return IResponse
56 | */
57 | public function processResponse(array $jsonResponse): IResponse
58 | {
59 | return new EmptyResponse();
60 | }
61 |
62 | /**
63 | * Base route without binding.
64 | *
65 | * @return string
66 | */
67 | public function baseRoute(): string
68 | {
69 | return 'accounting/account/:accountId/invoice_profiles/invoice_profiles/:invoiceProfileId';
70 | }
71 |
72 | /**
73 | * Set the invoice profile ID in the URL
74 | *
75 | * @param string $id
76 | *
77 | * @return $this
78 | */
79 | public function setInvoiceProfileId(string $id): InvoiceProfileDeleteRequest
80 | {
81 | $this->addBinding('invoiceProfileId', $id);
82 |
83 | return $this;
84 | }
85 | }
86 |
87 |
--------------------------------------------------------------------------------
/src/Response/Report/ReportInvoiceDetailsResponse.php:
--------------------------------------------------------------------------------
1 | data['clients']
55 | );
56 | }
57 |
58 | /**
59 | * Summary
60 | *
61 | * @return Summary
62 | */
63 | public function getSummaryAttribute(): Summary
64 | {
65 | return new Summary($this->data['summary']);
66 | }
67 |
68 | /**
69 | * @return CurrencyEnum
70 | */
71 | public function getCurrencyAttribute(): CurrencyEnum
72 | {
73 | return CurrencyEnum::get($this->data['currency_code']);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/Request/Call/Invoice/ShareLink/InvoiceShareLinkReadRequest.php:
--------------------------------------------------------------------------------
1 | addArgument(new ShareMethodArgument('share_link'));
35 | }
36 |
37 | /**
38 | * Base route without binding.
39 | *
40 | * @return string
41 | */
42 | public function baseRoute(): string
43 | {
44 | return 'accounting/account/:accountId/invoices/invoices/:invoiceId/share_link';
45 | }
46 |
47 | /**
48 | * Set the id of the invoice
49 | *
50 | * @param string $id
51 | *
52 | * @return $this
53 | */
54 | public function setInvoiceId(string $id): InvoiceShareLinkReadRequest
55 | {
56 | $this->addBinding('invoiceId', $id);
57 |
58 | return $this;
59 | }
60 |
61 | /**
62 | * Type of request.
63 | *
64 | * @return RequestType
65 | */
66 | public function httpType(): RequestType
67 | {
68 | return RequestType::HTTP_GET();
69 | }
70 |
71 | /**
72 | * Process the data that is in the response.
73 | *
74 | * @param array $jsonResponse
75 | *
76 | * @return IResponse
77 | */
78 | public function processResponse(array $jsonResponse): IResponse
79 | {
80 | return new ShareLinkResponse($jsonResponse['response']['result']['share_link']);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/Request/Call/InvoiceProfile/InvoiceProfileUpdateRequest.php:
--------------------------------------------------------------------------------
1 | invoiceProfile = $data;
38 | }
39 |
40 | /**
41 | * Type of request.
42 | *
43 | * @return RequestType
44 | */
45 | public function httpType(): RequestType
46 | {
47 | return RequestType::HTTP_PUT();
48 | }
49 |
50 | /**
51 | * Process the data that is in the response.
52 | *
53 | * @param array $jsonResponse
54 | *
55 | * @return IResponse
56 | */
57 | public function processResponse(array $jsonResponse): IResponse
58 | {
59 | return new InvoiceProfileResponse($jsonResponse['response']['result']['invoice_profile']);
60 | }
61 |
62 | /**
63 | * Base route without binding.
64 | *
65 | * @return string
66 | */
67 | public function baseRoute(): string
68 | {
69 | return 'accounting/account/:accountId/invoice_profiles/invoice_profiles/:invoiceProfileId';
70 | }
71 |
72 | /**
73 | * Set the invoice profile ID in the URL
74 | *
75 | * @param string $id
76 | *
77 | * @return $this
78 | */
79 | public function setInvoiceProfileId(string $id): InvoiceProfileUpdateRequest
80 | {
81 | $this->addBinding('invoiceProfileId', $id);
82 |
83 | return $this;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/Response/Report/ReportProfitLossResponse.php:
--------------------------------------------------------------------------------
1 | data()['net_profit']);
53 | }
54 |
55 | /**
56 | * Expenses
57 | *
58 | * @return Entry[]
59 | */
60 | public function getExpensesAttribute(): array
61 | {
62 | return array_map(
63 | function ($data) {
64 | return new Entry($data);
65 | },
66 | $this->data()['expenses']
67 | );
68 | }
69 |
70 | /**
71 | * Total income
72 | *
73 | * @return Entry
74 | */
75 | public function getTotalIncomeAttribute(): Entry
76 | {
77 | return new Entry($this->data()['total_income']);
78 | }
79 |
80 | /**
81 | * Income
82 | *
83 | * @return Entry[]
84 | */
85 | public function getIncomeAttribute(): array
86 | {
87 | return array_map(
88 | function ($data) {
89 | return new Entry($data);
90 | },
91 | $this->data()['income']
92 | );
93 | }
94 |
95 | /**
96 | * Total expenses
97 | *
98 | * @return Entry
99 | */
100 | public function getTotalExpensesAttribute(): Entry
101 | {
102 | return new Entry($this->data()['total_expenses']);
103 | }
104 |
105 | /**
106 | * @return CurrencyEnum
107 | */
108 | public function getCurrencyAttribute(): CurrencyEnum
109 | {
110 | return CurrencyEnum::get($this->data['currency_code']);
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/Response/Report/ReportExpenseDetailsResponse.php:
--------------------------------------------------------------------------------
1 | data()['clients']
60 | );
61 | }
62 |
63 | /**
64 | * Authors
65 | *
66 | * @return Author[]
67 | */
68 | public function getAuthorsAttribute(): array
69 | {
70 | return array_map(
71 | function ($data) {
72 | return new Author($data);
73 | },
74 | $this->data()['authors']
75 | );
76 | }
77 |
78 | /**
79 | * Data
80 | *
81 | * @return ExpenseDetailsData[]
82 | */
83 | public function getDataAttribute(): array
84 | {
85 | return array_map(
86 | function ($data) {
87 | return new ExpenseDetailsData($data);
88 | },
89 | $this->data()['data']
90 | );
91 | }
92 |
93 | /**
94 | * Categories
95 | *
96 | * @return Category[]
97 | */
98 | public function getCategoriesAttribute(): array
99 | {
100 | return array_map(
101 | function ($data) {
102 | return new Category($data);
103 | },
104 | $this->data()['categories']
105 | );
106 | }
107 |
108 | /**
109 | * @return CurrencyEnum
110 | */
111 | public function getCurrencyAttribute(): CurrencyEnum
112 | {
113 | return CurrencyEnum::get($this->data['currency_code']);
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/tests/src/Requests/Account/AccountTest.php:
--------------------------------------------------------------------------------
1 | preSuccess($json);
25 | $request = new OwnAccountRequest();
26 | $client->getOAuthTestClient()->processRequest($request);
27 |
28 | $response = $request->getResponse();
29 | $this->assertInstanceOf(BusinessMembership::class, $response->business_memberships[0]);
30 | $this->assertInstanceOf(BusinessData::class, $response->business_memberships[0]->business);
31 | $this->assertEquals($response->business_memberships[0]->business->account_id, $response->account_id);
32 | $this->assertEquals('k0LBE', $response->account_id);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Request/Data/Invoice/InvoiceLineData.php:
--------------------------------------------------------------------------------
1 | 'taxName1',
49 | 'tax_amount1' => 'taxAmount1',
50 | 'tax_name2' => 'taxName2',
51 | 'tax_amount2' => 'taxAmount2',
52 | ];
53 |
54 | /**
55 | * @param int $type
56 | * @return $this
57 | */
58 | public function setType(int $type): InvoiceLineData
59 | {
60 | $this->type = $type;
61 |
62 | return $this;
63 | }
64 |
65 | /**
66 | * @param int $expenseid
67 | * @return $this
68 | */
69 | public function setExpenseid(int $expenseid): InvoiceLineData
70 | {
71 | $this->expenseid = $expenseid;
72 |
73 | return $this;
74 | }
75 |
76 | /**
77 | * @param int $qty
78 | * @return $this
79 | */
80 | public function setQty(int $qty): InvoiceLineData
81 | {
82 | $this->qty = $qty;
83 |
84 | return $this;
85 | }
86 |
87 | /**
88 | * @param AmountData $unitCost
89 | * @return $this
90 | */
91 | public function setUnitCost(AmountData $unitCost): InvoiceLineData
92 | {
93 | $this->unitCost = $unitCost;
94 |
95 | return $this;
96 | }
97 |
98 | /**
99 | * @param string $description
100 | * @return $this
101 | */
102 | public function setDescription(string $description): InvoiceLineData
103 | {
104 | $this->description = $description;
105 |
106 | return $this;
107 | }
108 |
109 | /**
110 | * @param string $name
111 | * @return $this
112 | */
113 | public function setName(string $name): InvoiceLineData
114 | {
115 | $this->name = $name;
116 |
117 | return $this;
118 | }
119 |
120 | /**
121 | * @param string $taxName1
122 | * @return $this
123 | */
124 | public function setTaxName1(string $taxName1): InvoiceLineData
125 | {
126 | $this->taxName1 = $taxName1;
127 |
128 | return $this;
129 | }
130 |
131 | /**
132 | * @param string $taxAmount1
133 | * @return $this
134 | */
135 | public function setTaxAmount1(string $taxAmount1): InvoiceLineData
136 | {
137 | $this->taxAmount1 = $taxAmount1;
138 |
139 | return $this;
140 | }
141 |
142 | /**
143 | * @param string $taxName2
144 | * @return $this
145 | */
146 | public function setTaxName2(string $taxName2): InvoiceLineData
147 | {
148 | $this->taxName2 = $taxName2;
149 |
150 | return $this;
151 | }
152 |
153 | /**
154 | * @param string $taxAmount2
155 | * @return $this
156 | */
157 | public function setTaxAmount2(string $taxAmount2): InvoiceLineData
158 | {
159 | $this->taxAmount2 = $taxAmount2;
160 |
161 | return $this;
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/src/Business/Report/InvoiceDetails/Invoice.php:
--------------------------------------------------------------------------------
1 | data['outstanding']);
56 | }
57 |
58 | /**
59 | * Tax
60 | *
61 | * @return Amount
62 | */
63 | public function getTaxAttribute(): Amount
64 | {
65 | return new Amount($this->data['tax']);
66 | }
67 |
68 | /**
69 | * Tax summaries
70 | *
71 | * @return TaxSummary[]
72 | */
73 | public function getTaxSummariesAttribute(): array
74 | {
75 | return array_map(
76 | function (array $data) {
77 | return new TaxSummary($data);
78 | },
79 | $this->data['tax_summaries']
80 | );
81 | }
82 |
83 | /**
84 | * Lines
85 | *
86 | * @return ReportInvoiceLine[]
87 | */
88 | public function getLinesAttribute(): array
89 | {
90 | return array_map(
91 | function (array $data) {
92 | return new ReportInvoiceLine($data);
93 | },
94 | $this->data['lines']
95 | );
96 | }
97 |
98 | /**
99 | * Paid
100 | *
101 | * @return Amount
102 | */
103 | public function getPaidAttribute(): Amount
104 | {
105 | return new Amount($this->data['paid']);
106 | }
107 |
108 | /**
109 | * Discount total
110 | *
111 | * @return Amount
112 | */
113 | public function getDiscountTotalAttribute(): Amount
114 | {
115 | return new Amount($this->data['discount_total']);
116 | }
117 |
118 | /**
119 | * Total
120 | *
121 | * @return Amount
122 | */
123 | public function getTotalAttribute(): Amount
124 | {
125 | return new Amount($this->data['total']);
126 | }
127 |
128 | /**
129 | * Subtotal
130 | *
131 | * @return Amount
132 | */
133 | public function getSubtotalAttribute(): Amount
134 | {
135 | return new Amount($this->data['subtotal']);
136 | }
137 |
138 | /**
139 | * @return CurrencyEnum
140 | */
141 | public function getCurrencyAttribute(): CurrencyEnum
142 | {
143 | return CurrencyEnum::get($this->data['currency_code']);
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/src/Request/Data/Client/LatePayment/FeeData.php:
--------------------------------------------------------------------------------
1 | compoundedTaxes = $compoundedTaxes;
56 |
57 | return $this;
58 | }
59 |
60 | /**
61 | * @param int $days
62 | * @return $this
63 | */
64 | public function setDays(int $days): FeeData
65 | {
66 | $this->days = $days;
67 |
68 | return $this;
69 | }
70 |
71 | /**
72 | * @param bool $enabled
73 | * @return $this
74 | */
75 | public function setEnabled(bool $enabled): FeeData
76 | {
77 | $this->enabled = $enabled;
78 |
79 | return $this;
80 | }
81 |
82 | /**
83 | * @param null|string $firstTaxName
84 | * @return $this
85 | */
86 | public function setFirstTaxName(?string $firstTaxName): FeeData
87 | {
88 | $this->nullableChanged();
89 | $this->firstTaxName = $firstTaxName;
90 |
91 | return $this;
92 | }
93 |
94 | /**
95 | * @param float|null $firstTaxPercent
96 | * @return $this
97 | */
98 | public function setFirstTaxPercent(?float $firstTaxPercent): FeeData
99 | {
100 | $this->nullableChanged();
101 | $this->firstTaxPercent = $firstTaxPercent;
102 |
103 | return $this;
104 | }
105 |
106 | /**
107 | * @param int $userid
108 | * @return $this
109 | */
110 | public function setUserid(int $userid): FeeData
111 | {
112 | $this->id = 'userid' . $userid;
113 |
114 | return $this;
115 | }
116 |
117 | /**
118 | * @param bool $repeat
119 | * @return $this
120 | */
121 | public function setRepeat(bool $repeat): FeeData
122 | {
123 | $this->repeat = $repeat;
124 |
125 | return $this;
126 | }
127 |
128 | /**
129 | * @param null|string $secondTaxName
130 | * @return $this
131 | */
132 | public function setSecondTaxName(?string $secondTaxName): FeeData
133 | {
134 | $this->nullableChanged();
135 | $this->secondTaxName = $secondTaxName;
136 |
137 | return $this;
138 | }
139 |
140 | /**
141 | * @param float|null $secondTaxPercent
142 | * @return $this
143 | */
144 | public function setSecondTaxPercent(?float $secondTaxPercent): FeeData
145 | {
146 | $this->nullableChanged();
147 | $this->secondTaxPercent = $secondTaxPercent;
148 |
149 | return $this;
150 | }
151 |
152 | /**
153 | * @param LatePaymentFeeType $type
154 | * @return $this
155 | */
156 | public function setType(LatePaymentFeeType $type): FeeData
157 | {
158 | $this->type = $type;
159 |
160 | return $this;
161 | }
162 |
163 | /**
164 | * @param float $value
165 | * @return $this
166 | */
167 | public function setValue(float $value): FeeData
168 | {
169 | $this->value = $value;
170 |
171 | return $this;
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/src/Response/InvoiceProfile/InvoiceProfileResponse.php:
--------------------------------------------------------------------------------
1 | data['discount_total']);
86 | }
87 |
88 | /**
89 | * Amount
90 | *
91 | * @return Amount
92 | */
93 | public function getAmountAttribute(): Amount
94 | {
95 | return new Amount($this->data['amount']);
96 | }
97 |
98 | /**
99 | * Lines
100 | *
101 | * @return InvoiceLine[]|null
102 | */
103 | public function getLinesAttribute(): ?array
104 | {
105 | if (!isset($this->data['lines'])) {
106 | return null;
107 | }
108 |
109 | return array_map(
110 | function (array $data) {
111 | return new InvoiceLine($data);
112 | },
113 | $this->data['lines']
114 | );
115 | }
116 |
117 | /**
118 | * Getter for currency_code
119 | *
120 | * @return CurrencyEnum
121 | */
122 | public function getCurrencyAttribute(): CurrencyEnum
123 | {
124 | return CurrencyEnum::get($this->data['currency_code']);
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/src/Response/Clients/ClientResponse.php:
--------------------------------------------------------------------------------
1 | data['late_reminders'])) {
92 | return null;
93 | }
94 |
95 | return array_map(
96 | function (array $data) {
97 | return new LatePaymentReminder($data);
98 | },
99 | $this->data['late_reminders']
100 | );
101 | }
102 |
103 | /**
104 | * LateFee
105 | *
106 | * @return LatePaymentFee|null
107 | */
108 | public function getLateFeeAttribute(): ?LatePaymentFee
109 | {
110 | if (!isset($this->data['late_fee'])) {
111 | return null;
112 | }
113 |
114 | return new LatePaymentFee($this->data['late_fee']);
115 | }
116 |
117 | /**
118 | * @return CurrencyEnum
119 | */
120 | public function getCurrencyAttribute(): CurrencyEnum
121 | {
122 | return CurrencyEnum::get($this->data()['currency_code']);
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/src/Request/Data/Invoice/WritableInvoiceFieldsTrait.php:
--------------------------------------------------------------------------------
1 | invoiceNumber = $invoiceNumber;
60 |
61 | return $this;
62 | }
63 |
64 | /**
65 | * @param Carbon|null $generationDate
66 | *
67 | * @return $this
68 | */
69 | public function setGenerationDate(?Carbon $generationDate)
70 | {
71 | $this->nullableChanged();
72 | $this->generationDate = new DateTimeData($generationDate, 'Y-m-d');
73 |
74 | return $this;
75 | }
76 |
77 | /**
78 | * @param null|string $discountDescription
79 | *
80 | * @return $this
81 | */
82 | public function setDiscountDescription(?string $discountDescription)
83 | {
84 | $this->nullableChanged();
85 | $this->discountDescription = $discountDescription;
86 |
87 | return $this;
88 | }
89 |
90 | /**
91 | * @param null|string $returnUri
92 | *
93 | * @return $this
94 | */
95 | public function setReturnUri(?string $returnUri)
96 | {
97 | $this->nullableChanged();
98 | $this->returnUri = $returnUri;
99 |
100 | return $this;
101 | }
102 |
103 | /**
104 | * @param null|string $depositPercentage
105 | *
106 | * @return $this
107 | */
108 | public function setDepositPercentage(?string $depositPercentage)
109 | {
110 | $this->nullableChanged();
111 | $this->depositPercentage = $depositPercentage;
112 |
113 | return $this;
114 | }
115 |
116 | /**
117 | * @param bool $showAttachments
118 | *
119 | * @return $this
120 | */
121 | public function setShowAttachments(bool $showAttachments)
122 | {
123 | $this->showAttachments = $showAttachments;
124 |
125 | return $this;
126 | }
127 |
128 | /**
129 | * @param int $dueOffsetDays
130 | *
131 | * @return $this
132 | */
133 | public function setDueOffsetDays(int $dueOffsetDays)
134 | {
135 | $this->dueOffsetDays = $dueOffsetDays;
136 |
137 | return $this;
138 | }
139 |
140 | /**
141 | * @param int $basecampid
142 | *
143 | * @return $this
144 | */
145 | public function setBasecampid(int $basecampid)
146 | {
147 | $this->basecampid = $basecampid;
148 |
149 | return $this;
150 | }
151 |
152 | /**
153 | * @param string $status
154 | *
155 | * @return $this
156 | */
157 | public function setStatus(string $status)
158 | {
159 | $this->status = $status;
160 |
161 | return $this;
162 | }
163 |
164 | /**
165 | * @param int $parent
166 | *
167 | * @return $this
168 | */
169 | public function setParent(int $parent)
170 | {
171 | $this->parent = $parent;
172 |
173 | return $this;
174 | }
175 |
176 | /**
177 | * @param bool $autoBill
178 | *
179 | * @return $this
180 | */
181 | public function setAutoBill(bool $autoBill)
182 | {
183 | $this->autoBill = $autoBill;
184 |
185 | return $this;
186 | }
187 |
188 | /**
189 | * Set state of the invoice
190 | *
191 | * @param int $visState
192 | *
193 | * @return $this
194 | */
195 | public function setVisState(int $visState)
196 | {
197 | $this->visState = $visState;
198 |
199 | return $this;
200 | }
201 |
202 | /**
203 | * Set the invoice deleted or recovered
204 | *
205 | * @return $this
206 | */
207 | public function setDeleted()
208 | {
209 | return $this->setVisState(1);
210 | }
211 |
212 | /**
213 | * Set the invoice as active
214 | *
215 | * @return $this
216 | */
217 | public function setActive()
218 | {
219 | return $this->setVisState(0);
220 | }
221 |
222 | /**
223 | * Set the invoice as archived
224 | *
225 | * @return $this
226 | */
227 | public function setArchived()
228 | {
229 | return $this->setVisState(2);
230 | }
231 | }
232 |
--------------------------------------------------------------------------------
/src/Request/Data/Presentation/PresentationData.php:
--------------------------------------------------------------------------------
1 | dateFormat = $dateFormat;
42 |
43 | return $this;
44 | }
45 |
46 | /**
47 | * @param int|null $id
48 | *
49 | * @return $this
50 | */
51 | public function setId(?int $id): PresentationData
52 | {
53 | $this->id = $id;
54 |
55 | return $this;
56 | }
57 |
58 | /**
59 | * @param int|null $imageBannerPosition_y
60 | *
61 | * @return $this
62 | */
63 | public function setImageBannerPositionY(?int $imageBannerPosition_y): PresentationData
64 | {
65 | $this->imageBannerPosition_y = $imageBannerPosition_y;
66 |
67 | return $this;
68 | }
69 |
70 | /**
71 | * @param null|string $imageBannerSrc
72 | *
73 | * @return $this
74 | */
75 | public function setImageBannerSrc(?string $imageBannerSrc): PresentationData
76 | {
77 | $this->imageBannerSrc = $imageBannerSrc;
78 |
79 | return $this;
80 | }
81 |
82 | /**
83 | * @param null|string $imageLogoSrc
84 | *
85 | * @return $this
86 | */
87 | public function setImageLogoSrc(?string $imageLogoSrc): PresentationData
88 | {
89 | $this->imageLogoSrc = $imageLogoSrc;
90 |
91 | return $this;
92 | }
93 |
94 | /**
95 | * @param null|string $themeFontName
96 | *
97 | * @return $this
98 | */
99 | public function setThemeFontName(?string $themeFontName): PresentationData
100 | {
101 | $this->themeFontName = $themeFontName;
102 |
103 | return $this;
104 | }
105 |
106 | /**
107 | * @param null|string $themeLayout
108 | *
109 | * @return $this
110 | */
111 | public function setThemeLayout(?string $themeLayout): PresentationData
112 | {
113 | $this->themeLayout = $themeLayout;
114 |
115 | return $this;
116 | }
117 |
118 | /**
119 | * @param null|string $themePrimaryColor
120 | *
121 | * @return $this
122 | */
123 | public function setThemePrimaryColor(?string $themePrimaryColor): PresentationData
124 | {
125 | $this->themePrimaryColor = $themePrimaryColor;
126 |
127 | return $this;
128 | }
129 |
130 |
131 | /**
132 | * @param IResponse $response
133 | *
134 | * @return static
135 | */
136 | public static function fromResponse(IResponse $response)
137 | {
138 | if (!$response instanceof PresentationResponse) {
139 | return parent::fromResponse($response);
140 | }
141 | /** @var PresentationData $data */
142 | $data = parent::fromResponse($response);
143 | $data->setId($response->invoiceid);
144 |
145 | return $data;
146 | }
147 |
148 | /**
149 | * @return string|null
150 | */
151 | public function getDateFormat(): ?string
152 | {
153 | return $this->dateFormat;
154 | }
155 |
156 | /**
157 | * @return int|null
158 | */
159 | public function getId(): ?int
160 | {
161 | return $this->id;
162 | }
163 |
164 | /**
165 | * @return int|null
166 | */
167 | public function getImageBannerPositionY(): ?int
168 | {
169 | return $this->imageBannerPosition_y;
170 | }
171 |
172 | /**
173 | * @return string|null
174 | */
175 | public function getImageBannerSrc(): ?string
176 | {
177 | return $this->imageBannerSrc;
178 | }
179 |
180 | /**
181 | * @return string|null
182 | */
183 | public function getImageLogoSrc(): ?string
184 | {
185 | return $this->imageLogoSrc;
186 | }
187 |
188 | /**
189 | * @return string|null
190 | */
191 | public function getThemeFontName(): ?string
192 | {
193 | return $this->themeFontName;
194 | }
195 |
196 | /**
197 | * @return string|null
198 | */
199 | public function getThemeLayout(): ?string
200 | {
201 | return $this->themeLayout;
202 | }
203 |
204 | /**
205 | * @return string|null
206 | */
207 | public function getThemePrimaryColor(): ?string
208 | {
209 | return $this->themePrimaryColor;
210 | }
211 | }
212 |
--------------------------------------------------------------------------------
/src/Response/Estimate/EstimateResponse.php:
--------------------------------------------------------------------------------
1 | data['amount']);
88 | }
89 |
90 | /**
91 | * Currency code mutator
92 | *
93 | * @return CurrencyEnum
94 | */
95 | public function getCurrencyCodeAttribute(): CurrencyEnum
96 | {
97 | return CurrencyEnum::get($this->data['currency_code']);
98 | }
99 |
100 | /**
101 | * Estimate status mutator
102 | *
103 | * @return EstimateStatusEnum
104 | */
105 | public function getStatusAttribute(): EstimateStatusEnum
106 | {
107 | return EstimateStatusEnum::byValue($this->data['status']);
108 | }
109 |
110 | /**
111 | * Estimate ui_status mutator
112 | *
113 | * @return UIEstimateStatusEnum
114 | */
115 | public function getUiStatusAttribute(): UIEstimateStatusEnum
116 | {
117 | return UIEstimateStatusEnum::byValueInsensitive($this->data['ui_status']);
118 | }
119 |
120 | /**
121 | * Estimate display status mutator
122 | *
123 | * Should be one in (draft, sent, viewed)
124 | *
125 | * @return UIEstimateStatusEnum
126 | */
127 | public function getDisplayStatusAttribute(): UIEstimateStatusEnum
128 | {
129 | return UIEstimateStatusEnum::byValueInsensitive($this->data['ui_status']);
130 | }
131 |
132 | /**
133 | * Language mutator
134 | *
135 | * @return LanguageEnum
136 | */
137 | public function getLanguageAttribute(): LanguageEnum
138 | {
139 | return LanguageEnum::byValueInsensitive($this->data['language']);
140 | }
141 |
142 | /**
143 | * Mutator for estimate lines
144 | *
145 | * @return InvoiceLine[]|null
146 | */
147 | public function getLinesAttribute(): ?array
148 | {
149 | if (!isset($this->data['lines'])) {
150 | return null;
151 | }
152 |
153 | return array_map(
154 | function (array $line) {
155 | return new InvoiceLine($line);
156 | }, $this->data['lines']);
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/src/Response/Invoice/InvoiceResponse.php:
--------------------------------------------------------------------------------
1 | data['status']);
104 | }
105 |
106 | /**
107 | * Outstanding
108 | *
109 | * @return Amount
110 | */
111 | public function getOutstandingAttribute(): Amount
112 | {
113 | return new Amount($this->data['outstanding']);
114 | }
115 |
116 |
117 | /**
118 | * Deposit amount
119 | *
120 | * @return Amount|null
121 | */
122 | public function getDepositAmountAttribute(): ?Amount
123 | {
124 | if (is_null($this->data['deposit_amount'])) {
125 | return null;
126 | }
127 | return new Amount($this->data['deposit_amount']);
128 | }
129 |
130 |
131 | /**
132 | * Paid
133 | *
134 | * @return Amount
135 | */
136 | public function getPaidAttribute(): Amount
137 | {
138 | return new Amount($this->data['paid']);
139 | }
140 |
141 |
142 | /**
143 | * Discount total
144 | *
145 | * @return Amount
146 | */
147 | public function getDiscountTotalAttribute(): Amount
148 | {
149 | return new Amount($this->data['discount_total']);
150 | }
151 |
152 |
153 | /**
154 | * Amount
155 | *
156 | * @return Amount
157 | */
158 | public function getAmountAttribute(): Amount
159 | {
160 | return new Amount($this->data['amount']);
161 | }
162 |
163 | /**
164 | * Language mutator
165 | *
166 | * @return LanguageEnum
167 | */
168 | public function getLanguageAttribute(): LanguageEnum
169 | {
170 | return LanguageEnum::byValueInsensitive($this->data['language']);
171 | }
172 |
173 |
174 | /**
175 | * Lines
176 | *
177 | * @return InvoiceLine[]|null
178 | */
179 | public function getLinesAttribute(): ?array
180 | {
181 | if (!isset($this->data['lines'])) {
182 | return null;
183 | }
184 |
185 | return array_map(
186 | function (array $data) {
187 | return new InvoiceLine($data);
188 | },
189 | $this->data['lines']
190 | );
191 | }
192 |
193 | /**
194 | * @return CurrencyEnum
195 | */
196 | public function getCurrencyAttribute(): CurrencyEnum
197 | {
198 | return CurrencyEnum::get($this->data['currency_code']);
199 | }
200 | }
201 |
--------------------------------------------------------------------------------
/phpdox.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
98 |
99 |
100 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/tests/src/Requests/Invoice/Presentations/PresentationsTest.php:
--------------------------------------------------------------------------------
1 | preSuccess($JSON);
28 | $request = new PresentationsReadRequest();
29 | $request->setAccountId('id');
30 | $client->getOAuthTestClient()->processRequest($request);
31 |
32 | $response = $request->getResponse();
33 |
34 | $this->assertEquals('yyyy-mm-dd', $response->date_format);
35 | $this->assertEquals('226105', $response->invoiceid);
36 | $this->assertArraySubset([
37 | 'image_logo_src' => '/service/uploads/images/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50IjozNDAxMTU3LCJvcmlnaW5hbF9maWxlbmFtZSI6Ilplcm9TcGFtX0xvZ29fU21hbGwucG5nIiwiYnVja2V0IjoidXBsb2FkcyIsImZpbGVuYW1lIjoidXBsb2FkLTI2YzAwZGI0M2VhZjUxNGI1MDU5NmFjOTk4Njg3MzUzMGFlZjZmM2QiLCJsZW5ndGgiOjE5NTEyLCJrZXkiOiInZG9jcy0nLTM0MDExNTcvdXBsb2FkLTI2YzAwZGI0M2VhZjUxNGI1MDU5NmFjOTk4Njg3MzUzMGFlZjZmM2QifQ.HP_Ww3kSFLRnYkAt0xbJSUxh2mfxtLmNtvPuq7l2bkI'
38 | ], $response->toArray());
39 | }
40 |
41 | public function testPresentationsToData(): void
42 | {
43 | $JSON
44 | = '{"response": {"result": {"presentation": {"quantity_heading": null, "date_format": "yyyy-mm-dd", "invoiceid": 226105, "theme_layout": "simple", "image_banner_position_y": 0, "unit_cost_heading": null, "time_entry_notes_heading": null, "task_heading": null, "image_logo_src": "/service/uploads/images/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50IjozNDAxMTU3LCJvcmlnaW5hbF9maWxlbmFtZSI6Ilplcm9TcGFtX0xvZ29fU21hbGwucG5nIiwiYnVja2V0IjoidXBsb2FkcyIsImZpbGVuYW1lIjoidXBsb2FkLTI2YzAwZGI0M2VhZjUxNGI1MDU5NmFjOTk4Njg3MzUzMGFlZjZmM2QiLCJsZW5ndGgiOjE5NTEyLCJrZXkiOiInZG9jcy0nLTM0MDExNTcvdXBsb2FkLTI2YzAwZGI0M2VhZjUxNGI1MDU5NmFjOTk4Njg3MzUzMGFlZjZmM2QifQ.HP_Ww3kSFLRnYkAt0xbJSUxh2mfxtLmNtvPuq7l2bkI", "image_banner_src": null, "theme_primary_color": "#dc143c", "theme_font_name": "modern", "item_heading": null, "hours_heading": null, "description_heading": null, "label": null, "rate_heading": null}}}}';
45 |
46 | $client = $this->preSuccess($JSON);
47 | $request = new PresentationsReadRequest();
48 | $request->setAccountId('id');
49 | $client->getOAuthTestClient()->processRequest($request);
50 |
51 | $response = $request->getResponse();
52 |
53 |
54 | $data = PresentationData::fromResponse($response);
55 |
56 | $this->assertEquals('yyyy-mm-dd', $data->getDateFormat());
57 | $this->assertEquals(226105, $data->getId());
58 | }
59 |
60 | public function testSetPresentationInvoice(): void
61 | {
62 | $jsonPresentation
63 | = '{"response": {"result": {"presentation": {"quantity_heading": null, "date_format": "yyyy-mm-dd", "invoiceid": 226105, "theme_layout": "simple", "image_banner_position_y": 0, "unit_cost_heading": null, "time_entry_notes_heading": null, "task_heading": null, "image_logo_src": "/service/uploads/images/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50IjozNDAxMTU3LCJvcmlnaW5hbF9maWxlbmFtZSI6Ilplcm9TcGFtX0xvZ29fU21hbGwucG5nIiwiYnVja2V0IjoidXBsb2FkcyIsImZpbGVuYW1lIjoidXBsb2FkLTI2YzAwZGI0M2VhZjUxNGI1MDU5NmFjOTk4Njg3MzUzMGFlZjZmM2QiLCJsZW5ndGgiOjE5NTEyLCJrZXkiOiInZG9jcy0nLTM0MDExNTcvdXBsb2FkLTI2YzAwZGI0M2VhZjUxNGI1MDU5NmFjOTk4Njg3MzUzMGFlZjZmM2QifQ.HP_Ww3kSFLRnYkAt0xbJSUxh2mfxtLmNtvPuq7l2bkI", "image_banner_src": null, "theme_primary_color": "#dc143c", "theme_font_name": "modern", "item_heading": null, "hours_heading": null, "description_heading": null, "label": null, "rate_heading": null}}}}';
64 | $jsonInvoice
65 | = <<getTestClient($mockHandler);
84 | $request = new PresentationsReadRequest();
85 | $request->setAccountId('id');
86 | $client = $config->getOAuthTestClient();
87 | $client->processRequest($request);
88 |
89 | $response = $request->getResponse();
90 |
91 | $request = new InvoiceCreateRequest((new InvoiceCreateData())->setPresentation($response));
92 | $request->setAccountId('id');
93 | $client->processRequest($request);
94 | $this->validateRequest(
95 | $config,
96 | [
97 | 'invoice' => [
98 | 'presentation' => [
99 | 'date_format' => 'yyyy-mm-dd',
100 | 'id' => 226105,
101 | 'image_banner_position_y' => 0,
102 | 'image_logo_src' => '/service/uploads/images/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50IjozNDAxMTU3LCJvcmlnaW5hbF9maWxlbmFtZSI6Ilplcm9TcGFtX0xvZ29fU21hbGwucG5nIiwiYnVja2V0IjoidXBsb2FkcyIsImZpbGVuYW1lIjoidXBsb2FkLTI2YzAwZGI0M2VhZjUxNGI1MDU5NmFjOTk4Njg3MzUzMGFlZjZmM2QiLCJsZW5ndGgiOjE5NTEyLCJrZXkiOiInZG9jcy0nLTM0MDExNTcvdXBsb2FkLTI2YzAwZGI0M2VhZjUxNGI1MDU5NmFjOTk4Njg3MzUzMGFlZjZmM2QifQ.HP_Ww3kSFLRnYkAt0xbJSUxh2mfxtLmNtvPuq7l2bkI',
103 | 'theme_font_name' => 'modern',
104 | 'theme_layout' => 'simple',
105 | 'theme_primary_color' => '#dc143c',
106 | ],
107 | ],
108 | ]
109 | );
110 | }
111 | }
112 |
--------------------------------------------------------------------------------