Class: Sumsub::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/sumsub/parser.rb

Class Method Summary collapse

Class Method Details

.parse(json_payload) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/sumsub/parser.rb', line 5

def self.parse(json_payload)
  payload = JSON.parse(json_payload)

  # return unless is an error response
  return payload unless (payload['code'] && payload['description'])

  Sumsub::Struct::ErrorResponse.new(
    description: payload['description'],
    code: payload['code'],
    correlation_id: payload['correlationId'],
    error_code: payload['errorCode'],
    error_name: payload['errorName']
  )
end