2021-07-07 08:32:55 +00:00
# include <stdlib.h>
# include <string.h>
# include <stdio.h>
# include "downlink_data_notification_control_rm.h"
OpenAPI_downlink_data_notification_control_rm_t * OpenAPI_downlink_data_notification_control_rm_create (
2023-10-05 11:39:14 +00:00
bool is_notif_ctrl_inds_null ,
2021-07-07 08:32:55 +00:00
OpenAPI_list_t * notif_ctrl_inds ,
2023-10-05 11:39:14 +00:00
bool is_types_of_notif_null ,
2021-07-07 08:32:55 +00:00
OpenAPI_list_t * types_of_notif
)
{
2022-01-03 23:29:18 +00:00
OpenAPI_downlink_data_notification_control_rm_t * downlink_data_notification_control_rm_local_var = ogs_malloc ( sizeof ( OpenAPI_downlink_data_notification_control_rm_t ) ) ;
ogs_assert ( downlink_data_notification_control_rm_local_var ) ;
2023-10-05 11:39:14 +00:00
downlink_data_notification_control_rm_local_var - > is_notif_ctrl_inds_null = is_notif_ctrl_inds_null ;
2021-07-07 08:32:55 +00:00
downlink_data_notification_control_rm_local_var - > notif_ctrl_inds = notif_ctrl_inds ;
2023-10-05 11:39:14 +00:00
downlink_data_notification_control_rm_local_var - > is_types_of_notif_null = is_types_of_notif_null ;
2021-07-07 08:32:55 +00:00
downlink_data_notification_control_rm_local_var - > types_of_notif = types_of_notif ;
return downlink_data_notification_control_rm_local_var ;
}
void OpenAPI_downlink_data_notification_control_rm_free ( OpenAPI_downlink_data_notification_control_rm_t * downlink_data_notification_control_rm )
{
2023-03-01 08:50:25 +00:00
OpenAPI_lnode_t * node = NULL ;
2021-07-07 08:32:55 +00:00
if ( NULL = = downlink_data_notification_control_rm ) {
return ;
}
2023-03-01 08:50:25 +00:00
if ( downlink_data_notification_control_rm - > notif_ctrl_inds ) {
OpenAPI_list_free ( downlink_data_notification_control_rm - > notif_ctrl_inds ) ;
downlink_data_notification_control_rm - > notif_ctrl_inds = NULL ;
}
if ( downlink_data_notification_control_rm - > types_of_notif ) {
OpenAPI_list_free ( downlink_data_notification_control_rm - > types_of_notif ) ;
downlink_data_notification_control_rm - > types_of_notif = NULL ;
}
2021-07-07 08:32:55 +00:00
ogs_free ( downlink_data_notification_control_rm ) ;
}
cJSON * OpenAPI_downlink_data_notification_control_rm_convertToJSON ( OpenAPI_downlink_data_notification_control_rm_t * downlink_data_notification_control_rm )
{
cJSON * item = NULL ;
2023-03-01 08:50:25 +00:00
OpenAPI_lnode_t * node = NULL ;
2021-07-07 08:32:55 +00:00
if ( downlink_data_notification_control_rm = = NULL ) {
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_convertToJSON() failed [DownlinkDataNotificationControlRm] " ) ;
return NULL ;
}
item = cJSON_CreateObject ( ) ;
2023-03-01 08:50:25 +00:00
if ( downlink_data_notification_control_rm - > notif_ctrl_inds ! = OpenAPI_notification_control_indication_NULL ) {
cJSON * notif_ctrl_indsList = cJSON_AddArrayToObject ( item , " notifCtrlInds " ) ;
if ( notif_ctrl_indsList = = NULL ) {
2021-07-07 08:32:55 +00:00
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_convertToJSON() failed [notif_ctrl_inds] " ) ;
goto end ;
}
2023-03-01 08:50:25 +00:00
OpenAPI_list_for_each ( downlink_data_notification_control_rm - > notif_ctrl_inds , node ) {
if ( cJSON_AddStringToObject ( notif_ctrl_indsList , " " , OpenAPI_notification_control_indication_ToString ( ( intptr_t ) node - > data ) ) = = NULL ) {
2021-07-07 08:32:55 +00:00
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_convertToJSON() failed [notif_ctrl_inds] " ) ;
goto end ;
}
}
2023-10-05 11:39:14 +00:00
} else if ( downlink_data_notification_control_rm - > is_notif_ctrl_inds_null ) {
if ( cJSON_AddNullToObject ( item , " notifCtrlInds " ) = = NULL ) {
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_convertToJSON() failed [notif_ctrl_inds] " ) ;
goto end ;
}
2021-07-07 08:32:55 +00:00
}
2023-03-01 08:50:25 +00:00
if ( downlink_data_notification_control_rm - > types_of_notif ! = OpenAPI_dl_data_delivery_status_NULL ) {
cJSON * types_of_notifList = cJSON_AddArrayToObject ( item , " typesOfNotif " ) ;
if ( types_of_notifList = = NULL ) {
2021-07-07 08:32:55 +00:00
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_convertToJSON() failed [types_of_notif] " ) ;
goto end ;
}
2023-03-01 08:50:25 +00:00
OpenAPI_list_for_each ( downlink_data_notification_control_rm - > types_of_notif , node ) {
if ( cJSON_AddStringToObject ( types_of_notifList , " " , OpenAPI_dl_data_delivery_status_ToString ( ( intptr_t ) node - > data ) ) = = NULL ) {
2021-07-07 08:32:55 +00:00
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_convertToJSON() failed [types_of_notif] " ) ;
goto end ;
}
}
2023-10-05 11:39:14 +00:00
} else if ( downlink_data_notification_control_rm - > is_types_of_notif_null ) {
if ( cJSON_AddNullToObject ( item , " typesOfNotif " ) = = NULL ) {
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_convertToJSON() failed [types_of_notif] " ) ;
goto end ;
}
2021-07-07 08:32:55 +00:00
}
end :
return item ;
}
OpenAPI_downlink_data_notification_control_rm_t * OpenAPI_downlink_data_notification_control_rm_parseFromJSON ( cJSON * downlink_data_notification_control_rmJSON )
{
OpenAPI_downlink_data_notification_control_rm_t * downlink_data_notification_control_rm_local_var = NULL ;
2023-03-01 08:50:25 +00:00
OpenAPI_lnode_t * node = NULL ;
cJSON * notif_ctrl_inds = NULL ;
OpenAPI_list_t * notif_ctrl_indsList = NULL ;
cJSON * types_of_notif = NULL ;
OpenAPI_list_t * types_of_notifList = NULL ;
notif_ctrl_inds = cJSON_GetObjectItemCaseSensitive ( downlink_data_notification_control_rmJSON , " notifCtrlInds " ) ;
2021-07-16 08:02:33 +00:00
if ( notif_ctrl_inds ) {
2023-10-05 11:39:14 +00:00
if ( ! cJSON_IsNull ( notif_ctrl_inds ) ) {
2023-03-01 08:50:25 +00:00
cJSON * notif_ctrl_inds_local = NULL ;
if ( ! cJSON_IsArray ( notif_ctrl_inds ) ) {
2021-07-07 08:32:55 +00:00
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_parseFromJSON() failed [notif_ctrl_inds] " ) ;
goto end ;
}
2023-03-01 08:50:25 +00:00
notif_ctrl_indsList = OpenAPI_list_create ( ) ;
2021-07-07 08:32:55 +00:00
2023-03-01 08:50:25 +00:00
cJSON_ArrayForEach ( notif_ctrl_inds_local , notif_ctrl_inds ) {
2023-09-24 00:54:53 +00:00
OpenAPI_notification_control_indication_e localEnum = OpenAPI_notification_control_indication_NULL ;
2023-03-01 08:50:25 +00:00
if ( ! cJSON_IsString ( notif_ctrl_inds_local ) ) {
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_parseFromJSON() failed [notif_ctrl_inds] " ) ;
goto end ;
}
2023-09-24 00:54:53 +00:00
localEnum = OpenAPI_notification_control_indication_FromString ( notif_ctrl_inds_local - > valuestring ) ;
if ( ! localEnum ) {
2023-10-26 13:44:51 +00:00
ogs_info ( " Enum value \" %s \" for field \" notif_ctrl_inds \" is not supported. Ignoring it ... " ,
notif_ctrl_inds_local - > valuestring ) ;
} else {
OpenAPI_list_add ( notif_ctrl_indsList , ( void * ) localEnum ) ;
2023-09-24 00:54:53 +00:00
}
2023-10-26 13:44:51 +00:00
}
if ( notif_ctrl_indsList - > count = = 0 ) {
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_parseFromJSON() failed: Expected notif_ctrl_indsList to not be empty (after ignoring unsupported enum values). " ) ;
goto end ;
2023-03-01 08:50:25 +00:00
}
2021-07-07 08:32:55 +00:00
}
2023-10-05 11:39:14 +00:00
}
2021-07-07 08:32:55 +00:00
2023-03-01 08:50:25 +00:00
types_of_notif = cJSON_GetObjectItemCaseSensitive ( downlink_data_notification_control_rmJSON , " typesOfNotif " ) ;
if ( types_of_notif ) {
2023-10-05 11:39:14 +00:00
if ( ! cJSON_IsNull ( types_of_notif ) ) {
2023-03-01 08:50:25 +00:00
cJSON * types_of_notif_local = NULL ;
if ( ! cJSON_IsArray ( types_of_notif ) ) {
2021-07-07 08:32:55 +00:00
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_parseFromJSON() failed [types_of_notif] " ) ;
goto end ;
}
2023-03-01 08:50:25 +00:00
types_of_notifList = OpenAPI_list_create ( ) ;
cJSON_ArrayForEach ( types_of_notif_local , types_of_notif ) {
2023-09-24 00:54:53 +00:00
OpenAPI_dl_data_delivery_status_e localEnum = OpenAPI_dl_data_delivery_status_NULL ;
2023-03-01 08:50:25 +00:00
if ( ! cJSON_IsString ( types_of_notif_local ) ) {
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_parseFromJSON() failed [types_of_notif] " ) ;
goto end ;
}
2023-09-24 00:54:53 +00:00
localEnum = OpenAPI_dl_data_delivery_status_FromString ( types_of_notif_local - > valuestring ) ;
if ( ! localEnum ) {
2023-10-26 13:44:51 +00:00
ogs_info ( " Enum value \" %s \" for field \" types_of_notif \" is not supported. Ignoring it ... " ,
types_of_notif_local - > valuestring ) ;
} else {
OpenAPI_list_add ( types_of_notifList , ( void * ) localEnum ) ;
2023-09-24 00:54:53 +00:00
}
2023-10-26 13:44:51 +00:00
}
if ( types_of_notifList - > count = = 0 ) {
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_parseFromJSON() failed: Expected types_of_notifList to not be empty (after ignoring unsupported enum values). " ) ;
goto end ;
2023-03-01 08:50:25 +00:00
}
2021-07-08 06:00:59 +00:00
}
2023-10-05 11:39:14 +00:00
}
2021-07-07 08:32:55 +00:00
downlink_data_notification_control_rm_local_var = OpenAPI_downlink_data_notification_control_rm_create (
2023-10-05 11:39:14 +00:00
notif_ctrl_inds & & cJSON_IsNull ( notif_ctrl_inds ) ? true : false ,
2021-07-07 08:32:55 +00:00
notif_ctrl_inds ? notif_ctrl_indsList : NULL ,
2023-10-05 11:39:14 +00:00
types_of_notif & & cJSON_IsNull ( types_of_notif ) ? true : false ,
2021-07-07 08:32:55 +00:00
types_of_notif ? types_of_notifList : NULL
) ;
return downlink_data_notification_control_rm_local_var ;
end :
2023-03-01 08:50:25 +00:00
if ( notif_ctrl_indsList ) {
OpenAPI_list_free ( notif_ctrl_indsList ) ;
notif_ctrl_indsList = NULL ;
}
if ( types_of_notifList ) {
OpenAPI_list_free ( types_of_notifList ) ;
types_of_notifList = NULL ;
}
2021-07-07 08:32:55 +00:00
return NULL ;
}
OpenAPI_downlink_data_notification_control_rm_t * OpenAPI_downlink_data_notification_control_rm_copy ( OpenAPI_downlink_data_notification_control_rm_t * dst , OpenAPI_downlink_data_notification_control_rm_t * src )
{
cJSON * item = NULL ;
char * content = NULL ;
ogs_assert ( src ) ;
item = OpenAPI_downlink_data_notification_control_rm_convertToJSON ( src ) ;
if ( ! item ) {
ogs_error ( " OpenAPI_downlink_data_notification_control_rm_convertToJSON() failed " ) ;
return NULL ;
}
content = cJSON_Print ( item ) ;
cJSON_Delete ( item ) ;
if ( ! content ) {
ogs_error ( " cJSON_Print() failed " ) ;
return NULL ;
}
item = cJSON_Parse ( content ) ;
ogs_free ( content ) ;
if ( ! item ) {
ogs_error ( " cJSON_Parse() failed " ) ;
return NULL ;
}
OpenAPI_downlink_data_notification_control_rm_free ( dst ) ;
dst = OpenAPI_downlink_data_notification_control_rm_parseFromJSON ( item ) ;
cJSON_Delete ( item ) ;
return dst ;
}