#import <Foundation/Foundation.h>

// C function declarations to be called from Unity
#ifdef __cplusplus
extern "C" {
#endif

/// OAuth success callback type
typedef void (*CROSSxOAuthSuccessCallback)(const char* jsonData);

/// OAuth failure callback type
typedef void (*CROSSxOAuthErrorCallback)(const char* errorCode, const char* errorMessage);

/// Start the OAuth flow
///
/// @param authUrl Authentication start URL (e.g. "https://oauth.example.com/google?redirectScheme=myapp")
/// @param callbackScheme Callback URL scheme (e.g. "myapp")
/// @param prefersEphemeral Whether to use an ephemeral session (1: true, 0: false)
/// @param onSuccess Success callback
/// @param onError Error callback
void CROSSxOAuth_StartFlow(
    const char* authUrl,
    const char* callbackScheme,
    int prefersEphemeral,
    CROSSxOAuthSuccessCallback onSuccess,
    CROSSxOAuthErrorCallback onError
);

/// Cancel the OAuth flow
void CROSSxOAuth_CancelFlow(void);

/// Forwards a Unity Deep Link to the SDK (calls the SDK's handleCallbackURL)
/// @param url Deep Link URL
void CROSSxOAuth_HandleDeepLink(const char* url);

#ifdef __cplusplus
}
#endif
