https://github.com/jage/elk
:telephone: Ruby API client for 46elks messaging service
https://github.com/jage/elk
api-client elk messaging ruby sms
Last synced: 10 months ago
JSON representation
:telephone: Ruby API client for 46elks messaging service
- Host: GitHub
- URL: https://github.com/jage/elk
- Owner: jage
- License: mit
- Created: 2011-07-06T19:14:27.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2019-05-31T16:46:30.000Z (almost 7 years ago)
- Last Synced: 2025-05-31T08:57:53.235Z (11 months ago)
- Topics: api-client, elk, messaging, ruby, sms
- Language: Ruby
- Homepage:
- Size: 116 KB
- Stars: 18
- Watchers: 2
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# Elk - 46elks API-client
[](https://travis-ci.org/jage/elk)
[](https://codeclimate.com/github/jage/elk)
Ruby client for 46elks "Voice, SMS & MMS" service. https://www.46elks.com/
At the moment the API only supports sending SMS messages.
## Requirements
* Modern Ruby: >= 2.4
* API account at 46elks.com
## Install
Install via RubyGems
gem install elk
## Source and development
The source for Elk is available on Github:
https://github.com/jage/elk
Elk uses rspec and webmock for testing, do a `bundle install` for all the development requirements.
Test specs with:
bundle exec rake spec
## Usage
elk can be used to allocate phone numbers, manage the numbers and send/receive messages through these numbers.
### Authentication and configuration
First thing when using elk is to set the authentication parameters
```Ruby
require "elk"
Elk.configure do |config|
config.username = "USERNAME"
config.password = "PASSWORD"
end
```
It is possible to avoid the singleton configuration:
```Ruby
require "elk"
client = Elk::Client.new
client.configure do |config|
config.username = "USERNAME"
config.password = "PASSWORD"
end
# Then pass client to the class methods
numbers = Elk::Number.all(client: client)
# => [#, #]
Elk::SMS.send(client: client, from: "MyService", to: "+46704508449", message: "Your order #171 has now been sent!")
# => #
```
### Numbers
To be able to send and recieve messages, a number is needed. Several numbers can be allocated.
```Ruby
number = Elk::Number.allocate(sms_url: "http://myservice.se/callback/newsms.php", country: "se")
# => #
```
Get all numbers
```Ruby
numbers = Elk::Number.all
# => [#, #]
```
Change number settings
```Ruby
number.sms_url = "http://myservice.se/callback/newsms.php"
number.save
# => true
```
Deallocate a number.
Beware that there is no way to get your number back once it has been deallocated!
```Ruby
number.deallocate!
# => true
number.status
# => :deallocated
```
### SMS
Send SMS. Messages can be sent from one of the allocated numbers or an arbitrary alphanumeric string of at most 11 characters.
```Ruby
Elk::SMS.send(from: "MyService", to: "+46704508449", message: "Your order #171 has now been sent!")
# => #
```
Receiving SMS does not require Elk, but should be of interest anyway.
Example with Sinatra:
```Ruby
post "/receive" do
if request.params["message"] == "Hello"
# Sends a return SMS with message "world!"
"world!"
end
end
```
SMS history
```Ruby
Elk::SMS.all
# => [#, #, ]
```
## Copyright
Copyright (c) 2011 Johan Eckerström. See [MIT-LICENSE](MIT-LICENSE) for details.