2020-03-18 17:24:33 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include "v1_token_request_status.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
static v1_token_request_status_t *v1_token_request_status_create_internal(
|
2020-03-18 17:24:33 +08:00
|
|
|
char *expiration_timestamp,
|
|
|
|
|
char *token
|
|
|
|
|
) {
|
|
|
|
|
v1_token_request_status_t *v1_token_request_status_local_var = malloc(sizeof(v1_token_request_status_t));
|
|
|
|
|
if (!v1_token_request_status_local_var) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
v1_token_request_status_local_var->expiration_timestamp = expiration_timestamp;
|
|
|
|
|
v1_token_request_status_local_var->token = token;
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
v1_token_request_status_local_var->_library_owned = 1;
|
2020-03-18 17:24:33 +08:00
|
|
|
return v1_token_request_status_local_var;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
__attribute__((deprecated)) v1_token_request_status_t *v1_token_request_status_create(
|
|
|
|
|
char *expiration_timestamp,
|
|
|
|
|
char *token
|
|
|
|
|
) {
|
|
|
|
|
return v1_token_request_status_create_internal (
|
|
|
|
|
expiration_timestamp,
|
|
|
|
|
token
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
|
|
|
|
|
void v1_token_request_status_free(v1_token_request_status_t *v1_token_request_status) {
|
|
|
|
|
if(NULL == v1_token_request_status){
|
|
|
|
|
return ;
|
|
|
|
|
}
|
2025-02-11 19:36:46 +00:00
|
|
|
if(v1_token_request_status->_library_owned != 1){
|
|
|
|
|
fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "v1_token_request_status_free");
|
|
|
|
|
return ;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
listEntry_t *listEntry;
|
2021-01-05 15:42:34 +08:00
|
|
|
if (v1_token_request_status->expiration_timestamp) {
|
|
|
|
|
free(v1_token_request_status->expiration_timestamp);
|
|
|
|
|
v1_token_request_status->expiration_timestamp = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (v1_token_request_status->token) {
|
|
|
|
|
free(v1_token_request_status->token);
|
|
|
|
|
v1_token_request_status->token = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
free(v1_token_request_status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cJSON *v1_token_request_status_convertToJSON(v1_token_request_status_t *v1_token_request_status) {
|
|
|
|
|
cJSON *item = cJSON_CreateObject();
|
|
|
|
|
|
|
|
|
|
// v1_token_request_status->expiration_timestamp
|
|
|
|
|
if (!v1_token_request_status->expiration_timestamp) {
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
if(cJSON_AddStringToObject(item, "expirationTimestamp", v1_token_request_status->expiration_timestamp) == NULL) {
|
|
|
|
|
goto fail; //Date-Time
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// v1_token_request_status->token
|
|
|
|
|
if (!v1_token_request_status->token) {
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
if(cJSON_AddStringToObject(item, "token", v1_token_request_status->token) == NULL) {
|
|
|
|
|
goto fail; //String
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
fail:
|
|
|
|
|
if (item) {
|
|
|
|
|
cJSON_Delete(item);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
v1_token_request_status_t *v1_token_request_status_parseFromJSON(cJSON *v1_token_request_statusJSON){
|
|
|
|
|
|
|
|
|
|
v1_token_request_status_t *v1_token_request_status_local_var = NULL;
|
|
|
|
|
|
|
|
|
|
// v1_token_request_status->expiration_timestamp
|
|
|
|
|
cJSON *expiration_timestamp = cJSON_GetObjectItemCaseSensitive(v1_token_request_statusJSON, "expirationTimestamp");
|
2025-02-11 19:36:46 +00:00
|
|
|
if (cJSON_IsNull(expiration_timestamp)) {
|
|
|
|
|
expiration_timestamp = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
if (!expiration_timestamp) {
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-11-07 10:45:06 +08:00
|
|
|
if(!cJSON_IsString(expiration_timestamp) && !cJSON_IsNull(expiration_timestamp))
|
2020-03-18 17:24:33 +08:00
|
|
|
{
|
|
|
|
|
goto end; //DateTime
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// v1_token_request_status->token
|
|
|
|
|
cJSON *token = cJSON_GetObjectItemCaseSensitive(v1_token_request_statusJSON, "token");
|
2025-02-11 19:36:46 +00:00
|
|
|
if (cJSON_IsNull(token)) {
|
|
|
|
|
token = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
if (!token) {
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!cJSON_IsString(token))
|
|
|
|
|
{
|
|
|
|
|
goto end; //String
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
v1_token_request_status_local_var = v1_token_request_status_create_internal (
|
2020-03-18 17:24:33 +08:00
|
|
|
strdup(expiration_timestamp->valuestring),
|
|
|
|
|
strdup(token->valuestring)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return v1_token_request_status_local_var;
|
|
|
|
|
end:
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
}
|