package com.sibilantsolutions.grison.rx;

import static com.sibilantsolutions.grison.driver.foscam.dto.VerifyReqTextDto.PASSWORD_LEN;
import static com.sibilantsolutions.grison.driver.foscam.dto.VerifyReqTextDto.USER_LEN;

import java.nio.charset.StandardCharsets;

import com.google.common.base.Strings;
import com.sibilantsolutions.grison.driver.foscam.dto.KeepAliveOperationTextDto;
import com.sibilantsolutions.grison.driver.foscam.dto.LoginReqOperationTextDto;
import com.sibilantsolutions.grison.driver.foscam.dto.VerifyReqTextDto;
import com.sibilantsolutions.grison.driver.foscam.dto.VideoEndTextDto;
import com.sibilantsolutions.grison.driver.foscam.dto.VideoStartReqTextDto;
import io.reactivex.Flowable;

public class OpClientImpl implements OpClient {

    private final ChannelSender channelSender;

    public OpClientImpl(ChannelSender channelSender) {
        this.channelSender = channelSender;
    }

    @Override
    public Flowable<ChannelSendEvent> login() {

        final LoginReqOperationTextDto text = LoginReqOperationTextDto.builder().build();

        return channelSender.doSend(text);
    }

    @Override
    public Flowable<ChannelSendEvent> ping() {

        final KeepAliveOperationTextDto text = KeepAliveOperationTextDto.builder().build();

        return channelSender.doSend(text);
    }

    @Override
    public Flowable<ChannelSendEvent> verify(String username, String password) {

        final VerifyReqTextDto text = VerifyReqTextDto.builder()
                .user(Strings.padEnd(username, USER_LEN, (char) 0).getBytes(StandardCharsets.ISO_8859_1))
                .password(Strings.padEnd(password, PASSWORD_LEN, (char) 0).getBytes(StandardCharsets.ISO_8859_1))
                .build();

        return channelSender.doSend(text);
    }

    @Override
    public Flowable<ChannelSendEvent> videoStart() {

        final VideoStartReqTextDto text = VideoStartReqTextDto.builder().build();

        return channelSender.doSend(text);
    }

    @Override
    public Flowable<ChannelSendEvent> videoEnd() {

        final VideoEndTextDto text = VideoEndTextDto.builder().build();

        return channelSender.doSend(text);
    }

}

@@ -39,271 +39,8 @@
 x;%0A%0A
-import static com.sibilantsolutions.grison.driver.foscam.dto.VerifyReqTextDto.PASSWORD_LEN;%0Aimport static com.sibilantsolutions.grison.driver.foscam.dto.VerifyReqTextDto.USER_LEN;%0A%0Aimport java.nio.charset.StandardCharsets;%0A%0Aimport com.google.common.base.Strings;%0A
 impo
@@ -108,32 +108,32 @@
 erationTextDto;%0A
+
 import com.sibil
@@ -411,24 +411,172 @@
 ReqTextDto;%0A
+import com.sibilantsolutions.grison.driver.foscam.entity.VerifyReqTextEntity;%0Aimport com.sibilantsolutions.grison.driver.foscam.mapper.EntityToDto;%0A
 import io.re
@@ -1340,17 +1340,29 @@
  text = 
-V
+EntityToDto.v
 erifyReq
@@ -1361,32 +1361,58 @@
 erifyReqTextDto.
+apply(VerifyReqTextEntity.
 builder()%0A      
@@ -1430,205 +1430,57 @@
 user
-(Strings.padEnd(username, USER_LEN, (char) 0).getBytes(StandardCharsets.ISO_8859_1))%0A                .password(Strings.padEnd(password, PASSWORD_LEN, (char) 0).getBytes(StandardCharsets.ISO_8859_1)
+name(username)%0A                .password(password
 )%0A  
@@ -1493,32 +1493,33 @@
         .build()
+)
 ;%0A%0A        retur

Use VerifyReqTextEntity on the send side.