dnsimple-ruby 1.2.6 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg
2
+ rdoc
3
+ turbulence
data/Gemfile CHANGED
@@ -1,16 +1,5 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'httparty'
3
+ gemspec
4
4
 
5
- group :development do
6
- gem 'rake'
7
- gem 'jeweler'
8
- gem 'rspec', '>= 2.0.0'
9
- gem 'mocha'
10
- gem 'ruby-debug', :platforms => 'ruby_18'
11
- gem 'cucumber'
12
- gem 'aruba'
13
- gem 'ruby-debug'
14
- gem 'fakeweb'
15
- gem 'vcr'
16
- end
5
+ gem 'ruby-debug', :platform => :ruby_18, :group => :development
data/Gemfile.lock CHANGED
@@ -1,3 +1,9 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dnsimple-ruby (1.3.0)
5
+ httparty
6
+
1
7
  GEM
2
8
  remote: http://rubygems.org/
3
9
  specs:
@@ -21,14 +27,9 @@ GEM
21
27
  ffi (1.0.9)
22
28
  gherkin (2.6.3)
23
29
  json (>= 1.4.6)
24
- git (1.2.5)
25
30
  httparty (0.8.1)
26
31
  multi_json
27
32
  multi_xml
28
- jeweler (1.6.4)
29
- bundler (~> 1.0)
30
- git (>= 1.2.5)
31
- rake
32
33
  json (1.6.1)
33
34
  linecache (0.46)
34
35
  rbx-require-relative (> 0.0.4)
@@ -61,9 +62,8 @@ PLATFORMS
61
62
  DEPENDENCIES
62
63
  aruba
63
64
  cucumber
65
+ dnsimple-ruby!
64
66
  fakeweb
65
- httparty
66
- jeweler
67
67
  mocha
68
68
  rake
69
69
  rspec (>= 2.0.0)
data/Rakefile CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'rake'
2
- require 'rake/testtask'
3
2
  require 'rake/rdoctask'
4
3
 
4
+ require 'bundler/gem_tasks'
5
+
5
6
  desc 'Default: run tests.'
6
7
  task :default => [:spec]
7
8
 
@@ -14,20 +15,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
14
15
  rdoc.rdoc_files.include('lib/*.rb')
15
16
  rdoc.rdoc_files.include('lib/**/*.rb')
16
17
  end
17
-
18
- begin
19
- require 'jeweler'
20
- Jeweler::Tasks.new do |gemspec|
21
- gemspec.name = "dnsimple-ruby"
22
- gemspec.summary = "A ruby wrapper for the DNSimple API"
23
- gemspec.description = "A ruby wrapper for the DNSimple API that also includes a command-line client."
24
- gemspec.email = "anthony.eden@dnsimple.com"
25
- gemspec.homepage = "http://github.com/aetrion/dnsimple-ruby"
26
- gemspec.authors = ["Anthony Eden"]
27
- gemspec.add_dependency "httparty"
28
- gemspec.executables = 'dnsimple'
29
- end
30
- rescue LoadError
31
- puts "Jeweler not available. Install it with: gem install jeweler"
32
- end
33
-
@@ -1,185 +1,31 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'dnsimple/version'
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = "dnsimple-ruby"
8
- s.version = "1.1.1"
6
+ s.name = 'dnsimple-ruby'
7
+ s.version = DNSimple::VERSION
8
+ s.authors = ['Anthony Eden']
9
+ s.email = ['anthony.eden@dnsimple.com']
10
+ s.homepage = 'http://github.com/aetrion/dnsimple-ruby'
11
+ s.summary = 'A ruby wrapper for the DNSimple API'
12
+ s.description = 'A ruby wrapper for the DNSimple API that also includes a command-line client.'
9
13
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Anthony Eden"]
12
- s.date = "2011-11-03"
13
- s.description = "A ruby wrapper for the DNSimple API that also includes a command-line client."
14
- s.email = "anthony.eden@dnsimple.com"
15
- s.executables = ["dnsimple"]
16
- s.extra_rdoc_files = [
17
- "LICENSE",
18
- "README",
19
- "README.rdoc",
20
- "README.textile"
21
- ]
22
- s.files = [
23
- ".bundle/config",
24
- ".rvmrc",
25
- "Gemfile",
26
- "Gemfile.lock",
27
- "LICENSE",
28
- "README",
29
- "README.rdoc",
30
- "README.textile",
31
- "Rakefile",
32
- "VERSION",
33
- "bin/dnsimple",
34
- "bin/dnsimple.rb",
35
- "dnsimple-ruby.gemspec",
36
- "features/README",
37
- "features/cli/certificates/purchase_certificate.feature",
38
- "features/cli/contacts/create_contact.feature",
39
- "features/cli/domains/check_domain.feature",
40
- "features/cli/domains/create_domain.feature",
41
- "features/cli/domains/delete_domain.feature",
42
- "features/cli/domains/register_domain.feature",
43
- "features/cli/records/create_ptr_record.feature",
44
- "features/cli/records/create_record.feature",
45
- "features/cli/records/delete_record.feature",
46
- "features/cli/templates/apply_template.feature",
47
- "features/step_definitions/certificate_steps.rb",
48
- "features/step_definitions/cli_steps.rb",
49
- "features/step_definitions/domain_steps.rb",
50
- "features/step_definitions/record_steps.rb",
51
- "features/step_definitions/template_steps.rb",
52
- "features/support/env.rb",
53
- "fixtures/vcr_cassettes/DNSimple_Contact/a_new_contact.yml",
54
- "fixtures/vcr_cassettes/DNSimple_Contact/an_existing_contact.yml",
55
- "fixtures/vcr_cassettes/DNSimple_Domain/_all.yml",
56
- "fixtures/vcr_cassettes/DNSimple_Domain/applying_templates.yml",
57
- "fixtures/vcr_cassettes/DNSimple_Domain/creating_a_new_domain.yml",
58
- "fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain.yml",
59
- "fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_id.yml",
60
- "fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_name.yml",
61
- "fixtures/vcr_cassettes/DNSimple_Domain/registration/with_a_new_registrant_contact.yml",
62
- "fixtures/vcr_cassettes/DNSimple_Domain/registration/with_an_existing_contact.yml",
63
- "fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_ca.yml",
64
- "fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_com.yml",
65
- "fixtures/vcr_cassettes/DNSimple_Record/_all.yml",
66
- "fixtures/vcr_cassettes/DNSimple_Record/creating_a_new_record.yml",
67
- "fixtures/vcr_cassettes/DNSimple_Record/find_a_record.yml",
68
- "fixtures/vcr_cassettes/DNSimple_Template/a_template.yml",
69
- "fixtures/vcr_cassettes/DNSimple_User/_me.yml",
70
- "lib/dnsimple.rb",
71
- "lib/dnsimple/certificate.rb",
72
- "lib/dnsimple/cli.rb",
73
- "lib/dnsimple/client.rb",
74
- "lib/dnsimple/commands/add_service.rb",
75
- "lib/dnsimple/commands/add_template_record.rb",
76
- "lib/dnsimple/commands/apply_template.rb",
77
- "lib/dnsimple/commands/check_domain.rb",
78
- "lib/dnsimple/commands/clear_domain.rb",
79
- "lib/dnsimple/commands/create_contact.rb",
80
- "lib/dnsimple/commands/create_domain.rb",
81
- "lib/dnsimple/commands/create_record.rb",
82
- "lib/dnsimple/commands/create_template.rb",
83
- "lib/dnsimple/commands/delete_contact.rb",
84
- "lib/dnsimple/commands/delete_domain.rb",
85
- "lib/dnsimple/commands/delete_record.rb",
86
- "lib/dnsimple/commands/delete_template.rb",
87
- "lib/dnsimple/commands/delete_template_record.rb",
88
- "lib/dnsimple/commands/describe_contact.rb",
89
- "lib/dnsimple/commands/describe_domain.rb",
90
- "lib/dnsimple/commands/describe_record.rb",
91
- "lib/dnsimple/commands/describe_service.rb",
92
- "lib/dnsimple/commands/describe_user.rb",
93
- "lib/dnsimple/commands/list_applied_services.rb",
94
- "lib/dnsimple/commands/list_available_services.rb",
95
- "lib/dnsimple/commands/list_contacts.rb",
96
- "lib/dnsimple/commands/list_domains.rb",
97
- "lib/dnsimple/commands/list_extended_attributes.rb",
98
- "lib/dnsimple/commands/list_records.rb",
99
- "lib/dnsimple/commands/list_services.rb",
100
- "lib/dnsimple/commands/list_template_records.rb",
101
- "lib/dnsimple/commands/list_templates.rb",
102
- "lib/dnsimple/commands/purchase_certificate.rb",
103
- "lib/dnsimple/commands/register_domain.rb",
104
- "lib/dnsimple/commands/remove_service.rb",
105
- "lib/dnsimple/commands/transfer_domain.rb",
106
- "lib/dnsimple/commands/update_contact.rb",
107
- "lib/dnsimple/commands/update_record.rb",
108
- "lib/dnsimple/contact.rb",
109
- "lib/dnsimple/domain.rb",
110
- "lib/dnsimple/error.rb",
111
- "lib/dnsimple/extended_attribute.rb",
112
- "lib/dnsimple/record.rb",
113
- "lib/dnsimple/service.rb",
114
- "lib/dnsimple/template.rb",
115
- "lib/dnsimple/template_record.rb",
116
- "lib/dnsimple/transfer_order.rb",
117
- "lib/dnsimple/user.rb",
118
- "spec/README",
119
- "spec/certificate_spec.rb",
120
- "spec/contact_spec.rb",
121
- "spec/domain_spec.rb",
122
- "spec/extended_attributes_spec.rb",
123
- "spec/record_spec.rb",
124
- "spec/spec_helper.rb",
125
- "spec/template_spec.rb",
126
- "spec/user_spec.rb"
127
- ]
128
- s.homepage = "http://github.com/aetrion/dnsimple-ruby"
129
- s.require_paths = ["lib"]
130
- s.rubygems_version = "1.8.10"
131
- s.summary = "A ruby wrapper for the DNSimple API"
132
- s.test_files = [
133
- "spec/certificate_spec.rb",
134
- "spec/contact_spec.rb",
135
- "spec/domain_spec.rb",
136
- "spec/extended_attributes_spec.rb",
137
- "spec/record_spec.rb",
138
- "spec/spec_helper.rb",
139
- "spec/template_spec.rb",
140
- "spec/user_spec.rb"
141
- ]
14
+ s.require_paths = ['lib']
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.extra_rdoc_files = %w( LICENSE README README.rdoc README.textile )
18
+ s.executables = `git ls-files -- bin/*`.split("\n").collect { |f|
19
+ File.basename(f)
20
+ }
142
21
 
