# URI-G-02 會員買主註冊 API > [name=Tony Fan] ###### tags: `URI-G` `API規格` 買主帳號註冊(寫入DB並透過SSO API 新增至SSO) - 注意事項: - 由於註冊會由TT發送 帳號啟用函 (內含 自動產生的 [G-26 帳號啟用頁](https://hackmd.io/GwBwXlFKS7qr5RPZZ-xcxQ) 的 URL),UAT(Stage)環境需在 [ADM 郵件管理 > 白名單維護](https://adm.ttstaging.com.tw/mailWhiteListlist) 中設定要註冊的email的白名單,否則無法寄送。 ![](https://i.imgur.com/8wlPXKi.png) ## 網址 - path : `${TT-API網址}/domains/front/buyer-register` ## Input JSON Path - path : `${TT-API網址}/domains/front/buyer-register` - method : POST - query : 無 - body : ```=json { "language" : <languageId>, "email": <email>, "password": <password>, "titleCode": <titleCode>, "name": <name>, "companyName": <companyName>, "individualbuyer": <individualbuyer>, "location": <location>, "officeStateCode": <officeStateCode>, "officeOtherState": <officeOtherState>, "officeAddress": <officeAddress>, "companyWebsite": <companyWebsite>, "telCountry": <telCountry>, "tel": <tel>, "telExt": <telExt>, "mobileCountry": <mobileCountry>, "mobile": <mobile>, "acceptAgreement": <acceptAgreement>, "newShowInfo": <newShowInfo>, "newsLetter": <newsLetter> } ``` ### 輸入參數說明 買主註冊欄位 | 欄位名稱 | 欄位說明 | 型態 | 是否必要欄位 | | -------- | -------- | -------- | -------- | | languageId | 語系代碼 | number | Y | | email | 帳號Email | String | Y | | password | 密碼 | String | Y | | titleCode | 代碼 | number | Y | | name | 姓名 | String | Y | | individualbuyer | 是否為買主個人 | number | Y | | companyName | 姓名 | String | Y | | websiteNotAvaliable | 是否有公司網址 | number | Y | | companyWebsite | 公司網址 | String | Y | | location | 國家代碼 | number | Y | | officeStateCode | 一級行政區代碼 | number | N | | officeOtherState | 一級行政區其他名稱 | String | N | | officeAddress | 地址 | String | N | | telCountry | 電話國際區號 | String(數字) | N | | tel | 電話號碼 | String(數字) |N | | telExt | 電話分機號碼 | String(數字) | N | | mobileCountry | 行動電話國際區號 | String(數字) | N | | mobile | 行動電話號碼 | String(數字) | N | | acceptAgreement | 同意服務條款 | number | Y | | newShowInfo | 公開Email給供應商 | number | Y | | newsLetter | 接受相關的產品和活動信息 | number | Y | | registerIp | 註冊IP | String | N | * languageId : 參考 [URI054](https://hackmd.io/Nftm3f0tS6661WC-n-9n0Q#%E4%BB%A3%E7%A2%BC%E5%B0%8D%E6%87%89%E8%AA%AA%E6%98%8E%E8%A1%A8) language * titleCode : 參考 [URI054](https://hackmd.io/Nftm3f0tS6661WC-n-9n0Q#%E4%BB%A3%E7%A2%BC%E5%B0%8D%E6%87%89%E8%AA%AA%E6%98%8E%E8%A1%A8) user-title-code * individualbuyer : (預設0,此時companyName必填) * 1 : 買主個人 * 0 : 買主公司 * companyName: 如果`individualbuyer`=1,這裡會強制改成`Individual buyer`來儲存 * websiteNotAvaliable : (預設0,此時companyWebsite必填) * 1 : 沒有公司網址 * 0 : 有公司網址 * companyWebsite:如果`websiteNotAvaliable`=1,這裏會強制改成 `Not Available`來儲存 * location:參考 [URI054](https://hackmd.io/Nftm3f0tS6661WC-n-9n0Q#%E4%BB%A3%E7%A2%BC%E5%B0%8D%E6%87%89%E8%AA%AA%E6%98%8E%E8%A1%A8) user-country * officeStateCode:參考 [URI054](https://hackmd.io/Nftm3f0tS6661WC-n-9n0Q#%E4%BB%A3%E7%A2%BC%E5%B0%8D%E6%87%89%E8%AA%AA%E6%98%8E%E8%A1%A8) user-country-state,用location所選的國家代碼帶入取得國家的第一級行政區。 * officeOtherState:當location有值,officeStateCode沒值時為必填 * telCountry:可以參考 [URI054](https://hackmd.io/Nftm3f0tS6661WC-n-9n0Q#%E4%BB%A3%E7%A2%BC%E5%B0%8D%E6%87%89%E8%AA%AA%E6%98%8E%E8%A1%A8) user-country的客製輸出欄位`telcode`,查出 location對應的區碼。 * newShowInfo:(預設0) * 1 : I'd like to show my email address to the suppliers I contact on Taiwantrade.com. * 0 : I don't. * registerIp: 如果不是直接從Client端呼叫此API,請想辦法填上Client端的IP,否則會預設抓取 Request Header : `X-FORWARDED-FOR ` 或 `CLIENT-IP` 作為註冊來源IP。追溯到註冊的來源IP就會只到Server Side。 * newsLetter:(預設1) * 1 : I’d like to receive information on related products and events. * 0 : I don't * acceptAgreement:(預設1) * 1 : 同意服務條款 * 0 : 不同意 * 基本上都會是1,因為不同意就不能註冊 ## Output JSON Path ```=json { "code" : <code> , // 代碼,0:ok、 < 0: error 使用 "errorMsg" : <errorMsg> // 錯誤訊息 } ``` ### 輸出參數說明 - 回傳成功或是失敗 標準I/O結果輸出 | 欄位名稱 | 欄位說明 | 型態 | 是否可為空值 | | -------- | -------- | -------- | -------- | | code | 代碼 | number | N | | errorMsg | 錯誤訊息 | String | Y | * code : 0:ok、 < 0: error 使用 * 在此API, 0: ok 代表 submit成功 / -1 : 代表Email已存在 / -2 : 其他錯誤,看errorMsg描述 ## API 邏輯 參考 [URI-G-02 API邏輯](https://hackmd.io/6pxl2BODRy65Or15Gt6DZg) (需有權限才能瀏覽) ## 範例 參考 [URI-G-02 測試案例](https://docs.google.com/spreadsheets/d/1ZqC0P3s5wzeh1jzWM970TAwkBO3KUoaYe4LQJHn-hJ0/edit#gid=1426594997)