Skip to content

Commit

Permalink
* BrandAPIs.java -> get brand by key api #28
Browse files Browse the repository at this point in the history
  • Loading branch information
yamin8000 committed Dec 22, 2021
1 parent 7aa3e23 commit f76141d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions example-kotlin/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ fun main() {
.build()
.createDefaultInstance()

val api = client.retrofit.create(BrandAPIs::class.java).all
val api = client.retrofit.create(BrandAPIs::class.java).get("61b57b85892acc894cd7f02f")
val response = api.execute()
println(response.code())

createBrand(client)
//createBrand(client)

// api.async { response, throwable ->
// println(response?.body()?.first()?.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,37 @@
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;

import java.util.List;

public interface BrandAPIs {

String BRAND = "Brand";

/**
* Get all brands
*
* @return List of brands
*/
@GET(R.ODATA + BRAND)
CallX<List<Brand>> getAll();

/**
* Create a new brand entity
*
* @param brand brand entity
* @return created brand entity
*/
@POST(R.ODATA + BRAND)
CallX<Brand> create(@Body Brand brand);

/**
* Get a brand by id
*
* @param key brand id
* @return List of brands that only contains one brand entity or null if not found
*/
@GET(R.ODATA + BRAND + "/{key}")
CallX<List<Brand>> get(@Path("key") String key);
}

0 comments on commit f76141d

Please sign in to comment.