GithubHelp home page GithubHelp logo

arcanericky / pushover Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 63 KB

Go package for the Pushover API

License: MIT License

Makefile 3.46% Go 96.06% Shell 0.48%
golang pushover pushover-api api cli cli-utility notifications notification-service notification-api go

pushover's People

Contributors

arcanericky avatar dependabot[bot] avatar imsingee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

imsingee

pushover's Issues

Add receipt parameter after Message API response

When a priority=2 notification is sent a receipt parameter will be returned in the response.

In the API, after extracting and saving the Request ID, extract and delete the receipt parameter, saving it in the MessageResponse structure. Note this parameter is optional so it should be extracted using code more like extracting the group parameters in the Validate API.

In the CLI, output the Receipt value when outputting the MessageResponse structure in outputMessageResponse().

Pushover Message API Input Validation

The pushover.Message() function validates input before calling messageWithoutValidation(). Remove all validation performed by the API, sending the data to the Pushover API and allowing Pushover to validate and reject the message if needed. Pushover may update their API and change parameter requires. This API should not be able to accomodate this without code changes.

If in the future, consumers of this package require validation this can be revisited. For now validation should be performed by the consumers of this package.

The Message API requires a token, user, and message. Additional limitations are listed for the Pushover Message API at https://pushover.net/api#limits.

These are:

  • Message has a limit of 1024 characters
  • Title has a limit of 250 characters
  • URL has a limit of 512 characters
  • URLTitle has a limit of 100 characters

Enforce these limits in the pushover.Message() function. For now, returning an error such as ErrInvalidRequest is sufficient.

Note that Message may actually consist of up to "1024 4-byte UTF-8 characters". Simply using len() to enforce the limit is not correct. Something like utf8.RuneCountInString() might be more appropriate.

Implement Emergency Priority (2) Fields

Setting the priority of a message to 2 indicates that it is Emergency Priority and the retry and expire parameters must be supplied.

retry "specifies how often (in seconds) the Pushover servers will send the same notification to the user." ... "This parameter must have a value of at least 30 seconds between retries."

expire "specifies how many seconds your notification will continue to be retried for (every retry seconds)." ... "This parameter must have a maximum value of at most 10800 seconds (3 hours)."

  • Implement the Retry and Expire fields in the the API in MessageRequest
  • Implement new --retry and --expire flags in the CLI utility, including validation of both fields.

For both, include in the unit tests where logical.

For the official API documentation, see https://pushover.net/api#priority.

Implement the Limits API

The Pushover Limits API is simple and has a very short writeup at https://pushover.net/api#limits. It uses only a single parameter (token) and can be viewed with:

$ curl https://api.pushover.net/1/apps/limits.json?token=apitoken
{"limit":7500,"remaining":7405,"reset":1564635600,"status":1,"request":"7e3888b4-0bc8-4525-b567-d30e11b68d92"}

Implement this API in a limits.go module, including appropriate comments for GoDoc and unit tests. Use the Messages and Validate API as examples.

Use this API in the Pushover CLI utility with a limits commmand. An example might be:

$ pushover limits --token apitoken
Request
Token:       apitoken

Response
HTML Status:      200 OK
HTML Status Code: 200
API Status:       1
Request ID:       7e3888b4-0bc8-4525-b567-d30e11b68d92
Limit:            7500
Remaining:        7405
Reset:            1564635600
Response Body: {"status":1,"group":0,"devices":["pixel2xl"],"licenses":["Android"],"request":"a5669be9-1160-40cb-b680-36dde650bc28"}

Include unit tests for the CLI functionality.

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.