Giter VIP home page Giter VIP logo

printnode-java's Introduction

PrintNode-Java

PrintNode is a cloud printing service which allows you to connect any printer to your application using our PrintNode Client and easy to use JSON API.

This quick start guide covers using the Java API Library. There are examples to show how to use the API Library. It assumes that you have a PrintNode account.

Quick Start

Firstly, you will want to import java.io.IOException, as a lot of the methods throw IOExceptions because of the org.apache.http packages throw them, and are used extensively throughout PrintNode-Java. A .jar file is included in PrintNode-Java/jar/.

Here is some sample code:

import java.io.IOException;
import com.printnode.api.*;

public class Example{
	public static void main(String args[] throws IOException { //To avoid try catches
		Auth myAuth = new Auth()
		myAuth.setApiKey("MyApiKey");

		APIClient myClient = new APIClient(myAuth);

		Computer[] myComputers = myClient.getComputers("");
	}
}

##Compiling from source

###Prerequisites

  • org.apache.commons
  • org.apache.http
  • com.google.gson
  • org.apache.commons-logging

Then place these files in lib/ or add them to your CLASSPATH.

The included compile.sh will then compile all the files and place them in PrintNode-Java/build/.

##Maven

###Prerequisites

  • Change /src/test/java/com/printnode/api/AppTest.java to use your own API-Key.

Running mvn install dependency:copy-dependencies package in the base folder will then build a PrintNode-Java.jar into target/ and will put all the dependencies required in target/dependency/.

##Docs

A javadoc is included in PrintNode-Java/docs/.

printnode-java's People

Contributors

alexanderwink avatar printnode-jake avatar tomaszdurda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

printnode-java's Issues

Please Publish Maven Packages

Hi there and thank you for this SDK. We are integrating your API and noticed there are no packages for public use.

Would you be willing to publish packages for this library?

Thank you!

Printer's name is not parsed from the JSON response

The printer's name is not parsed on the JSON response. Attaching suggested change on Printer.java:

public Printer(final JsonObject response) {
        if (!response.get("id").isJsonNull()) {
            id = response.get("id").getAsInt();
        }
        if (!response.get("computer").isJsonNull()) {
            computer = new Computer(response.get("computer").getAsJsonObject());
        }
        if (!response.get("description").isJsonNull()) {
            description = response.get("description").getAsString();
        }
        if (!response.get("name").isJsonNull()) {
            name = response.get("name").getAsString();
        }
        if (!response.get("capabilities").isJsonNull()) {
            capabilities = new Capabilities(response.get("capabilities").getAsJsonObject());
        }
        if (!response.get("default").isJsonNull()) {
            defaults = response.get("default").getAsString();
        }
        if (!response.get("createTimestamp").isJsonNull()) {
            createTimestamp = response.get("createTimestamp").getAsString();
        }
        if (!response.get("state").isJsonNull()) {
            state = response.get("state").getAsString();
        }
        json = response.toString();
    }

Requests are sent to printer 2x (twice) - Solved

APIClient.java has a method called "createPrintJob" which passes PrintJobJson as a parameter. This file (PrintJobJson.java) has a varible qty = -1 which was sending the requests twice.
I changed it to 1 and now I'm getting only one copy.

fitToPage incorrect Gson mapping

in class com.printnode.api.Options there is a private Boolean fitToPage; which maps by default to "fitToPage" json field, not "fit_to_page" as PrintNode api expected

According to the Json docs i found that you need use annotation like:
@SerializedName("fit_to_page") instead plain field declaration

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.