Fixed appendPathSegment and added addParamIf

Summary: Previously appendPathSegment was wrongly implemented.
addParamIf allow to add parameter only if some condition is
true.
Added gradle support

Change-Id: Ib05b3883c29959628efb3a44a181910ee14aa37c