Class: Skuby::Report
- Inherits:
-
Object
- Object
- Skuby::Report
- Defined in:
- lib/skuby/report.rb
Constant Summary collapse
- STATUS_MAPPING =
{ 'DELIVERED' => 'Messaggio consegnato', 'EXPIRED' => 'Messaggio scaduto (telefono spento/non raggiungibile)', 'DELETED' => 'Errore rete operatore', 'UNDELIVERABLE' => 'Messaggio non spedito (Vedi sotto variabile error_code)', 'UNKNOWN' => 'Errore generico', 'REJECTD' => 'Messaggio rifiutato dall\'operatore' }.freeze
- ERROR_CODES =
{ 1 => 'Consegnato', 401 => 'Messaggio scaduto (telefono spento/non raggiungibile)', 201 => 'Malfunzionamento rete operatore', 203 => 'Destinatario non raggiungibile (in roaming)', 301 => 'Destinatario non valido (inesistente/in portabilita\' - non abilitato)', 302 => 'Numero errato', 303 => 'Servizio SMS non abilitato', 304 => 'Testo riconosciuto come spam', 501 => 'Telefono non supporta l\'SMS', 502 => 'Telefono con memoria piena', 901 => 'Mappatura errata del malfunzionamento', 902 => 'Servizio temporaneamente non disponibile', 903 => 'Nessun operatore disponibile', 904 => 'Messaggio privo di testo', 905 => 'Destinatario non valido', 906 => 'Destinatari duplicati', 907 => 'Compilazione messaggio non corretta', 909 => 'User_reference non corretta', 910 => 'Testo troppo lungo', 101 => 'Malfunzionamento generico operatore', 202 => 'Messaggio rifiutato dall\'operatore' }.freeze
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #delivered_at ⇒ Object
- #dispatch_id ⇒ Object
- #error_code ⇒ Object
- #error_message ⇒ Object
-
#initialize(params) ⇒ Report
constructor
A new instance of Report.
- #message_id ⇒ Object
- #status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(params) ⇒ Report
Returns a new instance of Report.
38 39 40 |
# File 'lib/skuby/report.rb', line 38 def initialize(params) @raw = params end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
36 37 38 |
# File 'lib/skuby/report.rb', line 36 def raw @raw end |
Instance Method Details
#delivered_at ⇒ Object
66 67 68 |
# File 'lib/skuby/report.rb', line 66 def delivered_at Time.parse(@raw["operator_date_time"]) end |
#dispatch_id ⇒ Object
62 63 64 |
# File 'lib/skuby/report.rb', line 62 def dispatch_id @raw["skebby_dispatch_id"] end |
#error_code ⇒ Object
50 51 52 |
# File 'lib/skuby/report.rb', line 50 def error_code @raw["error_code"].to_i end |
#error_message ⇒ Object
54 55 56 |
# File 'lib/skuby/report.rb', line 54 def "#{STATUS_MAPPING[status]} - #{ERROR_CODES[error_code]}" end |
#message_id ⇒ Object
58 59 60 |
# File 'lib/skuby/report.rb', line 58 def @raw["skebby_message_id"] end |
#status ⇒ Object
46 47 48 |
# File 'lib/skuby/report.rb', line 46 def status @raw["status"] end |
#success? ⇒ Boolean
42 43 44 |
# File 'lib/skuby/report.rb', line 42 def success? status == "DELIVERED" end |