Class: TicketSrv

Inherits:
Rack::RPC::Server
  • Object
show all
Defined in:
rtxmlsrv.rb,
rtxmlsrv2.rb

Constant Summary collapse

INTERFACE =
XMLRPC::interface("rt") {
  meth 'string add_watcher(struct)','Calls RT_Client::add_watcher'
  meth 'array attachments(struct)','Calls RT_Client::attachments'
  meth 'string comment(struct)','Calls RT_Client::comment'
  meth 'string correspond(struct)','Calls RT_Client::correspond'
  meth 'string create(struct)','Calls RT_Client::create'
  meth 'string create_user(struct)','Calls RT_Client::create_user'
  meth 'string edit(struct)','Calls RT_Client::edit'
  meth 'string edit_or_create_user(struct)','Calls RT_Client::edit_or_create_user'
  meth 'struct get_attachment(struct)','Calls RT_Client::get_attachment'
  meth 'struct history(struct)','Calls RT_Client::history (long form)'
  meth 'struct history_item(struct)','Calls RT_Client::history_item'
  meth 'array list(struct)','Calls RT_Client::list'
  meth 'array query(struct)','Calls RT_Client::query (long form)'
  meth 'struct show(struct)','Calls RT_Client::show'
}

Instance Method Summary collapse

Constructor Details

#initializeTicketSrv

Returns a new instance of TicketSrv.



32
33
# File 'rtxmlsrv.rb', line 32

def initialize
end

Instance Method Details

#add_watcher(struct) ⇒ Object

Allows watchers to be added via RT_Client::add_watcher You need to pass :id, :addr, and optionally :type



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'rtxmlsrv.rb', line 54

def add_watcher(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.add_watcher(struct)
  rt = nil
  val
end

#attachments(struct) ⇒ Object

Gets a list of attachments via RT_Client::attachments You need to pass :id, and optionally :unnamed



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'rtxmlsrv.rb', line 70

def attachments(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  rt = RT_Client.new
  val = rt.attachments(struct)
  rt = nil
  val
end

#comment(struct) ⇒ Object

Adds comments to tickets via RT_Client::comment



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'rtxmlsrv.rb', line 86

def comment(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.comment(struct)
  rt = nil
  val
end

#correspond(struct) ⇒ Object

Allows new tickets to be created via RT_Client::correspond



101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'rtxmlsrv.rb', line 101

def correspond(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.correspond(struct)
  rt = nil
  val
end

#create(struct) ⇒ Object

Allows new tickets to be created via RT_Client::create



116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'rtxmlsrv.rb', line 116

def create(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.create(struct)
  rt = nil
  val
end

#create_user(struct) ⇒ Object

Allows new users to be created via RT_Client::create_user



131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'rtxmlsrv.rb', line 131

def create_user(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.create_user(struct)
  rt = nil
  val
end

#edit(struct) ⇒ Object

Allows existing ticket to be modified via RT_Client::edit



176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'rtxmlsrv.rb', line 176

def edit(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.edit(struct)
  rt = nil
  val
end

#edit_or_create_user(struct) ⇒ Object

Allows new users to be edited or created if they don’t exist



161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'rtxmlsrv.rb', line 161

def edit_or_create_user(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.edit_or_create_user(struct)
  rt = nil
  val
end

#get_attachment(struct) ⇒ Object

Retrieves attachments via RT_Client::get_attachment



191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'rtxmlsrv.rb', line 191

def get_attachment(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.get_attachment(struct)
  rt = nil
  val
end

#history(struct) ⇒ Object

Gets the history of a ticket via RT_Client::history



206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'rtxmlsrv.rb', line 206

def history(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.history(struct)
  rt = nil
  val
end

#history_item(struct) ⇒ Object

Gets a single history item via RT_Client::history_item



221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'rtxmlsrv.rb', line 221

def history_item(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.history_item(struct)
  rt = nil
  val
end

#list(struct) ⇒ Object

Gets a list of tickets via RT_Client::list



236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'rtxmlsrv.rb', line 236

def list(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.list(struct)
  rt = nil
  val
end

#query(struct) ⇒ Object

Gets a list of tickets via RT_Client::query



251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'rtxmlsrv.rb', line 251

def query(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.query(struct)
  rt = nil
  val
end

#show(struct) ⇒ Object

Gets detail (minus history/attachments) via RT_Client::show



266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'rtxmlsrv.rb', line 266

def show(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.show(struct)
  rt = nil
  val
end

#usersearch(struct) ⇒ Object

Find RT user details from email address via RT_Cleint::usersearch



146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'rtxmlsrv.rb', line 146

def usersearch(struct)
  struct.remapkeys!
  if struct.has_key? :user and struct.has_key? :pass
    rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
    struct.delete(:user)
    struct.delete(:pass)
  else
    rt = RT_Client.new
  end
  val = rt.usersearch(struct)
  rt = nil
  val
end