All files / client/methods renamefile.js

100% Statements 7/7
100% Branches 0/0
100% Functions 3/3
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21          19x 3x 2x 2x 1x   1x             1x    
/* @flow */
 
import invariant from "invariant";
import type { MethodApi } from "../types";
 
export default ({ client }: MethodApi) => (fileid: number, toname: string): Promise<boolean> => {
  invariant(typeof fileid === "number", "`fileid` must be number.");
  invariant(fileid !== 0, "`fileid` cannot be 0.");
  invariant(toname, "`toname` is required.");
  invariant(toname.length, "`toname` is required.");
 
  return client
    .api("renamefile", {
      params: {
        fileid: fileid,
        toname: toname
      }
    })
    .then(response => response.metadata);
};