Module: Nihaopay::Queryable::ClassMethods

Defined in:
lib/nihaopay/mixins/queryable.rb

Instance Method Summary collapse

Instance Method Details

#after(time) ⇒ Object



32
33
34
# File 'lib/nihaopay/mixins/queryable.rb', line 32

def after(time)
  q.after(time.strftime(TIME_FORMAT))
end

#before(time) ⇒ Object



28
29
30
# File 'lib/nihaopay/mixins/queryable.rb', line 28

def before(time)
  q.before(time.strftime(TIME_FORMAT))
end

#fetch(options = {}) ⇒ Object



18
19
20
21
22
# File 'lib/nihaopay/mixins/queryable.rb', line 18

def fetch(options = {})
  options[:starting_after] = options.delete(:after).strftime(TIME_FORMAT) if options[:after]
  options[:ending_before] = options.delete(:before).strftime(TIME_FORMAT) if options[:before]
  q.fetch(options)
end

#find(transaction_id) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/nihaopay/mixins/queryable.rb', line 10

def find(transaction_id)
  url = "#{base_url}/transactions/#{transaction_id}"
  response = HTTParty.get(url, headers: request_headers)
  build_from_response!(response)
rescue Nihaopay::TransactionError => e
  raise Nihaopay::TransactionLookUpError, e.message
end

#limit(num) ⇒ Object



24
25
26
# File 'lib/nihaopay/mixins/queryable.rb', line 24

def limit(num)
  q.limit(num)
end