dnsimple-ruby 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +9 -2
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +7 -0
  7. data/CHANGELOG.md +20 -0
  8. data/Gemfile +0 -2
  9. data/LICENSE +2 -2
  10. data/README.md +121 -0
  11. data/Rakefile +30 -14
  12. data/bin/dnsimple.rb +1 -1
  13. data/dnsimple-ruby.gemspec +9 -8
  14. data/features/README +1 -1
  15. data/features/step_definitions/cli_steps.rb +1 -1
  16. data/features/support/env.rb +4 -4
  17. data/fixtures/vcr_cassettes/DNSimple_Certificate/_all.yml +45 -32
  18. data/fixtures/vcr_cassettes/DNSimple_Certificate/_purchase.yml +45 -32
  19. data/fixtures/vcr_cassettes/DNSimple_Certificate/_submit.yml +45 -32
  20. data/fixtures/vcr_cassettes/DNSimple_Contact/a_new_contact.yml +39 -31
  21. data/fixtures/vcr_cassettes/DNSimple_Contact/an_existing_contact.yml +39 -31
  22. data/fixtures/vcr_cassettes/DNSimple_Domain/_all.yml +113 -94
  23. data/fixtures/vcr_cassettes/DNSimple_Domain/applying_templates.yml +186 -156
  24. data/fixtures/vcr_cassettes/DNSimple_Domain/creating_a_new_domain.yml +39 -32
  25. data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_id.yml +39 -32
  26. data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_name.yml +39 -32
  27. data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_a_new_registrant_contact.yml +40 -32
  28. data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_an_existing_contact.yml +40 -32
  29. data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_ca.yml +262 -29
  30. data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_com.yml +35 -29
  31. data/fixtures/vcr_cassettes/DNSimple_Record/_all.yml +147 -125
  32. data/fixtures/vcr_cassettes/DNSimple_Record/creating_a_new_record.yml +39 -32
  33. data/fixtures/vcr_cassettes/DNSimple_Record/find_a_record.yml +39 -32
  34. data/fixtures/vcr_cassettes/DNSimple_Template/a_template.yml +41 -32
  35. data/fixtures/vcr_cassettes/DNSimple_User/_me.yml +38 -31
  36. data/lib/dnsimple.rb +14 -1
  37. data/lib/dnsimple/base.rb +7 -5
  38. data/lib/dnsimple/certificate.rb +100 -95
  39. data/lib/dnsimple/cli.rb +92 -93
  40. data/lib/dnsimple/client.rb +109 -99
  41. data/lib/dnsimple/commands/{describe_certificate.rb → certificate_describe.rb} +2 -2
  42. data/lib/dnsimple/commands/{list_certificates.rb → certificate_list.rb} +2 -2
  43. data/lib/dnsimple/commands/{purchase_certificate.rb → certificate_purchase.rb} +3 -5
  44. data/lib/dnsimple/commands/{submit_certificate.rb → certificate_submit.rb} +3 -5
  45. data/lib/dnsimple/commands/{create_contact.rb → contact_create.rb} +8 -6
  46. data/lib/dnsimple/commands/{delete_contact.rb → contact_delete.rb} +2 -2
  47. data/lib/dnsimple/commands/{describe_contact.rb → contact_describe.rb} +2 -2
  48. data/lib/dnsimple/commands/{list_contacts.rb → contact_list.rb} +2 -2
  49. data/lib/dnsimple/commands/{update_contact.rb → contact_update.rb} +2 -2
  50. data/lib/dnsimple/commands/{apply_template.rb → domain_apply_template.rb} +2 -2
  51. data/lib/dnsimple/commands/{check_domain.rb → domain_check.rb} +2 -2
  52. data/lib/dnsimple/commands/{clear_domain.rb → domain_clear.rb} +2 -2
  53. data/lib/dnsimple/commands/{create_domain.rb → domain_create.rb} +2 -2
  54. data/lib/dnsimple/commands/{delete_domain.rb → domain_delete.rb} +2 -2
  55. data/lib/dnsimple/commands/{describe_domain.rb → domain_describe.rb} +2 -2
  56. data/lib/dnsimple/commands/{list_domains.rb → domain_list.rb} +2 -2
  57. data/lib/dnsimple/commands/{register_domain.rb → domain_register.rb} +2 -2
  58. data/lib/dnsimple/commands/{transfer_domain.rb → domain_transfer.rb} +2 -2
  59. data/lib/dnsimple/commands/{list_extended_attributes.rb → extended_attribute_list.rb} +2 -2
  60. data/lib/dnsimple/commands/{describe_user.rb → me.rb} +2 -2
  61. data/lib/dnsimple/commands/{create_record.rb → record_create.rb} +5 -7
  62. data/lib/dnsimple/commands/{delete_record.rb → record_delete.rb} +2 -2
  63. data/lib/dnsimple/commands/{describe_record.rb → record_describe.rb} +2 -2
  64. data/lib/dnsimple/commands/{list_records.rb → record_list.rb} +4 -6
  65. data/lib/dnsimple/commands/{update_record.rb → record_update.rb} +2 -2
  66. data/lib/dnsimple/commands/{add_service.rb → service_add.rb} +3 -5
  67. data/lib/dnsimple/commands/{describe_service.rb → service_describe.rb} +2 -2
  68. data/lib/dnsimple/commands/{list_services.rb → service_list.rb} +2 -2
  69. data/lib/dnsimple/commands/{list_applied_services.rb → service_list_applied.rb} +2 -2
  70. data/lib/dnsimple/commands/{list_available_services.rb → service_list_available.rb} +2 -2
  71. data/lib/dnsimple/commands/{remove_service.rb → service_remove.rb} +2 -2
  72. data/lib/dnsimple/commands/{create_template.rb → template_create.rb} +2 -2
  73. data/lib/dnsimple/commands/{delete_template.rb → template_delete.rb} +2 -2
  74. data/lib/dnsimple/commands/{add_template_record.rb → template_record_create.rb} +2 -2
  75. data/lib/dnsimple/commands/{delete_template_record.rb → template_record_delete.rb} +2 -2
  76. data/lib/dnsimple/commands/{list_template_records.rb → template_record_list.rb} +2 -2
  77. data/lib/dnsimple/commands/{list_templates.rb → templates_list.rb} +2 -2
  78. data/lib/dnsimple/contact.rb +115 -110
  79. data/lib/dnsimple/domain.rb +134 -132
  80. data/lib/dnsimple/error.rb +8 -19
  81. data/lib/dnsimple/extended_attribute.rb +39 -33
  82. data/lib/dnsimple/record.rb +71 -67
  83. data/lib/dnsimple/service.rb +31 -24
  84. data/lib/dnsimple/template.rb +52 -46
  85. data/lib/dnsimple/template_record.rb +61 -53
  86. data/lib/dnsimple/transfer_order.rb +24 -18
  87. data/lib/dnsimple/user.rb +22 -18
  88. data/lib/dnsimple/version.rb +1 -1
  89. data/spec/README +1 -1
  90. data/spec/ci/.dnsimple.test +3 -0
  91. data/spec/commands/{purchase_certificate_spec.rb → certificate_purchase_spec.rb} +3 -4
  92. data/spec/commands/{submit_certificate_spec.rb → certificate_submit_spec.rb} +3 -4
  93. data/spec/commands/{create_record_spec.rb → record_create_spec.rb} +4 -4
  94. data/spec/commands/{list_records_spec.rb → records_list_spec.rb} +2 -13
  95. data/spec/commands/{add_service_spec.rb → service_add_spec.rb} +3 -12
  96. data/spec/{certificate_spec.rb → dnsimple/certificate_spec.rb} +0 -0
  97. data/spec/dnsimple/client_spec.rb +45 -18
  98. data/spec/{contact_spec.rb → dnsimple/contact_spec.rb} +3 -1
  99. data/spec/{domain_spec.rb → dnsimple/domain_spec.rb} +2 -0
  100. data/spec/{extended_attributes_spec.rb → dnsimple/extended_attributes_spec.rb} +4 -0
  101. data/spec/{record_spec.rb → dnsimple/record_spec.rb} +2 -0
  102. data/spec/{template_spec.rb → dnsimple/template_spec.rb} +0 -0
  103. data/spec/{user_spec.rb → dnsimple/user_spec.rb} +2 -0
  104. data/spec/spec_helper.rb +24 -10
  105. metadata +96 -99
  106. data/Gemfile.lock +0 -71
  107. data/README +0 -108
  108. data/README.rdoc +0 -108
  109. data/README.textile +0 -138
  110. data/lib/dnsimple/command.rb +0 -10
  111. data/spec/command_spec.rb +0 -19
data/lib/dnsimple/cli.rb CHANGED
@@ -1,7 +1,5 @@
1
- require 'yaml'
2
-
3
1
  module DNSimple
4
-
2
+
5
3
  class CommandNotFound < RuntimeError
6
4
  end
7
5
 
@@ -25,98 +23,99 @@ module DNSimple
25
23
 
26
24
  def commands
27
25
  {
28
- 'info' => DNSimple::Commands::DescribeUser,
29
-
30
- 'check' => DNSimple::Commands::CheckDomain,
31
- 'create' => DNSimple::Commands::CreateDomain,
32
- 'register' => DNSimple::Commands::RegisterDomain,
33
- 'transfer' => DNSimple::Commands::TransferDomain,
34
- 'describe' => DNSimple::Commands::DescribeDomain,
35
- 'list' => DNSimple::Commands::ListDomains,
36
- 'delete' => DNSimple::Commands::DeleteDomain,
37
- 'clear' => DNSimple::Commands::ClearDomain,
38
- 'apply' => DNSimple::Commands::ApplyTemplate,
39
-
40
- 'record:describe' => DNSimple::Commands::DescribeRecord,
41
- 'record:create' => DNSimple::Commands::CreateRecord,
42
- 'record:list' => DNSimple::Commands::ListRecords,
43
- 'record:update' => DNSimple::Commands::UpdateRecord,
44
- 'record:delete' => DNSimple::Commands::DeleteRecord,
45
-
46
- 'template:create' => DNSimple::Commands::CreateTemplate,
47
- 'template:list' => DNSimple::Commands::ListTemplates,
48
- 'template:delete' => DNSimple::Commands::DeleteTemplate,
49
-
50
- 'template:list_records' => DNSimple::Commands::ListTemplateRecords,
51
- 'template:add_record' => DNSimple::Commands::AddTemplateRecord,
52
- 'template:delete_record' => DNSimple::Commands::DeleteTemplateRecord,
53
-
54
- 'contact:create' => DNSimple::Commands::CreateContact,
55
- 'contact:list' => DNSimple::Commands::ListContacts,
56
- 'contact:describe' => DNSimple::Commands::DescribeContact,
57
- 'contact:update' => DNSimple::Commands::UpdateContact,
58
- 'contact:delete' => DNSimple::Commands::DeleteContact,
59
-
60
- 'extended-attributes:list' => DNSimple::Commands::ListExtendedAttributes,
61
-
62
- 'service:list' => DNSimple::Commands::ListServices,
63
- 'service:describe' => DNSimple::Commands::DescribeService,
64
-
65
- 'service:applied' => DNSimple::Commands::ListAppliedServices,
66
- 'service:available' => DNSimple::Commands::ListAvailableServices,
67
- 'service:add' => DNSimple::Commands::AddService,
68
- 'service:remove' => DNSimple::Commands::RemoveService,
69
-
70
- 'certificate:list' => DNSimple::Commands::ListCertificates,
71
- 'certificate:describe' => DNSimple::Commands::DescribeCertificate,
72
- 'certificate:purchase' => DNSimple::Commands::PurchaseCertificate,
73
- 'certificate:submit' => DNSimple::Commands::SubmitCertificate
26
+ 'info' => DNSimple::Commands::Me,
27
+
28
+ 'list' => DNSimple::Commands::DomainList,
29
+ 'describe' => DNSimple::Commands::DomainDescribe,
30
+ 'check' => DNSimple::Commands::DomainCheck,
31
+ 'create' => DNSimple::Commands::DomainCreate,
32
+ 'register' => DNSimple::Commands::DomainRegister,
33
+ 'transfer' => DNSimple::Commands::DomainTransfer,
34
+ 'delete' => DNSimple::Commands::DomainDelete,
35
+ 'clear' => DNSimple::Commands::DomainClear,
36
+ 'apply' => DNSimple::Commands::DomainApplyTemplate,
37
+
38
+ 'record:describe' => DNSimple::Commands::RecordDescribe,
39
+ 'record:create' => DNSimple::Commands::RecordCreate,
40
+ 'record:list' => DNSimple::Commands::RecordList,
41
+ 'record:update' => DNSimple::Commands::RecordUpdate,
42
+ 'record:delete' => DNSimple::Commands::RecordDelete,
43
+
44
+ 'template:create' => DNSimple::Commands::TemplateCreate,
45
+ 'template:list' => DNSimple::Commands::TemplateList,
46
+ 'template:delete' => DNSimple::Commands::TemplateDelete,
47
+
48
+ 'template:list_records' => DNSimple::Commands::TemplateRecordList,
49
+ 'template:add_record' => DNSimple::Commands::TemplateRecordCreate,
50
+ 'template:delete_record' => DNSimple::Commands::TemplateRecordDelete,
51
+
52
+ 'contact:create' => DNSimple::Commands::ContactCreate,
53
+ 'contact:list' => DNSimple::Commands::ContactList,
54
+ 'contact:describe' => DNSimple::Commands::ContactDescribe,
55
+ 'contact:update' => DNSimple::Commands::ContactUpdate,
56
+ 'contact:delete' => DNSimple::Commands::ContactDelete,
57
+
58
+ 'extended-attributes:list' => DNSimple::Commands::ExtendedAttributeList,
59
+
60
+ 'service:list' => DNSimple::Commands::ServiceList,
61
+ 'service:describe' => DNSimple::Commands::ServiceDescribe,
62
+
63
+ 'service:applied' => DNSimple::Commands::ServiceListApplied,
64
+ 'service:available' => DNSimple::Commands::ServiceListAvailable,
65
+ 'service:add' => DNSimple::Commands::ServiceAdd,
66
+ 'service:remove' => DNSimple::Commands::ServiceRemove,
67
+
68
+ 'certificate:list' => DNSimple::Commands::CertificateList,
69
+ 'certificate:describe' => DNSimple::Commands::CertificateDescribe,
70
+ 'certificate:purchase' => DNSimple::Commands::CertificatePurchase,
71
+ 'certificate:submit' => DNSimple::Commands::CertificateSubmit,
74
72
  }
75
73
  end
76
74
  end
77
75
  end
78
76
 
79
- require 'dnsimple/commands/describe_user'
80
- require 'dnsimple/commands/check_domain'
81
- require 'dnsimple/commands/create_domain'
82
- require 'dnsimple/commands/register_domain'
83
- require 'dnsimple/commands/transfer_domain'
84
- require 'dnsimple/commands/describe_domain'
85
- require 'dnsimple/commands/list_domains'
86
- require 'dnsimple/commands/delete_domain'
87
- require 'dnsimple/commands/clear_domain'
88
- require 'dnsimple/commands/apply_template'
89
-
90
- require 'dnsimple/commands/describe_record'
91
- require 'dnsimple/commands/create_record'
92
- require 'dnsimple/commands/list_records'
93
- require 'dnsimple/commands/update_record'
94
- require 'dnsimple/commands/delete_record'
95
-
96
- require 'dnsimple/commands/create_template'
97
- require 'dnsimple/commands/list_templates'
98
- require 'dnsimple/commands/delete_template'
99
- require 'dnsimple/commands/list_template_records'
100
- require 'dnsimple/commands/add_template_record'
101
- require 'dnsimple/commands/delete_template_record'
102
-
103
- require 'dnsimple/commands/create_contact'
104
- require 'dnsimple/commands/list_contacts'
105
- require 'dnsimple/commands/describe_contact'
106
- require 'dnsimple/commands/update_contact'
107
- require 'dnsimple/commands/delete_contact'
108
-
109
- require 'dnsimple/commands/list_extended_attributes'
110
-
111
- require 'dnsimple/commands/list_services'
112
- require 'dnsimple/commands/describe_service'
113
-
114
- require 'dnsimple/commands/list_available_services'
115
- require 'dnsimple/commands/list_applied_services'
116
- require 'dnsimple/commands/add_service'
117
- require 'dnsimple/commands/remove_service'
118
-
119
- require 'dnsimple/commands/list_certificates'
120
- require 'dnsimple/commands/describe_certificate'
121
- require 'dnsimple/commands/purchase_certificate'
122
- require 'dnsimple/commands/submit_certificate'
77
+ require 'dnsimple/commands/me'
78
+
79
+ require 'dnsimple/commands/domain_list'
80
+ require 'dnsimple/commands/domain_describe'
81
+ require 'dnsimple/commands/domain_check'
82
+ require 'dnsimple/commands/domain_create'
83
+ require 'dnsimple/commands/domain_register'
84
+ require 'dnsimple/commands/domain_transfer'
85
+ require 'dnsimple/commands/domain_delete'
86
+ require 'dnsimple/commands/domain_clear'
87
+ require 'dnsimple/commands/domain_apply_template'
88
+
89
+ require 'dnsimple/commands/record_list'
90
+ require 'dnsimple/commands/record_describe'
91
+ require 'dnsimple/commands/record_create'
92
+ require 'dnsimple/commands/record_update'
93
+ require 'dnsimple/commands/record_delete'
94
+
95
+ require 'dnsimple/commands/template_list'
96
+ require 'dnsimple/commands/template_create'
97
+ require 'dnsimple/commands/template_delete'
98
+ require 'dnsimple/commands/template_record_list'
99
+ require 'dnsimple/commands/template_record_create'
100
+ require 'dnsimple/commands/template_record_delete'
101
+
102
+ require 'dnsimple/commands/contact_list'
103
+ require 'dnsimple/commands/contact_describe'
104
+ require 'dnsimple/commands/contact_create'
105
+ require 'dnsimple/commands/contact_update'
106
+ require 'dnsimple/commands/contact_delete'
107
+
108
+ require 'dnsimple/commands/extended_attribute_list'
109
+
110
+ require 'dnsimple/commands/service_list'
111
+ require 'dnsimple/commands/service_describe'
112
+
113
+ require 'dnsimple/commands/service_list_available'
114
+ require 'dnsimple/commands/service_list_applied'
115
+ require 'dnsimple/commands/service_add'
116
+ require 'dnsimple/commands/service_remove'
117
+
118
+ require 'dnsimple/commands/certificate_list'
119
+ require 'dnsimple/commands/certificate_describe'
120
+ require 'dnsimple/commands/certificate_purchase'
121
+ require 'dnsimple/commands/certificate_submit'
@@ -1,131 +1,141 @@
1
- class DNSimple::Client
2
- def self.debug?
3
- @debug
4
- end
1
+ require 'yaml'
5
2
 
