@echo off
cd %~dp0

set /p ID="Sellers　ログインIDを入力してください。"
set /p PASS="Sellers　ログインパスワードを入力してください。"


FOR /F %%i in ('curl -X POST -H "Content-Type: application/json" -d "{""userId"":""%ID%"",""pass"":""%PASS%""}" https://weauto-sellers.com/TOOL3/api/v1/shopify/auth.php -o /dev/null -w "%%{http_code}\n" -s
') do set CODE=%%i

if %CODE%==200 (

echo インストールを開始します
curl -O https://weauto-sellers.com/tmp/SellersTool.zip -s
curl -O https://weauto-sellers.com/tmp/run.bat -s
curl -O https://weauto-sellers.com/tmp/set.ps1 -s
curl -O https://weauto-sellers.com/tmp/reinstall.bat -s

call powershell -command "Expand-Archive -Force SellersTool.zip"

echo { "UUID":"%ID%"} > ./SellersTool/SellersTool/appsetting.json

powershell -NoProfile -ExecutionPolicy Unrestricted .\set.ps1 %ID%
echo インストールが完了しました。
pause
) else (
  echo ユーザーIDまたはパスワードが間違っています。
  echo ID・パスワードを確認してやり直してください。
  pause
)