#include "ocpp21_datatype.h"

int AbsolutePriceScheduleType_decode(cJSON *object, AbsolutePriceScheduleType_t *value)
{
    if (value)
    {
        memset(value, 0, sizeof(AbsolutePriceScheduleType_t));
        
        if (object)
        {
            sprintf(value->timeAnchor, cJSON_GetStringValue(cJSON_GetObjectItem(object, "timeAnchor")));
            value->priceScheduleID = (int)cJSON_GetNumberValue(cJSON_GetObjectItem(object, "priceScheduleID"));

            if (cJSON_HasObjectItem(object, "priceScheduleDescription"))
            {
                value->priceScheduleDescription_isUsed = 1;
                sprintf(value->priceScheduleDescription, cJSON_GetStringValue(cJSON_GetObjectItem(object, "priceScheduleDescription")));
            }

            if (cJSON_HasObjectItem(object, "currency"))
            {
                value->currency_isUsed = 1;
                sprintf(value->currency, cJSON_GetStringValue(cJSON_GetObjectItem(object, "currency")));
            }

            if (cJSON_HasObjectItem(object, "language"))
            {
                value->language_isUsed = 1;
                sprintf(value->language, cJSON_GetStringValue(cJSON_GetObjectItem(object, "language")));
            }

            if (cJSON_HasObjectItem(object, "priceAlgorithm"))
            {
                value->priceAlgorithm_isUsed = 1;
                sprintf(value->priceAlgorithm, cJSON_GetStringValue(cJSON_GetObjectItem(object, "priceAlgorithm")));
            }

            return 0;
        }
    }
    return -1;
}

