Created
April 25, 2021 19:02
-
-
Save Ochornma/deb87ec166b86c805f0f94f6e7f16825 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface SoftKashApiService { | |
| @GET("admins") | |
| fun getAdminsAsync(): Deferred<GetAdminResponse> | |
| @Multipart | |
| @POST("admins") | |
| fun addAdminsAsync( | |
| @Part("first_name") firstName: RequestBody, | |
| @Part("last_name") lastName: RequestBody, | |
| @Part("email") email: RequestBody, | |
| @Part("phone_number") phoneNumber: RequestBody, | |
| @Part("department") department: RequestBody, | |
| @Part("role_name") roleName: RequestBody, | |
| @Part("staff_id") staffId: RequestBody, | |
| @Part("role_id") roleId: RequestBody, | |
| @Part("password") password: RequestBody | |
| ): Call<AddAdminResponse> | |
| @GET("loans/by_status/{status}") | |
| fun getLoanByStatusAsync(@Path("status") status: String): Call<LoanByStatusResponse> | |
| @GET("loan_products") | |
| fun getLoanProductAsync(): Deferred<LoanProductResponse> | |
| @GET("transactions") | |
| fun getTransactionsAsync(@Query("paginate") paginate: String): Call<TransactionResponse> | |
| @GET("loans") | |
| fun getLoansAsync(@Query("paginate") paginate: String): Call<LoansResponse> | |
| @GET("users") | |
| fun getUsersAsync(@Query("paginate") paginate: String): Call<GetUserResponse> | |
| @GET("users/{user_id}") | |
| fun getUserDetailsAsync(@Path("user_id") userId: Int): Call<UserDetailsResponse> | |
| @GET("user/next_of_kins/{user_id}") | |
| fun getUserNextOfKinAsync(@Path("user_id") userId: Int): Call<NestOfKinResponse> | |
| @GET("employers/user/{user_id}") | |
| fun getUserEmployerDetailAsync(@Path("user_id") userId: Int): Call<EmployerResponse> | |
| @DELETE("business_documents/{id}") | |
| fun deleteDocuments(@Path("id") id: Int): Call<DocumentDeleteResponse> | |
| @GET("repayment_histories") | |
| fun getPaymentHistoryAsync(@Query("paginate") paginate: String): Call<RepaymentHistoryResponse> | |
| @GET("loans/user/{user_id}") | |
| fun getSpecificUserLoans(@Path("user_id") userId: Int): Call<UserDetailLoanResponse> | |
| @GET("user-transactions/{user_id}") | |
| fun getUserTransactionHistory(@Path("user_id") userId: Int, | |
| @Query("paginate") paginate: String | |
| ): Call<UserTransactionResponse> | |
| @Multipart | |
| @POST("loans/reject_or_approve") | |
| fun approveAndReject( | |
| @Part("action") action: RequestBody, | |
| @Part("loan_id") loanId: RequestBody, | |
| @Part("admin_id") adminId: RequestBody, | |
| @Part("user_id") userId: RequestBody | |
| ): Call<ApproveAndRejectLoanResponse> | |
| @Multipart | |
| @POST("loans/disburse_loan") | |
| fun disburseLoan( | |
| @Part("admin_id") adminId: RequestBody, | |
| @Part("user_id") userId: RequestBody, | |
| @Part("loan_id") loanId: RequestBody | |
| ): Call<DisburseLoanResponse> | |
| @Multipart | |
| @POST("admin/login") | |
| fun login( | |
| @Part("email") email: RequestBody, | |
| @Part("password") password: RequestBody | |
| ): Call<LogInResponse> | |
| @POST("disable/admin_users/{id}") | |
| fun blockAdmin(@Path("id") adminId: Int): Call<BlockAdminResponse> | |
| @POST("enable/admin_users/{id}") | |
| fun unblockAdmin(@Path("id") adminId: Int): Call<BlockAdminResponse> | |
| @Multipart | |
| @POST("admin_send_otp") | |
| fun sendOtp( | |
| @Part("phone_number") phoneNumber: RequestBody | |
| ): Call<OtpResponse> | |
| @Multipart | |
| @POST("admin/password/forgot/{admin_id}") | |
| fun forgotPassword( | |
| @Path("admin_id") adminId: Int, | |
| @Part("token") token: RequestBody, | |
| @Part("new_password")newPassword: RequestBody, | |
| @Part("confirm_new_password") confirmPassword: RequestBody | |
| ): Call<ForgotPasswordResponse> | |
| @Multipart | |
| @POST("admin/password/reset/{admin_id}") | |
| fun changePassword( | |
| @Path("admin_id") adminId: Int, | |
| @Part("old_password") oldPassword: RequestBody, | |
| @Part("new_password") newPassword: RequestBody, | |
| @Part("c_new_password") confirmPassword: RequestBody | |
| ): Call<ResetPasswordResponse> | |
| @GET("disable/user/{user_id}") | |
| fun blockUser(@Path("user_id") userId: Int): Call<BlockUserResponse> | |
| @GET("enable/users/{user_id}") | |
| fun unBlockUser(@Path("user_id") userId: Int): Call<BlockUserResponse> | |
| @GET("all-system-analysis") | |
| fun getSystemAnalysis(): Call<SystemAnalysisResponse> | |
| //for search | |
| @POST("search/users") | |
| fun searchUsers(@Query("paginate") paginate: String, | |
| @Query("words") words: String | |
| ): Call<SearchUserResponse> | |
| @POST("search-loans") | |
| fun searchLoans(@Query("paginate") paginate: String, | |
| @Query("words") words: String | |
| ): Call<LoansResponse> | |
| @POST("search-transactions") | |
| fun searchTransaction( | |
| @Query("paginate") paginate: String, | |
| @Query("words") words: String | |
| ): Call<TransactionResponse> | |
| @GET("loans") | |
| fun searchLoansByDate(@Query("paginate") paginate: String, | |
| @Query("from") from: String, | |
| @Query("to") to: String | |
| ): Call<LoansResponse> | |
| @GET("transactions") | |
| fun searchTransactionsByDate(@Query("paginate") paginate: String, | |
| @Query("from") from: String, | |
| @Query("to") to: String | |
| ): Call<TransactionResponse> | |
| @Multipart | |
| @POST("loan_products") | |
| fun addLoanProduct( | |
| @Part("name") productName: RequestBody, | |
| @Part("min_amount") minAmount: RequestBody, | |
| @Part("max_amount") maxAmount: RequestBody, | |
| @Part("penalty") penalty: RequestBody, | |
| @Part("tenure_type") tenureType: RequestBody, | |
| @Part("min_credit_score") minCreditSCore: RequestBody, | |
| @Part("min_kyc_level") minKycLevel: RequestBody, | |
| @Part("process_fees") processFees: RequestBody, | |
| @Part("system_can_approved") systemCanApprove: RequestBody, | |
| @Part("max_tenure") maxTenure: RequestBody, | |
| @Part("interest_rate") interestRate: RequestBody, | |
| @Part("interest_rate_type") interestRateType: RequestBody, | |
| @Part("loan_type") loanType: RequestBody | |
| ): Call<AddLoanProductResponse> | |
| //add items | |
| @GET("type_of_businesses") | |
| fun getTypeOfBusiness(): Call<TypeOfBusinessResponse> | |
| @Multipart | |
| @POST("type_of_businesses") | |
| fun addTypeOfBusiness( | |
| @Part("name") name: RequestBody, | |
| @Part("description") desc: RequestBody | |
| ): Call<AddTypeOfBusinessResponse> | |
| @Multipart | |
| @POST("reasons") | |
| fun addReasons( | |
| @Part("name") name: RequestBody, | |
| @Part("description") desc: RequestBody | |
| ): Call<AddReasonsRespose> | |
| @DELETE("type_of_businesses/{id}") | |
| fun deleteTypeOfBusiness(@Path("id") id: Int): Call<DeleteTypeOfBusinessResponse> | |
| @GET("reasons") | |
| fun getReasonForLoan(): Call<ReasonForLoanResponse> | |
| @DELETE("reasons/{id}") | |
| fun deleteReasonForLoan(@Path("id") id: Int): Call<DeleteTypeOfBusinessResponse> | |
| @DELETE("loan_products/{id}") | |
| fun deleteLoanProduct(@Path("id") id: Int): Call<DeleteLoanProductResponse> | |
| @GET("roles") | |
| fun getRoles(): Call<GetRolesResponse> | |
| @Multipart | |
| @POST("roles") | |
| fun addRoles( | |
| @Part("name") name: RequestBody, | |
| @Part("description") desc: RequestBody | |
| ): Call<AddRolesResponse> | |
| @DELETE("roles/{id}") | |
| fun deleteRoles(@Path("id")id: Int): Call<DeleteRolesResponse> | |
| //bureau | |
| @POST("check_credit_score/{user_id}") | |
| fun getBureau(@Path("user_id") userId: Int): Call<BureauResponse> | |
| //login otp | |
| @Multipart | |
| @POST("verify_token/admin/login") | |
| fun logInOtp(@Part("token") token: RequestBody): Call<LoginOtpResponse> | |
| //get unverifed bvn | |
| @GET("") | |
| fun getUnverifiedBVN(): Call<UnverifiedResponse> | |
| @Multipart | |
| @POST("") | |
| fun verifyBVN(@Part("user_id")userId:RequestBody, | |
| @Path("admin_id") adminId: RequestBody) : Call<VerifyResponse> | |
| companion object { | |
| operator fun invoke( | |
| connectivityInterceptor: ConnectivityInterceptor | |
| ):SoftKashApiService{ | |
| val httpLoggingInterceptor = HttpLoggingInterceptor() | |
| httpLoggingInterceptor.level = HttpLoggingInterceptor.Level.BASIC | |
| val client = OkHttpClient.Builder().addInterceptor(object : Interceptor { | |
| @Throws(IOException::class) | |
| override fun intercept(chain: Interceptor.Chain): Response { | |
| val sPref = SoftKashApplication.ApplicationContext.getSharedPreferences("identifier", Context.MODE_PRIVATE) | |
| val token = sPref.getString(Constants.TOKEN, null) | |
| val newRequest: Request = chain.request().newBuilder() | |
| .addHeader("Authorization", "Bearer $token") | |
| .addHeader("Accept", "application/json") | |
| .build() | |
| val response = chain.proceed(newRequest) | |
| if (response.code == 401) { | |
| Log.d("code", "${response.code}") | |
| } | |
| return response | |
| } | |
| }).readTimeout(5, TimeUnit.MINUTES) | |
| .connectTimeout(5, TimeUnit.MINUTES) | |
| .addInterceptor(connectivityInterceptor) | |
| .build() | |
| return Retrofit.Builder() | |
| .client(client) | |
| .baseUrl(API) | |
| .addCallAdapterFactory(CoroutineCallAdapterFactory()) | |
| .addConverterFactory(GsonConverterFactory.create()) | |
| .build() | |
| .create(SoftKashApiService::class.java) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment