Giter Site home page Giter Site logo

pushover4j's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pushover4j's Issues

attachment support

Code example for the PushoverRestClient class with the dependencies to httpmime.

	private static final ContentType plainUTF = ContentType.create("text/plain", MIME.UTF8_CHARSET);
	
	public Status pushMessage(PushoverMessage msg) throws PushoverException {
		final MultipartEntityBuilder builder = MultipartEntityBuilder.create();
		builder.addTextBody("token", msg.getApiToken(), plainUTF);
		builder.addTextBody("user", msg.getUserId(), plainUTF);
		builder.addTextBody("message", msg.getMessage(), plainUTF);

		addBodyIfNotNull(builder, "title", msg.getTitle());

		addBodyIfNotNull(builder, "url", msg.getUrl());
		addBodyIfNotNull(builder, "url_title", msg.getTitle());

		addBodyIfNotNull(builder, "device", msg.getDevice());
		addBodyIfNotNull(builder, "timestamp", "" + msg.getTimestamp());
		addBodyIfNotNull(builder, "sound", msg.getSound());
		addBodyIfNotNull(builder, "html", msg.isHtml() ? "1" : "0");

		if (!MessagePriority.NORMAL.equals(msg.getPriority())) {
			addBodyIfNotNull(builder, "priority", "" + msg.getPriority());
		}

		if (msg.getFile != null) {
			builder.addBinaryBody("attachment", msg.getFile().getStream(), msg.getFile().getContentType(),
					msg.getFile().getName());
		}

		HttpEntity multipart = builder.build();
		HttpPost post = new HttpPost(PUSH_MESSAGE_URL);
		post.setEntity(multipart);

		try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
			HttpResponse response = httpClient.execute(post);
			return PushoverResponseFactory.createStatus(response);
		} catch (Exception e) {
			throw new PushoverException(e.getMessage(), e.getCause());
		}
	}
	private void addBodyIfNotNull(MultipartEntityBuilder builder, String name, String value) {
		builder.addTextBody(name, value, plainUTF);
	}

Update Maven

The latest version of maven (1.0.0) doesn't contain any new pulls from 2013, please update maven for ease of access!

Publish to Central?

Hey there - I know it's something of a pain, but if it's not too much trouble, it would be super handy if this was published somewhere. I have it as an external dep for my projects, and I was thinking about pushing it to Central under my own groupId but figured you might rather have it under yours. :)

(It's a fantastic library, and thank you for working on it!)

License?

I may want to use your Java lib in a project of my own. However, I'm not sure what license this project is released under.

Can you add license information to your project?

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.