6
- def self.debug=(debug)
7
- @debug = debug
8
- end
3
+ module DNSimple
4
+ class Client
9
5
 
10
- def self.username
11
- @username
12
- end
13
-
14
- def self.username=(username)
15
- @username = username
16
- end
6
+ def self.debug?
7
+ @debug
8
+ end
17
9
 
18
- def self.password
19
- @password
20
- end
10
+ def self.debug=(debug)
11
+ @debug = debug
12
+ end
21
13
 
22
- def self.password=(password)
23
- @password = password
24
- end
14
+ def self.username
15
+ @username
16
+ end
25
17
 
26
- def self.api_token
27
- @api_token
28
- end
18
+ def self.username=(username)
19
+ @username = username
20
+ end
29
21
 
30
- def self.api_token=(api_token)
31
- @api_token = api_token
32
- end
22
+ def self.password
23
+ @password
24
+ end
33
25
 
34
- def self.base_uri
35
- @base_uri ||= "https://dnsimple.com/"
36
- end
26
+ def self.password=(password)
27
+ @password = password
28
+ end
37
29
 
38
- def self.base_uri=(base_uri)
39
- base_uri += '/' if base_uri && base_uri[/\/$/].nil?
40
- @base_uri = base_uri
41
- end
30
+ def self.api_token
31
+ @api_token
32
+ end
42
33
 
