diff --git a/app/Http/Controllers/Shop/ProfileController.php b/app/Http/Controllers/Shop/ProfileController.php new file mode 100644 index 000000000000..2fae460ebe2d --- /dev/null +++ b/app/Http/Controllers/Shop/ProfileController.php @@ -0,0 +1,41 @@ +header('X-API-COMPANY-KEY'))->first(); + + if(!$company->enable_shop_api) + return response()->json(['message' => 'Shop is disabled', 'errors' => []],403); + + return $this->itemResponse($company); + } +} diff --git a/app/Transformers/Shop/CompanyShopProfileTransformer.php b/app/Transformers/Shop/CompanyShopProfileTransformer.php new file mode 100644 index 000000000000..832a05fbbb14 --- /dev/null +++ b/app/Transformers/Shop/CompanyShopProfileTransformer.php @@ -0,0 +1,107 @@ + (string)$company->company_key ?: '', + 'settings' => $this->trimCompany($company), + ]; + } + + private function trimCompany($company) + { + $trimmed_company_settings = [ + 'custom_value1' => $company->settings->custom_value1, + 'custom_value2' => $company->settings->custom_value2, + 'custom_value3' => $company->settings->custom_value3, + 'custom_value4' => $company->settings->custom_value4, + 'name' => $company->settings->name, + 'company_logo' => $company->settings->company_logo, + 'website' => $company->settings->website, + 'address1' => $company->settings->address1, + 'address2' => $company->settings->address2, + 'city' => $company->settings->city, + 'state' => $company->settings->state, + 'postal_code' => $company->settings->postal_code, + 'phone' => $company->settings->phone, + 'email' => $company->settings->email, + 'country_id' => $company->settings->country_id, + 'vat_number' => $company->settings->vat_number, + ]; + + $new_settings = new \stdClass; + + foreach($trimmed_company_settings as $key => $value) + $new_settings->{$key} = $value; + + return $new_settings; + } +} diff --git a/routes/shop.php b/routes/shop.php index 9187fdf2be8a..da600175b427 100644 --- a/routes/shop.php +++ b/routes/shop.php @@ -10,5 +10,5 @@ Route::group(['middleware' => ['company_key_db','locale'], 'prefix' => 'api/v1'] Route::get('shop/client/{contact_key}', 'Shop\ClientController@show'); Route::get('shop/invoice/{invitation_key}', 'Shop\InvoiceController@show'); Route::get('shop/product/{product_key}', 'Shop\ProductController@show'); - + Route::get('shop/profile', 'Shop\ProfileController@show'); }); \ No newline at end of file