dnsimple-ruby 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,44 +1,51 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
4
- method: :get
5
- uri: http://<USERNAME>:<PASSWORD>@localhost:3000/domains/example.com/records/70
6
- body:
7
- headers:
8
- accept:
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com/domains/example.com/records/70
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
9
11
  - application/json
10
- authorization:
12
+ Authorization:
11
13
  - Basic YW50aG9ueWVkZW5AZ21haWwuY29tOmxldG1laW4=
12
- response: !ruby/struct:VCR::Response
13
- status: !ruby/struct:VCR::ResponseStatus
14
+ response:
15
+ status:
14
16
  code: 200
15
17
  message: OK
16
- headers:
17
- x-ua-compatible:
18
+ headers:
19
+ X-Ua-Compatible:
18
20
  - IE=Edge
19
- access-control-allow-headers:
21
+ Access-Control-Allow-Headers:
20
22
  - Authorization,Accepts,Content-Type
21
- x-dnsimple-api-version:
23
+ X-Dnsimple-Api-Version:
22
24
  - 1.0.0
23
- etag:
24
- - "\"e44e23e8947baa8e4e07637aaae785a2\""
25
- access-control-allow-methods:
25
+ Etag:
26
+ - ! '"e44e23e8947baa8e4e07637aaae785a2"'
27
+ Access-Control-Allow-Methods:
26
28
  - OPTIONS
27
- content-type:
29
+ Content-Type:
28
30
  - application/json; charset=utf-8
29
- access-control-allow-origin:
30
- - "*"
31
- date:
31
+ Access-Control-Allow-Origin:
32
+ - ! '*'
33
+ Date:
32
34
  - Fri, 11 Nov 2011 20:23:36 GMT
33
- server:
35
+ Server:
34
36
  - WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
35
- x-runtime:
36
- - "0.599019"
37
- content-length:
38
- - "245"
39
- set-cookie:
40
- - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlMWJiN2NjM2IzYTM5MzMzOTUyNzllYjk5MzJlYmQ2YWFJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--a2cdbda5d90cb97836aa557e8d2511b91c1b1b80; path=/; HttpOnly
41
- cache-control:
37
+ X-Runtime:
38
+ - '0.599019'
39
+ Content-Length:
40
+ - '245'
41
+ Set-Cookie:
42
+ - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlMWJiN2NjM2IzYTM5MzMzOTUyNzllYjk5MzJlYmQ2YWFJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--a2cdbda5d90cb97836aa557e8d2511b91c1b1b80;
43
+ path=/; HttpOnly
44
+ Cache-Control:
42
45
  - max-age=0, private, must-revalidate
43
- body: "{\"record\":{\"content\":\"1.2.3.4\",\"created_at\":\"2011-11-11T20:22:26Z\",\"domain_id\":39,\"domain_service_id\":null,\"id\":70,\"name\":\"\",\"pdns_identifier\":null,\"prio\":null,\"record_type\":\"A\",\"special_type\":null,\"ttl\":600,\"updated_at\":\"2011-11-11T20:22:26Z\"}}"
44
- http_version: "1.1"
46
+ body:
47
+ encoding: UTF-8
48
+ string: ! '{"record":{"content":"1.2.3.4","created_at":"2011-11-11T20:22:26Z","domain_id":39,"domain_service_id":null,"id":70,"name":"","pdns_identifier":null,"prio":null,"record_type":"A","special_type":null,"ttl":600,"updated_at":"2011-11-11T20:22:26Z"}}'
49
+ http_version: '1.1'
50
+ recorded_at: Thu, 06 Sep 2012 18:52:19 GMT
51
+ recorded_with: VCR 2.2.5
@@ -1,44 +1,53 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
4
- method: :get
5
- uri: http://<USERNAME>:<PASSWORD>@localhost:3000/templates/googleapps
6
- body:
7
- headers:
8
- accept:
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com/templates/googleapps
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
9
11
  - application/json
10
- authorization:
12
+ Authorization:
11
13
  - Basic YW50aG9ueWVkZW5AZ21haWwuY29tOmxldG1laW4=
12
- response: !ruby/struct:VCR::Response
13
- status: !ruby/struct:VCR::ResponseStatus
14
+ response:
15
+ status:
14
16
  code: 200
15
17
  message: OK
16
- headers:
17
- x-ua-compatible:
18
+ headers:
19
+ X-Ua-Compatible:
18
20
  - IE=Edge
19
- access-control-allow-headers:
21
+ Access-Control-Allow-Headers:
20
22
  - Authorization,Accepts,Content-Type
