Class: Splicer::DnsMadeEasy::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/splicer/dns_made_easy/client.rb

Overview

The client that talks to DnsMadeEasy

## Example Usage

client = Splicer::DnsMadeEasy::Client.new('key','secret')
client.get('dns/managed/123456')

client.post('dns/managed', {name: 'mydumbdomain.com'})

Author:

  • Matthew A. Johnston

Constant Summary collapse

DEFAULT_END_POINTS =
{
  :sandbox => "https://api.sandbox.dnsmadeeasy.com/V2.0",
  :live    => "https://api.dnsmadeeasy.com/V2.0"
}

Instance Method Summary collapse

Constructor Details

#initialize(key, secret, options = {}) ⇒ Client

Returns a new instance of Client.

Parameters:

  • key (String)
  • secret (String)


22
23
24
25
26
27
# File 'lib/splicer/dns_made_easy/client.rb', line 22

def initialize(key, secret, options = {})
  @key = key
  @secret = secret
  @api_mode = options[:api_mode] || :live
  @use_ssl = options[:use_ssl]
end

Instance Method Details

#delete(resource, payload = {}) ⇒ String

Parameters:

  • resource (String)

    the resource path

  • payload (Hash) (defaults to: {})

    the data you wish to send

Returns:

  • (String)

Raises:

  • (Splicer::Errors::Error)

    when the request fails



75
76
77
78
79
80
81
82
# File 'lib/splicer/dns_made_easy/client.rb', line 75

def delete(resource, payload={})
  execute({
    method: :delete,
    url: resource_url(resource),
    payload: process_payload(payload),
    headers: headers
  })
end

#get(resource, params = {}) ⇒ String

Parameters:

  • resource (String)

    the resource path

Returns:

  • (String)

Raises:

  • (Splicer::Errors::Error)

    when the request fails



33
34
35
36
37
38
39
# File 'lib/splicer/dns_made_easy/client.rb', line 33

def get(resource, params={})
  execute({
    method: :get,
    url: resource_url(resource),
    headers: headers('params' => params)
  })
end

#post(resource, payload) ⇒ String

Parameters:

  • resource (String)

    the resource path

  • payload (Hash)

    the data you wish to send

Returns:

  • (String)

Raises:

  • (Splicer::Errors::Error)

    when the request fails



47
48
49
50
51
52
53
54
# File 'lib/splicer/dns_made_easy/client.rb', line 47

def post(resource, payload)
  execute({
    method: :post,
    url: resource_url(resource),
    payload: process_payload(payload),
    headers: headers
  })
end

#put(resource, payload) ⇒ String

Parameters:

  • resource (String)

    the resource path

  • payload (Hash)

    the data you wish to send

Returns:

  • (String)

Raises:

  • (Splicer::Errors::Error)

    when the request fails



61
62
63
64
65
66
67
68
# File 'lib/splicer/dns_made_easy/client.rb', line 61

def put(resource, payload)
  execute({
    method: :put,
    url: resource_url(resource),
    payload: process_payload(payload),
    headers: headers
  })
end