@@ 155,23 155,40 @@ class ExpiredCustomer
protected
+ def jid
+ REDIS.get("jmp_customer_jid-#{customer_id}")
+ end
+
+ def tel
+ REDIS.lindex("catapult_cred-#{jid}", 3)
+ end
+
+ def btc_addresses
+ @btc_addresses ||= REDIS.smembers(
+ "jmp_customer_btc_addresses-#{customer_id}"
+ )
+ end
+
+ def btc_addresses_for_notification
+ return if btc_addresses.empty?
+ "\nYou can buy credit by sending any amount of Bitcoin to one of "\
+ "these addresses:\n#{btc_addresses.join("\n")}"
+ end
+
def send_notification
- jid = REDIS.get("jmp_customer_jid-#{customer_id}")
- tel = REDIS.lindex("catapult_cred-#{jid}", 3)
BlatherNotify.say(
CONFIG[:notify_using][:target].call(jid),
CONFIG[:notify_using][:body].call(
- jid, format_renewal_notification(tel)
+ jid, renewal_notification
)
)
end
- def format_renewal_notification(tel)
- <<~NOTIFY
- Failed to renew account for #{tel},
- balance of #{@row['balance']} is too low.
- To keep your number, please buy more credit soon.
- NOTIFY
+ def renewal_notification
+ "Failed to renew account for #{tel}, " \
+ "balance of #{@row['balance']} is too low. " \
+ "To keep your number, please buy more credit soon. " \
+ "#{btc_addresses_for_notification}"
end
end
end