//
// Copyright 2025 Alibaba Cloud Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef AlibabaCloudRUMBridge_h
#define AlibabaCloudRUMBridge_h

#import <Foundation/Foundation.h>

#ifdef __cplusplus
extern "C" {
#endif

// SDK Initialization and Configuration
void AlibabaCloudRUMSDK_setDebuggable(bool debuggable);
bool AlibabaCloudRUMSDK_start(const char* configAddress, const char* workspace, const char* serviceId);
bool AlibabaCloudRUMSDK_stop(void);
bool AlibabaCloudRUMSDK_isStarted(void);
void AlibabaCloudRUMSDK_setEnvironment(const char* env);
void AlibabaCloudRUMSDK_setAppName(const char* name);
void AlibabaCloudRUMSDK_setAppVersion(const char* version);
void AlibabaCloudRUMSDK_setChannel(const char* channel);
void AlibabaCloudRUMSDK_setUserId(const char* userId);
void AlibabaCloudRUMSDK_setUserName(const char* userName);
const char* AlibabaCloudRUMSDK_deviceId(void);

// RUM Reporting Methods
void AlibabaCloudRUMSDK_reportException(const char* exceptionType, const char* causeBy, const char* errorDump, const char* language);
bool AlibabaCloudRUMSDK_reportCustomResource(const char* type, bool success, const char* url, const char* method,
                                              int statusCode, const char* errorMessage, const char* provider,
                                              void* tracing, void* measuring);
void AlibabaCloudRUMSDK_setCustomEvent(const char* name, const char* type, const char* group,
                                        const char* snapshots, double value, void* info);
void AlibabaCloudRUMSDK_setCustomLog(const char* logInfo, const char* name, const char* type,
                                      const char* snapshots, const char* level, void* info);
void AlibabaCloudRUMSDK_reportView(const char* viewId, int loadTime, bool enter, const char* name,
                                        const char* method, void* map, const char* type);
    
// Helper Functions for Object Creation
void* AlibabaCloudTraceContext_create(const char* traceId, const char* spanId, const char* parentSpanId,
                                       bool sampled, int protocol);
void AlibabaCloudTraceContext_release(void* context);
void* AlibabaCloudResourceMeasuring_create(unsigned long long duration, unsigned long long size,
                                            unsigned long long connectDuration, unsigned long long sslDuration,
                                            unsigned long long dnsDuration, unsigned long long redirectDuration,
                                            unsigned long long firstByteDuration, unsigned long long downloadDuration);
void AlibabaCloudResourceMeasuring_release(void* measuring);
void* NSDictionary_create(void);
void NSDictionary_addString(void* dict, const char* key, const char* value);
void NSDictionary_release(void* dict);

#ifdef __cplusplus
}
#endif

#endif /* AlibabaCloudRUMBridge_h */
