Sha256: 9db86478e4c38babb1d4d3771a6598778a089635276177949e546c694f250ca7

Contents?: true

Size: 1.8 KB

Versions: 30

Compression:

Stored size: 1.8 KB

Contents

module Fog
  module DNS
    class DNSimple
      class Real
        # Create a single domain in DNSimple in your account.
        #
        # ==== Parameters
        # * name<~String> - domain name to host (ie example.com)
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'domain'<~Hash> The representation of the domain.
        def create_domain(name)
          body = {
            "domain" => {
              "name" => name
            }
          }

          request(
            :body     => Fog::JSON.encode(body),
            :expects  => 201,
            :method   => 'POST',
            :path     => "/domains"
          )
        end
      end

      class Mock
        def create_domain(name)
          body = {
            "domain" =>  {
              "id"                 => Fog::Mock.random_numbers(1).to_i,
              "user_id"            => 1,
              "registrant_id"      => nil,
              "name"               => name,
              "unicode_name"       => name,
              "token"              => "4fIFYWYiJayvL2tkf_mkBkqC4L+4RtYqDA",
              "state"              => "registered",
              "language"           => nil,
              "lockable"           => true,
              "auto_renew"         => nil,
              "whois_protected"    => false,
              "record_count"       => 0,
              "service_count"      => 0,
              "expires_on"         => Date.today + 365,
              "created_at"         => Time.now.iso8601,
              "updated_at"         => Time.now.iso8601,
            }
          }
          self.data[:domains] << body

          response = Excon::Response.new
          response.status = 201
          response.body = body
          response
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 4 rubygems

Version Path
fog-1.38.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.37.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.36.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.35.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-2.0.0.pre.0 lib/fog/dnsimple/requests/dns/create_domain.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.34.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.33.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.32.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.31.0 lib/fog/dnsimple/requests/dns/create_domain.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.30.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.29.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.28.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.27.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.26.0 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.25.0 lib/fog/dnsimple/requests/dns/create_domain.rb
nsidc-fog-1.24.1 lib/fog/dnsimple/requests/dns/create_domain.rb
fog-1.24.0 lib/fog/dnsimple/requests/dns/create_domain.rb
ns-fog-1.22.11 lib/fog/dnsimple/requests/dns/create_domain.rb