All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.vtex.Main Maven / Gradle / Ivy

There is a newer version: 0.3.0
Show newest version
package br.com.vtex;

/**
 * Created by felipe-moraais on 10/02/15.
 */

import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.async.Callback;
import com.mashape.unirest.http.exceptions.UnirestException;

public class Main {
    // ESTE MÉTODO MAIN SERVE PARA TESTES
    public static void main(String[] args){
        // INSTANCIA O SDK
        // TODO -> TRANSFORMAR O VtexSDK CLASSE EM UM SINGLETON
        final VtexSDK api = VtexSDK.getInstance("walmartv5");

//        DADOS PARA TESTE
        final Integer sku = 1;
        final Integer quantity = 1;
        final Integer seller = 1;
        final Integer sallesChannel = 1;

        final Callback getOrderFormCallback = new Callback() {
            @Override
            public void completed(HttpResponse response) {
                System.out.println("olar");
                System.out.println(response.getStatus());
//                TODO mostrar items
                System.out.println(response.getHeaders().get("set-cookie"));
            }

            @Override
            public void failed(UnirestException e) {

            }

            @Override
            public void cancelled() {

            }
        };

        Callback callback = new Callback() {
            @Override
            public void completed(HttpResponse response) {
                System.out.println(response.getStatus());
                System.out.println(response.getHeaders().get("set-cookie"));
//                TODO getOrderForm
                api.addToCart(sku, quantity, seller, sallesChannel, getOrderFormCallback);
            }

            @Override
            public void failed(UnirestException e) {

            }

            @Override
            public void cancelled() {

            }
        };

        api.addToCart(sku, quantity, seller, sallesChannel, callback);
        System.out.println("after");

//        orderForm = api.getOrderForm("http://walmartv5.vtexcommercebeta.com.br/");
//        orderForm = api.getOrderForm("http://walmartv5.vtexcommercebeta.com.br/",  "[email protected]");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy