gandi_v5 0.1.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 (108) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +20 -0
  5. data/.travis.yml +23 -0
  6. data/CHANGELOG.md +3 -0
  7. data/Gemfile +6 -0
  8. data/Guardfile +40 -0
  9. data/LICENSE.md +32 -0
  10. data/README.md +94 -0
  11. data/Rakefile +3 -0
  12. data/TODO.md +29 -0
  13. data/bin/console +13 -0
  14. data/gandi_v5.gemspec +41 -0
  15. data/lib/gandi_v5/billing/info/prepaid.rb +33 -0
  16. data/lib/gandi_v5/billing/info.rb +26 -0
  17. data/lib/gandi_v5/billing.rb +28 -0
  18. data/lib/gandi_v5/data/converter/array_of.rb +35 -0
  19. data/lib/gandi_v5/data/converter/symbol.rb +26 -0
  20. data/lib/gandi_v5/data/converter/time.rb +28 -0
  21. data/lib/gandi_v5/data/converter.rb +41 -0
  22. data/lib/gandi_v5/data.rb +244 -0
  23. data/lib/gandi_v5/domain/auto_renew.rb +64 -0
  24. data/lib/gandi_v5/domain/contact.rb +102 -0
  25. data/lib/gandi_v5/domain/contract.rb +22 -0
  26. data/lib/gandi_v5/domain/dates.rb +44 -0
  27. data/lib/gandi_v5/domain/renewal_information.rb +41 -0
  28. data/lib/gandi_v5/domain/restore_information.rb +18 -0
  29. data/lib/gandi_v5/domain/sharing_space.rb +21 -0
  30. data/lib/gandi_v5/domain.rb +431 -0
  31. data/lib/gandi_v5/email/mailbox/responder.rb +36 -0
  32. data/lib/gandi_v5/email/mailbox.rb +236 -0
  33. data/lib/gandi_v5/email/offer.rb +27 -0
  34. data/lib/gandi_v5/email/slot.rb +134 -0
  35. data/lib/gandi_v5/email.rb +11 -0
  36. data/lib/gandi_v5/error/gandi_error.rb +21 -0
  37. data/lib/gandi_v5/error.rb +9 -0
  38. data/lib/gandi_v5/live_dns/domain.rb +211 -0
  39. data/lib/gandi_v5/live_dns/record_set.rb +79 -0
  40. data/lib/gandi_v5/live_dns/zone/snapshot.rb +62 -0
  41. data/lib/gandi_v5/live_dns/zone.rb +301 -0
  42. data/lib/gandi_v5/live_dns.rb +30 -0
  43. data/lib/gandi_v5/organization.rb +66 -0
  44. data/lib/gandi_v5/version.rb +5 -0
  45. data/lib/gandi_v5.rb +178 -0
  46. data/spec/.rubocop.yml +4 -0
  47. data/spec/features/domain_spec.rb +45 -0
  48. data/spec/features/livedns_domain_spec.rb +8 -0
  49. data/spec/features/livedns_zone_spec.rb +45 -0
  50. data/spec/features/mailbox_spec.rb +18 -0
  51. data/spec/fixtures/bodies/GandiV5_Billing/info.yaml +10 -0
  52. data/spec/fixtures/bodies/GandiV5_Domain/availability.yaml +15 -0
  53. data/spec/fixtures/bodies/GandiV5_Domain/fetch_contacts.yaml +8 -0
  54. data/spec/fixtures/bodies/GandiV5_Domain/get.yaml +37 -0
  55. data/spec/fixtures/bodies/GandiV5_Domain/list.yaml +20 -0
  56. data/spec/fixtures/bodies/GandiV5_Domain/renewal_info.yaml +12 -0
  57. data/spec/fixtures/bodies/GandiV5_Domain/restore_info.yaml +5 -0
  58. data/spec/fixtures/bodies/GandiV5_Domain/tld.yaml +10 -0
  59. data/spec/fixtures/bodies/GandiV5_Domain/tlds.yaml +7 -0
  60. data/spec/fixtures/bodies/GandiV5_Email_Mailbox/get.yaml +16 -0
  61. data/spec/fixtures/bodies/GandiV5_Email_Mailbox/list.yaml +8 -0
  62. data/spec/fixtures/bodies/GandiV5_Email_Slot/get.yaml +10 -0
  63. data/spec/fixtures/bodies/GandiV5_Email_Slot/list.yaml +8 -0
  64. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/get.yaml +4 -0
  65. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/list.yaml +2 -0
  66. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/get.yaml +11 -0
  67. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/list.yaml +11 -0
  68. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/get.yaml +9 -0
  69. data/spec/fixtures/bodies/GandiV5_Organization/get.yaml +17 -0
  70. data/spec/fixtures/vcr/Domain_features/List_domains.yml +54 -0
  71. data/spec/fixtures/vcr/Domain_features/Renew_domain.yml +133 -0
  72. data/spec/fixtures/vcr/LiveDNS_Domain_features/List_domains.yml +32 -0
  73. data/spec/fixtures/vcr/LiveDNS_Zone_features/List_zones.yml +42 -0
  74. data/spec/fixtures/vcr/LiveDNS_Zone_features/Make_and_save_snapshot.yml +72 -0
  75. data/spec/fixtures/vcr/LiveDNS_Zone_features/Save_zone_to_file.yml +28 -0
  76. data/spec/fixtures/vcr/Mailbox_features/List_mailboxes.yml +39 -0
  77. data/spec/spec_helper.rb +60 -0
  78. data/spec/test.env +1 -0
  79. data/spec/units/gandi_v5/billing/info/prepaid_spec.rb +20 -0
  80. data/spec/units/gandi_v5/billing/info_spec.rb +4 -0
  81. data/spec/units/gandi_v5/billing_spec.rb +41 -0
  82. data/spec/units/gandi_v5/data/converter/array_of_spec.rb +18 -0
  83. data/spec/units/gandi_v5/data/converter/symbol_spec.rb +16 -0
  84. data/spec/units/gandi_v5/data/converter/time_spec.rb +16 -0
  85. data/spec/units/gandi_v5/data/converter_spec.rb +31 -0
  86. data/spec/units/gandi_v5/data_spec.rb +340 -0
  87. data/spec/units/gandi_v5/domain/auto_renew_spec.rb +70 -0
  88. data/spec/units/gandi_v5/domain/contact_spec.rb +36 -0
  89. data/spec/units/gandi_v5/domain/contract_spec.rb +4 -0
  90. data/spec/units/gandi_v5/domain/dates_spec.rb +4 -0
  91. data/spec/units/gandi_v5/domain/renewal_information_spec.rb +81 -0
  92. data/spec/units/gandi_v5/domain/restore_information_spec.rb +4 -0
  93. data/spec/units/gandi_v5/domain/sharing_space_spec.rb +4 -0
  94. data/spec/units/gandi_v5/domain_spec.rb +451 -0
  95. data/spec/units/gandi_v5/email/mailbox/responder_spec.rb +131 -0
  96. data/spec/units/gandi_v5/email/mailbox_spec.rb +384 -0
  97. data/spec/units/gandi_v5/email/offer_spec.rb +17 -0
  98. data/spec/units/gandi_v5/email/slot_spec.rb +102 -0
  99. data/spec/units/gandi_v5/error/gandi_error_spec.rb +30 -0
  100. data/spec/units/gandi_v5/error_spec.rb +4 -0
  101. data/spec/units/gandi_v5/live_dns/domain_spec.rb +247 -0
  102. data/spec/units/gandi_v5/live_dns/record_set_spec.rb +74 -0
  103. data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +37 -0
  104. data/spec/units/gandi_v5/live_dns/zone_spec.rb +329 -0
  105. data/spec/units/gandi_v5/live_dns_spec.rb +17 -0
  106. data/spec/units/gandi_v5/organization_spec.rb +30 -0
  107. data/spec/units/gandi_v5_spec.rb +204 -0
  108. metadata +406 -0
@@ -0,0 +1,133 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.gandi.net/v5/domain/domains/example.net
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Authorization:
13
+ - Apikey abdce12345
14
+ Host:
15
+ - api.gandi.net
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ body:
24
+ encoding: UTF-8
25
+ string: |-
26
+ {
27
+ "status": [
28
+ "clientTransferProhibited"
29
+ ],
30
+ "dates": {
31
+ "created_at": "2019-02-13T11:04:18Z",
32
+ "deletes_at": "2021-03-30T00:04:18Z",
33
+ "hold_begins_at": "2021-02-13T10:04:18Z",
34
+ "hold_ends_at": "2021-03-30T10:04:18Z",
35
+ "pending_delete_ends_at": "2021-05-04T10:04:18Z",
36
+ "registry_created_at": "2019-02-13T10:04:18Z",
37
+ "registry_ends_at": "2021-02-13T10:04:18Z",
38
+ "renew_begins_at": "2012-01-01T00:00:00Z",
39
+ "restore_ends_at": "2021-04-29T10:04:18Z",
40
+ "updated_at": "2019-02-25T16:20:49Z",
41
+ "authinfo_expires_at": "2020-02-25T16:20:49Z"
42
+ },
43
+ "can_tld_lock": true,
44
+ "tags": [],
45
+ "nameservers": [
46
+ "ns-25-a.gnadi.net",
47
+ "ns-113-b.gnadi.net",
48
+ "ns-58-c.gnadi.net"
49
+ ],
50
+ "contacts": {
51
+ "owner": {
52
+ "city": "Paris",
53
+ "given": "Alice",
54
+ "reachability": "pending",
55
+ "family": "Doe",
56
+ "zip": "75001",
57
+ "extra_parameters": {
58
+ "birth_date": "",
59
+ "birth_department": "",
60
+ "birth_city": "",
61
+ "birth_country": ""
62
+ },
63
+ "country": "FR",
64
+ "streetaddr": "5 rue neuve",
65
+ "data_obfuscated": true,
66
+ "mail_obfuscated": true,
67
+ "phone": "+33.123456789",
68
+ "state": "FR-J",
69
+ "validation": "none",
70
+ "type": 0,
71
+ "email": "alice@example.org"
72
+ }
73
+ },
74
+ "fqdn": "example.net",
75
+ "autorenew": {
76
+ "dates": [
77
+ "2021-01-13T09:04:18Z",
78
+ "2021-01-29T10:04:18Z",
79
+ "2021-02-12T10:04:18Z"
80
+ ],
81
+ "org_id": "fe0b931c-18c5-11e9-b9b5-00163ec4cb00",
82
+ "duration": 1,
83
+ "href": "http://api.test/v5/domain/domains/example.net/autorenew",
84
+ "enabled": false
85
+ },
86
+ "authinfo": "8vyhljvJg+",
87
+ "sharing_space": {
88
+ "id": "fe0b931c-18c5-11e9-b9b5-00163ec4cb00",
89
+ "name": "alice_doe"
90
+ },
91
+ "tld": "net",
92
+ "services": [
93
+ "gandilivedns",
94
+ "mailboxv2"
95
+ ],
96
+ "id": "ba1167be-2f76-11e9-9dfb-00163ec4cb00",
97
+ "trustee_roles": [],
98
+ "href": "http://api.test/v5/domain/domains/example.net",
99
+ "fqdn_unicode": "example.net"
100
+ }
101
+ http_version:
102
+ recorded_at: Thu, 30 May 2019 06:22:02 GMT
103
+
104
+ - request:
105
+ method: post
106
+ uri: https://api.gandi.net/v5/domain/domains/example.net/renew
107
+ body:
108
+ encoding: US-ASCII
109
+ string: '{"duration":2}'
110
+ headers:
111
+ Accept:
112
+ - application/json
113
+ Authorization:
114
+ - Apikey abdce12345
115
+ Host:
116
+ - api.gandi.net
117
+ response:
118
+ status:
119
+ code: 200
120
+ message: OK
121
+ headers:
122
+ Content-Type:
123
+ - application/json; charset=utf-8
124
+ body:
125
+ encoding: UTF-8
126
+ string: |-
127
+ {
128
+ "message":"Domain renewed."
129
+ }
130
+ http_version:
131
+ recorded_at: Thu, 30 May 2019 06:22:02 GMT
132
+
133
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,32 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://dns.api.gandi.net/api/v5/domains
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Authorization:
13
+ - Apikey abdce12345
14
+ Host:
15
+ - api.gandi.net
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ body:
24
+ encoding: UTF-8
25
+ string: |-
26
+ [
27
+ {"fqdn":"example.com"},
28
+ {"fqdn":"example.net"}
29
+ ]
30
+ http_version:
31
+ recorded_at: Thu, 30 May 2019 06:22:02 GMT
32
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://dns.api.gandi.net/api/v5/zones
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ X-Api-Key:
13
+ - abdce12345
14
+ Host:
15
+ - api.gandi.net
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ body:
24
+ encoding: UTF-8
25
+ string: |-
26
+ [
27
+ {
28
+ "retry": 3600,
29
+ "uuid": "uuid-of-zone",
30
+ "minimum": 10800,
31
+ "refresh": 10800,
32
+ "expire": 604800,
33
+ "serial": 1432798405,
34
+ "user_uuid": "uuid-of-user",
35
+ "email": "hostmaster.gandi.net.",
36
+ "primary_ns": "a.dns.gandi.net.",
37
+ "name": "Zone Name"
38
+ }
39
+ ]
40
+ http_version:
41
+ recorded_at: Thu, 30 May 2019 06:22:02 GMT
42
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,72 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ X-Api-Key:
13
+ - abdce12345
14
+ Host:
15
+ - api.gandi.net
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ body:
24
+ encoding: UTF-8
25
+ string: |-
26
+ {
27
+ "message": "Zone Snapshot Created",
28
+ "uuid": "snapshot-uuid"
29
+ }
30
+ http_version:
31
+ recorded_at: Thu, 30 May 2019 06:22:02 GMT
32
+
33
+ - request:
34
+ method: get
35
+ uri: https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots/snapshot-uuid
36
+ body:
37
+ encoding: US-ASCII
38
+ string: ''
39
+ headers:
40
+ Accept:
41
+ - text/plain
42
+ X-Api-Key:
43
+ - abdce12345
44
+ Host:
45
+ - api.gandi.net
46
+ response:
47
+ status:
48
+ code: 200
49
+ message: OK
50
+ headers:
51
+ Content-Type:
52
+ - application/json; charset=utf-8
53
+ body:
54
+ encoding: UTF-8
55
+ string: |-
56
+ {
57
+ "date_created": "2016-12-16T16:51:26Z",
58
+ "uuid": "snapshot-uuid",
59
+ "zone_uuid": "zone-uuid",
60
+ "zone_data": [
61
+ {
62
+ "rrset_type": "A",
63
+ "rrset_ttl": 10800,
64
+ "rrset_name": "www",
65
+ "rrset_values": ["10.0.1.42"]
66
+ }
67
+ ]
68
+ }
69
+ http_version:
70
+ recorded_at: Thu, 30 May 2019 06:22:02 GMT
71
+
72
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,28 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://dns.api.gandi.net/api/v5/zones/zone-uuid/records
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - text/plain
12
+ X-Api-Key:
13
+ - abdce12345
14
+ Host:
15
+ - api.gandi.net
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - text/plain; charset=utf-8
23
+ body:
24
+ encoding: UTF-8
25
+ string: "Contents of zone file.\n"
26
+ http_version:
27
+ recorded_at: Thu, 30 May 2019 06:22:02 GMT
28
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.gandi.net/v5/email/mailboxes/example.net?page=1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Authorization:
13
+ - Apikey abdce12345
14
+ Host:
15
+ - api.gandi.net
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ body:
24
+ encoding: UTF-8
25
+ string: |-
26
+ [
27
+ {
28
+ "domain": "example.net",
29
+ "login": "alice",
30
+ "address": "alice@example.net",
31
+ "id": "066743e5-96e4-4a1d-9195-8b8a700a8a79",
32
+ "mailbox_type": "standard",
33
+ "quota_used": 1200,
34
+ "href": "https://api.test/api/v5/email/example.net/066743e5-96e4-4a1d-9195-8b8a700a8a79"
35
+ }
36
+ ]
37
+ http_version:
38
+ recorded_at: Thu, 30 May 2019 06:22:02 GMT
39
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dotenv'
4
+ require 'coveralls'
5
+ require 'rspec/its'
6
+ require 'simplecov'
7
+ require 'timecop'
8
+ require 'vcr'
9
+ require 'webmock/rspec'
10
+ require 'yaml'
11
+
12
+ allow_http_connections_to = %w[localhost 127.0.0.1]
13
+
14
+ Dotenv.load File.join(__dir__, 'test.env')
15
+
16
+ SimpleCov.coverage_dir(File.join('tmp', 'coverage'))
17
+ SimpleCov.start do
18
+ add_filter 'spec/'
19
+ end
20
+
21
+ if ENV['TRAVIS']
22
+ Coveralls.wear!
23
+ allow_http_connections_to.push 'coveralls.io'
24
+ end
25
+
26
+ RSpec.configure do |config|
27
+ # == Mock Framework
28
+ #
29
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
30
+ #
31
+ # config.mock_with :mocha
32
+ # config.mock_with :flexmock
33
+ # config.mock_with :rr
34
+ config.mock_with :rspec do |configuration|
35
+ # Using the expect syntax is preferable to the should syntax in some cases.
36
+ # The problem here is that the :should syntax that RSpec uses can fail in
37
+ # the case of proxy objects, and objects that include the delegate module.
38
+ # Essentially it requires that we define methods on every object in the
39
+ # system. Not owning every object means that we cannot ensure this works in
40
+ # a consistent manner. The expect syntax gets around this problem by not
41
+ # relying on RSpec specific methods being defined on every object in the
42
+ # system.
43
+ # configuration.syntax = [:expect, :should]
44
+ configuration.syntax = :expect
45
+ end
46
+
47
+ config.before(:each) { Timecop.return }
48
+ end
49
+
50
+ VCR.configure do |config|
51
+ config.ignore_hosts(*allow_http_connections_to)
52
+ config.cassette_library_dir = File.join __dir__, 'fixtures', 'vcr'
53
+ config.hook_into :webmock
54
+ # config.default_cassette_options = { :record => :none }
55
+ end
56
+ VCR::RSpec::Metadata.configure!
57
+
58
+ WebMock.disable_net_connect! allow: allow_http_connections_to
59
+
60
+ require 'gandi_v5'
data/spec/test.env ADDED
@@ -0,0 +1 @@
1
+ GANDI_API_KEY = 'abdce12345'
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GandiV5::Billing::Info::Prepaid do
4
+ describe '#warning?' do
5
+ it 'No warning theshold set' do
6
+ prepaid_info = described_class.new amount: 10, warning_threshold: nil
7
+ expect(prepaid_info.warning?).to be nil
8
+ end
9
+
10
+ it 'More than warning theshold' do
11
+ prepaid_info = described_class.new amount: 10, warning_threshold: 5
12
+ expect(prepaid_info.warning?).to be false
13
+ end
14
+
15
+ it 'Less than warning theshold' do
16
+ prepaid_info = described_class.new amount: 10, warning_threshold: 20
17
+ expect(prepaid_info.warning?).to be true
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GandiV5::Billing::Info do
4
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GandiV5::Billing do
4
+ describe '.info' do
5
+ subject { described_class.info }
6
+ before :each do
7
+ body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Billing', 'info.yaml'))
8
+ expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/billing/info')
9
+ .and_return(YAML.load_file(body_fixture))
10
+ end
11
+
12
+ its('annual_balance') { should eq 123.45 }
13
+ its('grid') { should eq 'A' }
14
+ its('outstanding_amount') { should eq 0 }
15
+ its('prepaid_monthly_invoice') { should be_nil }
16
+ its('prepaid.amount') { should eq 1 }
17
+ its('prepaid.created_at') { should eq Time.new(2011, 2, 19, 11, 23, 25) }
18
+ its('prepaid.currency') { should eq 'GBP' }
19
+ its('prepaid.updated_at') { should eq Time.new(2019, 2, 23, 21, 47, 22) }
20
+ its('prepaid.warning_threshold') { should be_nil }
21
+ end
22
+
23
+ describe '.info (for a sharing_id)' do
24
+ subject { described_class.info('sharing-id') }
25
+ before :each do
26
+ body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Billing', 'info.yaml'))
27
+ expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/billing/info/sharing-id')
28
+ .and_return(YAML.load_file(body_fixture))
29
+ end
30
+
31
+ its('annual_balance') { should eq 123.45 }
32
+ its('grid') { should eq 'A' }
33
+ its('outstanding_amount') { should eq 0 }
34
+ its('prepaid_monthly_invoice') { should be_nil }
35
+ its('prepaid.amount') { should eq 1 }
36
+ its('prepaid.created_at') { should eq Time.new(2011, 2, 19, 11, 23, 25) }
37
+ its('prepaid.currency') { should eq 'GBP' }
38
+ its('prepaid.updated_at') { should eq Time.new(2019, 2, 23, 21, 47, 22) }
39
+ its('prepaid.warning_threshold') { should be_nil }
40
+ end
41
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GandiV5::Data::Converter::ArrayOf do
4
+ subject { described_class.new GandiV5::Data::Converter::Symbol }
5
+
6
+ it '#from_gandi' do
7
+ expect(subject.from_gandi(['value'])).to match_array [:value]
8
+ end
9
+
10
+ it '#to_gandi' do
11
+ expect(subject.to_gandi([:value])).to match_array ['value']
12
+ end
13
+
14
+ it 'nil value' do
15
+ expect(subject.from_gandi(nil)).to be nil
16
+ expect(subject.to_gandi(nil)).to be nil
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GandiV5::Data::Converter::Symbol do
4
+ it '.from_gandi' do
5
+ expect(described_class.from_gandi('value')).to eq :value
6
+ end
7
+
8
+ it '.to_gandi' do
9
+ expect(described_class.to_gandi(:value)).to eq 'value'
10
+ end
11
+
12
+ it 'nil value' do
13
+ expect(described_class.from_gandi(nil)).to be nil
14
+ expect(described_class.to_gandi(nil)).to be nil
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GandiV5::Data::Converter::Time do
4
+ it '.from_gandi' do
5
+ expect(described_class.from_gandi('2019-02-13T11:04:18Z')).to eq Time.new(2019, 2, 13, 11, 4, 18, 0)
6
+ end
7
+
8
+ it '.to_gandi' do
9
+ expect(described_class.to_gandi(Time.new(2019, 2, 13, 11, 4, 18, 0))).to eq '2019-02-13T11:04:18Z'
10
+ end
11
+
12
+ it 'nil value' do
13
+ expect(described_class.from_gandi(nil)).to be nil
14
+ expect(described_class.to_gandi(nil)).to be nil
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GandiV5::Data::Converter do
4
+ let(:proc) { double Proc }
5
+
6
+ describe '#to_gandi' do
7
+ it 'Has a to_gandi proc' do
8
+ expect(proc).to receive(:call).with(:value).and_return(:return)
9
+ subject = described_class.new to_gandi: proc
10
+ expect(subject.to_gandi(:value)).to be :return
11
+ end
12
+
13
+ it 'Hasn\'t a to_gandi proc' do
14
+ subject = described_class.new
15
+ expect(subject.to_gandi(:value)).to be :value
16
+ end
17
+ end
18
+
19
+ describe '#from_gandi' do
20
+ it 'Has a from_gandi proc' do
21
+ expect(proc).to receive(:call).with(:value).and_return(:return)
22
+ subject = described_class.new from_gandi: proc
23
+ expect(subject.from_gandi(:value)).to be :return
24
+ end
25
+
26
+ it 'Hasn\'t a from_gandi proc' do
27
+ subject = described_class.new
28
+ expect(subject.from_gandi(:value)).to be :value
29
+ end
30
+ end
31
+ end