217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/netsuite/utilities.rb', line 217
def get_record(record_klass, id, opts = {})
opts[:external_id] ||= false
if opts[:cache]
netsuite_get_record_cache[record_klass.to_s] ||= {}
if netsuite_get_record_cache[record_klass.to_s].has_key?(id.to_i)
return netsuite_get_record_cache[record_klass.to_s][id.to_i]
end
end
begin
ns_record = if opts[:external_id]
backoff { record_klass.get(external_id: id) }
else
backoff { record_klass.get(id) }
end
if opts[:cache]
netsuite_get_record_cache[record_klass.to_s][id.to_i] = ns_record
end
return ns_record
rescue ::NetSuite::RecordNotFound
if opts[:cache]
netsuite_get_record_cache[record_klass.to_s][id.to_i] = nil
end
return nil
end
end
|