Sha256: 2cd38cc067f807294c83ad4cf9d648b8c1500a04831f4cdf35b27cba5e914f21
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
module CmSms module Webhook class Response ATTRIBUTE_NAMES = %w(sent received to reference statuscode errorcode errordescription) attr_reader *ATTRIBUTE_NAMES, :attributes def initialize(attributes = {}) @attributes = attributes attributes.each { |attr, value| instance_variable_set("@#{attr}", value) } if attributes end def sent? !sent.to_s.strip.empty? end def received? !received.to_s.strip.empty? end def statuscode? !statuscode.to_s.strip.empty? end def errorcode? !errorcode.to_s.strip.empty? end def sent_at Time.parse(sent) if sent? end def received_at Time.parse(received) if received? end def accepted? statuscode? && statuscode.to_s == '0' end def rejected? statuscode? && statuscode.to_s == '1' end def delivered? statuscode? && statuscode.to_s == '2' end def failed? statuscode? && statuscode.to_s == '3' end def error? errorcode? || rejected? || failed? end def to_yaml (@attributes || {}).to_yaml end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cm-sms-0.2.7 | lib/cm_sms/webhook/response.rb |
cm-sms-0.2.6 | lib/cm_sms/webhook/response.rb |
cm-sms-0.2.5 | lib/cm_sms/webhook/response.rb |
cm-sms-0.2.4 | lib/cm_sms/webhook/response.rb |