Skip to content

tinglesoftware/kotlin-apiclients

Repository files navigation

Tingle Api Client: Android

This is an abstract API client library build on top of Okhttp library to ease the process of making various server request.

Assumptions

  • Knowledge on development of android applications.
  • Knowledge on how to compile android libraries.

Features

  • Making POST requests.
  • Making GET requests.
  • Making PUT requests.
  • Making DELETE requests.
  • Making PATCH requests.

Installation

Requirements

Configuration

Add abstractions to your build.gradle dependencies.

implementation 'software.tingle:abstractions:VERSION_NUMBER'

Examples

Configuration

class SampleApiClient: AbstractApiClient(EmptyAuthenticationHeaderProvider()) {
    
    // Get a URL 
    @Throws(IOException::class)
    fun getFromRequest(): ResourceResponse<MyClass> {
        val builder = Request.Builder()
            .url(url)
            .get()

        return execute(builder, MyClass::class.java)
    }

    // Post a URL 
    @Throws(IOException::class)
    fun postToServer(request: MyClass): ResourceResponse<MyClass> {
        val builder = Request.Builder()
            .url(url)
            .post(makeJson(request).toRequestBody(MEDIA_TYPE_JSON))

        return execute(builder, MyClass::class.java)
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages