Skip to content

Commit

Permalink
* BrandAPIs.java added create entity api
Browse files Browse the repository at this point in the history
  • Loading branch information
yamin8000 committed Dec 21, 2021
1 parent 8bc9cdb commit a7d65cf
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
42 changes: 38 additions & 4 deletions example-kotlin/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import io.githhub.TradersTeam.grand_node_java_client.models.Brand
import io.githhub.TradersTeam.grand_node_java_client.network.GrandNodeClient
import io.githhub.TradersTeam.grand_node_java_client.network.apis.BrandAPIs
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.create

fun main() {
val client = GrandNodeClient.builder()
Expand All @@ -12,10 +14,12 @@ fun main() {

val api = client.retrofit.create(BrandAPIs::class.java).all

api.async { response, throwable ->
println(response?.body()?.first()?.name)
return@async true
}
createBrand(client)

// api.async { response, throwable ->
// println(response?.body()?.first()?.name)
// return@async true
// }

// api.enqueueAsync { response, throwable ->
// if (throwable != null) {
Expand Down Expand Up @@ -51,4 +55,34 @@ fun main() {
// }, {
// val message = it.message
// })
}

private fun createBrand(client: GrandNodeClient) {
val brand = Brand.builder()
.Name("Brand")
.SeName("Brand")
.Description("Brand")
.BottomDescription("Brand")
.BrandLayoutId(null)
.MetaKeywords("Brand")
.MetaDescription("Brand")
.MetaTitle("Brand")
.PictureId(null)
.PageSize(0)
.AllowCustomersToSelectPageSize(false)
.PageSizeOptions("Brand")
.ShowOnHomePage(false)
.IncludeInTopMenu(false)
.Icon(null)
.Published(true)
.ExternalId("")
.build()

client.retrofit.create<BrandAPIs>().create(brand).atomicAsync { response, throwable ->
if (response != null && throwable == null) {
println(response.body()?.id)
} else {
println(throwable)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private CallXAdapterFactory getCallXAdapterFactory() {
return chain.proceed(requestBuilder.build());
}

public <T> T create(Class<T> modelClass) {
return retrofit.create(modelClass);
public <T> T create(Class<T> serviceClass) {
return retrofit.create(serviceClass);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

import io.githhub.TradersTeam.grand_node_java_client.models.Brand;
import io.githhub.TradersTeam.grand_node_java_client.network.CallX;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;

import java.util.List;

public interface BrandAPIs {

@GET(R.ODATA + "Brand")
CallX<List<Brand>> getAll();

@POST(R.ODATA + "Brand")
CallX<Brand> create(@Body Brand brand);
}

0 comments on commit a7d65cf

Please sign in to comment.