package com.banesco.module.service_order_payment_search.domain.dto.request;

import com.banesco.module.instruction.domain.model.Instruction;
import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.*;

import java.util.Map;
import java.util.Objects;

import static java.util.Map.entry;

@Getter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@RegisterForReflection
public class ServiceOrderPaymentSearchRequest {
    @NonNull
    private String customerReferenceFintechId;
    @NonNull
    private String appId;
    @NonNull
    private Instruction procedureRequest;

    public String getId() {
        return getProcedureRequest().getInstructionIdentifier().getIdentification().getIdentifierValue();
    }

    public String getChannelCode() {
        return getProcedureRequest().getInstructionPurposeType().name();
    }

    public String getSignatureIdentifier() {
        return getProcedureRequest().getInstructionDescription();
    }

    public Map<String, String> toQueryString() {
        return Map.ofEntries(
            entry("appId", Objects.toString(getAppId(), "")),
            entry("customerReferenceFintechId", Objects.toString(getCustomerReferenceFintechId(), ""))
        );
    }
}