OVH Rest client is a tiny helper library based on faraday, wrapping the authentication parts and simplifying interaction with OVH API in Ruby programs.
Put this in your Gemfile
:
git_source(:github){ |repo_name| "https://github.com/#{repo_name}.git" }
gem 'ovh', github: 'jbox-web/ovh-rest', tag: '1.0.0'
then run bundle install
.
require 'ovh-rest'
ovh = OvhRest::Client.new(
application_key: <application_key>,
application_secret: <application_secret>,
consumer_key: <consumer_key>
)
# Get sms account status
result = ovh.get("/sms/sms-xx12345-1")
puts YAML.dump(result)
=>
{
"status": "enable",
"creditsLeft": 42,
"name": "sms-xx12345-1",
"userQuantityWithQuota": 0,
"description": "",
[...]
}
# Send sms
result = ovh.post("/sms/sms-xx12345-1/jobs", {
"charset" => "UTF-8",
"class" => "phoneDisplay",
"coding" => "7bit",
"priority" => "high",
"validityPeriod" => 2880
"message" => "Dude! Disk is CRITICAL!",
"receivers" => ["+12345678900", "+12009876543"],
"sender" => "+12424242424",
})
puts YAML.dump(result)
=>
{
"totalCreditsRemoved": 2,
"ids": [
12345,
12346
]
}