NetworkSDK is a lightweight Android SDK for making HTTP requests easily in your Android applications.
To integrate NetworkSDK into your Android project, follow these steps:
-
Open your root
build.gradle
file and add the Jitpack repository:dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { mavenCentral() maven { url 'https://jitpack.io' } } }
-
Then, add the dependency to your app's
build.gradle
file:dependencies { implementation 'com.github.amanjn38:NetworkSDK:1.0' }
-
Add the Jitpack repository to your
pom.xml
file:<repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories>
-
Then, add the dependency to your
pom.xml
file:<dependency> <groupId>com.github.amanjn38</groupId> <artifactId>NetworkSDK</artifactId> <version>1.0</version> </dependency>
To use the NetworkSDK in your Android app, you can call the executeRequest
function provided by the SDK.
private suspend fun executeRequest(
url: String,
endpoint: String,
queryMap: Map<String, String>? = null,
headers: Map<String, String>
): Resource<Response> {
return try {
val result = requestViewModel.executeRequest(url, endpoint, METHOD_NAME, queryMap, headers, body)
result
} catch (e: Exception) {
Resource.Error("An error occurred: ${e.message}", null)
}
}
Function Parameters
url: The base URL for the HTTP request.
endpoint: The endpoint to hit.
queryMap (optional): A map containing query parameters.
headers: A map containing HTTP headers