Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
27| Name | Data Type | Length | Description |
|---|---|---|---|
| @action | varchar | 20 | |
| @p_clienteid | int | 4 | |
| @p_topeclidiario | int | 4 | |
| @p_topeclimensual | int | 4 | |
| @p_topeclianual | int | 4 | |
| @p_bloqueacliente | bit | 1 | |
| @p_vigenciacliente | varchar | 10 | |
| @p_estadocliprod | bit | 1 | |
| @p_productoid | varchar | 10 | |
| @p_userid_apikey | int | 4 | |
| @p_estadouserprod | bit | 1 | |
| @p_tokenid | int | 4 | |
| @p_tokenkey | varchar | 20 | |
| @p_topetokendiario | bigint | 8 | |
| @p_topetokenmensual | bigint | 8 | |
| @p_topetokenanual | bigint | 8 | |
| @p_bloqueatoken | bit | 1 | |
| @p_vigenciatoken | datetime | 8 | |
| @p_estadotoken | bit | 1 | |
| @p_token_rango_ip | varchar | -1 | |
| @p_fecha_alta | datetime | 8 | |
| @p_tipo_api | char | 1 | |
| @p_tipo_contrato | char | 1 | |
| @p_moneda | varchar | 10 | |
| @p_precio_unitario | decimal | 13 | |
| @p_userid | int | 4 | |
| @p_id_producto | int | 4 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
select * from apikey where id_api_key = 54
select * from trazabilidad where doc_id = 54 order by created desc
select * from apikey_marita where id_api_key = 54
*/
/*
exec apikey_abm 'UPDAPIDATA','2254875','0','0','0','1','','1','0','94437923','1','54','99B59DCFLED79786',
'30000','0','0','0','2035-06-02','1','ALL','2022-01-01','I','C','ARS','180'
exec apikey_abm 'ALTA', '2254875', '0', '0', '0', '1', '', '1', '0', '94437923', '1', '0',
'4NJFYIPL7152OSKTGZMB', '1', '30', '365', '0', '', '1', '', '', 'I', '', '', '', '94437923', '87'
exec apikey_abm 'ALTA', '2254875', '0', '0', '0', '1', '', '1', '87', '94437923',
'1', '0', 'S09PRZTLAI41FO7KBV5N',
'', '', '', '0', '', '1', '', '', 'I', '', '', '', '94437923', '87'
*/
CREATE OR ALTER PROCEDURE dbo.apikey_abm
@action varchar(20)='LISTAR',
@p_clienteid int = null,
@p_topeclidiario int = 0,
@p_topeclimensual int = 0,
@p_topeclianual int = 0,
@p_bloqueacliente bit = 1,
@p_vigenciacliente varchar(10) = null,
@p_estadocliprod bit = 1,
@p_productoid varchar(10) = null,
@p_userid_apikey int = null,
@p_estadouserprod bit = 1,
@p_tokenid int = null,
@p_tokenkey varchar(20) = null,
@p_topetokendiario bigint = 0,
@p_topetokenmensual bigint = 0,
@p_topetokenanual bigint = 0,
@p_bloqueatoken bit = 1,
@p_vigenciatoken datetime = null,
@p_estadotoken bit = 1,
@p_token_rango_ip varchar(max) = 'ALL',
@p_fecha_alta datetime = null,
@p_tipo_api char(1) = 'C', -- C=CLIENTES, I=INTERNAS, P=PROVEEDORES
@p_tipo_contrato char(1) = null, -- C=POR CONSUMO, P=PREPAGO
@p_moneda varchar(10) = null,
@p_precio_unitario decimal(20,2) = null,
@p_userid int = null,
@p_id_producto int = 0
AS
BEGIN
SET NOCOUNT ON;
if (@p_userid is null) set @p_userid = @p_userid_apikey
declare
@tokenid int,
@tokenkey varchar(20),
@topetokendiario bigint,
@topetokenmensual bigint,
@topetokenanual bigint,
@bloqueatoken bit,
@vigenciatoken datetime,
@estadotoken bit,
@token_rango_ip varchar(max),
@fecha_alta datetime,
@rango_ip varchar(max),
@tipo_api char(1),
@tipo_contrato char(1),
@moneda varchar(10),
@precio_unitario decimal(20,2)
declare @txt varchar(500)
IF (@action = 'UPDAPIDATA')
BEGIN
select
@topetokendiario = topediario,
@topetokenmensual = topemensual,
@topetokenanual = topeanual,
@bloqueatoken = bloquea,
@vigenciatoken = vigencia,
@fecha_alta = vigencia_desde,
@estadotoken = activo,
@rango_ip = apikey.ip,
@tipo_api = tipo_api,
@tipo_contrato = tipo_contrato,
@moneda = moneda,
@precio_unitario = precio_unitario
from apikey
where id_api_key=@p_tokenid
if (@topetokendiario is null) set @topetokendiario = 0
if (@topetokenmensual is null) set @topetokenmensual = 0
if (@topetokenanual is null) set @topetokenanual = 0
if (@bloqueatoken is null) set @bloqueatoken = 0
if (@estadotoken is null) set @estadotoken = 1
if (@fecha_alta is null) set @fecha_alta = convert(date,'1901-01-01')
if (@vigenciatoken is null) set @vigenciatoken = convert(date,'2999-01-01')
if (@rango_ip is null) set @rango_ip = ''
if (@tipo_api is null) set @tipo_api = ''
if (@tipo_contrato is null) set @tipo_contrato = ''
if (@moneda is null) set @moneda = ''
if (@precio_unitario is null) set @precio_unitario = '0.00'
--LECT TOP 10 * FROM apikey
update apikey set topediario=@p_topetokendiario,topemensual=@p_topetokenmensual,topeanual=@p_topetokenanual,
vigencia_desde=@p_fecha_alta,vigencia=@p_vigenciatoken,bloquea=@p_bloqueatoken,activo=@p_estadotoken,
tipo_api = @p_tipo_api,
tipo_contrato = @p_tipo_contrato,
moneda = @p_moneda,
precio_unitario = @p_precio_unitario,
apikey.ip = upper(@p_token_rango_ip)
where id_api_key=@p_tokenid
if (@topetokendiario != @p_topetokendiario)
begin
set @txt = 'Cambio tope diario de ' + CONVERT(varchar,@topetokendiario) + ' a ' + CONVERT(varchar,@p_topetokendiario)
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_numerico_old, valor_numerico_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@topetokendiario,@p_topetokendiario,@p_tokenid)
end
if (@topetokenmensual != @p_topetokenmensual)
begin
set @txt = 'Cambio tope mensual de ' + CONVERT(varchar,@topetokenmensual) + ' a ' + CONVERT(varchar,@p_topetokenmensual)
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_numerico_old, valor_numerico_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@topetokenmensual,@p_topetokenmensual,@p_tokenid)
end
if (@topetokenanual != @p_topetokenanual)
begin
set @txt = 'Cambio tope anual de ' + CONVERT(varchar,@topetokenanual) + ' a ' + CONVERT(varchar,@p_topetokenanual)
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_numerico_old, valor_numerico_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@topetokenanual,@p_topetokenanual,@p_tokenid)
end
if (@bloqueatoken != @p_bloqueatoken)
begin
set @txt = 'Cambio bloquea de ' + iif(@bloqueatoken=1,'SI','NO') + ' a ' + iif(@p_bloqueatoken=1,'SI','NO')
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_numerico_old, valor_numerico_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@bloqueatoken,@p_bloqueatoken,@p_tokenid)
end
if (@vigenciatoken != @p_vigenciatoken)
begin
set @txt = 'Cambio vigencia hasta de ' + convert(varchar,@vigenciatoken,103) + ' a ' + convert(varchar,@p_vigenciatoken,103)
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_fecha_old, valor_fecha_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@vigenciatoken,@p_vigenciatoken,@p_tokenid)
end
if (@fecha_alta != @p_fecha_alta)
begin
set @txt = 'Cambio vigencia desde de ' + convert(varchar,@fecha_alta,103) + ' a ' + convert(varchar,@p_fecha_alta,103)
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_fecha_old, valor_fecha_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@fecha_alta,@p_fecha_alta,@p_tokenid)
end
if (@estadotoken != @p_estadotoken)
begin
set @txt = 'Cambio estado token de ' + iif(@estadotoken=0,'INACTIVO','ACTIVO') + ' a ' + iif(@p_estadotoken=0,'INACTIVO','ACTIVO')
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_numerico_old, valor_numerico_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@estadotoken,@p_estadotoken,@p_tokenid)
end
if (isnull(@rango_ip,'') != isnull(@p_token_rango_ip,''))
begin
set @txt = 'Cambio rango IP de ' + isnull(@rango_ip,'') + ' a ' + isnull(@p_token_rango_ip,'')
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_memo_old, valor_memo_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@rango_ip,@p_token_rango_ip,@p_tokenid)
end
if (isnull(@tipo_api,'') != isnull(@p_tipo_api,''))
begin
set @txt = 'Cambio tipo de api de ' + iif(@tipo_api='P','PROVEEDORES',(iif(@tipo_api='I','INTERNA',(iif(@tipo_api='C','CLIENTES',isnull(@tipo_api,'null'))))))
+ ' a ' + iif(@p_tipo_api='P','PROVEEDORES',(iif(@p_tipo_api='I','INTERNA',(iif(@p_tipo_api='C','CLIENTES',isnull(@p_tipo_api,'null'))))))
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_texto_old, valor_texto_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@tipo_api,@p_tipo_api,@p_tokenid)
end
if (isnull(@tipo_contrato,'') != isnull(@p_tipo_contrato,''))
begin
set @txt = 'Cambio tipo de contrato de ' + iif(@tipo_contrato='C','X CONSUMO',iif(@tipo_contrato='P','PREPAGO',isnull(@tipo_contrato,'null')))
+ ' a ' + iif(@p_tipo_contrato='C','X CONSUMO',iif(@p_tipo_contrato='P','PREPAGO',isnull(@p_tipo_contrato,'null')))
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_texto_old, valor_texto_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@tipo_contrato,@p_tipo_contrato,@p_tokenid)
end
if (isnull(@moneda,'') != isnull(@p_moneda,''))
begin
set @txt = 'Cambio moneda de ' + isnull(@moneda,'null') + ' a ' + isnull(@p_moneda,'null')
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_texto_old, valor_texto_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@moneda,@p_moneda,@p_tokenid)
end
if (isnull(@precio_unitario,'0.00') != isnull(@p_precio_unitario,'0.00'))
begin
set @txt = 'Cambio precio unitario de ' + convert(varchar,isnull(@precio_unitario,'0.00')) + ' a ' + convert(varchar,isnull(@p_precio_unitario,'0.00'))
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_texto_old, valor_texto_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@precio_unitario,@p_precio_unitario,@p_tokenid)
end
--select @txt
END
IF (@action = 'ALTA')
BEGIN
insert into apikey (topediario ,topemensual ,topeanual ,
vigencia_desde ,vigencia ,bloquea ,activo ,
tipo_api ,
tipo_contrato ,
moneda ,
precio_unitario ,
ip,
api_key,producto,user_id,client_id)
values (@p_topetokendiario,@p_topetokenmensual,@p_topetokenanual,
@p_fecha_alta,@p_vigenciatoken,@p_bloqueatoken,@p_estadotoken,
@p_tipo_api,
@p_tipo_contrato,
@p_moneda,
@p_precio_unitario,
upper(@p_token_rango_ip),
@p_tokenkey,@p_id_producto,@p_userid_apikey,@p_clienteid)
SET @p_tokenid = SCOPE_IDENTITY()
if exists (select * from usuarios_productos where user_id = @p_userid_apikey and id_producto = @p_id_producto and activo = 0)
begin
update usuarios_productos
set activo = 1,
modified = GETDATE(),
modified_by = @p_userid,
bloquear_consumo = @p_bloqueatoken,
limite_consumo = @p_topeclimensual
where user_id = @p_userid_apikey and id_producto = @p_id_producto
end
if not exists (select * from usuarios_productos where user_id = @p_userid_apikey and id_producto = @p_id_producto and activo = 1)
begin
insert into usuarios_productos
(cliente, user_id, id_producto, limite_consumo, bloquear_consumo, activo, created, created_by)
values (@p_clienteid, @p_userid, @p_productoid, @p_topetokenmensual, @p_bloqueatoken, 1, GETDATE(), @p_userid )
end
set @txt = 'Alta nuevo registro en apikey'
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@p_tokenid)
END
select @p_tokenid as id_api_key
END
select * from usuarios_productos
/*
[apikey_abm] 'UPDAPIDATA',2254875,0,0,0,1,null,1,null,970439242,1,78,'3D1CT02N1NjaS1V1',20000,100000,3000000,0,'2035-06-02',1,'ALL','2022-01-01'
select * from trazabilidad where id_plataforma = 'API' order by created desc
*/
GO
GO
/*
select * from apikey where id_api_key = 54
select * from trazabilidad where doc_id = 54 order by created desc
select * from apikey_marita where id_api_key = 54
*/
/*
exec apikey_abm 'UPDAPIDATA','2254875','0','0','0','1','','1','0','94437923','1','54','99B59DCFLED79786',
'30000','0','0','0','2035-06-02','1','ALL','2022-01-01','I','C','ARS','180'
exec apikey_abm 'ALTA', '2254875', '0', '0', '0', '1', '', '1', '0', '94437923', '1', '0',
'4NJFYIPL7152OSKTGZMB', '1', '30', '365', '0', '', '1', '', '', 'I', '', '', '', '94437923', '87'
exec apikey_abm 'ALTA', '2254875', '0', '0', '0', '1', '', '1', '87', '94437923',
'1', '0', 'S09PRZTLAI41FO7KBV5N',
'', '', '', '0', '', '1', '', '', 'I', '', '', '', '94437923', '87'
*/
CREATE OR ALTER PROCEDURE dbo.apikey_abm
@action varchar(20)='LISTAR',
@p_clienteid int = null,
@p_topeclidiario int = 0,
@p_topeclimensual int = 0,
@p_topeclianual int = 0,
@p_bloqueacliente bit = 1,
@p_vigenciacliente varchar(10) = null,
@p_estadocliprod bit = 1,
@p_productoid varchar(10) = null,
@p_userid_apikey int = null,
@p_estadouserprod bit = 1,
@p_tokenid int = null,
@p_tokenkey varchar(20) = null,
@p_topetokendiario bigint = 0,
@p_topetokenmensual bigint = 0,
@p_topetokenanual bigint = 0,
@p_bloqueatoken bit = 1,
@p_vigenciatoken datetime = null,
@p_estadotoken bit = 1,
@p_token_rango_ip varchar(max) = 'ALL',
@p_fecha_alta datetime = null,
@p_tipo_api char(1) = 'C', -- C=CLIENTES, I=INTERNAS, P=PROVEEDORES
@p_tipo_contrato char(1) = null, -- C=POR CONSUMO, P=PREPAGO
@p_moneda varchar(10) = null,
@p_precio_unitario decimal(20,2) = null,
@p_userid int = null,
@p_id_producto int = 0
AS
BEGIN
SET NOCOUNT ON;
if (@p_userid is null) set @p_userid = @p_userid_apikey
declare
@tokenid int,
@tokenkey varchar(20),
@topetokendiario bigint,
@topetokenmensual bigint,
@topetokenanual bigint,
@bloqueatoken bit,
@vigenciatoken datetime,
@estadotoken bit,
@token_rango_ip varchar(max),
@fecha_alta datetime,
@rango_ip varchar(max),
@tipo_api char(1),
@tipo_contrato char(1),
@moneda varchar(10),
@precio_unitario decimal(20,2)
declare @txt varchar(500)
IF (@action = 'UPDAPIDATA')
BEGIN
select
@topetokendiario = topediario,
@topetokenmensual = topemensual,
@topetokenanual = topeanual,
@bloqueatoken = bloquea,
@vigenciatoken = vigencia,
@fecha_alta = vigencia_desde,
@estadotoken = activo,
@rango_ip = apikey.ip,
@tipo_api = tipo_api,
@tipo_contrato = tipo_contrato,
@moneda = moneda,
@precio_unitario = precio_unitario
from apikey
where id_api_key=@p_tokenid
if (@topetokendiario is null) set @topetokendiario = 0
if (@topetokenmensual is null) set @topetokenmensual = 0
if (@topetokenanual is null) set @topetokenanual = 0
if (@bloqueatoken is null) set @bloqueatoken = 0
if (@estadotoken is null) set @estadotoken = 1
if (@fecha_alta is null) set @fecha_alta = convert(date,'1901-01-01')
if (@vigenciatoken is null) set @vigenciatoken = convert(date,'2999-01-01')
if (@rango_ip is null) set @rango_ip = ''
if (@tipo_api is null) set @tipo_api = ''
if (@tipo_contrato is null) set @tipo_contrato = ''
if (@moneda is null) set @moneda = ''
if (@precio_unitario is null) set @precio_unitario = '0.00'
--LECT TOP 10 * FROM apikey
update apikey set topediario=@p_topetokendiario,topemensual=@p_topetokenmensual,topeanual=@p_topetokenanual,
vigencia_desde=@p_fecha_alta,vigencia=@p_vigenciatoken,bloquea=@p_bloqueatoken,activo=@p_estadotoken,
tipo_api = @p_tipo_api,
tipo_contrato = @p_tipo_contrato,
moneda = @p_moneda,
precio_unitario = @p_precio_unitario,
apikey.ip = upper(@p_token_rango_ip)
where id_api_key=@p_tokenid
if (@topetokendiario != @p_topetokendiario)
begin
set @txt = 'Cambio tope diario de ' + CONVERT(varchar,@topetokendiario) + ' a ' + CONVERT(varchar,@p_topetokendiario)
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_numerico_old, valor_numerico_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@topetokendiario,@p_topetokendiario,@p_tokenid)
end
if (@topetokenmensual != @p_topetokenmensual)
begin
set @txt = 'Cambio tope mensual de ' + CONVERT(varchar,@topetokenmensual) + ' a ' + CONVERT(varchar,@p_topetokenmensual)
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_numerico_old, valor_numerico_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@topetokenmensual,@p_topetokenmensual,@p_tokenid)
end
if (@topetokenanual != @p_topetokenanual)
begin
set @txt = 'Cambio tope anual de ' + CONVERT(varchar,@topetokenanual) + ' a ' + CONVERT(varchar,@p_topetokenanual)
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_numerico_old, valor_numerico_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@topetokenanual,@p_topetokenanual,@p_tokenid)
end
if (@bloqueatoken != @p_bloqueatoken)
begin
set @txt = 'Cambio bloquea de ' + iif(@bloqueatoken=1,'SI','NO') + ' a ' + iif(@p_bloqueatoken=1,'SI','NO')
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_numerico_old, valor_numerico_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@bloqueatoken,@p_bloqueatoken,@p_tokenid)
end
if (@vigenciatoken != @p_vigenciatoken)
begin
set @txt = 'Cambio vigencia hasta de ' + convert(varchar,@vigenciatoken,103) + ' a ' + convert(varchar,@p_vigenciatoken,103)
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_fecha_old, valor_fecha_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@vigenciatoken,@p_vigenciatoken,@p_tokenid)
end
if (@fecha_alta != @p_fecha_alta)
begin
set @txt = 'Cambio vigencia desde de ' + convert(varchar,@fecha_alta,103) + ' a ' + convert(varchar,@p_fecha_alta,103)
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_fecha_old, valor_fecha_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@fecha_alta,@p_fecha_alta,@p_tokenid)
end
if (@estadotoken != @p_estadotoken)
begin
set @txt = 'Cambio estado token de ' + iif(@estadotoken=0,'INACTIVO','ACTIVO') + ' a ' + iif(@p_estadotoken=0,'INACTIVO','ACTIVO')
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_numerico_old, valor_numerico_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@estadotoken,@p_estadotoken,@p_tokenid)
end
if (isnull(@rango_ip,'') != isnull(@p_token_rango_ip,''))
begin
set @txt = 'Cambio rango IP de ' + isnull(@rango_ip,'') + ' a ' + isnull(@p_token_rango_ip,'')
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_memo_old, valor_memo_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@rango_ip,@p_token_rango_ip,@p_tokenid)
end
if (isnull(@tipo_api,'') != isnull(@p_tipo_api,''))
begin
set @txt = 'Cambio tipo de api de ' + iif(@tipo_api='P','PROVEEDORES',(iif(@tipo_api='I','INTERNA',(iif(@tipo_api='C','CLIENTES',isnull(@tipo_api,'null'))))))
+ ' a ' + iif(@p_tipo_api='P','PROVEEDORES',(iif(@p_tipo_api='I','INTERNA',(iif(@p_tipo_api='C','CLIENTES',isnull(@p_tipo_api,'null'))))))
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_texto_old, valor_texto_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@tipo_api,@p_tipo_api,@p_tokenid)
end
if (isnull(@tipo_contrato,'') != isnull(@p_tipo_contrato,''))
begin
set @txt = 'Cambio tipo de contrato de ' + iif(@tipo_contrato='C','X CONSUMO',iif(@tipo_contrato='P','PREPAGO',isnull(@tipo_contrato,'null')))
+ ' a ' + iif(@p_tipo_contrato='C','X CONSUMO',iif(@p_tipo_contrato='P','PREPAGO',isnull(@p_tipo_contrato,'null')))
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_texto_old, valor_texto_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@tipo_contrato,@p_tipo_contrato,@p_tokenid)
end
if (isnull(@moneda,'') != isnull(@p_moneda,''))
begin
set @txt = 'Cambio moneda de ' + isnull(@moneda,'null') + ' a ' + isnull(@p_moneda,'null')
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_texto_old, valor_texto_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@moneda,@p_moneda,@p_tokenid)
end
if (isnull(@precio_unitario,'0.00') != isnull(@p_precio_unitario,'0.00'))
begin
set @txt = 'Cambio precio unitario de ' + convert(varchar,isnull(@precio_unitario,'0.00')) + ' a ' + convert(varchar,isnull(@p_precio_unitario,'0.00'))
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, valor_texto_old, valor_texto_new,doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@precio_unitario,@p_precio_unitario,@p_tokenid)
end
--select @txt
END
IF (@action = 'ALTA')
BEGIN
insert into apikey (topediario ,topemensual ,topeanual ,
vigencia_desde ,vigencia ,bloquea ,activo ,
tipo_api ,
tipo_contrato ,
moneda ,
precio_unitario ,
ip,
api_key,producto,user_id,client_id)
values (@p_topetokendiario,@p_topetokenmensual,@p_topetokenanual,
@p_fecha_alta,@p_vigenciatoken,@p_bloqueatoken,@p_estadotoken,
@p_tipo_api,
@p_tipo_contrato,
@p_moneda,
@p_precio_unitario,
upper(@p_token_rango_ip),
@p_tokenkey,@p_id_producto,@p_userid_apikey,@p_clienteid)
SET @p_tokenid = SCOPE_IDENTITY()
if exists (select * from usuarios_productos where user_id = @p_userid_apikey and id_producto = @p_id_producto and activo = 0)
begin
update usuarios_productos
set activo = 1,
modified = GETDATE(),
modified_by = @p_userid,
bloquear_consumo = @p_bloqueatoken,
limite_consumo = @p_topeclimensual
where user_id = @p_userid_apikey and id_producto = @p_id_producto
end
if not exists (select * from usuarios_productos where user_id = @p_userid_apikey and id_producto = @p_id_producto and activo = 1)
begin
insert into usuarios_productos
(cliente, user_id, id_producto, limite_consumo, bloquear_consumo, activo, created, created_by)
values (@p_clienteid, @p_userid, @p_productoid, @p_topetokenmensual, @p_bloqueatoken, 1, GETDATE(), @p_userid )
end
set @txt = 'Alta nuevo registro en apikey'
insert into
trazabilidad (cliente,texto,accion,id_plataforma,user_id,created, doc_id)
values
(@p_clienteid,@txt,'APIKEY_ABM','API',@p_userid,getdate(),@p_tokenid)
END
select @p_tokenid as id_api_key
END
select * from usuarios_productos
/*
[apikey_abm] 'UPDAPIDATA',2254875,0,0,0,1,null,1,null,970439242,1,78,'3D1CT02N1NjaS1V1',20000,100000,3000000,0,'2035-06-02',1,'ALL','2022-01-01'
select * from trazabilidad where id_plataforma = 'API' order by created desc
*/
GO
Depends On
2Used By
No items found