Class: OpenMarket::DR

Inherits:
Object
  • Object
show all
Defined in:
lib/open_market/dr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ DR

Returns a new instance of DR.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/open_market/dr.rb', line 6

def initialize(data)
  (class << self; self; end).class_eval do
    # Defining a member variable for xml would pollute #inspect
    # This solution is inspired by https://github.com/jordansissel/software-patterns/tree/master/dont-log-secrets/ruby
    define_method(:xml) { REXML::Document.new(data).root }
    private :xml
  end
  @ticket_id = xml.attributes["ticketId"]
  @parent_ticket_id = xml.attributes["parentTicketId"]
  @note = xml.attributes["note"]
  response = xml.elements["response"]
  @description = response.attributes["description"]
  @code = response.attributes["code"].to_i
  message = xml.elements["message"]
  @segment_number = message.attributes["segmentNumber"]
  @timestamp = DateTime.strptime(message.attributes["deliveryDate"] + "+0000", '%FT%T.%LZ%z').utc
  state = message.elements["state"]
  @state_id = state.attributes["id"].to_i
  @state_description = state.attributes["description"]
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/open_market/dr.rb', line 5

def code
  @code
end

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/open_market/dr.rb', line 5

def description
  @description
end

#noteObject (readonly)

Returns the value of attribute note.



5
6
7
# File 'lib/open_market/dr.rb', line 5

def note
  @note
end

#parent_ticket_idObject (readonly)

Returns the value of attribute parent_ticket_id.



5
6
7
# File 'lib/open_market/dr.rb', line 5

def parent_ticket_id
  @parent_ticket_id
end

#segment_numberObject (readonly)

Returns the value of attribute segment_number.



5
6
7
# File 'lib/open_market/dr.rb', line 5

def segment_number
  @segment_number
end

#state_descriptionObject (readonly)

Returns the value of attribute state_description.



5
6
7
# File 'lib/open_market/dr.rb', line 5

def state_description
  @state_description
end

#state_idObject (readonly)

Returns the value of attribute state_id.



5
6
7
# File 'lib/open_market/dr.rb', line 5

def state_id
  @state_id
end

#ticket_idObject (readonly)

Returns the value of attribute ticket_id.



5
6
7
# File 'lib/open_market/dr.rb', line 5

def ticket_id
  @ticket_id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



5
6
7
# File 'lib/open_market/dr.rb', line 5

def timestamp
  @timestamp
end