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'})

Instance Method Summary collapse

Constructor Details

#initialize(key, secret) ⇒ Client

Returns a new instance of Client.

Parameters:

  • key (String)
  • secret (String)


16
17
18
19
# File 'lib/splicer/dns_made_easy/client.rb', line 16

def initialize(key, secret)
  @key = key
  @secret = secret
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



67
68
69
70
71
72
73
74
# File 'lib/splicer/dns_made_easy/client.rb', line 67

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



25
26
27
28
29
30
31
# File 'lib/splicer/dns_made_easy/client.rb', line 25

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



39
40
41
42
43
44
45
46
# File 'lib/splicer/dns_made_easy/client.rb', line 39

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



53
54
55
56
57
58
59
60
# File 'lib/splicer/dns_made_easy/client.rb', line 53

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