module SmsBroker module Client class OpenMarket < Base def initialize(options) client = ::OpenMarket::SMS::Client.new( account_id: options[:account_id], account_password: options[:account_password] ) super :open_market, client, options end def send_message(message) response = client.send_message \ text: message[:text], from: message[:from], to: message[:to] if success_response?(response) Response::OpenMarket::SendMessageSuccess.new(response) else Response::OpenMarket::Error.new(response) end end def send_voice_message(_message) message = 'openmarket voice message is not implemented' exception = \ Exceptions::NotImplemented.new(message) raise exception end def message_status(params) response = client.message_status \ ticket_id: params[:message_id] if success_response?(response) Response::OpenMarket::MessageStatusSuccess.new(response) else Response::OpenMarket::Error.new(response) end end private def success_response?(response) response.success? end end end end