mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Current company route
This commit is contained in:
parent
7801635568
commit
f4aae330eb
@ -117,11 +117,21 @@ class CompanyController extends BaseController
|
|||||||
/** @var \App\Models\User $user */
|
/** @var \App\Models\User $user */
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
|
||||||
$companies = Company::whereAccountId($user->company()->account->id);
|
$companies = Company::where('account_id', $user->company()->account->id);
|
||||||
|
|
||||||
return $this->listResponse($companies);
|
return $this->listResponse($companies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function current()
|
||||||
|
{
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
$company = Company::find($user->company()->id);
|
||||||
|
|
||||||
|
return $this->itemResponse($company);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* Show the form for creating a new resource.
|
||||||
*
|
*
|
||||||
|
@ -206,12 +206,10 @@ paths:
|
|||||||
description: "The users email address."
|
description: "The users email address."
|
||||||
type: string
|
type: string
|
||||||
example: "demo@invoiceninja.com"
|
example: "demo@invoiceninja.com"
|
||||||
required: true
|
|
||||||
password:
|
password:
|
||||||
description: "The user password. Must meet minimum criteria ~ > 6 characters"
|
description: "The user password. Must meet minimum criteria ~ > 6 characters"
|
||||||
type: string
|
type: string
|
||||||
example: "Password0"
|
example: "Password0"
|
||||||
required: true
|
|
||||||
one_time_password:
|
one_time_password:
|
||||||
description: "The one time password if 2FA is enabled"
|
description: "The one time password if 2FA is enabled"
|
||||||
type: string
|
type: string
|
||||||
@ -12061,15 +12059,12 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- clients
|
- clients
|
||||||
summary: 'List clients'
|
summary: 'List clients'
|
||||||
x-badges:
|
|
||||||
- color: blue
|
|
||||||
label: core
|
|
||||||
x-code-samples:
|
x-code-samples:
|
||||||
- lang: javascript
|
- lang: go
|
||||||
|
label: php
|
||||||
source: |
|
source: |
|
||||||
fetch('/example')
|
$ninja = new InvoiceNinja("your_token");
|
||||||
.then(response => response.json())
|
$invoices = $ninja->clients->all();
|
||||||
.then(data => console.log(data));
|
|
||||||
x-custom-element:
|
x-custom-element:
|
||||||
type: markdown
|
type: markdown
|
||||||
value: |
|
value: |
|
||||||
@ -15139,7 +15134,109 @@ components:
|
|||||||
example: '123456'
|
example: '123456'
|
||||||
readOnly: true
|
readOnly: true
|
||||||
company_user:
|
company_user:
|
||||||
$ref: '#/components/schemas/CompanyUser'
|
$ref: '#/components/schemas/CompanyUserRef'
|
||||||
|
type: object
|
||||||
|
UserRef:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
description: 'The hashed id of the user'
|
||||||
|
type: string
|
||||||
|
example: Opnel5aKBz
|
||||||
|
readOnly: true
|
||||||
|
first_name:
|
||||||
|
description: 'The first name of the user'
|
||||||
|
type: string
|
||||||
|
example: Brad
|
||||||
|
last_name:
|
||||||
|
description: 'The last name of the user'
|
||||||
|
type: string
|
||||||
|
example: Pitt
|
||||||
|
email:
|
||||||
|
description: 'The users email address'
|
||||||
|
type: string
|
||||||
|
example: brad@pitt.com
|
||||||
|
phone:
|
||||||
|
description: 'The users phone number'
|
||||||
|
type: string
|
||||||
|
example: 555-1233-23232
|
||||||
|
signature:
|
||||||
|
description: 'The users sign off signature'
|
||||||
|
type: string
|
||||||
|
example: 'Have a nice day!'
|
||||||
|
avatar:
|
||||||
|
description: 'The users avatar'
|
||||||
|
type: string
|
||||||
|
example: 'https://url.to.your/avatar.png'
|
||||||
|
accepted_terms_version:
|
||||||
|
description: 'The version of the invoice ninja terms that has been accepted by the user'
|
||||||
|
type: string
|
||||||
|
example: 1.0.1
|
||||||
|
readOnly: true
|
||||||
|
oauth_user_id:
|
||||||
|
description: 'The provider id of the oauth entity'
|
||||||
|
type: string
|
||||||
|
example: jkhasdf789as6f675sdf768sdfs
|
||||||
|
readOnly: true
|
||||||
|
oauth_provider_id:
|
||||||
|
description: 'The oauth entity id'
|
||||||
|
type: string
|
||||||
|
example: google
|
||||||
|
readOnly: true
|
||||||
|
language_id:
|
||||||
|
description: 'The language id of the user'
|
||||||
|
type: string
|
||||||
|
example: 1
|
||||||
|
verified_phone_number:
|
||||||
|
description: 'Boolean flag if the user has their phone verified. Required to settings up 2FA'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
sms_verification_code:
|
||||||
|
description: 'The sms verification code for the user. Required to settings up 2FA'
|
||||||
|
type: string
|
||||||
|
example: '123456'
|
||||||
|
readOnly: true
|
||||||
|
oauth_user_token_expiry:
|
||||||
|
description: 'The expiry date of the oauth token'
|
||||||
|
type: string
|
||||||
|
example: '2022-10-10'
|
||||||
|
readOnly: true
|
||||||
|
has_password:
|
||||||
|
description: 'Boolean flag determining if the user has a password'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
last_confirmed_email_address:
|
||||||
|
description: 'The last confirmed email address of the user'
|
||||||
|
type: string
|
||||||
|
example: 'bob@gmail.com'
|
||||||
|
readOnly: true
|
||||||
|
custom_value1:
|
||||||
|
description: 'A custom value'
|
||||||
|
type: string
|
||||||
|
example: 'Custom value 1'
|
||||||
|
custom_value2:
|
||||||
|
description: 'A custom value'
|
||||||
|
type: string
|
||||||
|
example: '$1000'
|
||||||
|
custom_value3:
|
||||||
|
description: 'A custom value'
|
||||||
|
type: string
|
||||||
|
example: 'Custom value 3'
|
||||||
|
custom_value4:
|
||||||
|
description: 'A custom value'
|
||||||
|
type: string
|
||||||
|
example: 'Custom value 4'
|
||||||
|
is_deleted:
|
||||||
|
description: 'Boolean flag determining if the user has been deleted'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
google_2fa_secret:
|
||||||
|
description: 'The google 2fa secret for the user'
|
||||||
|
type: string
|
||||||
|
example: '123456'
|
||||||
|
readOnly: true
|
||||||
type: object
|
type: object
|
||||||
Task:
|
Task:
|
||||||
properties:
|
properties:
|
||||||
@ -16365,7 +16462,53 @@ components:
|
|||||||
company:
|
company:
|
||||||
$ref: '#/components/schemas/Company'
|
$ref: '#/components/schemas/Company'
|
||||||
user:
|
user:
|
||||||
$ref: '#/components/schemas/User'
|
$ref: '#/components/schemas/UserRef'
|
||||||
|
token:
|
||||||
|
$ref: '#/components/schemas/CompanyToken'
|
||||||
|
type: object
|
||||||
|
CompanyUserRef:
|
||||||
|
properties:
|
||||||
|
permissions:
|
||||||
|
description: 'The user permissionsfor this company in a comma separated list'
|
||||||
|
type: string
|
||||||
|
example: 'create_invoice,create_client,view_client'
|
||||||
|
settings:
|
||||||
|
description: 'Settings that are used for the flutter applications to store user preferences / metadata'
|
||||||
|
type: object
|
||||||
|
readOnly: true
|
||||||
|
react_settings:
|
||||||
|
description: 'Dedicated settings object for the react web application'
|
||||||
|
type: object
|
||||||
|
readOnly: true
|
||||||
|
is_owner:
|
||||||
|
description: 'Determines whether the user owns this company'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
is_admin:
|
||||||
|
description: 'Determines whether the user is the admin of this company'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
is_locked:
|
||||||
|
description: 'Determines whether the users access to this company has been locked'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
updated_at:
|
||||||
|
description: 'The last time the record was modified, format Unix Timestamp'
|
||||||
|
type: integer
|
||||||
|
example: '1231232312321'
|
||||||
|
deleted_at:
|
||||||
|
description: 'Timestamp when the user was archived, format Unix Timestamp'
|
||||||
|
type: integer
|
||||||
|
example: '12312312321'
|
||||||
|
account:
|
||||||
|
$ref: '#/components/schemas/Account'
|
||||||
|
company:
|
||||||
|
$ref: '#/components/schemas/Company'
|
||||||
|
user:
|
||||||
|
$ref: '#/components/schemas/UserRef'
|
||||||
token:
|
token:
|
||||||
$ref: '#/components/schemas/CompanyToken'
|
$ref: '#/components/schemas/CompanyToken'
|
||||||
type: object
|
type: object
|
||||||
|
@ -40,7 +40,53 @@
|
|||||||
company:
|
company:
|
||||||
$ref: '#/components/schemas/Company'
|
$ref: '#/components/schemas/Company'
|
||||||
user:
|
user:
|
||||||
$ref: '#/components/schemas/User'
|
$ref: '#/components/schemas/UserRef'
|
||||||
|
token:
|
||||||
|
$ref: '#/components/schemas/CompanyToken'
|
||||||
|
type: object
|
||||||
|
CompanyUserRef:
|
||||||
|
properties:
|
||||||
|
permissions:
|
||||||
|
description: 'The user permissionsfor this company in a comma separated list'
|
||||||
|
type: string
|
||||||
|
example: 'create_invoice,create_client,view_client'
|
||||||
|
settings:
|
||||||
|
description: 'Settings that are used for the flutter applications to store user preferences / metadata'
|
||||||
|
type: object
|
||||||
|
readOnly: true
|
||||||
|
react_settings:
|
||||||
|
description: 'Dedicated settings object for the react web application'
|
||||||
|
type: object
|
||||||
|
readOnly: true
|
||||||
|
is_owner:
|
||||||
|
description: 'Determines whether the user owns this company'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
is_admin:
|
||||||
|
description: 'Determines whether the user is the admin of this company'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
is_locked:
|
||||||
|
description: 'Determines whether the users access to this company has been locked'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
updated_at:
|
||||||
|
description: 'The last time the record was modified, format Unix Timestamp'
|
||||||
|
type: integer
|
||||||
|
example: '1231232312321'
|
||||||
|
deleted_at:
|
||||||
|
description: 'Timestamp when the user was archived, format Unix Timestamp'
|
||||||
|
type: integer
|
||||||
|
example: '12312312321'
|
||||||
|
account:
|
||||||
|
$ref: '#/components/schemas/Account'
|
||||||
|
company:
|
||||||
|
$ref: '#/components/schemas/Company'
|
||||||
|
user:
|
||||||
|
$ref: '#/components/schemas/UserRef'
|
||||||
token:
|
token:
|
||||||
$ref: '#/components/schemas/CompanyToken'
|
$ref: '#/components/schemas/CompanyToken'
|
||||||
type: object
|
type: object
|
@ -100,5 +100,107 @@
|
|||||||
example: '123456'
|
example: '123456'
|
||||||
readOnly: true
|
readOnly: true
|
||||||
company_user:
|
company_user:
|
||||||
$ref: '#/components/schemas/CompanyUser'
|
$ref: '#/components/schemas/CompanyUserRef'
|
||||||
|
type: object
|
||||||
|
UserRef:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
description: 'The hashed id of the user'
|
||||||
|
type: string
|
||||||
|
example: Opnel5aKBz
|
||||||
|
readOnly: true
|
||||||
|
first_name:
|
||||||
|
description: 'The first name of the user'
|
||||||
|
type: string
|
||||||
|
example: Brad
|
||||||
|
last_name:
|
||||||
|
description: 'The last name of the user'
|
||||||
|
type: string
|
||||||
|
example: Pitt
|
||||||
|
email:
|
||||||
|
description: 'The users email address'
|
||||||
|
type: string
|
||||||
|
example: brad@pitt.com
|
||||||
|
phone:
|
||||||
|
description: 'The users phone number'
|
||||||
|
type: string
|
||||||
|
example: 555-1233-23232
|
||||||
|
signature:
|
||||||
|
description: 'The users sign off signature'
|
||||||
|
type: string
|
||||||
|
example: 'Have a nice day!'
|
||||||
|
avatar:
|
||||||
|
description: 'The users avatar'
|
||||||
|
type: string
|
||||||
|
example: 'https://url.to.your/avatar.png'
|
||||||
|
accepted_terms_version:
|
||||||
|
description: 'The version of the invoice ninja terms that has been accepted by the user'
|
||||||
|
type: string
|
||||||
|
example: 1.0.1
|
||||||
|
readOnly: true
|
||||||
|
oauth_user_id:
|
||||||
|
description: 'The provider id of the oauth entity'
|
||||||
|
type: string
|
||||||
|
example: jkhasdf789as6f675sdf768sdfs
|
||||||
|
readOnly: true
|
||||||
|
oauth_provider_id:
|
||||||
|
description: 'The oauth entity id'
|
||||||
|
type: string
|
||||||
|
example: google
|
||||||
|
readOnly: true
|
||||||
|
language_id:
|
||||||
|
description: 'The language id of the user'
|
||||||
|
type: string
|
||||||
|
example: 1
|
||||||
|
verified_phone_number:
|
||||||
|
description: 'Boolean flag if the user has their phone verified. Required to settings up 2FA'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
sms_verification_code:
|
||||||
|
description: 'The sms verification code for the user. Required to settings up 2FA'
|
||||||
|
type: string
|
||||||
|
example: '123456'
|
||||||
|
readOnly: true
|
||||||
|
oauth_user_token_expiry:
|
||||||
|
description: 'The expiry date of the oauth token'
|
||||||
|
type: string
|
||||||
|
example: '2022-10-10'
|
||||||
|
readOnly: true
|
||||||
|
has_password:
|
||||||
|
description: 'Boolean flag determining if the user has a password'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
last_confirmed_email_address:
|
||||||
|
description: 'The last confirmed email address of the user'
|
||||||
|
type: string
|
||||||
|
example: 'bob@gmail.com'
|
||||||
|
readOnly: true
|
||||||
|
custom_value1:
|
||||||
|
description: 'A custom value'
|
||||||
|
type: string
|
||||||
|
example: 'Custom value 1'
|
||||||
|
custom_value2:
|
||||||
|
description: 'A custom value'
|
||||||
|
type: string
|
||||||
|
example: '$1000'
|
||||||
|
custom_value3:
|
||||||
|
description: 'A custom value'
|
||||||
|
type: string
|
||||||
|
example: 'Custom value 3'
|
||||||
|
custom_value4:
|
||||||
|
description: 'A custom value'
|
||||||
|
type: string
|
||||||
|
example: 'Custom value 4'
|
||||||
|
is_deleted:
|
||||||
|
description: 'Boolean flag determining if the user has been deleted'
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
readOnly: true
|
||||||
|
google_2fa_secret:
|
||||||
|
description: 'The google 2fa secret for the user'
|
||||||
|
type: string
|
||||||
|
example: '123456'
|
||||||
|
readOnly: true
|
||||||
type: object
|
type: object
|
@ -116,12 +116,10 @@ paths:
|
|||||||
description: "The users email address."
|
description: "The users email address."
|
||||||
type: string
|
type: string
|
||||||
example: "demo@invoiceninja.com"
|
example: "demo@invoiceninja.com"
|
||||||
required: true
|
|
||||||
password:
|
password:
|
||||||
description: "The user password. Must meet minimum criteria ~ > 6 characters"
|
description: "The user password. Must meet minimum criteria ~ > 6 characters"
|
||||||
type: string
|
type: string
|
||||||
example: "Password0"
|
example: "Password0"
|
||||||
required: true
|
|
||||||
one_time_password:
|
one_time_password:
|
||||||
description: "The one time password if 2FA is enabled"
|
description: "The one time password if 2FA is enabled"
|
||||||
type: string
|
type: string
|
||||||
|
@ -3,15 +3,12 @@
|
|||||||
tags:
|
tags:
|
||||||
- clients
|
- clients
|
||||||
summary: 'List clients'
|
summary: 'List clients'
|
||||||
x-badges:
|
|
||||||
- color: blue
|
|
||||||
label: core
|
|
||||||
x-code-samples:
|
x-code-samples:
|
||||||
- lang: javascript
|
- lang: go
|
||||||
|
label: php
|
||||||
source: |
|
source: |
|
||||||
fetch('/example')
|
$ninja = new InvoiceNinja("your_token");
|
||||||
.then(response => response.json())
|
$invoices = $ninja->clients->all();
|
||||||
.then(data => console.log(data));
|
|
||||||
x-custom-element:
|
x-custom-element:
|
||||||
type: markdown
|
type: markdown
|
||||||
value: |
|
value: |
|
||||||
|
@ -184,7 +184,10 @@ Route::group(['middleware' => ['throttle:api', 'api_db', 'token_auth', 'locale']
|
|||||||
|
|
||||||
Route::post('client_statement', [ClientStatementController::class, 'statement'])->name('client.statement');
|
Route::post('client_statement', [ClientStatementController::class, 'statement'])->name('client.statement');
|
||||||
|
|
||||||
Route::post('companies/purge/{company}', [MigrationController::class, 'purgeCompany'])->middleware('password_protected');
|
|
||||||
|
Route::post('companies/purge/{company}', [MigrationController::class, 'purgeCompany'])->middleware('password_protected');
|
||||||
|
|
||||||
|
Route::post('companies/current', [CompanyController::class, 'current'])->name('companies.current');
|
||||||
Route::post('companies/purge_save_settings/{company}', [MigrationController::class, 'purgeCompanySaveSettings'])->middleware('password_protected');
|
Route::post('companies/purge_save_settings/{company}', [MigrationController::class, 'purgeCompanySaveSettings'])->middleware('password_protected');
|
||||||
Route::resource('companies', CompanyController::class); // name = (companies. index / create / show / update / destroy / edit
|
Route::resource('companies', CompanyController::class); // name = (companies. index / create / show / update / destroy / edit
|
||||||
|
|
||||||
|
@ -72,6 +72,21 @@ class CompanyTest extends TestCase
|
|||||||
$this->assertEquals(1, TaxRate::count());
|
$this->assertEquals(1, TaxRate::count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCompanyCurrent()
|
||||||
|
{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->postJson("/api/v1/companies/current");
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
$arr = $response->json();
|
||||||
|
|
||||||
|
$this->assertEquals($arr['data']['id'], $this->company->hashed_id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function testCompanyLogoInline()
|
public function testCompanyLogoInline()
|
||||||
{
|
{
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user