| Conditions | 4 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | require 'jsondoc' |
||
| 35 | |||
| 36 | def new_sms_count() |
||
| 37 | count = 0 |
||
| 38 | have_sms = false |
||
| 39 | changes = @doc.getAttr('body.changes') |
||
| 40 | |||
| 41 | puts '---' |
||
| 42 | pp changes |
||
| 43 | puts '===' |
||
| 44 | if changes.is_a?(Array) && changes.length > 0 |
||
| 45 | changes.each do |change| |
||
| 46 | if change.key?(:type) && change[:type].to_s.downcase == 'sms' |
||
| 47 | have_sms = true |
||
| 48 | if change.key?(:newCount) |
||
| 49 | count += change[:newCount] |
||
| 50 | end |
||
| 51 | end |
||
| 52 | end |
||
| 53 | end |
||
| 54 | return have_sms ? count : -1 |
||
| 55 | end |
||
| 60 |