Class: Her::Middleware::ParasutParser

Inherits:
DefaultParseJSON
  • Object
show all
Defined in:
lib/her/middleware/parasut_parser.rb

Overview

ParasutParser

Instance Method Summary collapse

Instance Method Details

#parse(body) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/her/middleware/parasut_parser.rb', line 5

def parse(body)
  json = parse_json(body)
  data = json
  # TODO: (dunyakirkali) :transactions exception should be removed
  data = data[:transactions].present? ? data[:transactions] : data if data[:account].blank?
  data = data[:items].present? ? data[:items] : data
  {
    data: data || {},
    errors: json[:errors] || [],
    metadata: json[:meta] || {}
  }
end