21
- x-dnsimple-api-version:
23
+ X-Dnsimple-Api-Version:
22
24
  - 1.0.0
23
- etag:
24
- - "\"3649a89c5333cc5c491e30a29901f286\""
25
- access-control-allow-methods:
25
+ Etag:
26
+ - ! '"3649a89c5333cc5c491e30a29901f286"'
27
+ Access-Control-Allow-Methods:
26
28
  - OPTIONS
27
- content-type:
29
+ Content-Type:
28
30
  - application/json; charset=utf-8
29
- access-control-allow-origin:
30
- - "*"
31
- date:
31
+ Access-Control-Allow-Origin:
32
+ - ! '*'
33
+ Date:
32
34
  - Fri, 11 Nov 2011 20:26:05 GMT
33
- server:
35
+ Server:
34
36
  - WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
35
- x-runtime:
36
- - "0.301433"
37
- content-length:
38
- - "266"
39
- set-cookie:
40
- - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYjMyMDBiMjQwNDdiN2FlMjE4OTUxMDU5ZGYzY2EyMjNJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--f1d49fb81f9ca5dae40e254e327c1c69b5352921; path=/; HttpOnly
41
- cache-control:
37
+ X-Runtime:
38
+ - '0.301433'
39
+ Content-Length:
40
+ - '266'
41
+ Set-Cookie:
42
+ - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYjMyMDBiMjQwNDdiN2FlMjE4OTUxMDU5ZGYzY2EyMjNJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--f1d49fb81f9ca5dae40e254e327c1c69b5352921;
43
+ path=/; HttpOnly
44
+ Cache-Control:
42
45
  - max-age=0, private, must-revalidate
43
- body: "{\"dns_template\":{\"created_at\":\"2011-09-04T01:08:50Z\",\"description\":\"The Google Mail Servers and Google Apps CNAME records in a single template.\",\"id\":3,\"name\":\"Google Apps\",\"short_name\":\"googleapps\",\"updated_at\":\"2011-09-04T01:08:50Z\",\"user_id\":null,\"visible\":true}}"
44
- http_version: "1.1"
46
+ body:
47
+ encoding: UTF-8
48
+ string: ! '{"dns_template":{"created_at":"2011-09-04T01:08:50Z","description":"The
49
+ Google Mail Servers and Google Apps CNAME records in a single template.","id":3,"name":"Google
50
+ Apps","short_name":"googleapps","updated_at":"2011-09-04T01:08:50Z","user_id":null,"visible":true}}'
51
+ http_version: '1.1'
52
+ recorded_at: Thu, 06 Sep 2012 18:52:19 GMT
53
+ recorded_with: VCR 2.2.5
@@ -1,42 +1,49 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
4
- method: :get
5
- uri: http://<USERNAME>:<PASSWORD>@localhost:3000/users/me.json
6
- body:
7
- headers:
8
- authorization:
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com/users/me
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Authorization:
9
11
  - Basic YW50aG9ueWVkZW5AZ21haWwuY29tOmxldG1laW4=
10
- response: !ruby/struct:VCR::Response
11
- status: !ruby/struct:VCR::ResponseStatus
12
+ response:
13
+ status:
12
14
  code: 200
13
15
  message: OK
14
- headers:
15
- x-ua-compatible:
16
+ headers:
17
+ X-Ua-Compatible:
16
18
  - IE=Edge
17
- access-control-allow-headers:
19
+ Access-Control-Allow-Headers:
18
20
  - Authorization,Accepts,Content-Type
19
- x-dnsimple-api-version:
21
+ X-Dnsimple-Api-Version:
20
22
  - 1.0.0
21
- etag:
22
- - "\"3aec1a878ad478216d54579f95258697\""
23
- access-control-allow-methods:
23
+ Etag:
24
+ - ! '"3aec1a878ad478216d54579f95258697"'
25
+ Access-Control-Allow-Methods:
24
26
  - OPTIONS
25
- content-type:
27
+ Content-Type:
26
28
  - application/json; charset=utf-8
27
- access-control-allow-origin:
28
- - "*"
29
- date:
29
+ Access-Control-Allow-Origin:
30
+ - ! '*'
31
+ Date:
30
32
  - Fri, 11 Nov 2011 20:33:01 GMT
31
- server:
33
+ Server:
32
34
  - WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
