Module: AffiliateWindow::Parser

Defined in:
lib/affiliate_window/parser.rb

Class Method Summary collapse

Class Method Details

.parse(response, method) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/affiliate_window/parser.rb', line 3

def self.parse(response, method)
  body = response.body
  root = body.fetch(:"#{method}_response")

  results = root.fetch(:"#{method}_return")
  pagination = root.fetch(:"#{method}_count_return", nil)

  if pagination
    { pagination: pagination, results: results }
  else
    results
  end
end

.parse_quota(response) ⇒ Object



17
18
19
20
21
22
# File 'lib/affiliate_window/parser.rb', line 17

def self.parse_quota(response)
  header = response.header
  quota = header.fetch(:get_quota_response)

  Integer(quota)
end