Sha256: 0d681d8f2eb34c1d3102128c993b58d83fa4160b8f7d3e97f6cf64439e7c9df5
Contents?: true
Size: 975 Bytes
Versions: 12
Compression:
Stored size: 975 Bytes
Contents
require 'chillout/server_side/plain_http_client' module Chillout class Registration class NotRegisteredByLimit < StandardError; end class NotRegisteredByInvalidData < StandardError; end class NotRegisteredByAccident < StandardError; end class NotRegisteredByCommunicationError < StandardError; end def initialize(http_client=PlainHttpClient.new) @http_client = http_client end def register(name, emails) data = { :name => name, :emails => emails } response_body = @http_client.post("/projects", data) response_body["api_key"].strip rescue PlainHttpClient::NotCreated => e if e.code == "403" raise NotRegisteredByLimit.new elsif e.code == "400" raise NotRegisteredByInvalidData.new else raise NotRegisteredByAccident.new end rescue PlainHttpClient::CommunicationError => e raise NotRegisteredByCommunicationError.new end end end
Version data entries
12 entries across 12 versions & 1 rubygems