33
- x-runtime:
34
- - "5.589996"
35
- content-length:
36
- - "325"
37
- set-cookie:
38
- - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlZTBlZTI5ZGMzYmNkZDgxY2QzMjZmMTQwZWEwOTdmMDVJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--ec4d0fa610542fdbeb1dca4838d8b4bb91e8597a; path=/; HttpOnly
39
- cache-control:
35
+ X-Runtime:
36
+ - '5.589996'
37
+ Content-Length:
38
+ - '325'
39
+ Set-Cookie:
40
+ - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlZTBlZTI5ZGMzYmNkZDgxY2QzMjZmMTQwZWEwOTdmMDVJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--ec4d0fa610542fdbeb1dca4838d8b4bb91e8597a;
41
+ path=/; HttpOnly
42
+ Cache-Control:
40
43
  - max-age=0, private, must-revalidate
41
- body: "{\"user\":{\"access_code\":null,\"created_at\":\"2011-09-25T09:11:23Z\",\"default_contact_id\":null,\"email\":\"anthonyeden@gmail.com\",\"failed_login_count\":0,\"first_name\":null,\"id\":1,\"last_name\":null,\"login_count\":2,\"referral_token\":\"a93b6fa7c98483\",\"style\":\"light\",\"updated_at\":\"2011-11-11T20:32:56Z\",\"domain_count\":5,\"domain_limit\":10}}"
42
- http_version: "1.1"
44
+ body:
45
+ encoding: UTF-8
46
+ string: ! '{"user":{"access_code":null,"created_at":"2011-09-25T09:11:23Z","default_contact_id":null,"email":"anthonyeden@gmail.com","failed_login_count":0,"first_name":null,"id":1,"last_name":null,"login_count":2,"referral_token":"a93b6fa7c98483","style":"light","updated_at":"2011-11-11T20:32:56Z","domain_count":5,"domain_limit":10}}'
47
+ http_version: '1.1'
48
+ recorded_at: Thu, 06 Sep 2012 18:52:19 GMT
49
+ recorded_with: VCR 2.2.5
data/lib/dnsimple.rb CHANGED
@@ -1,8 +1,21 @@
1
- require 'pp'
2
1
  require 'httparty'
3
2
 
4
3
  module DNSimple
4
+
5
5
  BLANK_REGEX = /\S+/
6
+
7
+ # Echoes a deprecation warning message.
8
+ #
9
+ # @param [String] message The message to display.
10
+ # @return [void]
11
+ #
12
+ # @api internal
13
+ # @private
14
+ def self.deprecate(message = nil)
15
+ message ||= "You are using deprecated behavior which will be removed from the next major or minor release."
16
+ warn("DEPRECATION WARNING: #{message}")
17
+ end
18
+
6
19
  end
7
20
 
8
21
  require 'dnsimple/base'
data/lib/dnsimple/base.rb CHANGED
@@ -1,8 +1,10 @@
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)
1
+ module DNSimple
2
+ class Base
3
+ def initialize(attributes = {})
4
+ attributes.each do |key, value|
5
+ m = "#{key}=".to_sym
6
+ self.send(m, value) if self.respond_to?(m)
7
+ end
6
8
  end
7
9
  end
8
10
  end
@@ -1,123 +1,128 @@
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
1
+ module DNSimple
6
2
 
7
- # The certificate ID in DNSimple
8
- attr_accessor :id
3
+ # Represents an SSL certificate that has been purchased.
4
+ #
5
+ # The certificate must also be submitted using the #submit method
6
+ # before the Certificate Authority will issue a signed certificate.
7
+ class Certificate < Base
9
8
 
10
- attr_accessor :domain
9
+ # The certificate ID in DNSimple
10
+ attr_accessor :id
11
11
 
12
- # The subdomain on the certificate
13
- attr_accessor :name
12
+ attr_accessor :domain
14
13
 
15
- # The private key, if DNSimple generated the Certificate Signing Request
16
- attr_accessor :private_key
14
+ # The subdomain on the certificate
15
+ attr_accessor :name
17
16
 
18
- # The SSL certificate, if it has been issued by the Certificate Authority
19
- attr_accessor :ssl_certificate
17
+ # The private key, if DNSimple generated the Certificate Signing Request
18
+ attr_accessor :private_key
20
19
 
21
- # The Certificate Signing Request
22
- attr_accessor :csr
20
+ # The SSL certificate, if it has been issued by the Certificate Authority
21
+ attr_accessor :ssl_certificate
23
22
 
24
- # The Certificate status
25
- attr_accessor :certificate_status
23
+ # The Certificate Signing Request
24
+ attr_accessor :csr
26
25
 
27
- # The date the Certificate order was placed
28
- attr_accessor :order_date
26
+ # The Certificate status
27
+ attr_accessor :certificate_status
29
28
 
