Project

beget_api

0.0
No commit activity in last 3 years
No release in over 3 years
Beget API wrapper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.12
 Project Readme

Beget API wrapper

Simple wrapper for API of hosting provider Beget

Installation

Add this line to your Gemfile:

gem 'beget_api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install beget_api

How to use it

Create a new instance:

api = Beget::API.new("mylogin", "mysecretpassword")

You can invoke any method in any section with the specified parameters:

api.mysql.addDb(suffix: "test", password: "strongpassword")
api.mysql.getList

It returns deserialized JSON data as is:

irb(main):004:0> pp api.site.getList
[{"id"=>12345,
  "path"=>"site.com/public_html",
  "domains"=>
    [{"id"=>12345,
      "fqdn"=>"site.com",
      "php_version"=>"7.4",
      "http_version"=>1,
      "ssl"=>false,
      "ssl_status"=>"none",
      "nginx_template"=>"default",
      "redis_session"=>false}]}]

There are exceptions that can be arise:

  • HTTPError - HTTP server responds with a non success code
  • RequestError - General method invoke error
  • AnswerError - Answer error

The RequestError and AnswerError exceptions have the attributes "code" and "text" that describe the error.

License

See LICENSE file