143
- if s.respond_to? :specification_version then
144
- s.specification_version = 3
22
+ s.add_runtime_dependency 'httparty', '>= 0'
145
23
 
146
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
147
- s.add_runtime_dependency(%q<httparty>, [">= 0"])
148
- s.add_development_dependency(%q<rake>, [">= 0"])
149
- s.add_development_dependency(%q<jeweler>, [">= 0"])
150
- s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
151
- s.add_development_dependency(%q<ruby-debug>, [">= 0"])
152
- s.add_development_dependency(%q<cucumber>, [">= 0"])
153
- s.add_development_dependency(%q<aruba>, [">= 0"])
154
- s.add_development_dependency(%q<ruby-debug>, [">= 0"])
155
- s.add_development_dependency(%q<fakeweb>, [">= 0"])
156
- s.add_development_dependency(%q<vcr>, [">= 0"])
157
- s.add_runtime_dependency(%q<httparty>, [">= 0"])
158
- else
159
- s.add_dependency(%q<httparty>, [">= 0"])
160
- s.add_dependency(%q<rake>, [">= 0"])
161
- s.add_dependency(%q<jeweler>, [">= 0"])
162
- s.add_dependency(%q<rspec>, [">= 2.0.0"])
163
- s.add_dependency(%q<ruby-debug>, [">= 0"])
164
- s.add_dependency(%q<cucumber>, [">= 0"])
165
- s.add_dependency(%q<aruba>, [">= 0"])
166
- s.add_dependency(%q<ruby-debug>, [">= 0"])
167
- s.add_dependency(%q<fakeweb>, [">= 0"])
168
- s.add_dependency(%q<vcr>, [">= 0"])
169
- s.add_dependency(%q<httparty>, [">= 0"])
170
- end
171
- else
172
- s.add_dependency(%q<httparty>, [">= 0"])
173
- s.add_dependency(%q<rake>, [">= 0"])
174
- s.add_dependency(%q<jeweler>, [">= 0"])
175
- s.add_dependency(%q<rspec>, [">= 2.0.0"])
176
- s.add_dependency(%q<ruby-debug>, [">= 0"])
177
- s.add_dependency(%q<cucumber>, [">= 0"])
178
- s.add_dependency(%q<aruba>, [">= 0"])
179
- s.add_dependency(%q<ruby-debug>, [">= 0"])
180
- s.add_dependency(%q<fakeweb>, [">= 0"])
181
- s.add_dependency(%q<vcr>, [">= 0"])
182
- s.add_dependency(%q<httparty>, [">= 0"])
183
- end
24
+ s.add_development_dependency 'aruba', '>= 0'
25
+ s.add_development_dependency 'cucumber', '>= 0'
26
+ s.add_development_dependency 'fakeweb', '>= 0'
27
+ s.add_development_dependency 'mocha', '>= 0'
28
+ s.add_development_dependency 'rake', '>= 0'
29
+ s.add_development_dependency 'rspec', '>= 2.0.0'
30
+ s.add_development_dependency 'vcr', '>= 0'
184
31
  end
