<commit_before>package com.corneliudascalu.glass.device.data;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

import com.corneliudascalu.glass.device.model.Device;
import com.corneliudascalu.glass.device.model.DeviceMessage;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;

import java.io.IOException;
import java.util.List;

/**
 * @author <NAME> <<EMAIL>>
 */
public class DeviceRepository {

    private OkHttpClient client = new OkHttpClient();

    public List<Device> getDevices() throws IOException {
        String url = "http://constantcontact.ofactory.biz/PushNotifService/gglass/devices.php";
        Request request = new Request.Builder().url(url).build();
        Response response = client.newCall(request).execute();
        String json = response.body().string();

        // json= "[{\"name\":\"asd\",\"token\":\"asdasd\"},{\"name\":\"asd\",\"token\":\"asdasd\"},{\"name\":\"asd\",\"token\":\"asdasd\"}]";
        Gson gson = new GsonBuilder().create();
        List<Device> devices = gson.fromJson(json, new TypeToken<List<Device>>() {
        }.getType());
        return devices;
    }

    public boolean sendData(Device device, String data) throws IOException {
        String url = "http://constantcontact.ofactory.biz/PushNotifService/gglass/push.php";

        DeviceMessage deviceMessage = DeviceMessage.create(device, data);
        String body = new GsonBuilder().create().toJson(deviceMessage);

        RequestBody requestBody = RequestBody.create(MediaType.parse(body), body);

        Request request = new Request.Builder().url(url).put(requestBody).build();
        Response response = client.newCall(request).execute();
        return response.isSuccessful();
    }

    public boolean registerToServer(Device device) throws IOException {
        String url = "http://constantcontact.ofactory.biz/PushNotifService/gglass/register.php";
        Gson gson = new GsonBuilder().create();
        String deviceData = gson.toJson(device);
        RequestBody requestBody = RequestBody.create(MediaType.parse(deviceData), deviceData);
        Request request = new Request.Builder().url(url).post(requestBody).build();
        Response response = client.newCall(request).execute();
        return response.isSuccessful();
    }

}<commit_msg>Fixed register device request<commit_after>package com.corneliudascalu.glass.device.data;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

import com.corneliudascalu.glass.device.model.Device;
import com.corneliudascalu.glass.device.model.DeviceMessage;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;

import java.io.IOException;
import java.util.List;

/**
 * @author <NAME> <<EMAIL>>
 */
public class DeviceRepository {

    private OkHttpClient client = new OkHttpClient();

    public List<Device> getDevices() throws IOException {
        String url = "http://constantcontact.ofactory.biz/PushNotifService/gglass/devices.php";
        Request request = new Request.Builder().url(url).build();
        Response response = client.newCall(request).execute();
        String json = response.body().string();

        // json= "[{\"name\":\"asd\",\"token\":\"asdasd\"},{\"name\":\"asd\",\"token\":\"asdasd\"},{\"name\":\"asd\",\"token\":\"asdasd\"}]";
        Gson gson = new GsonBuilder().create();
        List<Device> devices = gson.fromJson(json, new TypeToken<List<Device>>() {
        }.getType());
        return devices;
    }

    public boolean sendData(Device device, String data) throws IOException {
        String url = "http://constantcontact.ofactory.biz/PushNotifService/gglass/push.php";

        DeviceMessage deviceMessage = DeviceMessage.create(device, data);
        String body = new GsonBuilder().create().toJson(deviceMessage);

        RequestBody requestBody = RequestBody.create(MediaType.parse(body), body);

        Request request = new Request.Builder().url(url).put(requestBody).build();
        Response response = client.newCall(request).execute();
        return response.isSuccessful();
    }

    public boolean registerToServer(Device device) throws IOException {

        DeviceMessage deviceMessage = DeviceMessage.create(device, null);
        String url = "http://constantcontact.ofactory.biz/PushNotifService/gglass/register.php";
        Gson gson = new GsonBuilder().create();
        String deviceData = gson.toJson(deviceMessage);
        RequestBody requestBody = RequestBody.create(MediaType.parse(deviceData), deviceData);
        Request request = new Request.Builder().url(url).post(requestBody).build();
        Response response = client.newCall(request).execute();
        return response.isSuccessful();
    }

}
{'fraction_non_alphanumeric': 0.14257425742574256, 'fraction_numerical': 0.0, 'mean_word_length': 3.8058991436726926, 'pattern_counts': {'":': 12, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2896220', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1429, 'n_words': 267}