import { DeviceType, PushType } from '@ucap-webmessenger/core';
import {
  APIRequest,
  APIResponse,
  APIEncoder,
  APIDecoder,
  ParameterUtil
} from '@ucap-webmessenger/api';

export interface TokenUpdateRequest extends APIRequest {
  userSeq: number;
  deviceType: DeviceType;
  token: string;
  mobilePid?: string;
  pushType?: PushType;
}

// tslint:disable-next-line: no-empty-interface
export interface TokenUpdateResponse extends APIResponse {}

const tokenUpdateEncodeMap = {
  userSeq: 'p_user_seq',
  deviceType: 'p_device_type',
  token: 'p_token',
  mobilePid: 'p_mobile_pid',
  pushType: 'p_push_type'
};

export const encodeTokenUpdate: APIEncoder<TokenUpdateRequest> = (
  req: TokenUpdateRequest
) => {
  const extraParams: any = {};

  extraParams.userSeq = String(req.userSeq);

  return ParameterUtil.encode(tokenUpdateEncodeMap, req, extraParams);
};

export const decodeTokenUpdate: APIDecoder<TokenUpdateResponse> = (
  res: any
) => {
  return {} as TokenUpdateResponse;
};
