Sha256: f0fa5419bd3c5d4794b54fbd7ad7ffc550ec90e29b90470f7869138d5f902a06

Contents?: true

Size: 796 Bytes

Versions: 2

Compression:

Stored size: 796 Bytes

Contents

# frozen_string_literal: true

require 'cloudflair/api/zone/custom_hostname'

module Cloudflair
  class Zone
    def custom_hostnames(filter = {})
      raw_hostnames = response connection.get("#{path}/custom_hostnames", filter)

      raw_hostnames.map { |raw_hostname| build_custom_hostname(raw_hostname) }
    end

    def custom_hostname(custom_hostname_id)
      Cloudflair::CustomHostname.new zone_id, custom_hostname_id
    end

    def new_custom_hostname(hostname_data)
      raw_hostname = response connection.post("#{path}/custom_hostnames", hostname_data)

      build_custom_hostname raw_hostname
    end

    private

    def build_custom_hostname(raw_hostname)
      hostname = custom_hostname raw_hostname['id']
      hostname.data = raw_hostname
      hostname
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cloudflair-0.4.0 lib/cloudflair/api/zone__custom_hostnames.rb
cloudflair-0.3.0 lib/cloudflair/api/zone__custom_hostnames.rb