otrs_proxy 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,13 @@ module OtrsConnector
29
29
  end
30
30
  results
31
31
  end
32
+
33
+ def self.find_by_user_id_and_action(user_id, action)
34
+ data = { 'UserID' => user_id, 'Type' => action, 'Result' => 'HASH' }
35
+ params = { :object => 'GroupObject', :method => 'GroupMemberList', :data => data }
36
+
37
+ Hash[*connect(params)]
38
+ end
32
39
 
33
40
  end
34
41
  end
@@ -16,16 +16,18 @@ module OtrsConnector
16
16
  attributes["State"] ||= 'Valid'
17
17
  attributes["Object"] ||= "ITSMConfigItem"
18
18
  params = { :object => 'LinkObject', :method => 'LinkListWithData', :data => attributes }
19
- a = connect(params).collect do |item|
20
- next if item.blank?
21
- begin
22
- # нужно опустится на 3 уровня в хеш и забрать последнего потомка
23
- 4.times { item = item.values.first }
24
- OTRS::Ticket.new(item.symbolize_keys)
25
- rescue Exception => e
26
- nil
27
- end
28
- end.compact
19
+ a = connect(params)
20
+ result = []
21
+
22
+ (a.first["Ticket"]["RelevantTo"]["Source"].values rescue []).each do |ticket|
23
+ result << OTRS::Ticket.new(ticket.symbolize_keys)
24
+ end
25
+
26
+ (a.first["Ticket"]["DependsOn"]["Target"].values rescue []).each do |ticket|
27
+ result << OTRS::Ticket.new(ticket.symbolize_keys)
28
+ end
29
+
30
+ result
29
31
  end
30
32
 
31
33
  def self.where(attributes)
@@ -24,6 +24,16 @@ module OtrsConnector
24
24
  end
25
25
  c
26
26
  end
27
+
28
+ def self.find_id_by_queue(queue)
29
+ data = { 'Queue' => queue }
30
+ params = { :object => 'QueueObject', :method => 'QueueLookup', :data => data }
31
+ queue_id = connect(params).first
32
+
33
+ data = { 'QueueID' => queue_id }
34
+ params = { :object => 'QueueObject', :method => 'GetQueueGroupID', :data => data }
35
+ connect(params).first
36
+ end
27
37
 
28
38
  end
29
39
  end
@@ -1,3 +1,3 @@
1
1
  module OtrsConnector
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: otrs_proxy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Arion
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-13 00:00:00 Z
18
+ date: 2012-08-16 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  prerelease: false