arcanericky / pushover Goto Github PK
View Code? Open in Web Editor NEWGo package for the Pushover API
License: MIT License
Go package for the Pushover API
License: MIT License
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()
.
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 charactersTitle
has a limit of 250 charactersURL
has a limit of 512 charactersURLTitle
has a limit of 100 charactersEnforce 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.
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)."
Retry
and Expire
fields in the the API in MessageRequest
--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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.