otrs_proxy 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,13 @@ module OtrsConnector
18
18
  params = { :object => 'LinkObject', :method => 'LinkListWithData', :data => attributes }
19
19
  a = connect(params).collect do |item|
20
20
  next if item.blank?
21
- OTRS::Ticket.new(item['Ticket']['RelevantTo']['Source'].values.first.symbolize_keys) rescue nil
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
22
28
  end.compact
23
29
  end
24
30
 
@@ -73,6 +73,15 @@ module OtrsConnector
73
73
  end
74
74
  results
75
75
  end
76
+
77
+ # services = OtrsConnector::OTRS::Service.user_list('AUTO-110929111155')
78
+ def self.user_list(login)
79
+ data = {:CustomerUserLogin => login,
80
+ :Result => 'HASH',
81
+ :DefaultServices => 0}
82
+ params = { :object => 'ServiceObject', :method => 'CustomerUserServiceMemberList', :data => data }
83
+ Hash[*connect(params)]
84
+ end
76
85
 
77
86
  end
78
87
  end
@@ -0,0 +1,17 @@
1
+ module OtrsConnector
2
+ class OTRS::Sla < OTRS
3
+
4
+ def self.list(attributes)
5
+ tmp = {}
6
+ attributes.each do |key,value|
7
+ tmp[key.to_s.camelize.to_sym] = value
8
+ end
9
+ attributes = tmp
10
+ data = attributes
11
+ #params = "$SLAObject->SLAList"
12
+ params = { :object => 'SLAObject', :method => 'SLAList', :data => data }
13
+ Hash[*connect(params)]
14
+ end
15
+
16
+ end
17
+ end
@@ -24,6 +24,17 @@ module OtrsConnector
24
24
  params = { :object => 'TicketObject', :method => 'TicketFreeTextSet', :data => data }
25
25
  connect(params).first
26
26
  end
27
+
28
+ def self.pending_time_set(user_id, ticket_id, time)
29
+ data = {
30
+ "String" => time.strftime('%Y-%m-%d %H:%M:00'),
31
+ "UserID" => user_id,
32
+ "TicketID" => ticket_id
33
+ }
34
+
35
+ params = { :object => 'TicketObject', :method => 'TicketPendingTimeSet', :data => data }
36
+ connect(params).first
37
+ end
27
38
 
28
39
  def self.ticket_number_lookup(ticket_id)
29
40
  data = { 'TicketID' => ticket_id, 'UserID' => 1 }
@@ -42,6 +42,8 @@ module OtrsConnector
42
42
 
43
43
  result = ActiveSupport::JSON::decode(response.body)
44
44
 
45
+ raise "Can't parse OTRS response: [#{response.body}], params: [#{params}]" unless result
46
+
45
47
  return result["Data"] if result["Result"] == 'successful'
46
48
 
47
49
  if result['Message'].blank?
@@ -1,3 +1,3 @@
1
1
  module OtrsConnector
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
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-04-23 00:00:00 Z
18
+ date: 2012-08-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  prerelease: false
@@ -103,6 +103,7 @@ files:
103
103
  - lib/otrs_connector/otrs/group.rb
104
104
  - lib/otrs_connector/otrs/link.rb
105
105
  - lib/otrs_connector/otrs/service.rb
106
+ - lib/otrs_connector/otrs/sla.rb
106
107
  - lib/otrs_connector/otrs/ticket.rb
107
108
  - lib/otrs_connector/otrs/ticket/article.rb
108
109
  - lib/otrs_connector/otrs/ticket/state.rb