185
-
@@ -1,6 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.require :default, :development
5
+
1
6
  require 'aruba/cucumber'
2
- $:.unshift('lib')
3
- require 'dnsimple'
4
7
 
5
8
  Before do
6
9
  @aruba_timeout_seconds = 30
@@ -14,4 +17,3 @@ After do |scenario|
14
17
  end
15
18
  end
16
19
  end
17
-
@@ -0,0 +1 @@
1
+ require 'dnsimple'
data/lib/dnsimple.rb CHANGED
@@ -5,6 +5,7 @@ module DNSimple
5
5
  BLANK_REGEX = /\S+/
6
6
  end
7
7
 
8
+ require 'dnsimple/base'
8
9
  require 'dnsimple/client'
9
10
  require 'dnsimple/error'
10
11
  require 'dnsimple/user'
@@ -0,0 +1,8 @@
1
+ class DNSimple::Base
2
+ def initialize(attributes)
3
+ attributes.each do |key, value|
4
+ m = "#{key}=".to_sym
5
+ self.send(m, value) if self.respond_to?(m)
6
+ end
7
+ end
8
+ end
@@ -1,158 +1,123 @@
1
- module DNSimple #:nodoc:
2
- # Represents an SSL certificate that has been purchased. The certificate
3
- # must also be submitted using the #submit method before the Certificate
4
- # Authority will issue a signed certificate.
5
- class Certificate
6
- include HTTParty
7
- #debug_output $stdout
1
+ # Represents an SSL certificate that has been purchased. The certificate
2
+ # must also be submitted using the #submit method before the Certificate
3
+ # Authority will issue a signed certificate.
4
+ class DNSimple::Certificate < DNSimple::Base
5
+ #debug_output $stdout
8
6
 
9
- # The certificate ID in DNSimple
10
- attr_accessor :id
7
+ # The certificate ID in DNSimple
8
+ attr_accessor :id
11
9
 
12
- attr_accessor :domain
10
+ attr_accessor :domain
13
11
 
14
- # The subdomain on the certificate
15
- attr_accessor :name
16
-
17
- # The private key, if DNSimple generated the Certificate Signing Request
18
- attr_accessor :private_key
12
+ # The subdomain on the certificate
13
+ attr_accessor :name
19
14
 
20
- # The SSL certificate, if it has been issued by the Certificate Authority
21
- attr_accessor :ssl_certificate
15
+ # The private key, if DNSimple generated the Certificate Signing Request
16
+ attr_accessor :private_key
22
17
 
23
- # The Certificate Signing Request
24
- attr_accessor :csr
18
+ # The SSL certificate, if it has been issued by the Certificate Authority
19
+ attr_accessor :ssl_certificate
25
20
 
26
- # The Certificate status
27
- attr_accessor :certificate_status
28
-
29
- # The date the Certificate order was placed
30
- attr_accessor :order_date
21
+ # The Certificate Signing Request
22
+ attr_accessor :csr
31
23
 
