SimpleApiCalls is a type-safe REST client for Android. The library provides the ability to interact with APIs and send network requests with HttpURLConnection.

Overview

SimpleApiCalls


📢 SimpleApiCalls is a type-safe REST client for Android. The library provides the ability to interact with APIs and send network requests with HttpURLConnection.

The advantage of using this library is when you want your application or SDK not to contain many dependencies, you want a smaller size and you want it to be as easy to use as possible. This is a simple example, for more customizations, you can download the source code and customize it based on your requirements. 🎉


Including in your project

License

Gradle

Add below codes to your root build.gradle file.

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

And add a dependency code to your module's build.gradle file.

dependencies {
	        implementation 'com.github.BoyzDroizy:SimpleAPICalls:1.0.0'
	}

Usage

Basic Example (Kotlin)

Firstly, you need to make the setup for SimpleHttpRequest where you have to add the baseURL

  private val httpRequest: SimpleHttpRequest = SimpleHttpRequest.HTTPRequestBuilder()
    .baseUrl("$baseUrl")
    .build()

Here is a basic example with GET method.

  private fun testGetApiCall() {
    val callRequest = Api(
        HTTPMethods.GET,
        "/json/1"
    )

    val requestManager = RequestManager(httpRequest, TestModel::class.java)
    requestManager.request(
        callRequest,
        HttpCallback({ response ->
            binding.responseText.text = "OnSuccess: $response"
        }, { error ->
            binding.responseText.text = "onError: code ${error.code} message ${error.throwable?.message}$"
        })
    )
}

POST method.

 private fun testPOSTApiCall() {
    val callRequest = Api(
        HTTPMethods.POST,
        "/json"
    ).apply {
        setParams(TestModel(12345, "abc-def-ghi"))
    }

    val requestManager = RequestManager(httpRequest, Response::class.java)
    requestManager.request(
        callRequest,
        HttpCallback({ response ->
            binding.responseText.text = "OnSuccess: $response"
        }, { error ->
            binding.responseText.text = "onError: code ${error.code} message ${error.throwable?.message}$"
        })
    )
}

Api class params:

val httpMethod: HTTPMethods // POST, GET, PUT, DELETE
val url: String

Api class methods:

fun <T> setParams(clazz: T) {
    this.params = serialize(clazz)
}

fun setParams(params: JSONObject) {
    this.params = params
}

fun setRequestProperties(requestProperties: HashMap<String, String>) {
    this.requestProperties = requestProperties
}

fun setAuthorization(authorization: String) {
    this.authorization = authorization
}

Find this library useful? ❤️

Be free to use it and enjoy.

License

MIT License

    Copyright (c) 2022 BoyzDroizy

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
You might also like...
Easily upload files (Multipart/Binary/FTP out of the box) in the background with progress notification. Support for persistent upload requests, customizations and custom plugins.
Easily upload files (Multipart/Binary/FTP out of the box) in the background with progress notification. Support for persistent upload requests, customizations and custom plugins.

ℹ️ 🆕 Get started with 4.x 👉 Try it out Get the demo APK Still using 3.x ? It's not maintained or supported. You may have security issues and problem

Handle various HTTP status code by safe api call with Result sealed class

retrofit2-safe-api-call Handle various HTTP status code by safe api call with Result sealed class Library Retrofit2 OkHttp3 Gson Coroutine DI : Koin V

Android library listening network connection state and change of the WiFi signal strength with event bus

NetworkEvents Android library listening network connection state and change of the WiFi signal strength with event bus. It works with any implementati

A library that observes your network status.

A library that observes your network status. Update in progress ... Download Using gradle In your root build.gradle at the end of repositories add all

Note app that allows user to save/edit/delete/search any type of notes and view them in a list

NoteApp Note app that allows user to save/edit/delete/search any type of notes a

Kotlin-echo-client - Echo client using Kotlin with Ktor networking library
Kotlin-echo-client - Echo client using Kotlin with Ktor networking library

Overview This repository contains an echo server implemented with Kotlin and kto

Compact and easy to use, 'all-in-one' android network solution
Compact and easy to use, 'all-in-one' android network solution

Deprecated Unfortunately due to many reasons including maintenance cost, this library is deprecated. I recommend to use Retrofit/OkHttp instead. Curre

Write your asynchronous Network / IO call painlessly in Kotlin !!
Write your asynchronous Network / IO call painlessly in Kotlin !!

Asynkio : Write asynced IO/ Network calls painlessly on android | | | Documentation Write your network requests, IO calls in android with Kotlin seaml

Sandwich was invented for constructing the standardized response interface from the network response
Sandwich was invented for constructing the standardized response interface from the network response

🥪 A lightweight and standardized Android network response interface for handling successful data and error responses.

Releases(1.0.0)
Owner
null
A small Android project to practice executing network requests and parsing the network response

InspirationalQuotesExercise A small Android project to practice executing network requests and parsing the network response This app uses the ZenQuote

Caren 0 Oct 13, 2021
An android asynchronous http client built on top of HttpURLConnection.

Versions 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 Version 1.0.6 Description An android asynchronous http client based on HttpURLConnection. Updates U

David 15 Mar 29, 2020
A type-safe HTTP client for Android and the JVM

Retrofit A type-safe HTTP client for Android and Java. For more information please see the website. Download Download the latest JAR or grab from Mave

Square 40.8k Nov 23, 2022
Kotlin HTTP requests library. Similar to Python requests.

khttp khttp is a simple library for HTTP requests in Kotlin. It functions similarly to Python's requests module. import khttp.get fun main(args: Arra

Anna Clemens 463 Nov 22, 2022
Kotlin-REST-Retrofit - Simple client to consume a REST API with Retrofit using Kotlin

Kotlin REST Retrofit Sencillo cliente para consumir una API REST con Retrofit us

José Luis González Sánchez 5 Nov 4, 2022
Android network client based on Cronet. This library let you easily use QUIC protocol in your Android projects

Android network client based on Cronet. This library let you easily use QUIC protocol in your Android projects

VK.com 104 Nov 8, 2022
Cli lightning network server, based on LDK (rust-lightning). Provides DUMB-RPC interface (telnet friendly).

Hello Lightning Cli lightning network server, based on LDK (rust-lightning). Provides DUMB-RPC interface (telnet friendly). Example: Build it run it:

null 9 Mar 28, 2022
super simple library to manage http requests.

HttpAgent super simple library to manage http requests. Gradle dependencies { implementation 'com.studioidan.httpagent:httpagent:[email protected]' } No

idan ben shimon 32 Oct 24, 2021
Whois4K - A library for who is requests

Whois4K - A library for who is requests

Lyzev 1 Apr 6, 2022
Pluto is a on-device debugger for Android applications, which helps in inspection of HTTP requests/responses, capture Crashes and ANRs and manipulating application data on-the-go.

Pluto Pluto is a on-device debugger for Android applications, which helps in inspection of HTTP requests/responses, capture Crashes and ANRs and manip

Mocklets 8 Aug 22, 2022