require 'spec_helper' RSpec.describe PortalConnectors::VerifyClient do let(:client) { PortalConnectors::VerifyClient.singleton } describe "#submit_user_documents", vcr: true do let(:user) { { :service_user_token => "phuongnd08@gmail.com", :username => "santienao", :email => "phuongnd08@gmail.com", :doc_status => "verified", :doc_country => "vn", :green_id_status => "in_progress", :phone_number => "+84943337777", :phone_number_status => "verified", :status => "active", :blacklisted => false, :browser_fingerprint => "3447579879", :country_code => "cn", :verify_source => "upload", :twitter_status => "empty", :facebook_status => "empty", :revoke_phone_numbers => [], :postback_urls => ["http://localhost:3000/verify/update_service_user"]} } it "returns the service user" do result, ok = client.submit_user_documents(user, []) expect(ok).to be_truthy expect(result["user"]).to be_present end end describe "#get_service_users_info", vcr: true do it "returns current doc status" do result, ok = client.get_service_users_info(["seller"]) expect(ok).to be_truthy expect(result.first["doc_status_details"]).to eq({"remex"=>"uploading", "remitano"=>"temporarily_verified"}) end end describe "#update_service_user", vcr: true do user = { service_user_token: "quocthai010468@gmail.com", email: "quocthai010468@gmail.com", sign_up_ip: "192.168.1.1", current_sign_in_ip: "192.168.1.1" } it "returns the service user" do result, ok = client.update_service_user(user) expect(ok).to be_truthy expect(result["user"]).to be_present end end describe "#update_from_portal", vcr: true do let(:email) { "phuongnd08@gmail.com" } it "returns the service user" do result, ok = client.update_from_portal(email) expect(ok).to be_truthy expect(result["user"]).to be_present end end describe "#handle_comment", vcr: true do def comment_params { user_email: "seller@remitano.com", admin_email: "admin@remitano.com", id: nil, external_id: 1, comment: "This is a comment" } end it "returns the created status" do result, ok = client.handle_comment(comment_params) expect(ok).to be_truthy expect(result["text"]).to eq "created" end end describe "#close", vcr: true do context "email not found" do let(:email) { "notfound@gmail.com" } it "return error" do result, ok = client.close(email, "archived-10123@remitano.com") expect(ok).to be_falsey expect(result["message"]).to eq("Email not found") end end context "email found" do let(:email) { "tuenqviettel@gmail.com" } it "close ServiceUser" do result, ok = client.close(email, "archived-10124@remitano.com") expect(ok).to be_truthy expect(result["success"]).to be_truthy end end end describe "#request_sync_back", vcr: true do it "request success" do result, ok = client.request_sync_back(usernames: ["archived-10124"]) expect(ok).to be_truthy expect(result["success"]).to be_truthy end end end