32
- # The date the Certificate will expire
33
- attr_accessor :expiration_date
24
+ # The Certificate status
25
+ attr_accessor :certificate_status
34
26
 
35
- # The approver email address
36
- attr_accessor :approver_email
27
+ # The date the Certificate order was placed
28
+ attr_accessor :order_date
37
29
 
38
- # An array of all emails that can be used to approve the certificate
39
- attr_accessor :available_approver_emails
30
+ # The date the Certificate will expire
31
+ attr_accessor :expiration_date
40
32
 
41
- # When the certificate was purchased
42
- attr_accessor :created_at
33
+ # The approver email address
34
+ attr_accessor :approver_email
43
35
 
44
- # When the certificate was last updated
45
- attr_accessor :updated_at
36
+ # An array of all emails that can be used to approve the certificate
37
+ attr_accessor :available_approver_emails
46
38
 
47
-
39
+ # When the certificate was purchased
40
+ attr_accessor :created_at
48
41
 
49
- #:nodoc:
50
- def initialize(attributes)
51
- attributes.each do |key, value|
52
- m = "#{key}=".to_sym
53
- self.send(m, value) if self.respond_to?(m)
54
- end
55
- end
56
-
57
- # Get the fully-qualified domain name for the certificate. This is the
58
- # domain.name joined with the certificate name, separated by a period.
59
- def fqdn
60
- [name, domain.name].delete_if { |p| p !~ DNSimple::BLANK_REGEX }.join(".")
61
- end
42
+ # When the certificate was last updated
43
+ attr_accessor :updated_at
62
44
 
63
- def submit(approver_email, options={})
64
- raise DNSimple::Error, "Approver email is required" unless approver_email
45
+ # Get the fully-qualified domain name for the certificate. This is the
46
+ # domain.name joined with the certificate name, separated by a period.
47
+ def fqdn
48
+ [name, domain.name].delete_if { |p| p !~ DNSimple::BLANK_REGEX }.join(".")
49
+ end
65
50
 
66
- options.merge!(DNSimple::Client.standard_options_with_credentials)
67
- options.merge!(:body => {:certificate => {:approver_email => approver_email}})
51
+ def submit(approver_email, options={})
52
+ raise DNSimple::Error, "Approver email is required" unless approver_email
68
53
 
69
- response = self.class.put("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates/#{id}/submit", options)
54
+ options.merge!(:body => {:certificate => {:approver_email => approver_email}})
70
55
 
71
- pp response if DNSimple::Client.debug?
56
+ response = DNSimple::Client.put "domains/#{domain.name}/certificates/#{id}/submit", options
72
57
 
73
- case response.code
74
- when 200
75
- return DNSimple::Certificate.new({:domain => domain}.merge(response["certificate"]))
76
- when 401
77
- raise DNSimple::AuthenticationFailed, "Authentication failed"
78
- else
79
- raise DNSimple::Error.new("Error submitting certificate: #{response["errors"]}")
80
- end
58
+ case response.code
59
+ when 200
60
+ return DNSimple::Certificate.new({:domain => domain}.merge(response["certificate"]))
61
+ else
62
+ raise DNSimple::Error.new("Error submitting certificate: #{response["errors"]}")
81
63
  end
64
+ end
82
65
 
