module OneAndOne

Top-Level Module

Public Class Methods

build_url(endpoint) click to toggle source
# File lib/1and1/oneandone.rb, line 33
def OneAndOne.build_url(endpoint)

  $version + endpoint

end
check_response(message, status) click to toggle source
# File lib/1and1/oneandone.rb, line 40
def OneAndOne.check_response(message, status)
  
  # Check for server error
  if status == 500
    raise "Internal Server Error.  Please try again."
  end

  # Raise exception if a bad status code is received
  unless $success_codes.include? status
    raise message
  end

  true

end
clean_hash(hash) click to toggle source
# File lib/1and1/oneandone.rb, line 22
def OneAndOne.clean_hash(hash)

  hash.each do |key, value|
    if value == nil
      hash.delete(key)
    end
  end

end
start(api_token) click to toggle source
# File lib/1and1/oneandone.rb, line 4
def OneAndOne.start(api_token)
  
  # Set core values to be used across the module
  $api_token = api_token
  $base_url = 'https://cloudpanel-api.1and1.com'
  $version = '/v1'
  $header = {
    'X-TOKEN' => $api_token,
    'Content-Type' => 'application/json'
  }
  $success_codes = [200, 201, 202]
  $good_states = ['ACTIVE', 'ENABLED', 'POWERED_ON', 'POWERED_OFF']

  true

end