WooDroid icon indicating copy to clipboard operation
WooDroid copied to clipboard

How should i use it?

Open Alword opened this issue 4 years ago • 2 comments

I already manually add some implementations because of errors

    implementation 'com.github.gilokimu:woodroid:0.2.1'
    implementation 'com.squareup.retrofit2:retrofit:2.6.1'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation "com.google.code.gson:gson:2.8.2"
    implementation 'com.squareup.okhttp3:okhttp:4.1.0'
    implementation 'com.squareup.okio:okio:2.2.2'
    implementation "com.squareup.okhttp3:logging-interceptor:4.1.0"

Did I have to do that?

import me.gilo.woodroid.Woocommerce
import me.gilo.woodroid.models.Product
import retrofit2.*

fun main() {


    val siteUrl = "https://si.te/"
    val ConsumerKey = "ck_key"
    val ConsumerSecret = "cs_secret"
    WooComerceProvider(siteUrl, ConsumerKey, ConsumerSecret).loadProducts()
}

class WooComerceProvider(site: String, key: String, secretKey: String) {

    private val woocommerce = Woocommerce.Builder()
        .setSiteUrl(site)
        .setApiVersion(Woocommerce.API_V3)
        .setConsumerKey(key)
        .setConsumerSecret(secretKey)
        .build()


    fun loadProducts() {
        var products: MutableList<Product> = mutableListOf()

        woocommerce.ProductRepository().products().enqueue(object : Callback<List<Product>> {
            override fun onResponse(call: Call<List<Product>>, response: Response<List<Product>>) {
                val productsResponse = response.body()
                for (product in productsResponse!!) {
                    products.add(product)
                }
            }

            override fun onFailure(call: Call<List<Product>>, t: Throwable) {

            }
        })
    }
}

and there are more errors

Exception in thread "OkHttp Dispatcher" java.lang.RuntimeException: Stub! at org.apache.http.message.BasicNameValuePair.(BasicNameValuePair.java:121) at me.gilo.woodroid.data.auth.AuthIntercepter.getOauthParams(AuthIntercepter.java:90) at me.gilo.woodroid.data.auth.AuthIntercepter.intercept(AuthIntercepter.java:43) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184) at okhttp3.RealCall$AsyncCall.run(RealCall.kt:136) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

Woocommerce.Builder() worked, but the query did not. Sorry, it seems I don't really understand. Could you help me to install/use your package?

Alword avatar Aug 16 '19 15:08 Alword

Are you using a pure kotlin to test or running on android?

gilokimu avatar Aug 23 '19 03:08 gilokimu

I'm create android project but test it in just pure kotlin class.

Alword avatar Aug 23 '19 09:08 Alword