Class: SlidePay::Report

Inherits:
Hash
  • Object
show all
Defined in:
lib/slidepay/reports/report.rb

Direct Known Subclasses

PostReport, PutReport

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(search_params = {}) ⇒ Report

Returns a new instance of Report.



9
10
11
12
13
14
15
16
17
18
# File 'lib/slidepay/reports/report.rb', line 9

def initialize(search_params={})
  # Initialize search_filter_arrays
  if search_params.is_a? Hash
    @sfa = [search_params]
  elsif search_params.is_a? Array
    @sfa = search_params
  else
    @sfa = []
  end
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



7
8
9
# File 'lib/slidepay/reports/report.rb', line 7

def api_key
  @api_key
end

#endpointObject

Returns the value of attribute endpoint.



7
8
9
# File 'lib/slidepay/reports/report.rb', line 7

def endpoint
  @endpoint
end

#report_typeObject

Returns the value of attribute report_type.



5
6
7
# File 'lib/slidepay/reports/report.rb', line 5

def report_type
  @report_type
end

#sfaObject

Returns the value of attribute sfa.



3
4
5
# File 'lib/slidepay/reports/report.rb', line 3

def sfa
  @sfa
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/slidepay/reports/report.rb', line 7

def token
  @token
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/slidepay/reports/report.rb', line 4

def url
  @url
end

Instance Method Details

#retrieve(options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/slidepay/reports/report.rb', line 20

def retrieve(options={})
  token = @token || options[:token]
  api_key = @api_key || options[:api_key]
  endpoint = @endpoint || options[:endpoint]

  if @report_type == :put
    response = SlidePay.put(path: @url, data: data_from_sfa, token: token, api_key: api_key, endpoint: endpoint)
  elsif @report_type == :post
    response = SlidePay.post(path: @url, data: data_from_sfa, token: token, api_key: api_key, endpoint: endpoint)
  end

  if response.was_successful?
    populate_from_response(response)
  end
end