diff --git a/ShopIt_API_Postman_Collection.json b/ShopIt_API_Postman_Collection.json index bae3d9c..61eee11 100644 --- a/ShopIt_API_Postman_Collection.json +++ b/ShopIt_API_Postman_Collection.json @@ -898,7 +898,7 @@ } ], "url": { - "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/product-variants", + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/productos/{{producto_id}}/variants", "host": [ "{{base_url}}" ], @@ -906,7 +906,9 @@ "api", "tenants", "{{tenant_codigo}}", - "product-variants" + "productos", + "{{producto_id}}", + "variants" ] } }, @@ -930,10 +932,10 @@ ], "body": { "mode": "raw", - "raw": "{\n \"producto_id\": {{producto_id}},\n \"slug\": \"remera-basica-blanca-m\",\n \"nombre\": \"Remera Basica Blanca - Talle M\",\n \"stock\": 8,\n \"descripcion\": \"Variante de prueba\",\n \"precio\": 26999,\n \"definitions\": [\n {\n \"products_attribute_id\": {{color_product_attribute_id}},\n \"value\": \"Blanco\"\n },\n {\n \"products_attribute_id\": {{talle_product_attribute_id}},\n \"value\": \"M\"\n }\n ],\n \"images\": []\n}" + "raw": "{\n \"stock\": 8,\n \"definitions\": [\n {\n \"products_attribute_id\": {{color_product_attribute_id}},\n \"value\": \"Blanco\"\n },\n {\n \"products_attribute_id\": {{talle_product_attribute_id}},\n \"value\": \"M\"\n }\n ],\n \"images\": []\n}" }, "url": { - "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/product-variants", + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/productos/{{producto_id}}/variants", "host": [ "{{base_url}}" ], @@ -941,7 +943,9 @@ "api", "tenants", "{{tenant_codigo}}", - "product-variants" + "productos", + "{{producto_id}}", + "variants" ] } }, @@ -959,7 +963,7 @@ } ], "url": { - "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/product-variants/{{product_variant_id}}", + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/productos/{{producto_id}}/variants/{{product_variant_id}}", "host": [ "{{base_url}}" ], @@ -967,7 +971,9 @@ "api", "tenants", "{{tenant_codigo}}", - "product-variants", + "productos", + "{{producto_id}}", + "variants", "{{product_variant_id}}" ] } @@ -992,10 +998,10 @@ ], "body": { "mode": "raw", - "raw": "{\n \"slug\": \"remera-basica-blanca-m\",\n \"nombre\": \"Remera Basica Blanca - Talle M Updated\",\n \"stock\": 12,\n \"descripcion\": \"Variante actualizada\",\n \"precio\": 27999,\n \"definitions\": [\n {\n \"products_attribute_id\": {{color_product_attribute_id}},\n \"value\": \"Blanco\"\n },\n {\n \"products_attribute_id\": {{talle_product_attribute_id}},\n \"value\": \"M\"\n }\n ],\n \"images\": []\n}" + "raw": "{\n \"stock\": 12,\n \"definitions\": [\n {\n \"products_attribute_id\": {{color_product_attribute_id}},\n \"value\": \"Blanco\"\n },\n {\n \"products_attribute_id\": {{talle_product_attribute_id}},\n \"value\": \"M\"\n }\n ],\n \"images\": []\n}" }, "url": { - "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/product-variants/{{product_variant_id}}", + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/productos/{{producto_id}}/variants/{{product_variant_id}}", "host": [ "{{base_url}}" ], @@ -1003,7 +1009,9 @@ "api", "tenants", "{{tenant_codigo}}", - "product-variants", + "productos", + "{{producto_id}}", + "variants", "{{product_variant_id}}" ] } @@ -1022,7 +1030,7 @@ } ], "url": { - "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/product-variants/{{product_variant_id}}", + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/productos/{{producto_id}}/variants/{{product_variant_id}}", "host": [ "{{base_url}}" ], @@ -1030,7 +1038,9 @@ "api", "tenants", "{{tenant_codigo}}", - "product-variants", + "productos", + "{{producto_id}}", + "variants", "{{product_variant_id}}" ] } @@ -1403,6 +1413,454 @@ } ] }, + { + "name": "Bank Accounts", + "item": [ + { + "name": "List Bank Accounts", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/bank-accounts", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "tenants", + "{{tenant_codigo}}", + "bank-accounts" + ] + } + }, + "response": [] + }, + { + "name": "Create Bank Account", + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"titular\": \"Ada Lovelace\",\n \"entidad\": \"Banco Demo\",\n \"alias\": \"ada.demo.alias\",\n \"cvu\": \"0000003100000000000001\"\n}" + }, + "url": { + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/bank-accounts", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "tenants", + "{{tenant_codigo}}", + "bank-accounts" + ] + } + }, + "response": [] + }, + { + "name": "Show Selected Bank Account", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/bank-accounts/selected", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "tenants", + "{{tenant_codigo}}", + "bank-accounts", + "selected" + ] + } + }, + "response": [] + }, + { + "name": "Show Bank Account", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/bank-accounts/{{bank_account_id}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "tenants", + "{{tenant_codigo}}", + "bank-accounts", + "{{bank_account_id}}" + ] + } + }, + "response": [] + }, + { + "name": "Update Bank Account", + "request": { + "method": "PATCH", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"titular\": \"Ada Lovelace Updated\",\n \"entidad\": \"Banco Demo Updated\",\n \"alias\": \"ada.demo.updated\",\n \"cvu\": \"0000003100000000000002\"\n}" + }, + "url": { + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/bank-accounts/{{bank_account_id}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "tenants", + "{{tenant_codigo}}", + "bank-accounts", + "{{bank_account_id}}" + ] + } + }, + "response": [] + }, + { + "name": "Select Bank Account", + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/bank-accounts/{{bank_account_id}}/select", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "tenants", + "{{tenant_codigo}}", + "bank-accounts", + "{{bank_account_id}}", + "select" + ] + } + }, + "response": [] + }, + { + "name": "Delete Bank Account", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{base_url}}/api/tenants/{{tenant_codigo}}/bank-accounts/{{bank_account_id}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "tenants", + "{{tenant_codigo}}", + "bank-accounts", + "{{bank_account_id}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "Integrations", + "item": [ + { + "name": "List Integrations", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{base_url}}/api/integrations", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "integrations" + ] + } + }, + "response": [] + }, + { + "name": "Create Integration", + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"integration_code\": \"mercadopago\",\n \"name\": \"Mercado Pago\",\n \"url\": \"https://api.mercadopago.com\",\n \"integration_data_schema\": {\n \"access_token\": \"required|string\",\n \"public_key\": \"nullable|string\"\n }\n}" + }, + "url": { + "raw": "{{base_url}}/api/integrations", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "integrations" + ] + } + }, + "response": [] + }, + { + "name": "Show Integration", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{base_url}}/api/integrations/{{integration_id}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "integrations", + "{{integration_id}}" + ] + } + }, + "response": [] + }, + { + "name": "Update Integration", + "request": { + "method": "PUT", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"integration_code\": \"mercadopago\",\n \"name\": \"Mercado Pago Updated\",\n \"url\": \"https://api.mercadopago.com\",\n \"integration_data_schema\": {\n \"access_token\": \"required|string\",\n \"public_key\": \"nullable|string\"\n }\n}" + }, + "url": { + "raw": "{{base_url}}/api/integrations/{{integration_id}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "integrations", + "{{integration_id}}" + ] + } + }, + "response": [] + }, + { + "name": "Delete Integration", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{base_url}}/api/integrations/{{integration_id}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "integrations", + "{{integration_id}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "Tenant Integrations", + "item": [ + { + "name": "List Tenant Integrations", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{base_url}}/api/{{tenant_codigo}}/integrations", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "{{tenant_codigo}}", + "integrations" + ] + } + }, + "response": [] + }, + { + "name": "Show Tenant Integration", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{base_url}}/api/{{tenant_codigo}}/integrations/{{integration_code}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "{{tenant_codigo}}", + "integrations", + "{{integration_code}}" + ] + } + }, + "response": [] + }, + { + "name": "Configure Tenant Integration", + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"integration_data\": {\n \"access_token\": \"APP_USR-demo-token\",\n \"public_key\": \"APP_PUBLIC-demo-key\"\n }\n}" + }, + "url": { + "raw": "{{base_url}}/api/{{tenant_codigo}}/integrations/{{integration_code}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "api", + "{{tenant_codigo}}", + "integrations", + "{{integration_code}}" + ] + } + }, + "response": [] + } + ] + }, { "name": "Storage Test", "item": [ @@ -1628,6 +2086,21 @@ "key": "compra_id", "value": "1", "type": "string" + }, + { + "key": "integration_id", + "value": "1", + "type": "string" + }, + { + "key": "integration_code", + "value": "mercadopago", + "type": "string" + }, + { + "key": "bank_account_id", + "value": "1", + "type": "string" } ] } diff --git a/app/Domains/Integration/Casts/EncryptedIntegrationData.php b/app/Domains/Integration/Casts/EncryptedIntegrationData.php index 1d5db1d..0c51763 100644 --- a/app/Domains/Integration/Casts/EncryptedIntegrationData.php +++ b/app/Domains/Integration/Casts/EncryptedIntegrationData.php @@ -11,10 +11,10 @@ class EncryptedIntegrationData implements CastsAttributes { protected function getEncrypter(): Encrypter { - $secret = env('INTEGRATION_SECRET'); + $secret = config('services.integrations.secret'); if (empty($secret)) { - throw new Exception('INTEGRATION_SECRET is not set in the environment.'); + throw new Exception('The integrations secret is not configured.'); } // Laravel encrypter requires a key of exact length. Typically 32 bytes for AES-256-CBC. diff --git a/config/services.php b/config/services.php index 6a90eb8..c9d9b3a 100644 --- a/config/services.php +++ b/config/services.php @@ -35,4 +35,8 @@ return [ ], ], + 'integrations' => [ + 'secret' => env('INTEGRATION_SECRET'), + ], + ]; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 4d95f3b..3ef20aa 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -28,6 +28,7 @@ class DatabaseSeeder extends Seeder CategorySeeder::class, BrandSeeder::class, ProductCatalogFromImagesSeeder::class, + TelepagosIntegrationSeeder::class, ]); } }