package com.banesco.module.instruction.domain.model;

import com.banesco.common.domain.model.Identifier;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.*;

@Getter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Instruction {
    private InstructionIdentification instructionIdentifier;     // Request JSON: "id"
    private String instructionPurposeType;                       // Request JSON: "channelOrigin" (BOLE)

    public static Instruction fromResource(
        String securityNotificationId,
        String channelCode
    ) {
        return Instruction.builder()
                .instructionIdentifier(
                    InstructionIdentification.builder()
                        .identification(
                            Identifier.builder()
                                .identifierValue(securityNotificationId)
                                .build()
                        )
                        .identificationType(InstructionIdentificationType.INSTRUCTION_NUMBER)
                        .build()
                )
                .instructionPurposeType(channelCode)
                .build();
    }
}
