/*
 * au_dbio.h - au 모듈 (승인/한도) DB 접근 계층 (libaudbio.a).
 * ECPG (EXEC SQL) functions compiled into a static library and linked into
 * au_svr and the au batches. They run on the caller's XA branch/connection
 * (no EXEC SQL CONNECT); sqlca is the shared per-thread ECPG SQLCA.
 * Return convention: 0 = ok, -1 = SQL error (caller may also inspect sqlca).
 */
#ifndef AU_DBIO_H
#define AU_DBIO_H

/* authorization */
long audb_next_auth_id(void);
int  audb_insert_auth(long auth_id, const char *card, const char *merch, long amount,
                      const char *appr_code, const char *auth_type, const char *status,
                      const char *bizdate);
int  audb_update_auth_status(long auth_id, const char *status);
int  audb_get_auth_status(long auth_id, char *out /* >= 2 bytes */);
int  audb_update_auth_amount(long auth_id, long amount);

/* fraud */
long audb_insert_fraud(long auth_id, const char *card, long score, const char *reason,
                       const char *bizdate);

/* card limit */
int  audb_limit_get(const char *card, long *limit_out, long *used_out);
int  audb_limit_dec(const char *card, long amount);
int  audb_limit_reset(const char *card);
int  audb_limit_set(const char *card, long limit);
int  audb_upsert_auth_summary(const char *merch, const char *bizdate, long cnt,
                              long approved, long declined, long amount);

#endif /* AU_DBIO_H */
