CREATE TABLE TBAPI_BB (
    ID INTEGER NOT NULL,
    ESTABELECIMENTO_ID INTEGER,
    URL VARCHAR(100),
	URL_TOKEN VARCHAR(100),
    CLIENT_ID VARCHAR(150),
    CLIENT_SECRET VARCHAR(500),
    AUTH_BASIC VARCHAR(500),
    APPLICATION_KEY VARCHAR(500),
    CHAVE_PIX VARCHAR(500),
    ACCESS_TOKEN VARCHAR(500),
    EXPIRES_IN INTEGER);

ALTER TABLE TBAPI_BB
ADD CONSTRAINT PK_TBAPI_BB
PRIMARY KEY (ID);

CREATE SEQUENCE GTBAPI_BB;

SET TERM ^ ;

create trigger ttbapi_bb_b01i for tbapi_bb
active before insert position 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbapi_bb,1);
end
^

SET TERM ; ^


CREATE TABLE TBAPI_BB_TOKEN (
    ID INTEGER NOT NULL,
    API_BB_ID INTEGER,
    ACCESS_TOKEN VARCHAR(500),
    EXPIRES_IN INTEGER,
    EXPIRATE TIMESTAMP);

ALTER TABLE TBAPI_BB_TOKEN
ADD CONSTRAINT PK_TBAPI_BB_TOKEN
PRIMARY KEY (ID);

CREATE SEQUENCE GTBAPI_BB_TOKEN;

SET TERM ^ ;

create trigger ttbapi_bb_token_b01i for tbapi_bb_token
active before insert position 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbapi_bb_token,1);
end
^

SET TERM ; ^

ALTER TABLE TBPDV_CFE_FORMA_PAGAMENTO
    ADD TRANSACAO_PIX_BB VARCHAR(200);

CREATE SEQUENCE GTBPIX_DEVOLUCAO;

