mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 03:13:56 +08:00
24 lines
1.1 KiB
Bash
24 lines
1.1 KiB
Bash
pg=$1;
|
|
pgc="$(tr '[:lower:]' '[:upper:]' <<< ${pg:0:1})${pg:1}"
|
|
src="crates/router/src"
|
|
conn="$src/connector"
|
|
SCRIPT="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
|
if [[ -z "$pg" ]]; then
|
|
echo 'Connector name not present: try "sh add_connector.sh <adyen>"'
|
|
exit
|
|
fi
|
|
cd $SCRIPT/..
|
|
rm -rf $conn/$pg $conn/$pg.rs
|
|
git checkout $conn.rs $src/types/api.rs $src/configs/settings.rs
|
|
sed -i'' -e "s/pub use self::{/pub mod ${pg};\n\npub use self::{/" $conn.rs
|
|
sed -i'' -e "s/};/${pg}::${pgc},\n};/" $conn.rs
|
|
sed -i'' -e "s/_ => Err/\"${pg}\" => Ok(Box::new(\&connector::${pgc})),\n\t\t\t_ => Err/" $src/types/api.rs
|
|
sed -i'' -e "s/pub supported: SupportedConnectors,/pub supported: SupportedConnectors,\n\tpub ${pg}: ConnectorParams,/" $src/configs/settings.rs
|
|
rm $conn.rs-e $src/types/api.rs-e $src/configs/settings.rs-e
|
|
cd $conn/
|
|
cargo gen-pg $pg
|
|
mv $pg/mod.rs $pg.rs
|
|
mv $pg/test.rs ../../tests/connectors/$pg.rs
|
|
sed -i'' -e "s/mod utils;/mod ${pg};\nmod utils;/" ../../tests/connectors/main.rs
|
|
rm ../../tests/connectors/main.rs-e
|
|
echo "Successfully created connector: try running the tests of "$pg.rs |