Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How should i use it? #11

Open
Alword opened this issue Aug 16, 2019 · 2 comments
Open

How should i use it? #11

Alword opened this issue Aug 16, 2019 · 2 comments

Comments

@Alword
Copy link

Alword commented Aug 16, 2019

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?

@gilokimu
Copy link
Owner

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

@Alword
Copy link
Author

Alword commented Aug 23, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants