gandi_v5 0.1.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +14 -4
  4. data/.travis.yml +16 -1
  5. data/CHANGELOG.md +80 -2
  6. data/FUNDING.yml +10 -0
  7. data/Guardfile +5 -6
  8. data/LICENSE.md +2 -6
  9. data/README.md +17 -23
  10. data/gandi_v5.gemspec +4 -3
  11. data/lib/gandi_v5.rb +54 -15
  12. data/lib/gandi_v5/billing.rb +2 -4
  13. data/lib/gandi_v5/billing/info.rb +0 -2
  14. data/lib/gandi_v5/data.rb +1 -2
  15. data/lib/gandi_v5/data/converter.rb +0 -4
  16. data/lib/gandi_v5/data/converter/integer.rb +26 -0
  17. data/lib/gandi_v5/domain.rb +201 -101
  18. data/lib/gandi_v5/domain/auto_renew.rb +4 -4
  19. data/lib/gandi_v5/domain/availability.rb +46 -0
  20. data/lib/gandi_v5/domain/availability/product.rb +49 -0
  21. data/lib/gandi_v5/domain/availability/product/period.rb +24 -0
  22. data/lib/gandi_v5/domain/availability/product/price.rb +36 -0
  23. data/lib/gandi_v5/domain/availability/tax.rb +20 -0
  24. data/lib/gandi_v5/domain/live_dns.rb +42 -0
  25. data/lib/gandi_v5/domain/renewal_information.rb +0 -3
  26. data/lib/gandi_v5/domain/sharing_space.rb +10 -2
  27. data/lib/gandi_v5/domain/tld.rb +57 -0
  28. data/lib/gandi_v5/email.rb +0 -4
  29. data/lib/gandi_v5/email/forward.rb +108 -0
  30. data/lib/gandi_v5/email/mailbox.rb +85 -24
  31. data/lib/gandi_v5/email/mailbox/responder.rb +43 -2
  32. data/lib/gandi_v5/email/offer.rb +2 -2
  33. data/lib/gandi_v5/email/slot.rb +52 -18
  34. data/lib/gandi_v5/error.rb +0 -2
  35. data/lib/gandi_v5/error/gandi_error.rb +2 -2
  36. data/lib/gandi_v5/live_dns.rb +20 -4
  37. data/lib/gandi_v5/live_dns/domain.rb +21 -150
  38. data/lib/gandi_v5/live_dns/has_zone_records.rb +153 -0
  39. data/lib/gandi_v5/live_dns/record_set.rb +1 -1
  40. data/lib/gandi_v5/live_dns/zone.rb +24 -165
  41. data/lib/gandi_v5/live_dns/zone/snapshot.rb +27 -8
  42. data/lib/gandi_v5/organization.rb +39 -6
  43. data/lib/gandi_v5/organization/customer.rb +90 -0
  44. data/lib/gandi_v5/version.rb +1 -1
  45. data/spec/.rubocop.yml +9 -2
  46. data/spec/features/domain_spec.rb +2 -2
  47. data/spec/features/livedns_zone_spec.rb +12 -13
  48. data/spec/fixtures/bodies/GandiV5_Billing/{info.yaml → info.yml} +0 -0
  49. data/spec/fixtures/bodies/GandiV5_Domain/{get.yaml → fetch.yml} +8 -0
  50. data/spec/fixtures/bodies/GandiV5_Domain/{fetch_contacts.yaml → fetch_contacts.yml} +0 -0
  51. data/spec/fixtures/bodies/GandiV5_Domain/fetch_glue_records.yml +7 -0
  52. data/spec/fixtures/bodies/GandiV5_Domain/fetch_livedns.yml +6 -0
  53. data/spec/fixtures/bodies/GandiV5_Domain/fetch_name_servers.yml +2 -0
  54. data/spec/fixtures/bodies/GandiV5_Domain/{renewal_info.yaml → fetch_renewal_info.yml} +0 -3
  55. data/spec/fixtures/bodies/GandiV5_Domain/{restore_info.yaml → fetch_restore_info.yml} +0 -0
  56. data/spec/fixtures/bodies/GandiV5_Domain/{list.yaml → list.yml} +1 -0
  57. data/spec/fixtures/bodies/{GandiV5_Domain/availability.yaml → GandiV5_Domain_Availability/fetch.yml} +0 -0
  58. data/spec/fixtures/bodies/{GandiV5_Domain/tld.yaml → GandiV5_Domain_TLD/fetch.yml} +0 -0
  59. data/spec/fixtures/bodies/{GandiV5_Domain/tlds.yaml → GandiV5_Domain_TLD/list.yml} +0 -0
  60. data/spec/fixtures/bodies/GandiV5_Email_Forward/list.yml +6 -0
  61. data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{get.yaml → fetch.yml} +0 -0
  62. data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{list.yaml → list.yml} +0 -0
  63. data/spec/fixtures/bodies/GandiV5_Email_Slot/{get.yaml → fetch.yml} +0 -0
  64. data/spec/fixtures/bodies/GandiV5_Email_Slot/{list.yaml → list.yml} +0 -0
  65. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/{get.yaml → fetch.yml} +0 -0
  66. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/{list.yaml → list.yml} +0 -0
  67. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/{get.yaml → fetch.yml} +0 -0
  68. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/{list.yaml → list.yml} +0 -0
  69. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/{get.yaml → fetch.yml} +0 -0
  70. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yml +3 -0
  71. data/spec/fixtures/bodies/GandiV5_Organization/{get.yaml → fetch.yml} +0 -0
  72. data/spec/fixtures/bodies/GandiV5_Organization/list.yml +7 -0
  73. data/spec/fixtures/bodies/GandiV5_Organization_Customer/list.yml +8 -0
  74. data/spec/fixtures/vcr/Domain_features/List_domains.yml +2 -1
  75. data/spec/spec_helper.rb +2 -2
  76. data/spec/units/gandi_v5/billing_spec.rb +4 -4
  77. data/spec/units/gandi_v5/data/converter/integer_spec.rb +16 -0
  78. data/spec/units/gandi_v5/domain/auto_renew_spec.rb +5 -5
  79. data/spec/units/gandi_v5/domain/availability/product/period_spec.rb +4 -0
  80. data/spec/units/gandi_v5/domain/availability/product/price_spec.rb +4 -0
  81. data/spec/units/gandi_v5/domain/availability/product_spec.rb +4 -0
  82. data/spec/units/gandi_v5/domain/availability/tax_spec.rb +4 -0
  83. data/spec/units/gandi_v5/domain/availability_spec.rb +43 -0
  84. data/spec/units/gandi_v5/domain/live_dns_spec.rb +45 -0
  85. data/spec/units/gandi_v5/domain/tld_spec.rb +29 -0
  86. data/spec/units/gandi_v5/domain_spec.rb +359 -91
  87. data/spec/units/gandi_v5/email/forward_spec.rb +121 -0
  88. data/spec/units/gandi_v5/email/mailbox/responder_spec.rb +52 -0
  89. data/spec/units/gandi_v5/email/mailbox_spec.rb +174 -33
  90. data/spec/units/gandi_v5/email/offer_spec.rb +1 -1
  91. data/spec/units/gandi_v5/email/slot_spec.rb +113 -17
  92. data/spec/units/gandi_v5/live_dns/domain_spec.rb +73 -43
  93. data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +32 -3
  94. data/spec/units/gandi_v5/live_dns/zone_spec.rb +70 -52
  95. data/spec/units/gandi_v5/live_dns_spec.rb +24 -0
  96. data/spec/units/gandi_v5/organization/customer_spec.rb +81 -0
  97. data/spec/units/gandi_v5/organization_spec.rb +52 -1
  98. data/spec/units/gandi_v5_spec.rb +56 -19
  99. metadata +71 -29
  100. data/TODO.md +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d32f073e157edcd88519f82b4dd082943d4ea049e0232de31dc80d6585070fd7
4
- data.tar.gz: ed3c8d5156a3efed4980f62775affc680e73c59890c3430740e41e27dca04763
3
+ metadata.gz: 023623b5d81a2f3acc4a5fee812f0e8ca24dd8735f59a0f12b53ad35ddb7a397
4
+ data.tar.gz: 3cf89099c45295da9b06a53ad64b601b3a77525a13ddade403d600c382be02d3
5
5
  SHA512:
6
- metadata.gz: a15a87d90b92a53b37544862adb13cf11d21fa7d3737300f2b392b2abc9fa28cc150da48d40d0bb1d63c9a7f5b65dbf13cde7ed8d002e51ab78aac084fb17567
7
- data.tar.gz: 91812fc13dabdb21e84164a478376d411271aaec1a30be651f1c9af78c9c1d0e521a5af5f6b4162adb1e5a46ff1cd0bc6ce6231bc80e41cd86d2a33d45060f38
6
+ metadata.gz: 5e816b9de44330c832f6591ca6724b44f5b05c6fab53d8fda6d13a9820211292f29ee608953d8a562da97f4bcfee38f24f799b4a68184bba2b0ec751d21b3f61
7
+ data.tar.gz: 622bded49d8bae3129ad74fae6fcaf1e8d7c3639b40348b7537e0ba46a3d5c668d2a134754dcf1ff31bcffe3cf0797f5c4368cbc849c386b4648f850d9e24117
data/.gitignore CHANGED
@@ -5,6 +5,7 @@ Gemfile.lock
5
5
  # And because this is Ruby, ignore the following
6
6
  # (source: https://github.com/github/gitignore/blob/master/Ruby.gitignore):
7
7
 
8
+ .ruby-version
8
9
  notes.txt
9
10
  todo.txt
10
11
  *.gem
@@ -16,6 +17,7 @@ InstalledFiles
16
17
  lib/bundler/man
17
18
  pkg
18
19
  rdoc
20
+ doc
19
21
  spec/reports
20
22
  test/tmp
21
23
  test/version_tmp
@@ -5,16 +5,26 @@ AllCops:
5
5
  Gemspec/RequiredRubyVersion:
6
6
  Enabled: false
7
7
  Metrics/AbcSize:
8
- Max: 17
8
+ Max: 20
9
9
  Metrics/ClassLength:
10
- Max: 200
11
- Metrics/LineLength:
12
- Max: 100
10
+ Max: 250
11
+ Metrics/CyclomaticComplexity:
12
+ Max: 8
13
13
  Metrics/MethodLength:
14
14
  Max: 15
15
15
  Metrics/ModuleLength:
16
16
  Max: 200
17
+ Metrics/ParameterLists:
18
+ Max: 6
17
19
  Style/DocumentationMethod:
18
20
  Enabled: true
21
+ Style/HashEachMethods:
22
+ Enabled: true
23
+ Style/HashTransformKeys:
24
+ Enabled: true
25
+ Style/HashTransformValues:
26
+ Enabled: true
19
27
  Style/SignalException:
20
28
  Enabled: false
29
+ Layout/LineLength:
30
+ Max: 100
@@ -3,6 +3,13 @@ rvm:
3
3
  - 2.6.0
4
4
  - 2.6.1
5
5
  - 2.6.2
6
+ - 2.6.3
7
+ - 2.6.4
8
+ - 2.6.5
9
+ - 2.6.6
10
+ - 2.7.0
11
+ - 2.7.1
12
+ - truffleruby-20.1.0
6
13
  gemfile:
7
14
  - Gemfile
8
15
  branches:
@@ -11,10 +18,18 @@ branches:
11
18
  - staging
12
19
  - /gh(?:\d)+(?:-.+)?/
13
20
  - /dev_ver_\d+\.\d+/
21
+ env:
22
+ global:
23
+ # CC_TEST_REPORTER_ID for reporting test coverage to code climate
24
+ - secure: "C3AcK+/2A4h2+ZayJXc89EQp76o8/2RL03PdtVjWPI6cfBSwN174ImWSdIcs6+Bjv8GH+bADsM4epkTjI7H24wh80If/4jAZJMB6LsAxVC3rZVx2UfDghp1Lwcy6BkNx4VVXMQJUR4rA8fXNd1l6n2a72RbPhTaGYxggw+yiKYNjj5m/u3HWPzTQ9wIx/rLzb2shQU1P9tDX4eRqJixYsd8LvStvXewUKlTQSaxNczzfcSOmeJrrytJGuPQxgBx67hlN40cs84oEbhndjlekZRwYepsRcan9umJEDHnE+k0wLlz/vb2cshYp5tdcfkqspaEhUSV7Vr7ZQNIppI3XyY1hs/pTYc2Vytp3OiY0EXBjKRmiHcnmA8EIkrV9i4OSt6Af3EQJaYU56a0BCaEqzRoQJWOZDS8bVowuO4rY8/xINQBwTojIYAplI/vqX/7xvlRbzIgeWdpvQipPC01d2JtmI/5D1FdGWtzYcDCTRTbHyWmjhr7Jt8qEDMFkbpkcAQiS61baEQ0p4CxaLYm/lpPco1U3e/gMOb/EXDhOrF1I8lSBmVJE/Uz2/3kfOa1DQSxDSRmV1nU3pSd7PUi25Pdx0rezJjRl1UC2gnsNZrCLbplk+VkImXTt3iirV/RuHDo+YVT0efaws7TVH7Uf87jqWf4VZEw/KI3tzfF43CE="
14
25
  before_install: gem update bundler
26
+ before_script:
27
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter && chmod +x ./cc-test-reporter && ./cc-test-reporter before-build
15
28
  script:
16
- - bundle exec rubocop
29
+ - if [[ $(echo $TRAVIS_JOB_NUMBER | awk -F . '{ print $2 }') == '1' ]]; then bundle exec rubocop; fi
17
30
  - bundle exec rspec
31
+ after_script:
32
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
18
33
  notifications:
19
34
  slack:
20
35
  on_success: always
@@ -1,3 +1,81 @@
1
- ## Version 0.0.1
1
+ # Gandi V5 API Gem Changelog
2
2
 
3
- * Initial release.
3
+ ## Version 0.6.0
4
+
5
+ * GandiV5::Email::Slot.create now supports sharing_id
6
+ * GandiV5::Email::Slot.create's type argument is now named not positional
7
+ * Add reseller information to GandiV5::Domain
8
+
9
+ ## Version 0.5.0
10
+
11
+ * Add support for truffleruby 20.1.0
12
+ * Fix issue with rails in production
13
+
14
+ ## Version 0.4.0
15
+
16
+ * Fix exception when delete returns no content-type
17
+ * Add support for ruby 2.7.0
18
+ * Add up/downgrading mailbox offer
19
+ * Add dry run option to creating a mailbox
20
+ * Add sharing_id & dry run option for renewing domain
21
+ * Add listing customers under a reseller organization (GandiV5::Organization::Customer.list and GandiV5::Organization#customers)
22
+ * Add creating customer under a reseller organization (GandiV5::Organization::Customer.create and GandiV5::Organization#create_customer)
23
+
24
+ ## Version 0.3.0
25
+
26
+ * Additions to GandiV5::Domain
27
+ * Glue record management
28
+ * LiveDNS management
29
+ * Name server management
30
+ * Update GandiV5::Domain.create to allow purchasing as a reseller and billing to a different organization
31
+ * Add forwarding address management to GandiV5::Email::Forwarding
32
+ * Add GandiV5::Organization.list
33
+ * Uses Zeitwerk for auto loading
34
+ * Add aliasing methods:
35
+ * GandiV5::Domain.mailboxes -> GandiV5::Email::Mailbox.list
36
+ * GandiV5::Domain.mailbox_slots -> GandiV5::Email::Slot.list
37
+ * GandiV5::Domain.email_forwards -> GandiV5::Email::Forward.list
38
+
39
+ ## Version 0.2.0
40
+
41
+ * Enhancements to GandiV5::Domain
42
+ * .availability(fqdn, **options) moved to GandiV5::Domain::Availability.fetch(fqdn, **options)
43
+ * .create now returns created domain (except in dry-run mode)
44
+ * .tlds moved to GandiV5::Domain::TLD.list
45
+ * .tld(name) moved to GandiV5::Domain::TLD.fetch(name)
46
+ * #renewal_price(currency: 'GBP', period: 1) added
47
+ * Enhancements to GandiV5::Email::Mailbox
48
+ * .create now returns created mailbox
49
+ * .create now checks for available slots and a valid type has been passed
50
+ * Enhancements to GandiV5::Email::Mailbox::Responder
51
+ * Add #enable(message:, ends_at:, starts_at: Time.now) to enable the auto responder in Gandi
52
+ * Add #disable to disable the auto responder in Gandi
53
+ * Enhancements to GandiV5::Email::Slot
54
+ * .create now returns created slot
55
+ * #delete now checks for inactiveness and refundableness
56
+ * Enhancements to GandiV5::LiveDNS::Domain
57
+ * Add #zone and #fetch_zone
58
+ * Remove #replace_*_records_for methods
59
+ * Changes to #replace_records_for to allow calling with name, type, ttl and values. When calling with name and fecords records MUST be passed as an array.
60
+ * Enhancements to GandiV5::LiveDNS::Zone
61
+ * .create now returns created zone
62
+ * Remove #replace_*_records_for methods
63
+ * Changes to #replace_records_for to allow calling with name, type, ttl and values. When calling with name and fecords records MUST be passed as an array.
64
+ * Enhancements to GandiV5::LiveDNS::Zone::Snapshot
65
+ * Add .list
66
+ * Add .fetch
67
+ * Add #zone and #fetch_zone
68
+ * Add support for ruby 2.6.3
69
+ * Add aliasing methods:
70
+ * GandiV5.domains -> GandiV5::Domain.list
71
+ * GandiV5.domain -> GandiV5::Domain.fetch
72
+ * GandiV5.mailboxes -> GandiV5::Email::Mailbox.list
73
+ * GandiV5.mailbox_slots -> GandiV5::Email::Slot.list
74
+ * GandiV5::LiveDNS.domains -> GandiV5::LiveDNS::Domain.list
75
+ * GandiV5::LiveDNS.domain -> GandiV5::LiveDNS::Domain.fetch
76
+ * GandiV5::LiveDNS.zones -> GandiV5::LiveDNS::Zone.list
77
+ * GandiV5::LiveDNS.zone -> GandiV5::LiveDNS::Zone.fetch
78
+
79
+ ## Version 0.1.0
80
+
81
+ * Initial release.
@@ -0,0 +1,10 @@
1
+ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
2
+ patreon: robertgauld
3
+ open_collective: # Replace with a single Open Collective username
4
+ ko_fi: # Replace with a single Ko-fi username
5
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
6
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
7
+ liberapay: # Replace with a single Liberapay username
8
+ issuehunt: # Replace with a single IssueHunt username
9
+ otechie: # Replace with a single Otechie username
10
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
data/Guardfile CHANGED
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  guard :bundler do
4
- watch(/^Gemfile(?:\.lock)$'/)
5
- watch(/^.+\.gemspec$'/)
4
+ watch(/^Gemfile(?:\.lock)$/)
5
+ watch(/^.+\.gemspec$/)
6
6
  end
7
7
 
8
8
  # rubocop:disable Metrics/BlockLength
9
9
  group :red_green_refactor, halt_on_fail: true do
10
10
  group :rspec do
11
11
  guard(
12
- 'rspec',
12
+ :rspec,
13
13
  all_on_start: true,
14
14
  all_after_pass: false,
15
15
  notification: :failed,
@@ -24,12 +24,11 @@ group :red_green_refactor, halt_on_fail: true do
24
24
 
25
25
  group :rubocop do
26
26
  guard(
27
- 'rubocop',
27
+ :rubocop,
28
28
  all_on_start: true,
29
29
  all_after_pass: false,
30
30
  notification: :failed,
31
- keep_failed: false,
32
- cmd: 'bundle exec rubocop'
31
+ keep_failed: false
33
32
  ) do
34
33
  watch(%r{^lib/(.+)\.rb$}) { |m| [m[0], "spec/units/#{m[1]}_spec.rb"] }
35
34
  watch(%r{^spec/.+?/(.+)_spec\.rb$}) { |m| [m[0], "lib/#{m[1]}.rb"] }
data/LICENSE.md CHANGED
@@ -1,14 +1,10 @@
1
- ##Copyright
2
- Copyright (c) 2018, Robert Gauld. All rights reserved.
3
-
4
-
5
- ##License
1
+ ## License
6
2
  This code can be used under the BSD License (reproduced below).
7
3
  Commiters to the project give Robert Gauld the right to redistribute their commits
8
4
  under the BSD license.
9
5
 
10
6
 
11
- ###BSD License
7
+ ### BSD License
12
8
  Redistribution and use in source and binary forms, with or without modification,
13
9
  are permitted provided that the following conditions are met:
14
10
 
data/README.md CHANGED
@@ -1,29 +1,18 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/gandi_v5.png)](http://badge.fury.io/rb/gandi_v5)
2
-
3
- Master branch:
4
2
  [![Build Status](https://secure.travis-ci.org/robertgauld/gandi_v5.png?branch=master)](http://travis-ci.org/robertgauld/gandi_v5)
5
3
  [![Coveralls Status](https://coveralls.io/repos/robertgauld/gandi_v5/badge.png?branch=master)](https://coveralls.io/r/robertgauld/gandi_v5)
6
4
  [![Code Climate](https://codeclimate.com/github/robertgauld/gandi_v5.png?branch=master)](https://codeclimate.com/github/robertgauld/gandi_v5)
7
-
8
- Staging branch:
9
- [![Build Status](https://secure.travis-ci.org/robertgauld/gandi_v5.png?branch=staging)](http://travis-ci.org/robertgauld/gandi_v5)
10
- [![Coveralls Status](https://coveralls.io/repos/robertgauld/gandi_v5/badge.png?branch=staging)](https://coveralls.io/r/robertgauld/gandi_v5)
11
-
12
-
13
- ## Build State
14
- This project uses continuous integration to help ensure that a quality product is delivered.
15
- Travis CI monitors two branches (versions) of the code:
16
-
17
- * Master (which is what gets released)
18
- * Staging (which is what is currently being developed ready for moving to master).
19
-
5
+ [![security](https://hakiri.io/github/robertgauld/gandi_v5/master.svg)](https://hakiri.io/github/robertgauld/gandi_v5/master)
20
6
 
21
7
  ## Ruby Versions
22
8
  This gem supports the following versions of ruby, it may work on other versions but is not tested against them so don't rely on it.
23
9
 
24
10
  * ruby:
25
- * 2.6.0 - 2.6.2
11
+ * 2.6.0 - 2.6.6
12
+ * 2.7.0 - 2.7.1
13
+ * truffleruby 20.1.0
26
14
  * jruby, once it's reached parity with ruby 2.6.x
15
+ * rubinius, once it's reached parity with ruby 2.6.x
27
16
 
28
17
 
29
18
  ## Gandi V5
@@ -38,8 +27,8 @@ But then you were going to be careful anyway as this gem is currently in the ver
38
27
 
39
28
  Details of the API can be found at:
40
29
 
41
- * (https://api.gandi.net/docs/)
42
- * (https://doc.livedns.gandi.net/)
30
+ * <https://api.gandi.net/docs/>
31
+ * <https://doc.livedns.gandi.net/>
43
32
 
44
33
 
45
34
  ## Installation
@@ -73,7 +62,7 @@ GandiV5.api_key = '…' # Unless you've set it in the environment variable GANDI
73
62
 
74
63
  ```ruby
75
64
  # Get an array of all your domains.
76
- domains = GandiV5::Domain.list
65
+ domains = GandiV5.domains
77
66
 
78
67
  # Since each domain has only basic information, lets get all of the information.
79
68
  domains.map!(&:refresh)
@@ -86,9 +75,14 @@ TODO: More examples!
86
75
 
87
76
  We follow the [Semantic Versioning](http://semver.org/) concept.
88
77
 
89
- | Gem Version | Gandi API Release Date |
90
- | --------------- | ---------------------- |
91
- | 0.1.0 | 2019-05-16 |
78
+ | Gem Version | Gandi API Release Date |
79
+ | --------------- | ------------------------ |
80
+ | 0.6.0 | 2020-05-07 (not LiveDNS) |
81
+ | 0.5.0 | 2019-10-01 |
82
+ | 0.4.0 | 2019-10-01 |
83
+ | 0.3.0 | 2019-08-22 |
84
+ | 0.2.0 | 2019-05-16 |
85
+ | 0.1.0 | 2019-05-16 |
92
86
 
93
- See (https://api.gandi.net/docs/reference#API-Changelog) to find out what
87
+ See <https://api.gandi.net/docs/reference#API-Changelog> to find out what
94
88
  Gandi changed on each date.
@@ -22,8 +22,9 @@ Gem::Specification.new do |gem|
22
22
 
23
23
  gem.add_dependency 'dotenv', '~> 2.5'
24
24
  gem.add_dependency 'rest-client', '>= 2', '< 3'
25
+ gem.add_dependency 'zeitwerk', '~> 2.1'
25
26
 
26
- gem.add_development_dependency 'coveralls', '~> 0.7'
27
+ gem.add_development_dependency 'coveralls', '~> 0.8'
27
28
  gem.add_development_dependency 'guard', '~> 2.15'
28
29
  gem.add_development_dependency 'guard-bundler', '~> 2.2'
29
30
  gem.add_development_dependency 'guard-rspec', '~> 4.2', '>= 4.2.5'
@@ -32,10 +33,10 @@ Gem::Specification.new do |gem|
32
33
  gem.add_development_dependency 'rb-inotify', '~> 0.9'
33
34
  gem.add_development_dependency 'rspec', '>= 3.7', '< 4'
34
35
  gem.add_development_dependency 'rspec-its', '~> 1.3'
35
- gem.add_development_dependency 'rubocop', '~> 0.67'
36
+ gem.add_development_dependency 'rubocop', '~> 0.73'
36
37
  gem.add_development_dependency 'rubocop-performance', '~> 1.1'
37
38
  gem.add_development_dependency 'simplecov', '~> 0.7'
38
39
  gem.add_development_dependency 'timecop', '~> 0.5'
39
40
  gem.add_development_dependency 'vcr', '~> 4.0'
40
- gem.add_development_dependency 'webmock', '~> 3.5'
41
+ gem.add_development_dependency 'webmock', '~> 3.6'
41
42
  end
@@ -1,17 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'gandi_v5/version'
4
- require_relative 'gandi_v5/data'
5
- require_relative 'gandi_v5/error'
6
-
7
- require_relative 'gandi_v5/billing'
8
- require_relative 'gandi_v5/domain'
9
- require_relative 'gandi_v5/email'
10
- require_relative 'gandi_v5/live_dns'
11
- require_relative 'gandi_v5/organization'
12
-
13
3
  require 'rest_client'
14
4
  require 'securerandom'
5
+ require 'zeitwerk'
6
+
7
+ # Custom inflector for Zeitwerk.
8
+ class MyInflector < Zeitwerk::Inflector
9
+ # Convert file's base name to class name when
10
+ # Zeitwerk's included inflector gets it wrong.
11
+ # @param basename [String] the file's base name (no path or extension)
12
+ # @param abspath [String] the file's absolute path
13
+ # @return [String] the class name
14
+ def camelize(basename, _abspath)
15
+ case basename
16
+ when 'live_dns'
17
+ 'LiveDNS'
18
+ when 'tld'
19
+ 'TLD'
20
+ when 'version'
21
+ 'VERSION'
22
+ else
23
+ super
24
+ end
25
+ end
26
+ end
27
+
28
+ loader = Zeitwerk::Loader.for_gem
29
+ loader.inflector = MyInflector.new
30
+ loader.setup
15
31
 
16
32
  # Namespace for classes which access the Gandi V5 API.
17
33
  # Also provides useful methods and constants for them.
@@ -26,6 +42,26 @@ require 'securerandom'
26
42
  class GandiV5
27
43
  BASE = 'https://api.gandi.net/v5/'
28
44
 
45
+ # @see GandiV5::Domain.fetch
46
+ def self.domain(fqdn)
47
+ GandiV5::Domain.fetch(fqdn)
48
+ end
49
+
50
+ # @see GandiV5::Domain.list
51
+ def self.domains(**params)
52
+ GandiV5::Domain.list(**params)
53
+ end
54
+
55
+ # @see GandiV5::Email::Mailbox.list
56
+ def self.mailboxes(fqdn, **params)
57
+ GandiV5::Email::Mailbox.list(fqdn, **params)
58
+ end
59
+
60
+ # @see GandiV5::Email::Slot.list
61
+ def self.mailbox_slots(fqdn)
62
+ GandiV5::Email::Slot.list(fqdn)
63
+ end
64
+
29
65
  class << self
30
66
  attr_writer :api_key
31
67
 
@@ -41,7 +77,7 @@ class GandiV5
41
77
  def get(url, **headers)
42
78
  prepare_headers headers, url
43
79
  response = RestClient.get url, **headers
44
- parse_response response
80
+ [response, parse_response(response)]
45
81
  rescue RestClient::BadRequest => e
46
82
  handle_bad_request(e)
47
83
  end
@@ -59,7 +95,10 @@ class GandiV5
59
95
  def delete(url, **headers)
60
96
  prepare_headers headers, url
61
97
  response = RestClient.delete url, **headers
62
- parse_response response
98
+ [
99
+ response,
100
+ response.headers.key?(:content_type) ? parse_response(response) : nil
101
+ ]
63
102
  rescue RestClient::BadRequest => e
64
103
  handle_bad_request(e)
65
104
  end
@@ -79,7 +118,7 @@ class GandiV5
79
118
  prepare_headers headers, url
80
119
  headers[:'content-type'] ||= 'application/json'
81
120
  response = RestClient.patch url, payload, **headers
82
- parse_response response
121
+ [response, parse_response(response)]
83
122
  rescue RestClient::BadRequest => e
84
123
  handle_bad_request(e)
85
124
  end
@@ -99,7 +138,7 @@ class GandiV5
99
138
  prepare_headers headers, url
100
139
  headers[:'content-type'] ||= 'application/json'
101
140
  response = RestClient.post url, payload, **headers
102
- parse_response response
141
+ [response, parse_response(response)]
103
142
  rescue RestClient::BadRequest => e
104
143
  handle_bad_request(e)
105
144
  end
@@ -119,7 +158,7 @@ class GandiV5
119
158
  prepare_headers headers, url
120
159
  headers[:'content-type'] ||= 'application/json'
121
160
  response = RestClient.put url, payload, **headers
122
- parse_response response
161
+ [response, parse_response(response)]
123
162
  rescue RestClient::BadRequest => e
124
163
  handle_bad_request(e)
125
164
  end