Class: Sendly::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/sendly/types.rb

Overview

Rules

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Rule

Returns a new instance of Rule.



793
794
795
796
797
798
799
800
801
# File 'lib/sendly/types.rb', line 793

def initialize(data)
  @id = data["id"]
  @name = data["name"]
  @conditions = data["conditions"] || {}
  @actions = data["actions"] || {}
  @priority = data["priority"]
  @created_at = parse_time(data["createdAt"] || data["created_at"])
  @updated_at = parse_time(data["updatedAt"] || data["updated_at"])
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



791
792
793
# File 'lib/sendly/types.rb', line 791

def actions
  @actions
end

#conditionsObject (readonly)

Returns the value of attribute conditions.



791
792
793
# File 'lib/sendly/types.rb', line 791

def conditions
  @conditions
end

#created_atObject (readonly)

Returns the value of attribute created_at.



791
792
793
# File 'lib/sendly/types.rb', line 791

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



791
792
793
# File 'lib/sendly/types.rb', line 791

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



791
792
793
# File 'lib/sendly/types.rb', line 791

def name
  @name
end

#priorityObject (readonly)

Returns the value of attribute priority.



791
792
793
# File 'lib/sendly/types.rb', line 791

def priority
  @priority
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



791
792
793
# File 'lib/sendly/types.rb', line 791

def updated_at
  @updated_at
end

Instance Method Details

#to_hObject



803
804
805
806
807
808
809
# File 'lib/sendly/types.rb', line 803

def to_h
  {
    id: id, name: name, conditions: conditions, actions: actions,
    priority: priority, created_at: created_at&.iso8601,
    updated_at: updated_at&.iso8601
  }.compact
end