1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Additions for shop api

This commit is contained in:
David Bomba 2024-06-02 19:29:49 +10:00
parent 6596aeb02e
commit 2c404b4f73
3 changed files with 59 additions and 1 deletions

View File

@ -72,6 +72,9 @@ class CompanyShopProfileTransformer extends EntityTransformer
'email' => $company->settings->email,
'country_id' => $company->settings->country_id,
'vat_number' => $company->settings->vat_number,
'product' => $company->settings->translations->product ?? ctrans('texts.product'),
'products' => $company->settings->translations->products ?? ctrans('texts.products'),
'client_registration_fields' => $company->client_registration_fields,
];
$new_settings = new stdClass();

View File

@ -36,7 +36,6 @@ return new class extends Migration
$table->mediumText('e_invoice')->nullable();
});
Schema::table('accounts', function (Blueprint $table) {
$table->integer('email_quota')->default(20)->nullable();
});

View File

@ -48,4 +48,60 @@ class ShopProfileTest extends TestCase
$this->assertArrayHasKey('custom_value1', $arr['data']['settings']);
$this->assertEquals($this->company->company_key, $arr['data']['company_key']);
}
public function testProfileSettingsUpdate()
{
$this->company->enable_shop_api = true;
$settings = $this->company->settings;
$trans = new \stdClass;
$trans->product = "Service";
$trans->products = "Services";
$settings->translations = $trans;
$this->company->settings = $settings;
$this->company->save();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-COMPANY-KEY' => $this->company->company_key,
])->getJson('/api/v1/shop/profile');
$response->assertStatus(200);
$arr = $response->json();
$this->assertEquals("Service", $arr['data']['settings']['product']);
$this->assertEquals("Services", $arr['data']['settings']['products']);
}
public function testProfileSettingsUpdate2()
{
$this->company->enable_shop_api = true;
$this->company->save();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-COMPANY-KEY' => $this->company->company_key,
])->getJson('/api/v1/shop/profile');
$response->assertStatus(200);
$arr = $response->json();
$this->assertEquals("Product", $arr['data']['settings']['product']);
$this->assertEquals("Products", $arr['data']['settings']['products']);
$this->assertIsArray($arr['data']['settings']['client_registration_fields']);
}
}