Learn more about the Midday PHP SDK in the official documentation.
Midday is a platform for Invoicing, Time tracking, File reconciliation, Storage, Financial Overview & your own Assistant.
Tip
To finish publishing your SDK you must run your first generation action.
The SDK relies on Composer to manage its dependencies.
To install the SDK first add the below to your composer.json
file:
{
"repositories": [
{
"type": "github",
"url": "<UNSET>.git"
}
],
"require": {
"midday/midday-php": "*"
}
}
Then run the following command:
composer update
declare(strict_types=1);
require 'vendor/autoload.php';
use Midday\Midday;
use Midday\Midday\Models\Operations;
$sdk = Midday\Midday::builder()
->setSecurity(
'MIDDAY_API_KEY'
)
->build();
$request = new Operations\ListTransactionsRequest(
cursor: 'eyJpZCI6IjEyMyJ9',
sort: [
'date',
'desc',
],
pageSize: 50,
q: 'office supplies',
categories: [
'office-supplies',
'travel',
],
tags: [
'tag-1',
'tag-2',
],
start: '2024-04-01T00:00:00.000Z',
end: '2024-04-30T23:59:59.999Z',
accounts: [
'account-1',
'account-2',
],
assignees: [
'user-1',
'user-2',
],
statuses: [
'pending',
'completed',
],
recurring: [
'monthly',
'annually',
],
attachments: Operations\Attachments::Include,
amountRange: [
100,
1000,
],
amount: [
'150.75',
'299.99',
],
type: Operations\ListTransactionsType::Expense,
);
$response = $sdk->transactions->list(
request: $request
);
if ($response->object !== null) {
// handle response
}
This SDK supports the following security scheme globally:
Name | Type | Scheme |
---|---|---|
token |
http | HTTP Bearer |
To authenticate with the API the token
parameter must be set when initializing the SDK. For example:
declare(strict_types=1);
require 'vendor/autoload.php';
use Midday\Midday;
use Midday\Midday\Models\Operations;
$sdk = Midday\Midday::builder()
->setSecurity(
'MIDDAY_API_KEY'
)
->build();
$request = new Operations\ListTransactionsRequest(
cursor: 'eyJpZCI6IjEyMyJ9',
sort: [
'date',
'desc',
],
pageSize: 50,
q: 'office supplies',
categories: [
'office-supplies',
'travel',
],
tags: [
'tag-1',
'tag-2',
],
start: '2024-04-01T00:00:00.000Z',
end: '2024-04-30T23:59:59.999Z',
accounts: [
'account-1',
'account-2',
],
assignees: [
'user-1',
'user-2',
],
statuses: [
'pending',
'completed',
],
recurring: [
'monthly',
'annually',
],
attachments: Operations\Attachments::Include,
amountRange: [
100,
1000,
],
amount: [
'150.75',
'299.99',
],
type: Operations\ListTransactionsType::Expense,
);
$response = $sdk->transactions->list(
request: $request
);
if ($response->object !== null) {
// handle response
}
Available methods
- list - List all bank accounts
- create - Create a bank account
- get - Retrieve a bank account
- delete - Delete a bank account
- update - Update a bank account
- list - List all customers
- create - Create customer
- get - Retrieve a customer
- delete - Delete a customer
- update - Update a customer
- list - List all inbox items
- get - Retrieve a inbox item
- delete - Delete a inbox item
- update - Update a inbox item
- list - List all invoices
- getInvoicesPaymentStatus - Payment status
- summary - Invoice summary
- get - Retrieve a invoice
- delete - Delete a invoice
- revenue - Revenue metrics
- profit - Profit metrics
- burnRate - Burn rate metrics
- runway - Runway metrics
- expenses - Expense metrics
- spending - Spending metrics
- search - Search
- list - List all tags
- create - Create a new tag
- get - Retrieve a tag
- delete - Delete a tag
- update - Update a tag
- delete - Delete a tracker entry
- list - List all tracker entries
- list - List all tracker projects
- create - Create a tracker project
- get - Retrieve a tracker project
- delete - Delete a tracker project
- update - Update a tracker project
- list - List all transactions
- create - Create a transaction
- get - Retrieve a transaction
- delete - Delete a transaction
- update - Update a transaction
- createMany - Bulk create transactions
- deleteMany - Bulk delete transactions
- updateMany - Bulk update transactions
Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.
By default an API error will raise a Errors\APIException
exception, which has the following properties:
Property | Type | Description |
---|---|---|
$message |
string | The error message |
$statusCode |
int | The HTTP status code |
$rawResponse |
?\Psr\Http\Message\ResponseInterface | The raw HTTP response |
$body |
string | The response content |
When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the list
method throws the following exceptions:
Error Type | Status Code | Content Type |
---|---|---|
Errors\APIException | 4XX, 5XX | */* |
declare(strict_types=1);
require 'vendor/autoload.php';
use Midday\Midday;
use Midday\Midday\Models\Operations;
$sdk = Midday\Midday::builder()
->setSecurity(
'MIDDAY_API_KEY'
)
->build();
try {
$request = new Operations\ListTransactionsRequest(
cursor: 'eyJpZCI6IjEyMyJ9',
sort: [
'date',
'desc',
],
pageSize: 50,
q: 'office supplies',
categories: [
'office-supplies',
'travel',
],
tags: [
'tag-1',
'tag-2',
],
start: '2024-04-01T00:00:00.000Z',
end: '2024-04-30T23:59:59.999Z',
accounts: [
'account-1',
'account-2',
],
assignees: [
'user-1',
'user-2',
],
statuses: [
'pending',
'completed',
],
recurring: [
'monthly',
'annually',
],
attachments: Operations\Attachments::Include,
amountRange: [
100,
1000,
],
amount: [
'150.75',
'299.99',
],
type: Operations\ListTransactionsType::Expense,
);
$response = $sdk->transactions->list(
request: $request
);
if ($response->object !== null) {
// handle response
}
} catch (Errors\APIException $e) {
// handle default exception
throw $e;
}
The default server can be overridden globally using the setServerUrl(string $serverUrl)
builder method when initializing the SDK client instance. For example:
declare(strict_types=1);
require 'vendor/autoload.php';
use Midday\Midday;
use Midday\Midday\Models\Operations;
$sdk = Midday\Midday::builder()
->setServerURL('https://api.midday.ai')
->setSecurity(
'MIDDAY_API_KEY'
)
->build();
$request = new Operations\ListTransactionsRequest(
cursor: 'eyJpZCI6IjEyMyJ9',
sort: [
'date',
'desc',
],
pageSize: 50,
q: 'office supplies',
categories: [
'office-supplies',
'travel',
],
tags: [
'tag-1',
'tag-2',
],
start: '2024-04-01T00:00:00.000Z',
end: '2024-04-30T23:59:59.999Z',
accounts: [
'account-1',
'account-2',
],
assignees: [
'user-1',
'user-2',
],
statuses: [
'pending',
'completed',
],
recurring: [
'monthly',
'annually',
],
attachments: Operations\Attachments::Include,
amountRange: [
100,
1000,
],
amount: [
'150.75',
'299.99',
],
type: Operations\ListTransactionsType::Expense,
);
$response = $sdk->transactions->list(
request: $request
);
if ($response->object !== null) {
// handle response
}
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.