Class: SmsLog
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SmsLog
- Defined in:
- app/models/sms_log.rb
Class Method Summary collapse
- .log(user, sms) ⇒ Object
- .log_result(res, user, sms, flag) ⇒ Object
-
.send_mms_and_log(user, mms) ⇒ Object
THIS NEEDs TO bE FixED,,, change to text rather string in database as well.
-
.send_sms_and_log(user, sms) ⇒ Object
this needs to be fixed.…
Instance Method Summary collapse
Class Method Details
.log(user, sms) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/models/sms_log.rb', line 3 def self.log(user, sms) sms_transaction_log = SmsLog.new # sms_transaction_log.user=user sms_transaction_log.setup(sms) sms_transaction_log.username=user sms_transaction_log.save! end |
.log_result(res, user, sms, flag) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/sms_log.rb', line 10 def self.log_result(res, user, sms,flag) sms_transaction_log = SmsLog.new # sms_transaction_log.user=user sms_transaction_log.setup(sms) sms_transaction_log.username=user case flag when true if res.kind_of? Net::HTTPResponse sms_transaction_log.response=res.code sms_transaction_log.response_body=res.body else sms_transaction_log.response=202 sms_transaction_log.response_body=res end else sms_transaction_log.response=9000 sms_transaction_log.response_body=res.to_s end sms_transaction_log.save! end |
.send_mms_and_log(user, mms) ⇒ Object
THIS NEEDs TO bE FixED,,, change to text rather string in database as well.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/models/sms_log.rb', line 54 def self.send_mms_and_log(user, mms) # sms_transaction_log.user=user successflag=false begin mms_sender= MmscManager::MmsSendTopic.new r= mms_sender.send_topic_mms(mms) mms_sender.disconnect_stomp successflag=true rescue Exception => e r = "send failed with #{e.}" end SmscManager::SmsLog.log_result(r,user,mms,successflag) end |
.send_sms_and_log(user, sms) ⇒ Object
this needs to be fixed.…
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/sms_log.rb', line 37 def self.send_sms_and_log(user, sms) # sms_transaction_log.user=user successflag=false begin sms_sender= SmscManager::SmsSendTopic.new r= sms_sender.send_topic_sms(sms) sms_sender.disconnect_stomp successflag=true rescue Exception => e r = "send failed with #{e.}" end SmscManager::SmsLog.log_result(r,user,sms,successflag) end |
Instance Method Details
#setup(sms) ⇒ Object
30 31 32 33 34 |
# File 'app/models/sms_log.rb', line 30 def setup(sms) self.sms_content=sms.text self.destination=sms.destination self.source= sms.source end |