class ECUtils::ECAdvisorApis
Attributes
everclear_session[RW]
Public Instance Methods
accept_chat_session(chat_id)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 269 def accept_chat_session(chat_id) options = { body: {type: "advisor_accept", success: true}.to_json, headers: authorized_headers } response = self.class.patch("/chats/#{chat_id}.json", options) end
decline_chat_session(chat_id)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 277 def decline_chat_session(chat_id) options = { body: {type: "advisor_accept_failed", success: false}.to_json, headers: authorized_headers } response = self.class.patch("/chats/#{chat_id}.json", options) end
end_chat_session(chat_id)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 301 def end_chat_session(chat_id) options = { body: {type: "end_session", success: true}.to_json, headers: authorized_headers } puts response = self.class.patch("/chats/#{chat_id}", options) end
get_advisor_feedbacks()
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 151 def get_advisor_feedbacks options = { headers: authorized_headers } response = self.class.get('/feedbacks.json?page=1', options) body_response = JSON.parse(response.body) body_response['feedbacks'] unless body_response.empty? end
get_advisor_pinned_feedbacks()
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 160 def get_advisor_pinned_feedbacks options = { headers: authorized_headers } response = self.class.get('/feedbacks/pinned.json', options) JSON.parse(response.body) end
get_availability()
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 207 def get_availability options = { headers: authorized_headers } response = self.class.get('/profile/availability', options) puts response.body expect(response.code).to eq 200 response['availability'] end
get_chat_contacts()
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 168 def get_chat_contacts options = { headers: authorized_headers } response = self.class.get('/chat_contacts.json', options) JSON.parse(response.body) end
get_lapsed_client(min_earn=5)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 198 def get_lapsed_client(min_earn=5) options = { query: { minimum_earn: min_earn }, headers: authorized_headers } response = self.class.get('/advisor/lapsed_clients', options) JSON.parse(response.body)['clients'] end
get_my_clients(direction, field, name, page=1)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 127 def get_my_clients(direction, field, name, page=1) query = {} unless direction.nil? query['direction'] = direction end unless field.nil? query['field'] = field end unless name.nil? query['name'] = name end unless page.nil? query['page'] = page end options = { query: query, headers: authorized_headers } response = self.class.get('/clients.json', options) puts response.body JSON.parse(response.body)['clients'] end
get_promoted_profile_campaign()
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 325 def get_promoted_profile_campaign options = { headers: authorized_headers } response = self.class.get('/promoted_profile_campaign.json', options) end
get_timezone_list()
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 260 def get_timezone_list options = { headers: authorized_headers } response = self.class.get('/advisors_basic_info/timezone_list', options) expect(response.code).to eq 200 response['available_timezones'] end
reset_unread_message(seeker_id)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 176 def reset_unread_message(seeker_id) options = { headers: authorized_headers } response = self.class.put("/text_chat/message_counts/#{seeker_id}/reset_unread_messages", options) JSON.parse(response.body) end
send_photo_message(receiver_id, photo_data)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 64 def send_photo_message(receiver_id, photo_data) options = { body: { 'receiver_id': receiver_id, 'recipient_id': receiver_id, 'ref_id': Time.now.to_i, 'photo_message[]': photo_data }, headers: { 'Cookie': "everclear_session=#{everclear_session}", 'Accept': '*/*' } } puts options response = self.class.post('/text_chat/photo_messages', options) puts response.body expect(response.code).to eq 200 end
send_ppm_chat(chat_id, content)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 293 def send_ppm_chat(chat_id, content) options = { body: {content: content}.to_json, headers: authorized_headers } response = self.class.post("/chats/#{chat_id}/messages", options) end
send_text_message(message, seeker_id)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 38 def send_text_message(message, seeker_id) options = { body: { 'cleaner': 'raw', 'content': message, 'recipient_id': seeker_id }.to_json, headers: authorized_headers } response = self.class.post('/text_chat/messages.json', options) puts response.body expect(response.code).to eq 200 end
send_typing_signal(chat_id)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 309 def send_typing_signal(chat_id) options = { body: {}.to_json, headers: authorized_headers } response = self.class.post("/chats/#{chat_id}/typing", options) end
set_availability(data)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 52 def set_availability(data) options = { body: { 'availability': data }.to_json, headers: authorized_headers } response = self.class.put('/profile/availability', options) puts response.body expect(response.code).to eq 200 end
set_phone_rate(rate)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 83 def set_phone_rate(rate) options = { body: { 'availability': { "price_per_minute": rate } }.to_json, headers: authorized_headers } response = self.class.patch('/profile/availability.json', options) puts response.body expect(response.code).to eq 200 end
sign_in_as_advisor(email, password='12345678')
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 25 def sign_in_as_advisor(email, password='12345678') options = { body: { 'advisor[email]': email, 'advisor[password]': password, 'advisor[remember_me]': 0, 'commit': 'Log in' } } response = self.class.post('/advisors/sign_in', options) @everclear_session = response.headers['Set-Cookie'].scan(/everclear_session[^;]*/)[0].split(/[=;]/)[1] end
start_chat_conference(chat_id)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 285 def start_chat_conference(chat_id) options = { body: {type: "start_conference", success: true}.to_json, headers: authorized_headers } response = self.class.patch("/chats/#{chat_id}.json", options) end
start_promoted_profile()
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 317 def start_promoted_profile options = { headers: authorized_headers } response = self.class.post('/promoted_profile_campaign.json', options) expect(response.code).to eq 200 end
unblock_client(user_id)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 191 def unblock_client(user_id) options = { headers: authorized_headers } self.class.post("/clients/#{user_id}/unblock.json", options) end
unpin_feedback(feedback_id)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 184 def unpin_feedback(feedback_id) options = { headers: authorized_headers } self.class.post("/feedbacks/#{feedback_id}/unpin.json", options) end
update_advisor_profile(name, biography, summary)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 245 def update_advisor_profile(name, biography, summary) options = { body: { name: name, biography: biography, summary: summary, tools: { numerology: true, tarot: true }, topics: {love_and_relationships: true, career: true} }.to_json, headers: authorized_headers } response = self.class.patch('/advisor_profile', options) expect(response.code).to eq 200 end
update_away_message(message)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 235 def update_away_message(message) options = { body: { away_message: message }.to_json, headers: authorized_headers } response = self.class.patch('/advisor_profile/update_away_message', options) puts response.body expect(response.code).to eq 200 end
update_email(advisor_id, advisor_email, password)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 97 def update_email(advisor_id, advisor_email, password) options = { body: { 'email': advisor_email, 'id': advisor_id, 'password': password }.to_json, headers: authorized_headers } response = self.class.patch("/advisors_basic_info/#{advisor_id}", options) puts response.body end
update_password(advisor_id, advisor_email, password, new_password)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 111 def update_password(advisor_id, advisor_email, password, new_password) options = { body: { 'email': advisor_email, 'id': advisor_id, 'password': password, 'new_password': new_password, 'new_password_confirmation': new_password }.to_json, headers: authorized_headers } puts options response = self.class.patch("/advisors_basic_info/#{advisor_id}", options) puts response.body end
update_schedule(schedules=[])
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 217 def update_schedule(schedules=[]) options = { body: { typical_schedule_blocks: schedules }.to_json, headers: authorized_headers } response = self.class.post('/advisor/typical_schedule.json', options) JSON.parse(response.body)['typical_schedule_blocks'] end
update_timezone(timezone)
click to toggle source
# File lib/ec_utils/ec_advisor_apis.rb, line 226 def update_timezone(timezone) options = { body: { timezone: timezone }.to_json, headers: authorized_headers } response = self.class.patch('/advisors_basic_info/update_timezone', options) JSON.parse(response.body)['data'] end