Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/theodorton/digipost-api-ruby

Simple API for sending messages through DigiPost
https://github.com/theodorton/digipost-api-ruby

Last synced: 3 months ago
JSON representation

Simple API for sending messages through DigiPost

Awesome Lists containing this project

README

        

# Ruby API for Digipost from Posten

Simple Ruby API for sending messages through Digipost from The Norwegian Postal Service (Posten).

## Getting started

### Prerequisites

* An account with Digipost
* A private key for sending messages

### Configuration

````ruby
user_id = 12345 #
certificate = '' # Not needed for now
private_key = File.new('path/to/your/private_key').read
Digipost::Service.configure(user_id, certificate, private_key)
````

### Sending messages

````ruby
# Prepare message
message = Digipost::Api::Representations::Message.new
message.recipient = "digipost-user#1235"
message.subject = "Hi there!"
message.authentication_level = 'PASSWORD' # or 'TWO_FACTOR'
message.sms_notification = false # or true
message.date = Time.now
message.pdf = File.read('path/to/your/pdf_file')

# Send the message
service = Digipost::Service.new
service.send_message(message)
````

And that should be about it :)

## How to contribute

1. Fork this project
2. `bundle install`
3. `bundle exec rspec spec/**/*_spec.rb`
4. Add your features, please add specs for it
5. Request a pull request