Class: RedmineRemotes::Esosti::Entities::Issue

Inherits:
Avmtrf1::Esosti::Entities::Issue
  • Object
show all
Defined in:
lib/redmine_remotes/esosti/entities/issue.rb

Constant Summary collapse

DEFAULT_TYPE_FOR_URL_PREFIX =
'_unmapped_'
EXTRA_DESCRIPTION_BEFORE =
{ reported_by: 'Relatado por', affected_person: 'Pessoa afetada',
type_description: 'Tipo de solicitação' }.freeze
TYPES_FOR_URL =
{
  'INCIDENTE' => 'ms_incident',
  'SS' => 'ms_sr'
}.freeze

Instance Method Summary collapse

Instance Method Details

#affected_personObject



25
26
27
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 25

def affected_person
  mail_local_part(attributes.fetch('AFFECTEDPERSON'))
end

#attributesObject



29
30
31
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 29

def attributes
  data.first.fetch('Attributes')
end

#author_loginObject



21
22
23
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 21

def 
  mail_local_part(attributes.fetch('CREATEDBY'))
end

#codeObject



33
34
35
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 33

def code
  attributes.fetch('TICKETID')
end

#created_onObject



37
38
39
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 37

def created_on
  attributes.fetch('CREATIONDATE')
end

#descriptionString

Returns:

  • (String)


42
43
44
45
46
47
48
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 42

def description
  ::RedmineRemotes::Esosti.remote_text_to_local(
    related_mbos.if_key('LONGDESCRIPTION', '') do |v|
      v.first.fetch('Attributes').fetch('LDTEXT')
    end
  )
end

#extra_description_beforeObject



50
51
52
53
54
55
56
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 50

def extra_description_before
  {
    'Relatado por' => "user:#{reported_by}",
    'Pessoa afetada' => "user:#{affected_person}",
    'Tipo de solicitação' => type_description
  }
end

#human_view_urlObject



17
18
19
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 17

def human_view_url
  instance.issue_human_view_url(type_for_url, uid)
end


58
59
60
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 58

def related_mbos
  data.first.fetch('RelatedMbos')
end

#reported_byObject



62
63
64
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 62

def reported_by
  mail_local_part(attributes.fetch('REPORTEDBY'))
end

#status_nameObject



66
67
68
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 66

def status_name
  attributes.fetch('STATUS')
end

#subjectObject



70
71
72
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 70

def subject
  description.gsub(/\s+/, ' ')
end

#type_classObject



78
79
80
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 78

def type_class
  attributes.fetch('CLASS')
end

#type_descriptionObject



82
83
84
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 82

def type_description
  attributes.fetch('DESCRIPTION')
end

#type_for_urlObject



74
75
76
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 74

def type_for_url
  TYPES_FOR_URL[type_class] || "#{DEFAULT_TYPE_FOR_URL_PREFIX}#{type_class}"
end

#uidObject



86
87
88
# File 'lib/redmine_remotes/esosti/entities/issue.rb', line 86

def uid
  attributes.fetch('TICKETUID').fetch('content')
end