43
- def self.http_proxy
44
- @http_proxy
45
- end
34
+ def self.api_token=(api_token)
35
+ @api_token = api_token
36
+ end
46
37
 
47
- def self.http_proxy=(http_proxy)
48
- @http_proxy = http_proxy
49
- end
38
+ # Gets the qualified API base uri.
39
+ #
40
+ # @return [String] The qualified API base uri.
41
+ def self.base_uri
42
+ @base_uri ||= "https://dnsimple.com"
43
+ end
50
44
 
51
- def self.load_credentials_if_necessary
52
- load_credentials unless credentials_loaded?
53
- end
45
+ # Sets the qualified API base uri.
46
+ #
47
+ # @param [String] value The qualified API base uri.
48
+ def self.base_uri=(value)
49
+ @base_uri = value.to_s.chomp("/")
50
+ end
54
51
 
55
- def self.config_path
56
- ENV['DNSIMPLE_CONFIG'] || '~/.dnsimple'
57
- end
52
+ def self.http_proxy
53
+ @http_proxy
54
+ end
58
55
 
59
- def self.load_credentials(path=config_path)
60
- begin
61
- credentials = YAML.load(File.new(File.expand_path(path)))
62
- self.username ||= credentials['username']
63
- self.password ||= credentials['password']
64
- self.api_token ||= credentials['api_token']
65
- self.base_uri ||= credentials['site']
66
- self.http_proxy = { :addr => credentials['proxy_addr'], :port => credentials['proxy_port'] }
67
- @credentials_loaded = true
68
- "Credentials loaded from #{path}"
69
- rescue
70
- puts "Error loading your credentials: #{$!.message}"
71
- exit 1
56
+ def self.http_proxy=(http_proxy)
57
+ @http_proxy = http_proxy
72
58
  end
