=begin #Synctera API #
Welcome to the official reference documentation for Synctera APIs. Our APIs are the best way to automate your company's banking needs and are designed to be easy to understand and implement.
We're continuously growing this library and what you see here is just the start, but if you need something specific or have a question, contact us.
The version of the OpenAPI document: 0.60.0 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.5.0 =end require 'date' require 'time' module SyncteraRubySdk # Card status module CardChangeState class << self # List of class defined in oneOf (OpenAPI v3) def openapi_one_of [ :'CardFulfillmentStatus', :'CardPinStatus', :'CardStatus' ] end # Builds the object # @param [Mixed] Data to be matched against the list of oneOf items # @return [Object] Returns the model or the data itself def build(data) # Go through the list of oneOf items and attempt to identify the appropriate one. # Note: # - We do not attempt to check whether exactly one item matches. # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) # due to the way the deserialization is made in the base_object template (it just casts without verifying). # - TODO: scalar values are de facto behaving as if they were nullable. # - TODO: logging when debugging is set. openapi_one_of.each do |klass| begin next if klass == :AnyType # "nullable: true" typed_data = find_and_cast_into_type(klass, data) return typed_data if typed_data rescue # rescue all errors so we keep iterating even if the current item lookup raises end end openapi_one_of.include?(:AnyType) ? data : nil end private SchemaMismatchError = Class.new(StandardError) # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. def find_and_cast_into_type(klass, data) return if data.nil? case klass.to_s when 'Boolean' return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) when 'Float' return data if data.instance_of?(Float) when 'Integer' return data if data.instance_of?(Integer) when 'Time' return Time.parse(data) when 'Date' return Date.parse(data) when 'String' return data if data.instance_of?(String) when 'Object' # "type: object" return data if data.instance_of?(Hash) when /\AArray<(?