// Copyright © 2022 Olo Inc. All rights reserved. // This software is made available under the Olo Pay SDK License (See LICENSE.md file) package com.olopaysdkreactnative.extensions import com.facebook.react.bridge.ReadableMap fun ReadableMap.getBoolean(name: String, defaultValue: Boolean): Boolean { if (!this.hasKey(name)) return defaultValue return this.getBoolean(name) } fun ReadableMap.getString(name: String, defaultValue: String): String { if (!this.hasKey(name)) return defaultValue return this.getString(name) as String } fun ReadableMap.getInt(name: String, defaultValue: Int): Int { return try { this.getInt(name) } catch (e: Exception) { defaultValue } } fun ReadableMap.getNullableDouble(name: String): Double? { return try { this.getDouble(name) } catch (e: Exception) { null } } fun ReadableMap.getNullableString(name: String): String? { return try { this.getString(name) } catch (e: Exception) { null } } fun ReadableMap.getNullableInt(name: String): Int? { return try { this.getInt(name) } catch (e: Exception) { null } }