83
- # Purchase a certificate under the given domain with the given name. The
84
- # name will be appended to the domain name, and thus should only be the
85
- # subdomain part.
86
- #
87
- # Example: DNSimple::Certificate.purchase(domain, 'www', contact)
88
- #
89
- # Please note that by invoking this method DNSimple will immediately charge
90
- # your credit card on file at DNSimple for the full certificate price.
91
- #
92
- # For wildcard certificates an asterisk must appear in the name.
93
- #
94
- # Example: DNSimple::Certificate.purchase(domain, '*', contact)
95
- def self.purchase(domain, name, contact, options={})
96
- certificate_hash = {
97
- :name => name,
98
- :contact_id => contact.id
99
- }
100
-
101
- options.merge!(DNSimple::Client.standard_options_with_credentials)
102
- options.merge!({:body => {:certificate => certificate_hash}})
103
-
104
- response = self.post("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates", options)
105
-
106
- pp response if DNSimple::Client.debug?
107
-
108
- case response.code
109
- when 201
110
- return DNSimple::Certificate.new({:domain => domain}.merge(response["certificate"]))
111
- when 401
112
- raise DNSimple::AuthenticationFailed, "Authentication failed"
113
- when 406
114
- raise DNSimple::CertificateExists.new("#{name}.#{domain.name}", response["errors"])
115
- else
116
- raise DNSimple::Error.new("#{name}.#{domain.name}", response["errors"])
117
- end
66
+ # Purchase a certificate under the given domain with the given name. The
67
+ # name will be appended to the domain name, and thus should only be the
68
+ # subdomain part.
69
+ #
70
+ # Example: DNSimple::Certificate.purchase(domain, 'www', contact)
71
+ #
72
+ # Please note that by invoking this method DNSimple will immediately charge
73
+ # your credit card on file at DNSimple for the full certificate price.
74
+ #
75
+ # For wildcard certificates an asterisk must appear in the name.
76
+ #
77
+ # Example: DNSimple::Certificate.purchase(domain, '*', contact)
78
+ def self.purchase(domain, name, contact, options={})
79
+ certificate_hash = {
80
+ :name => name,
81
+ :contact_id => contact.id
82
+ }
83
+
84
+ options.merge!({:body => {:certificate => certificate_hash}})
85
+
86
+ response = DNSimple::Client.post "domains/#{domain.name}/certificates", options
87
+
88
+ case response.code
89
+ when 201
90
+ return new({:domain => domain}.merge(response["certificate"]))
91
+ when 406
92
+ raise DNSimple::CertificateExists.new("#{name}.#{domain.name}", response["errors"])
93
+ else
94
+ raise DNSimple::Error.new("#{name}.#{domain.name}", response["errors"])
118
95
  end
96
+ end
119
97
 
120
- # Get an array of all certificates for the given domain.
121
- def self.all(domain, options={})
122
- options.merge!(DNSimple::Client.standard_options_with_credentials)
123
-
124
- response = self.get("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates", options)
125
-
126
- pp response if DNSimple::Client.debug?
98
+ # Get an array of all certificates for the given domain.
99
+ def self.all(domain, options={})
100
+ response = DNSimple::Client.get "domains/#{domain.name}/certificates", options
127
101
 
128
- case response.code
129
- when 200
130
- response.map { |r| DNSimple::Certificate.new({:domain => domain}.merge(r["certificate"])) }
131
- when 401
132
- raise DNSimple::AuthenticationFailed, "Authentication failed"
133
- else
134
- raise DNSimple::Error.new("List certificates error: #{response["errors"]}")
135
- end
102
+ case response.code
103
+ when 200
104
+ response.map { |r| new({:domain => domain}.merge(r["certificate"])) }
105
+ else
106
+ raise DNSimple::Error.new("List certificates error: #{response["errors"]}")
136
107
  end
108
+ end
137
109
 
138
- # Find a specific certificate for the given domain.
139
- def self.find(domain, certificate_id, options={})
140
- options.merge!(DNSimple::Client.standard_options_with_credentials)
141
-
142
- response = self.get("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates/#{certificate_id}", options)
143
-
144
- pp response if DNSimple::Client.debug?
145
-
146
- case response.code
147
- when 200
148
- DNSimple::Certificate.new({:domain => domain}.merge(response["certificate"]))
149
- when 401
150
- raise DNSimple::AuthenticationFailed, "Authentication failed"
151
- when 404
152
- raise DNSimple::CertificateNotFound, "Could not find certificate #{certificate_id} for domain #{domain.name}"
153
- else
154
- raise DNSimple::Error.new("Find certificate error: #{response["errors"]}")
155
- end
110
+ # Find a specific certificate for the given domain.
111
+ def self.find(domain, certificate_id, options={})
112
+ response = DNSimple::Client.get "domains/#{domain.name}/certificates/#{certificate_id}", options
113
+
114
+ case response.code
115
+ when 200
116
+ new({:domain => domain}.merge(response["certificate"]))
117
+ when 404
118
+ raise DNSimple::CertificateNotFound, "Could not find certificate #{certificate_id} for domain #{domain.name}"
119
+ else
120
+ raise DNSimple::Error.new("Find certificate error: #{response["errors"]}")
156
121
  end
157
122
  end
158
123
  end