10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/beanstream/reporting_api.rb', line 10
def search_transactions(start_date, end_date, start_row, end_row, criteria=nil)
if !start_date.is_a?(Time)
raise InvalidRequestException.new(0, 0, "start_date must be of type Time in ReportingApi.search_transactions", 0)
end
if !end_date.is_a?(Time)
raise InvalidRequestException.new(0, 0, "end_date must be of type Time in ReportingApi.search_transactions", 0)
end
if criteria != nil && !criteria.kind_of?(Array) && !criteria.is_a?(Beanstream::Criteria)
puts "criteria was of type: #{criteria.class}"
raise InvalidRequestException.new(0, 0, "criteria must be of type Array<Critiera> or Criteria in ReportingApi.search_transactions", 0)
end
if criteria.is_a?(Beanstream::Criteria)
criteria = Array[criteria]
end
startD = start_date.strftime "%Y-%m-%dT%H:%M:%S"
endD = end_date.strftime "%Y-%m-%dT%H:%M:%S"
criteria_hash = Array[]
if criteria != nil && criteria.length > 0
for c in criteria
criteria_hash << c.to_hash
end
end
query = {
"name" => "Search",
"start_date" => startD,
"end_date" => endD,
"start_row" => start_row,
"end_row" => end_row,
"criteria" => criteria_hash
}
puts "\n\nReport search query #{query}\n\n"
val = transaction_post("POST", reports_url, Beanstream.merchant_id, Beanstream.reporting_api_key, query)
results = val['records']
end
|