30
- # The date the Certificate will expire
31
- attr_accessor :expiration_date
29
+ # The date the Certificate order was placed
30
+ attr_accessor :order_date
32
31
 
33
- # The approver email address
34
- attr_accessor :approver_email
32
+ # The date the Certificate will expire
33
+ attr_accessor :expiration_date
35
34
 
36
- # An array of all emails that can be used to approve the certificate
37
- attr_accessor :available_approver_emails
35
+ # The approver email address
36
+ attr_accessor :approver_email
38
37
 
39
- # When the certificate was purchased
40
- attr_accessor :created_at
38
+ # An array of all emails that can be used to approve the certificate
39
+ attr_accessor :available_approver_emails
41
40
 
42
- # When the certificate was last updated
43
- attr_accessor :updated_at
41
+ # When the certificate was purchased
42
+ attr_accessor :created_at
44
43
 
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
44
+ # When the certificate was last updated
45
+ attr_accessor :updated_at
50
46
 
51
- def submit(approver_email, options={})
52
- raise DNSimple::Error, "Approver email is required" unless approver_email
53
47
 
54
- options.merge!(:body => {:certificate => {:approver_email => approver_email}})
48
+ # Get the fully-qualified domain name for the certificate. This is the
49
+ # domain.name joined with the certificate name, separated by a period.
50
+ def fqdn
51
+ [name, domain.name].delete_if { |p| p !~ DNSimple::BLANK_REGEX }.join(".")
52
+ end
53
+
54
+ def submit(approver_email, options={})
55
+ raise DNSimple::Error, "Approver email is required" unless approver_email
55
56
 
56
- response = DNSimple::Client.put "domains/#{domain.name}/certificates/#{id}/submit", options
57
+ options.merge!(:body => {:certificate => {:approver_email => approver_email}})
57
58
 
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"]}")
59
+ response = DNSimple::Client.put("domains/#{domain.name}/certificates/#{id}/submit", options)
60
+
61
+ case response.code
62
+ when 200
63
+ Certificate.new({ :domain => domain }.merge(response["certificate"]))
64
+ else
65
+ raise RequestError.new("Error submitting certificate", response)
66
+ end
63
67
  end
64
- end
65
68
 
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"])
69
+ # Purchase a certificate under the given domain with the given name. The
70
+ # name will be appended to the domain name, and thus should only be the
71
+ # subdomain part.
72
+ #
73
+ # Example: DNSimple::Certificate.purchase(domain, 'www', contact)
74
+ #
75
+ # Please note that by invoking this method DNSimple will immediately charge
76
+ # your credit card on file at DNSimple for the full certificate price.
77
+ #
78
+ # For wildcard certificates an asterisk must appear in the name.
79
+ #
80
+ # Example: DNSimple::Certificate.purchase(domain, '*', contact)
81
+ def self.purchase(domain, name, contact, options={})
82
+ certificate_hash = {
83
+ :name => name,
84
+ :contact_id => contact.id
85
+ }
86
+
87
+ options.merge!({:body => {:certificate => certificate_hash}})
88
+
89
+ response = DNSimple::Client.post("domains/#{domain.name}/certificates", options)
90
+
91
+ case response.code
92
+ when 201
93
+ new({ :domain => domain }.merge(response["certificate"]))
94
+ when 406
95
+ raise RecordExists, "Certificate for #{domain.name} already exists"
96
+ else
97
+ raise RequestError.new("Error purchasing certificate", response)
98
+ end
95
99
  end
96
- end
97
100
 
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
101
+ # Get an array of all certificates for the given domain.
102
+ def self.all(domain, options={})
103
+ response = DNSimple::Client.get("domains/#{domain.name}/certificates", options)
101
104
 
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"]}")
105
+ case response.code
106
+ when 200
107
+ response.map { |r| new({:domain => domain}.merge(r["certificate"])) }
108
+ else
109
+ raise RequestError.new("Error listing certificates", response)
110
+ end
107
111
  end
108
- end
109
112
 
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"]}")
113
+ # Find a specific certificate for the given domain.
114
+ def self.find(domain, id, options = {})
115
+ response = DNSimple::Client.get("domains/#{domain.name}/certificates/#{id}", options)
116
+
117
+ case response.code
118
+ when 200
119
+ new({:domain => domain}.merge(response["certificate"]))
120
+ when 404
121
+ raise RecordNotFound, "Could not find certificate #{id} for domain #{domain.name}"
122
+ else
123
+ raise RequestError.new("Error finding certificate", response)
124
+ end
121
125
  end
126
+
122
127
  end
123
128
  end