3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/invoice_count/invoice.rb', line 3
def self.count(id, starting_date, ending_date)
response = InvoiceCount::Connection.instance.get do |request|
request.url('/facturas')
request.params['id'] = id
request.params['start'] = starting_date
request.params['finish'] = ending_date
end
body = response.body.force_encoding('utf-8').encode
case body
when /Hay más de 100 resultados/
raise InvoiceCount::Error::TooManyResults
when /Te faltan parámetros/
raise InvoiceCount::Error::BadRequest
end
body.to_i
end
|