module Cloudflare::DDNS

Constants

IP_RESOLVER
VERSION

Public Class Methods

fetch_ip() click to toggle source
# File lib/cloudflare/ddns.rb, line 22
def self.fetch_ip
  HTTParty.get(IP_RESOLVER).body
end
update_record(api_token, zone_name, record_name) click to toggle source
# File lib/cloudflare/ddns.rb, line 11
def self.update_record(api_token, zone_name, record_name)
  api = API.new(api_token)
  zone_api = api.zone_api(zone_name)
  record = zone_api.record(record_name)
  current_ip = fetch_ip
  return if record['content'] == current_ip

  zone_api.patch_record(record['id'], content: current_ip)
  current_ip
end