require_relative "base_client" module PortalConnectors class VerifyClient < BaseClient def submit_user_documents(user_json, documents_json) params = { nonce: next_nonce, service_user: user_json, documents: documents_json } url = "#{host}/service_users" res = post_with_signature(url, params) [JSON.parse(res.body_str), [200, 201].include?(res.response_code)] rescue => e return_error e end def get_service_users_info(username_arr) params = { nonce: next_nonce, username_arr: username_arr, } url = "#{host}/api/v1/service_users" res = get_with_signature(url, params) [JSON.parse(res.body_str), [200].include?(res.response_code)] rescue => e return_error e end def update_service_user(user_json) params = { nonce: next_nonce, service_user: user_json, } url = "#{host}/service_users/update_service_user" res = post_with_signature(url, params) [JSON.parse(res.body_str), [200].include?(res.response_code)] rescue => e return_error e end def update_from_portal(email) params = { nonce: next_nonce, service_user: {service_user_token: email} } url = "#{host}/service_users" res = post_with_signature(url, params) [JSON.parse(res.body_str), [200, 201].include?(res.response_code)] rescue => e return_error e end def handle_comment(comment_params) params = comment_params.merge(nonce: next_nonce) url = "#{host}/api/v1/active_admin_comments/handle_comment" res = post_with_signature(url, params) [JSON.parse(res.body_str), [200, 201].include?(res.response_code)] rescue => e return_error e end def close(email, new_email) params = { nonce: next_nonce, service_user: { service_user_token: email, }, new_service_user_token: new_email, } url = "#{host}/service_users/close" res = post_with_signature(url, params) [JSON.parse(res.body_str), [200, 201].include?(res.response_code)] rescue => e return_error e end def update_email(email, new_email) params = { nonce: next_nonce, service_user: { service_user_token: email, }, new_service_user_token: new_email, } url = "#{host}/service_users/update_email" res = post_with_signature(url, params) [JSON.parse(res.body_str), [200, 201].include?(res.response_code)] rescue => e return_error e end def fetch_report(shift_id) params = { nonce: next_nonce, shift_id: shift_id } url = "#{host}/shifts/report" res = get_with_signature(url, params) [JSON.parse(res.body_str), [200, 201].include?(res.response_code)] rescue => e return_error e end def request_sync_back(usernames: []) params = { nonce: next_nonce, service_user: { usernames: usernames } } url = "#{host}/service_users/sync_back" res = post_with_signature(url, params) [JSON.parse(res.body_str), [200, 201].include?(res.response_code)] rescue => e return_error e end end end