73
- end
74
59
 
75
- def self.credentials_loaded?
76
- (@credentials_loaded ||= false) or (username and (password or api_token))
77
- end
60
+ def self.load_credentials_if_necessary
61
+ load_credentials unless credentials_loaded?
62
+ end
78
63
 
79
- def self.standard_options
80
- options = {
81
- :format => :json,
82
- :headers => {'Accept' => 'application/json'},
83
- }
64
+ def self.config_path
65
+ ENV['DNSIMPLE_CONFIG'] || '~/.dnsimple'
66
+ end
84
67
 
85
- if http_proxy
86
- options.merge!(
87
- :http_proxyaddr => self.http_proxy[:addr],
88
- :http_proxyport => self.http_proxy[:port]
89
- )
68
+ def self.load_credentials(path = config_path)
69
+ begin
70
+ credentials = YAML.load(File.new(File.expand_path(path)))
71
+ self.username ||= credentials['username']
72
+ self.password ||= credentials['password']
73
+ self.api_token ||= credentials['api_token']
74
+ self.base_uri = credentials['site'] if credentials['site']
75
+ self.base_uri = credentials['base_uri'] if credentials['base_uri']
76
+ self.http_proxy = { :addr => credentials['proxy_addr'], :port => credentials['proxy_port'] }
77
+ @credentials_loaded = true
78
+ puts "Credentials loaded from #{path}"
79
+ rescue => error
80
+ puts "Error loading your credentials: #{error.message}"
81
+ exit 1
82
+ end
90
83
  end
