// Path: src/main/java/org/adridadou/ethereum/values/smartcontract/SmartContractMetadata.java
// public class SmartContractMetadata {
//     private final ContractAbi abi;
// 
//     public SmartContractMetadata(String abi) {
//         this.abi = new ContractAbi(abi);
//     }
// 
//     public ContractAbi getAbi() {
//         return abi;
//     }
// 
//     @Override
//     public String toString() {
//         return "SmartContractMetadata{" +
//                 "abi=" + abi +
//                 '}';
//     }
// }


import org.adridadou.ethereum.values.smartcontract.SmartContractMetadata;
import org.adridadou.exception.EthereumApiException;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.fluent.Response;
import org.apache.http.entity.ContentType;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.IOException;
package org.adridadou.ethereum.swarm;




/**
 * Created by davidroon on 21.12.16.
 * This code is released under Apache 2 license
 */
public class SwarmService {
    public static final String PUBLIC_HOST = "http://swarm-gateways.net";

    private final String host;

    public SwarmService(String host) {
        this.host = host;
    }

    public static SwarmService from(final String host) {
        return new SwarmService(host);
    }

    public SwarmHash publish(final String content) {
        try {
            Response response = Request.Post(host + "/bzzr:/")
                    .bodyString(content, ContentType.TEXT_PLAIN)
                    .execute();
            return SwarmHash.of(response.returnContent().asString());
        } catch (IOException e) {
            throw new EthereumApiException("error while publishing the smart contract metadata to Swarm", e);
        }
    }

    public String get(final SwarmHash hash) throws IOException {
        Response response = Request.Get(host + "/bzzr:/" + hash.toString())
                .execute();

        return response.returnContent().asString();
    }

// Path: src/main/java/org/adridadou/ethereum/values/smartcontract/SmartContractMetadata.java
// public class SmartContractMetadata {
//     private final ContractAbi abi;
// 
//     public SmartContractMetadata(String abi) {
//         this.abi = new ContractAbi(abi);
//     }
// 
//     public ContractAbi getAbi() {
//         return abi;
//     }
// 
//     @Override
//     public String toString() {
//         return "SmartContractMetadata{" +
//                 "abi=" + abi +
//                 '}';
//     }
// }


// Path: src/main/java/org/adridadou/ethereum/swarm/SwarmService.java
import org.adridadou.ethereum.values.smartcontract.SmartContractMetadata;
import org.adridadou.exception.EthereumApiException;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.fluent.Response;
import org.apache.http.entity.ContentType;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.IOException;

package org.adridadou.ethereum.swarm;




/**
 * Created by davidroon on 21.12.16.
 * This code is released under Apache 2 license
 */
public class SwarmService {
    public static final String PUBLIC_HOST = "http://swarm-gateways.net";

    private final String host;

    public SwarmService(String host) {
        this.host = host;
    }

    public static SwarmService from(final String host) {
        return new SwarmService(host);
    }

    public SwarmHash publish(final String content) {
        try {
            Response response = Request.Post(host + "/bzzr:/")
                    .bodyString(content, ContentType.TEXT_PLAIN)
                    .execute();
            return SwarmHash.of(response.returnContent().asString());
        } catch (IOException e) {
            throw new EthereumApiException("error while publishing the smart contract metadata to Swarm", e);
        }
    }

    public String get(final SwarmHash hash) throws IOException {
        Response response = Request.Get(host + "/bzzr:/" + hash.toString())
                .execute();

        return response.returnContent().asString();
    }

    public SmartContractMetadata getMetadata(final SwarmHash hash) throws IOException {