class ECUtils::ECSeekerApis
Attributes
api_token[RW]
jwt_token[RW]
user_email[RW]
user_password[RW]
Public Instance Methods
add_card(card)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 611 def add_card(card) encrypted_card = encrypt_card(card) options = { body: { 'encrypted_card': { 'cardholder': encrypted_card[:cardholder], 'number': encrypted_card[:number], 'expiration': encrypted_card[:expiration], 'cvv': encrypted_card[:cvv], 'zip': encrypted_card[:zip] } }.to_json, headers: authorized_headers } puts response = self.class.post('/seeker_app/v2/my/user_credit_cards', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
add_encrypted_card(card)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 191 def add_encrypted_card(card) options = { body: { 'encrypted_card': { 'cardholder': card[:cardholder], 'number': card[:number], 'expiration': card[:expiration], 'cvv': card[:cvv], 'zip': card[:zip] } }.to_json, headers: authorized_headers } puts response = self.class.post('/seeker_app/v2/my/user_credit_cards', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
add_encrypted_card_data(encrypted_card)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 209 def add_encrypted_card_data(encrypted_card) options = { body: { 'encrypted_card': encrypted_card }.to_json, headers: authorized_headers } puts response = self.class.post('/seeker_app/v2/my/user_credit_cards', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
add_mood_entry(mood, topics, date_string, identifier, other)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 540 def add_mood_entry(mood, topics, date_string, identifier, other) mood_entries = { 'mood': mood, 'mood_date': date_string, 'client_identifier': identifier, 'life_area': topics } unless other.nil? mood_entries['other_text'] = other end options = { body: { 'mood_entries': [mood_entries] }.to_json, headers: authorized_headers } puts options puts response = self.class.post('/seeker_app/v2/mood_entries', options) expect(response.code).to eq 201 end
cancel_arranged_call(call_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 506 def cancel_arranged_call(call_id) options = { body: { 'max_hours_to_wait': 1, 'status': 'seeker_cancelled' }.to_json, headers: authorized_headers } puts response = self.class.patch("/seeker_app/v2/my/arranged_calls/#{call_id}", options) end
charge_card(card, amount)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 368 def charge_card(card, amount) encrypted_card = encrypt_card(card) options = { body: { 'encrypted_card': { 'cardholder': encrypted_card[:cardholder], 'number': encrypted_card[:number], 'expiration': encrypted_card[:expiration], 'cvv': encrypted_card[:cvv], 'zip': encrypted_card[:zip] }, 'transaction': { 'action': 'charge', 'amount': amount, 'default': true } }.to_json, headers: authorized_headers } puts response = self.class.post('/seeker_app/v2/my/user_credit_cards', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
charge_card_with_card_id(card_id, amount)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 598 def charge_card_with_card_id(card_id, amount) options = { body: { 'transaction': { 'action': 'charge', 'amount': amount } }.to_json, headers: authorized_headers } puts response = self.class.post("/seeker_app/v2/my/user_credit_cards/#{card_id}/charge", options) end
create_arranged_call(advisor_id, max_hours_to_wait=1)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 494 def create_arranged_call(advisor_id, max_hours_to_wait=1) options = { body: { 'advisor_id': advisor_id, 'max_hours_to_wait': max_hours_to_wait, 'source': 'Android' }.to_json, headers: authorized_headers } puts response = self.class.post('/seeker_app/v2/my/arranged_calls', options) end
create_new_chat(advisor_id, rate)
click to toggle source
PPM Chat
# File lib/ec_utils/ec_seeker_apis.rb, line 717 def create_new_chat(advisor_id, rate) options = { body: { 'advisor_id': advisor_id, 'rate': rate, }.to_json, headers: authorized_headers } response = self.class.post('/seeker_app/v2/chats', options) puts "Create new ppm chat - #{response.body}" expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
create_post_chat_session(chat_id, content)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 749 def create_post_chat_session(chat_id, content) options = { body: {content: content}.to_json, headers: authorized_headers } response = self.class.post("/seeker_app/v2/chats/#{chat_id}/messages", options) puts response end
create_user_phone(phone)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 517 def create_user_phone(phone) options = { body: { 'phone': phone }.to_json, headers: authorized_headers } puts response = self.class.post('/seeker_app/v2/my/user_phones', options) expect(response.code).to eq 200 response['data']['id'] end
delete_card(card_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 221 def delete_card(card_id) options = { headers: authorized_headers } puts response = self.class.delete("/seeker_app/v2/my/user_credit_cards/#{card_id}", options) expect(response.code).to eq 200 end
encrypt_card(card)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 776 def encrypt_card(card) { cardholder: encrypt_string(card[:cardholder]), number: encrypt_string(card[:number]), expiration: encrypt_string("#{card[:expiration_month]}/#{card[:expiration_year]}"), zip: encrypt_string(card[:zip]), cvv: encrypt_string(card[:cvv]) } end
encrypt_string(string)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 786 def encrypt_string(string) public_key = OpenSSL::PKey::RSA.new(PUBLIC_KEY) Base64.encode64(public_key.public_encrypt(string)) end
end_chat_conference(chat_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 740 def end_chat_conference(chat_id) options = { body: { type: "end_session", success: true }.to_json, headers: authorized_headers } response = self.class.put("/seeker_app/v2/chats/#{chat_id}", options) puts response end
favorite_advisor(advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 229 def favorite_advisor(advisor_id) options = { body: { 'advisor_id': advisor_id }.to_json, headers: authorized_headers } response = self.class.post('/seeker_app/v2/my/favorite_advisors', options) expect(response.code).to eq 200 end
get_advisor_profile(advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 309 def get_advisor_profile(advisor_id) options = { headers: authorized_headers } response = self.class.get("/seeker_app/v2/advisors/#{advisor_id}", options) puts "get_advisor_profile - #{response.body}" expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_advisor_typical_schedule(advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 706 def get_advisor_typical_schedule(advisor_id) options = { headers: authorized_headers } response = self.class.get("/seeker_app/v2/advisors/#{advisor_id}/typical_schedule", options) puts "Advisor schedule - #{response.body}" expect(response.code).to eq 200 JSON.parse(response.body)['data']['typical_schedule_blocks'] end
get_api_token()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 48 def get_api_token options = { body: { 'client_id': 'V3WmBjcHG8pJaxzuJGq72xgP27PVZT4p' } } puts response = self.class.post('/api/tokens', options) @api_token = JSON.parse(response.body)['data']['token'] end
get_cards_list()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 182 def get_cards_list options = { headers: authorized_headers } response = self.class.get('/seeker_app/v2/my/user_credit_cards', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_chat_contacts()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 359 def get_chat_contacts options = { headers: authorized_headers } response = self.class.get('/seeker_app/v2/chat/contacts', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_favorite_advisors(page_number=1, limit=1)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 261 def get_favorite_advisors(page_number=1, limit=1) options = { query: { 'page_number': page_number, 'limit': limit }, headers: authorized_headers } response = self.class.get('/seeker_app/v2/my/favorite_advisors', options) puts "get_favorite_advisors - #{response.body}" expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_messages(advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 658 def get_messages(advisor_id) options = { query: { selected_user_id: advisor_id, per_page: 100 }, headers: authorized_headers } response = self.class.get('/seeker_app/v2/chat/messages', options) JSON.parse(response.body)['data'] end
get_messages_list(advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 344 def get_messages_list(advisor_id) options = { query: { 'per_page': 10, 'page_number': 1, 'limit': 1, 'selected_user_id': advisor_id }, headers: authorized_headers } puts response = self.class.get('/seeker_app/v2/chat/messages', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_my_chats()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 766 def get_my_chats options = { headers: authorized_headers } puts response = self.class.get('/seeker_app/v2/my/chats', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_notification_settings()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 172 def get_notification_settings options = { headers: authorized_headers } puts response = self.class.get('/seeker_app/v2/my/settings/promotional_notifications', options) expect(response.code).to eq 200 data = JSON.parse(response.body)['data'] return data['sms'], data['email'] end
get_preferred_advisor_style()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 127 def get_preferred_advisor_style options = { headers: authorized_headers } puts response = self.class.get('/seeker_app/v2/my/profile/preferred_advisor_style', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_profile()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 96 def get_profile options = { headers: authorized_headers } response = self.class.get('/seeker_app/v2/my/profile', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_recent_advisors(page_number, limit = 10)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 248 def get_recent_advisors(page_number, limit = 10) options = { query: { 'page_number': page_number, 'limit': limit }, headers: authorized_headers } response = self.class.get('/seeker_app/v2/my/recent_advisors?show_closed=true', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_reviews_for_advisor(advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 319 def get_reviews_for_advisor(advisor_id) options = { headers: authorized_headers } response = self.class.get("/seeker_app/v2/advisors/#{advisor_id}/feedbacks?current_user_first=true", options) puts "get_reviews_for_advisor - #{response.body}" expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_search_advisor(keyword, topics, advisor_type, tools, genders, require_phone_availability)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 289 def get_search_advisor(keyword, topics, advisor_type, tools, genders, require_phone_availability) options = { query: { 'search_type': 'standard', 'page_number': 1, 'limit': 1, 'keyword': keyword, 'topics': topics.join(','), 'tools': tools.join(','), 'advisor_type': advisor_type, 'gender': genders.join(','), 'prefer_phone_availability': require_phone_availability }, headers: authorized_headers } response = self.class.get('/seeker_app/v2/advisors', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_special_offers()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 394 def get_special_offers options = { headers: authorized_headers } response = self.class.get('/seeker_app/v2/special_offers', options) puts "get_special_offers - #{response.body}" expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_suggested_advisors_for_advisor(advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 329 def get_suggested_advisors_for_advisor(advisor_id) options = { query: { 'search_type': 'suggested', 'page_number': 1, 'limit': 1, 'advisor_id': advisor_id }, headers: authorized_headers } puts response = self.class.get('/seeker_app/v2/advisors', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_suggestion_advisors()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 275 def get_suggestion_advisors options = { query: { 'search_type': 'suggested', 'page_number': 1, 'limit': 1 }, headers: authorized_headers } puts response = self.class.get('/seeker_app/v2/advisors', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_timezones()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 404 def get_timezones options = { headers: authorized_headers } puts response = self.class.get('/seeker_app/v2/my/timezone', options) expect(response.code).to eq 200 JSON.parse(response.body)['data']['current_timezone'] end
get_transaction_details(transaction_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 453 def get_transaction_details(transaction_id) options = { headers: authorized_headers } url = "/seeker_app/v2/my/transactions/#{transaction_id}" puts response = self.class.get(url, options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_transactions_list(limit=10, is_current_month=false, advisor_id=nil)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 430 def get_transactions_list(limit=10, is_current_month=false, advisor_id=nil) query = { 'page_number': 1, 'limit': limit } unless advisor_id.nil? query['advisor_id'] = advisor_id end if is_current_month query['month'] = Date.today.strftime("%B") end options = { query: query, headers: authorized_headers } puts response = self.class.get('/seeker_app/v2/my/transactions', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
get_what_on_mind()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 151 def get_what_on_mind options = { headers: authorized_headers } puts response = self.class.get('/seeker_app/v2/my/profile/focuses', options) expect(response.code).to eq 200 JSON.parse(response.body)['data']['focuses'] end
password()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 31 def password if user_password.nil? return '12345678' end return user_password end
purchase_special_offer(id, credit_card)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 463 def purchase_special_offer(id, credit_card) encrypted_card = encrypt_card(credit_card) options = { body: { 'encrypted_credit_card': { 'cardholder': encrypted_card[:cardholder], 'number': encrypted_card[:number], 'expiration': encrypted_card[:expiration], 'cvv': encrypted_card[:cvv], 'zip': encrypted_card[:zip] } }.to_json, headers: authorized_headers } url = "/seeker_app/v2/special_offers/#{id}/purchase" response = self.class.post(url, options) puts "response #{response}" expect(response.code).to eq 200 end
register(seeker_name)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 58 def register(seeker_name) options = { body: { 'name': seeker_name, 'email': "#{seeker_name}@a.com", 'password': '12345678', 'birth_date': '1971-12-16', 'timezone_offset_in_seconds': '-25200', 'device_type': 'IOS', 'device_id': '1234567890', 'app_version': '1.4.1' }.to_json, headers: { 'Api-Client-Authentication': api_token, 'Content-Type': 'application/json', 'Accept': 'application/json' } } puts response = self.class.post('/seeker_app/v2/sign_up', options) end
reset_unread_message(advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 118 def reset_unread_message(advisor_id) options = { headers: authorized_headers } puts response = self.class.put("/seeker_app/v2/chat/message_counts/#{advisor_id}/reset_unread_messages", options) expect(response.code).to eq 200 end
send_feedback(content, advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 413 def send_feedback(content, advisor_id) options = { body: { "feedback": { "vote": 'up', "content": content, "private": false, "technical_issue": '' } }.to_json, headers: authorized_headers } puts response = self.class.post("/seeker_app/v2/advisors/#{advisor_id}/feedbacks", options) expect(response.code).to eq 200 end
send_feedback_advisor(advisor_id, content)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 670 def send_feedback_advisor(advisor_id, content) options = { body: { 'feedback': { 'vote': 'up', "content": content, "private": false, "technical_issue": '' } }.to_json, headers: authorized_headers } response = self.class.post("/seeker_app/v2/advisors/#{advisor_id}/feedbacks", options) puts response.body response end
send_text_message(message, advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 105 def send_text_message(message, advisor_id) options = { body: { 'recipient_id': advisor_id, 'content': message }.to_json, headers: authorized_headers } puts response = self.class.post('/seeker_app/v2/chat/messages', options) expect(response.code).to eq 200 end
send_tip(advisor_id, amount)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 631 def send_tip(advisor_id, amount) options = { body: { 'amount': amount }.to_json, headers: authorized_headers } puts response = self.class.post("/seeker_app/v2/advisors/#{advisor_id}/tip", options) end
send_typing_signal(chat_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 758 def send_typing_signal(chat_id) options = { headers: authorized_headers } response = self.class.post("/seeker_app/v2/chats/#{chat_id}/typing", options) puts response end
set_onboarded(onboarded=true)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 648 def set_onboarded(onboarded=true) options = { body: { 'onboarded': onboarded }.to_json, headers: authorized_headers } self.class.patch('/seeker_app/v2/my/profile', options) end
set_preferred_advisor_style(approach, topics, tools, gender)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 136 def set_preferred_advisor_style(approach, topics, tools, gender) options = { body: { 'approach': approach, 'topics': topics, 'tools': tools, 'gender': gender }.to_json, headers: authorized_headers } response = self.class.patch('/seeker_app/v2/my/profile/preferred_advisor_style', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
sign_in_as_seeker()
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 79 def sign_in_as_seeker options = { body: { 'email': user_email, 'password': password }.to_json, headers: { 'Api-Client-Authentication': api_token, 'Content-Type': 'application/json', 'Accept': 'application/json' } } puts options puts response = self.class.post('/seeker_app/v2/sign_in', options) @jwt_token = JSON.parse(response.body)['data']['token'] end
sign_up_as_seeker(email)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 564 def sign_up_as_seeker(email) options = { body: { 'email': email, 'name': email.split('@').first, 'password': '12345678', 'birth_date': [rand(1930..2000), rand(1..12), rand(1..28)].join('-') }.to_json, headers: { 'Api-Client-Authentication': api_token, 'Content-Type': 'application/json', 'Accept': 'application/json' } } response = self.class.post('/seeker_app/v2/sign_up', options) expect(response.code).to eq 200 end
start_chat_conference(chat_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 732 def start_chat_conference(chat_id) options = { body: { type: "start_conference", success: true }.to_json, headers: authorized_headers } self.class.put("/seeker_app/v2/chats/#{chat_id}", options) end
unblock_advisor(advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 641 def unblock_advisor(advisor_id) options = { headers: authorized_headers } puts response = self.class.delete("/seeker_app/v2/my/blocked_advisors/#{advisor_id}", options) end
unfavorite_advisor(advisor_id)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 240 def unfavorite_advisor(advisor_id) options = { headers: authorized_headers } puts response = self.class.delete("/seeker_app/v2/my/favorite_advisors/#{advisor_id}", options) expect(response.code).to eq 200 end
update_account_info(full_name, new_email, new_password, current_password)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 688 def update_account_info(full_name, new_email, new_password, current_password) options = { body: { 'full_name': full_name, 'email': new_email, 'current_password': current_password, 'password': new_password }.to_json, headers: authorized_headers } puts options response = self.class.patch('/seeker_app/v2/my/settings/login_credentials', options) puts "Update account info - #{response.body}" expect(response.code).to eq 200 response end
update_notification_settings(sms_status, email_status)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 160 def update_notification_settings(sms_status, email_status) options = { body: { 'sms': sms_status, 'email': email_status }.to_json, headers: authorized_headers } puts response = self.class.patch('/seeker_app/v2/my/settings/promotional_notifications', options) expect(response.code).to eq 200 end
update_pref_advisor_styles(approach, tools, topics)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 582 def update_pref_advisor_styles(approach, tools, topics) options = { body: { approach: approach, tools: tools, topics: topics, gender: 'M', prefer_phone_availability: true, prefer_chat_availability: true }.to_json, headers: authorized_headers } response = self.class.patch('/seeker_app/v2/my/profile/preferred_advisor_style', options) expect(response.code).to eq 200 JSON.parse(response.body)['data'] end
update_user_name(user_name)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 483 def update_user_name(user_name) options = { body: { 'name': user_name }.to_json, headers: authorized_headers } puts response = self.class.patch('/seeker_app/v2/my/profile/username', options) expect(response.code).to eq 200 end
verify_phone(id, last_four_digits)
click to toggle source
# File lib/ec_utils/ec_seeker_apis.rb, line 529 def verify_phone(id, last_four_digits) options = { body: { 'verification_code': last_four_digits }.to_json, headers: authorized_headers } puts response = self.class.post("/seeker_app/v2/user_phones/#{id}/confirmations", options) expect(response.code).to eq 200 end