91
84
 
92
- if password
93
- options[:basic_auth] = {:username => username, :password => password}
94
- elsif api_token
95
- options[:headers]['X-DNSimple-Token'] = "#{username}:#{api_token}"
96
- else
97
- raise RuntimeError, 'A password or API token is required for all API requests.'
85
+ def self.credentials_loaded?
86
+ (@credentials_loaded ||= false) or (username and (password or api_token))
98
87
  end
99
88
 
100
- options
101
- end
89
+ def self.standard_options
90
+ options = {
91
+ :format => :json,
92
+ :headers => {'Accept' => 'application/json'},
93
+ }
94
+
95
+ if http_proxy
96
+ options.merge!(
97
+ :http_proxyaddr => self.http_proxy[:addr],
98
+ :http_proxyport => self.http_proxy[:port]
99
+ )
100
+ end
101
+
102
+ if password
103
+ options[:basic_auth] = {:username => username, :password => password}
104
+ elsif api_token
105
+ options[:headers]['X-DNSimple-Token'] = "#{username}:#{api_token}"
106
+ else
107
+ raise Error, 'A password or API token is required for all API requests.'
108
+ end
109
+
110
+ options
111
+ end
102
112
 
103
- def self.get(path, options = {})
104
- request :get, path, options
105
- end
113
+ def self.get(path, options = {})
114
+ request :get, path, options
115
+ end
106
116
 
107
- def self.post(path, options = {})
108
- request :post, path, options
109
- end
117
+ def self.post(path, options = {})
118
+ request :post, path, options
119
+ end
110
120
 
111
- def self.put(path, options = {})
112
- request :put, path, options
113
- end
121
+ def self.put(path, options = {})
122
+ request :put, path, options
123
+ end
114
124
 
115
- def self.delete(path, options = {})
116
- request :delete, path, options
117
- end
125
+ def self.delete(path, options = {})
126
+ request :delete, path, options
127
+ end
118
128
 
119
- def self.request(method, path, options)
120
- response = HTTParty.send(method, "#{base_uri}#{path}",
121
- standard_options.merge(options))
129
+ def self.request(method, path, options)
130
+ response = HTTParty.send(method, "#{base_uri}/#{path}",
131
+ standard_options.merge(options))
122
132
 
123
- pp response if debug?
133
+ if response.code == 401
134
+ raise AuthenticationFailed
135
+ end
124
136
 
125
- if response.code == 401
126
- raise DNSimple::AuthenticationFailed, 'Authentication failed'
137
+ response
127
138
  end
128
139
 
129
- response
130
140
  end
131
141
  end
@@ -1,7 +1,7 @@
1
1
  module DNSimple
2
2
  module Commands
3
- class DescribeCertificate
4
- def execute(args, options={})
3
+ class CertificateDescribe
4
+ def execute(args, options = {})
5
5
  domain_name = args.shift
6
6
  certificate_id = args.shift
7
7
  domain = Domain.find(domain_name)
@@ -1,7 +1,7 @@
1
1
  module DNSimple
2
2
  module Commands
3
- class ListCertificates
4
- def execute(args, options={})
3
+ class CertificateList
4
+ def execute(args, options = {})
5
5
  domain_name = args.shift
6
6
  domain = DNSimple::Domain.find(domain_name)
7
7
  certificates = DNSimple::Certificate.all(domain)