exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

exchange_do_insert_active_legitimization_measure.sql (1591B)


      1 --
      2 -- This file is part of TALER
      3 -- Copyright (C) 2023, 2024 Taler Systems SA
      4 --
      5 -- TALER is free software; you can redistribute it and/or modify it under the
      6 -- terms of the GNU General Public License as published by the Free Software
      7 -- Foundation; either version 3, or (at your option) any later version.
      8 --
      9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11 -- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 --
     13 -- You should have received a copy of the GNU General Public License along with
     14 -- TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 --
     16 
     17 DROP FUNCTION IF EXISTS exchange_do_insert_active_legitimization_measure;
     18 CREATE FUNCTION exchange_do_insert_active_legitimization_measure(
     19   IN in_access_token BYTEA,
     20   IN in_start_time INT8,
     21   IN in_jmeasures JSONB,
     22   OUT out_legitimization_measure_serial_id INT8)
     23 LANGUAGE plpgsql
     24 AS $$
     25 BEGIN
     26 
     27 UPDATE legitimization_measures
     28    SET is_finished=TRUE
     29  WHERE access_token=in_access_token
     30    AND NOT is_finished;
     31 
     32 INSERT INTO legitimization_measures
     33   (access_token
     34   ,start_time
     35   ,jmeasures
     36   ,display_priority)
     37   VALUES
     38   (in_access_token
     39   ,in_start_time
     40   ,in_jmeasures
     41   ,1)
     42   RETURNING
     43     legitimization_measure_serial_id
     44   INTO
     45     out_legitimization_measure_serial_id;
     46 
     47 END $$;
     48 
     49 
     50 COMMENT ON FUNCTION exchange_do_insert_active_legitimization_measure(BYTEA, INT8, JSONB)
     51   IS 'Inserts legitimization measure for an account and marks all existing such measures as inactive';