Skip to content

Instantly share code, notes, and snippets.

View happysingh23828's full-sized avatar
🎯
Focusing

Happy Singh happysingh23828

🎯
Focusing
View GitHub Profile
class CurlInterceptor extends Interceptor {
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
try {
final qp = options.queryParameters;
final h = options.headers;
final d = options.data;
final curl =
'curl -X ${options.method} \'${options.baseUrl}${options.path}' +
(qp.length != 0 ? qp.keys.fold('', (value, key) => '$value${value.length == 0 ? '?' : '&'}$key=${qp[key]}\'') : '\'') +
/**
Usage for extensions.
Initialize Moshi in your Converter class
*/
private val moshi: Moshi = Moshi.Builder()
.add(KotlinJsonAdapterFactory())
.build()
/**
* [Moshi] extension to transform a [List] to Json