sendgrid4r 1.8.1 → 1.10.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 (145) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -2
  3. data/README.md +1 -0
  4. data/lib/sendgrid4r/factory/campaign_factory.rb +18 -5
  5. data/lib/sendgrid4r/factory/condition_factory.rb +1 -1
  6. data/lib/sendgrid4r/factory/mail_factory.rb +57 -0
  7. data/lib/sendgrid4r/factory/segment_factory.rb +2 -5
  8. data/lib/sendgrid4r/factory/version_factory.rb +1 -1
  9. data/lib/sendgrid4r/rest/api.rb +48 -49
  10. data/lib/sendgrid4r/rest/api_keys_management/api_keys.rb +75 -0
  11. data/lib/sendgrid4r/rest/api_keys_management/permissions.rb +31 -0
  12. data/lib/sendgrid4r/rest/blocks.rb +49 -68
  13. data/lib/sendgrid4r/rest/bounces.rb +45 -64
  14. data/lib/sendgrid4r/rest/cancel_scheduled_sends.rb +53 -72
  15. data/lib/sendgrid4r/rest/categories.rb +31 -0
  16. data/lib/sendgrid4r/rest/email_activity.rb +72 -0
  17. data/lib/sendgrid4r/rest/invalid_emails.rb +50 -68
  18. data/lib/sendgrid4r/rest/ip_access_management.rb +86 -111
  19. data/lib/sendgrid4r/rest/ips/addresses.rb +50 -59
  20. data/lib/sendgrid4r/rest/ips/pools.rb +42 -53
  21. data/lib/sendgrid4r/rest/ips/warmup.rb +46 -55
  22. data/lib/sendgrid4r/rest/mail/address.rb +14 -0
  23. data/lib/sendgrid4r/rest/mail/attachment.rb +22 -0
  24. data/lib/sendgrid4r/rest/mail/content.rb +10 -0
  25. data/lib/sendgrid4r/rest/mail/mail.rb +28 -0
  26. data/lib/sendgrid4r/rest/mail/mail_settings.rb +62 -0
  27. data/lib/sendgrid4r/rest/mail/params.rb +64 -0
  28. data/lib/sendgrid4r/rest/mail/personalization.rb +33 -0
  29. data/lib/sendgrid4r/rest/mail/tracking_settings.rb +74 -0
  30. data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/custom_fields.rb +12 -27
  31. data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/lists.rb +20 -34
  32. data/lib/sendgrid4r/rest/marketing_campaigns/contacts/recipients.rb +134 -0
  33. data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/reserved_fields.rb +6 -9
  34. data/lib/sendgrid4r/rest/marketing_campaigns/contacts/segments.rb +86 -0
  35. data/lib/sendgrid4r/rest/marketing_campaigns/marketing_campaigns.rb +119 -0
  36. data/lib/sendgrid4r/rest/marketing_campaigns/senders.rb +101 -0
  37. data/lib/sendgrid4r/rest/request.rb +61 -63
  38. data/lib/sendgrid4r/rest/settings/enforced_tls.rb +23 -26
  39. data/lib/sendgrid4r/rest/settings/mail.rb +167 -183
  40. data/lib/sendgrid4r/rest/settings/partner.rb +33 -36
  41. data/lib/sendgrid4r/rest/settings/settings.rb +17 -22
  42. data/lib/sendgrid4r/rest/settings/tracking.rb +97 -107
  43. data/lib/sendgrid4r/rest/sm/global_unsubscribes.rb +52 -60
  44. data/lib/sendgrid4r/rest/sm/groups.rb +52 -58
  45. data/lib/sendgrid4r/rest/sm/sm.rb +15 -17
  46. data/lib/sendgrid4r/rest/sm/suppressions.rb +50 -67
  47. data/lib/sendgrid4r/rest/spam_reports.rb +49 -69
  48. data/lib/sendgrid4r/rest/stats/advanced.rb +100 -102
  49. data/lib/sendgrid4r/rest/stats/category.rb +31 -33
  50. data/lib/sendgrid4r/rest/stats/global.rb +17 -19
  51. data/lib/sendgrid4r/rest/stats/parse.rb +18 -20
  52. data/lib/sendgrid4r/rest/stats/stats.rb +59 -69
  53. data/lib/sendgrid4r/rest/stats/subuser.rb +70 -32
  54. data/lib/sendgrid4r/rest/subusers.rb +106 -134
  55. data/lib/sendgrid4r/rest/transactional_templates/templates.rb +63 -0
  56. data/lib/sendgrid4r/rest/transactional_templates/versions.rb +90 -0
  57. data/lib/sendgrid4r/rest/users.rb +125 -57
  58. data/lib/sendgrid4r/rest/webhooks/event.rb +36 -42
  59. data/lib/sendgrid4r/rest/webhooks/parse.rb +28 -37
  60. data/lib/sendgrid4r/rest/whitelabel/domains.rb +176 -222
  61. data/lib/sendgrid4r/rest/whitelabel/ips.rb +107 -128
  62. data/lib/sendgrid4r/rest/whitelabel/links.rb +131 -167
  63. data/lib/sendgrid4r/version.rb +1 -1
  64. data/lib/sendgrid4r.rb +23 -13
  65. data/sendgrid4r.gemspec +1 -1
  66. data/spec/client_spec.rb +12 -1
  67. data/spec/factory/campaign_factory_spec.rb +75 -35
  68. data/spec/factory/condition_factory_spec.rb +19 -18
  69. data/spec/factory/segment_factory_spec.rb +28 -21
  70. data/spec/factory/version_factory_spec.rb +28 -27
  71. data/spec/photo.jpg +0 -0
  72. data/spec/rest/api_keys_management/api_keys_spec.rb +174 -0
  73. data/spec/rest/api_keys_management/permissions_spec.rb +54 -0
  74. data/spec/rest/blocks_spec.rb +78 -106
  75. data/spec/rest/bounces_spec.rb +91 -118
  76. data/spec/rest/cancel_scheduled_sends_spec.rb +94 -149
  77. data/spec/rest/categories_spec.rb +77 -0
  78. data/spec/rest/email_activity_spec.rb +151 -0
  79. data/spec/rest/invalid_emails_spec.rb +85 -119
  80. data/spec/rest/ip_access_management_spec.rb +157 -195
  81. data/spec/rest/ips/addresses_spec.rb +94 -122
  82. data/spec/rest/ips/pools_spec.rb +84 -112
  83. data/spec/rest/ips/warmup_spec.rb +63 -71
  84. data/spec/rest/mail/address_spec.rb +28 -0
  85. data/spec/rest/mail/attachment_spec.rb +48 -0
  86. data/spec/rest/mail/content_spec.rb +32 -0
  87. data/spec/rest/mail/mail_settings_spec.rb +51 -0
  88. data/spec/rest/mail/mail_spec.rb +136 -0
  89. data/spec/rest/mail/params_spec.rb +152 -0
  90. data/spec/rest/mail/personalization_spec.rb +66 -0
  91. data/spec/rest/mail/tracking_settings_spec.rb +63 -0
  92. data/spec/rest/marketing_campaigns/contacts/custom_fields_spec.rb +146 -0
  93. data/spec/rest/marketing_campaigns/contacts/lists_spec.rb +307 -0
  94. data/spec/rest/marketing_campaigns/contacts/recipients_spec.rb +331 -0
  95. data/spec/rest/marketing_campaigns/contacts/reserved_fields_spec.rb +119 -0
  96. data/spec/rest/marketing_campaigns/contacts/segments_spec.rb +268 -0
  97. data/spec/rest/marketing_campaigns/marketing_campaigns_spec.rb +427 -0
  98. data/spec/rest/marketing_campaigns/senders_spec.rb +230 -0
  99. data/spec/rest/settings/enforced_tls_spec.rb +38 -54
  100. data/spec/rest/settings/mail_spec.rb +227 -330
  101. data/spec/rest/settings/partner_spec.rb +40 -59
  102. data/spec/rest/settings/settings_spec.rb +44 -42
  103. data/spec/rest/settings/tracking_spec.rb +130 -189
  104. data/spec/rest/sm/global_unsubscribes_spec.rb +47 -72
  105. data/spec/rest/sm/groups_spec.rb +88 -123
  106. data/spec/rest/sm/sm_spec.rb +32 -30
  107. data/spec/rest/sm/suppressions_spec.rb +105 -140
  108. data/spec/rest/spam_reports_spec.rb +81 -109
  109. data/spec/rest/stats/advanced_spec.rb +67 -125
  110. data/spec/rest/stats/category_spec.rb +27 -45
  111. data/spec/rest/stats/global_spec.rb +34 -42
  112. data/spec/rest/stats/parse_spec.rb +32 -30
  113. data/spec/rest/stats/stats_spec.rb +174 -172
  114. data/spec/rest/stats/subuser_spec.rb +97 -57
  115. data/spec/rest/subusers_spec.rb +156 -209
  116. data/spec/rest/transactional_templates/templates_spec.rb +199 -0
  117. data/spec/rest/transactional_templates/versions_spec.rb +228 -0
  118. data/spec/rest/users_spec.rb +176 -91
  119. data/spec/rest/webhooks/event_spec.rb +59 -85
  120. data/spec/rest/webhooks/parse_spec.rb +51 -71
  121. data/spec/rest/whitelabel/domains_spec.rb +333 -513
  122. data/spec/rest/whitelabel/ips_spec.rb +109 -147
  123. data/spec/rest/whitelabel/links_spec.rb +181 -265
  124. metadata +70 -40
  125. data/lib/sendgrid4r/rest/api_keys/api_keys.rb +0 -80
  126. data/lib/sendgrid4r/rest/api_keys/permissions.rb +0 -33
  127. data/lib/sendgrid4r/rest/campaigns/campaigns.rb +0 -126
  128. data/lib/sendgrid4r/rest/categories/categories.rb +0 -43
  129. data/lib/sendgrid4r/rest/contacts/recipients.rb +0 -150
  130. data/lib/sendgrid4r/rest/contacts/segments.rb +0 -97
  131. data/lib/sendgrid4r/rest/email_activity/email_activity.rb +0 -81
  132. data/lib/sendgrid4r/rest/templates/templates.rb +0 -69
  133. data/lib/sendgrid4r/rest/templates/versions.rb +0 -95
  134. data/spec/rest/api_keys/api_keys_spec.rb +0 -210
  135. data/spec/rest/api_keys/permissions_spec.rb +0 -65
  136. data/spec/rest/campaigns/campaigns_spec.rb +0 -492
  137. data/spec/rest/categories/categories_spec.rb +0 -96
  138. data/spec/rest/contacts/custom_fields_spec.rb +0 -174
  139. data/spec/rest/contacts/lists_spec.rb +0 -372
  140. data/spec/rest/contacts/recipients_spec.rb +0 -343
  141. data/spec/rest/contacts/reserved_fields_spec.rb +0 -146
  142. data/spec/rest/contacts/segments_spec.rb +0 -307
  143. data/spec/rest/email_activity/email_activity_spec.rb +0 -179
  144. data/spec/rest/templates/templates_spec.rb +0 -222
  145. data/spec/rest/templates/versions_spec.rb +0 -252
@@ -1,22 +1,20 @@
1
1
  # encoding: utf-8
2
2
  require File.dirname(__FILE__) + '/../../spec_helper'
3
3
 
4
- describe SendGrid4r::REST::Whitelabel::Domains do
5
- describe 'integration test', :it do
6
- before do
7
- begin
4
+ module SendGrid4r::REST::Whitelabel
5
+ describe Domains do
6
+ describe 'integration test', :it do
7
+ before do
8
8
  Dotenv.load
9
9
  @client = SendGrid4r::Client.new(api_key: ENV['SILVER_API_KEY'])
10
10
  @subdomain_name = ENV['SUBDOMAIN_DOMAIN']
11
11
  @domain_name = ENV['DOMAIN']
12
12
  @username = ENV['USERNAME']
13
- @ip = ENV['IP']
14
- @subuser1 = ENV['SUBUSER1']
15
- @subuser2 = ENV['SUBUSER2']
13
+ @subuser = ENV['SUBUSER']
16
14
  @email1 = ENV['MAIL']
17
15
  @password1 = ENV['PASS']
18
16
  @ip = ENV['IP']
19
- # celan up test env(lists)
17
+ # celan up test env
20
18
  @id1 = nil
21
19
  @id2 = nil
22
20
  @id3 = nil
@@ -41,83 +39,41 @@ describe SendGrid4r::REST::Whitelabel::Domains do
41
39
  end
42
40
  end
43
41
  # post domain
42
+ @client.delete_wl_domain(id: @id1) unless @id1.nil?
43
+ @client.delete_wl_domain(id: @id2) unless @id2.nil?
44
+ @client.delete_wl_domain(id: @id3) unless @id3.nil?
45
+ @client.delete_wl_domain(id: @id4) unless @id4.nil?
44
46
  @domain1 = @client.post_wl_domain(
45
47
  domain: @domain_name, subdomain: @subdomain_name + '1'
46
- ) if @id1.nil?
48
+ )
47
49
  @domain2 = @client.post_wl_domain(
48
50
  domain: @domain_name, subdomain: @subdomain_name + '2',
49
- username: @username,
50
- automatic_security: false, custom_spf: true, default: false
51
- ) if @id2.nil?
51
+ username: @subuser, ips: nil,
52
+ automatic_security: false, custom_spf: false, default: false
53
+ )
52
54
  @domain3 = @client.post_wl_domain(
53
55
  domain: @domain_name, subdomain: @subdomain_name + '3',
54
- username: @username, ips: nil,
56
+ username: @subuser, ips: nil,
55
57
  automatic_security: true, custom_spf: false, default: false
56
- ) if @id3.nil?
57
- @domain4 = @client.post_wl_domain(
58
- domain: @domain_name, subdomain: @subdomain_name + '4',
59
- username: @username, ips: [@ip],
60
- automatic_security: true, custom_spf: true, default: false
61
- ) if @id4.nil?
62
- # make a default
63
- @id1 = @domain1.id if @id1.nil?
64
- @id2 = @domain2.id if @id2.nil?
65
- @id3 = @domain3.id if @id3.nil?
66
- @id4 = @domain4.id if @id4.nil?
67
- @client.patch_wl_domain(id: @id3, default: true)
68
- @client.delete_wl_domain(id: @id1)
69
- @client.delete_wl_domain(id: @id2)
70
- @client.delete_wl_domain(id: @id4)
71
- @domain1 = @client.post_wl_domain(
72
- domain: @domain_name, subdomain: @subdomain_name + '1'
73
- )
74
- @domain2 = @client.post_wl_domain(
75
- domain: @domain_name, subdomain: @subdomain_name + '2',
76
- username: @username, ips: nil,
77
- automatic_security: false, custom_spf: false, default: false
78
58
  )
79
59
  @domain4 = @client.post_wl_domain(
80
60
  domain: @domain_name, subdomain: @subdomain_name + '4',
81
- username: @username, ips: [@ip],
61
+ username: @subuser, ips: [@ip],
82
62
  automatic_security: false, custom_spf: true, default: false
83
63
  )
84
- # clean subusers
85
- subusers = @client.get_subusers
86
- count = subusers.count { |subuser| subuser.username == @subuser1 }
87
- @client.delete_subuser(username: @subuser1) if count == 1
88
- @client.post_subuser(
89
- username: @subuser1,
90
- email: @email1,
91
- password: @password1,
92
- ips: [@ip]
93
- )
94
- rescue RestClient::ExceptionWithResponse => e
95
- puts e.inspect
96
- raise e
97
64
  end
98
- end
99
65
 
100
- context 'without block call' do
101
- it '#get_wl_domains' do
102
- begin
66
+ context 'without block call' do
67
+ it '#get_wl_domains' do
103
68
  domains = @client.get_wl_domains
104
69
  expect(domains).to be_a(Array)
105
70
  domains.each do |domain|
106
- expect(domain).to be_a(
107
- SendGrid4r::REST::Whitelabel::Domains::Domain
108
- )
71
+ expect(domain).to be_a(Domains::Domain)
109
72
  end
110
- rescue RestClient::ExceptionWithResponse => e
111
- puts e.inspect
112
- raise e
113
73
  end
114
- end
115
74
 
116
- it '#post_wl_domain' do
117
- begin
118
- expect(@domain1).to be_a(
119
- SendGrid4r::REST::Whitelabel::Domains::Domain
120
- )
75
+ it '#post_wl_domain' do
76
+ expect(@domain1).to be_a(Domains::Domain)
121
77
  expect(@domain1.domain).to eq(@domain_name)
122
78
  expect(@domain1.subdomain).to eq(@subdomain_name + '1')
123
79
  expect(@domain1.username).to eq(@username)
@@ -128,21 +84,13 @@ describe SendGrid4r::REST::Whitelabel::Domains do
128
84
  expect(@domain1.default).to eq(false)
129
85
  expect(@domain1.legacy).to eq(false)
130
86
  expect(@domain1.valid).to eq(false)
131
- expect(@domain1.dns.mail_cname).to be_a(
132
- SendGrid4r::REST::Whitelabel::Domains::Record
133
- )
134
- expect(@domain1.dns.dkim1).to be_a(
135
- SendGrid4r::REST::Whitelabel::Domains::Record
136
- )
137
- expect(@domain1.dns.dkim2).to be_a(
138
- SendGrid4r::REST::Whitelabel::Domains::Record
139
- )
140
- expect(@domain2).to be_a(
141
- SendGrid4r::REST::Whitelabel::Domains::Domain
142
- )
87
+ expect(@domain1.dns.mail_cname).to be_a(Domains::Record)
88
+ expect(@domain1.dns.dkim1).to be_a(Domains::Record)
89
+ expect(@domain1.dns.dkim2).to be_a(Domains::Record)
90
+ expect(@domain2).to be_a(Domains::Domain)
143
91
  expect(@domain2.domain).to eq(@domain_name)
144
92
  expect(@domain2.subdomain).to eq(@subdomain_name + '2')
145
- expect(@domain2.username).to eq(@username)
93
+ expect(@domain2.username).to eq(@subuser)
146
94
  expect(@domain2.user_id).to be_a(Numeric)
147
95
  expect(@domain2.ips).to eq([])
148
96
  expect(@domain2.automatic_security).to eq(false)
@@ -150,25 +98,14 @@ describe SendGrid4r::REST::Whitelabel::Domains do
150
98
  expect(@domain2.default).to eq(false)
151
99
  expect(@domain2.legacy).to eq(false)
152
100
  expect(@domain2.valid).to eq(false)
153
- expect(@domain2.dns.mail_server).to be_a(
154
- SendGrid4r::REST::Whitelabel::Domains::Record
155
- )
156
- expect(@domain2.dns.subdomain_spf).to be_a(
157
- SendGrid4r::REST::Whitelabel::Domains::Record
158
- )
159
- expect(@domain2.dns.dkim).to be_a(
160
- SendGrid4r::REST::Whitelabel::Domains::Record
161
- )
162
- rescue RestClient::ExceptionWithResponse => e
163
- puts e.inspect
164
- raise e
101
+ expect(@domain2.dns.mail_server).to be_a(Domains::Record)
102
+ expect(@domain2.dns.subdomain_spf).to be_a(Domains::Record)
103
+ expect(@domain2.dns.dkim).to be_a(Domains::Record)
165
104
  end
166
- end
167
105
 
168
- it '#get_wl_domain' do
169
- begin
106
+ it '#get_wl_domain' do
170
107
  domain1 = @client.get_wl_domain(id: @domain1.id)
171
- expect(domain1).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
108
+ expect(domain1).to be_a(Domains::Domain)
172
109
  expect(domain1.domain).to eq(@domain_name)
173
110
  expect(domain1.subdomain).to eq(@subdomain_name + '1')
174
111
  expect(domain1.username).to eq(@username)
@@ -180,9 +117,7 @@ describe SendGrid4r::REST::Whitelabel::Domains do
180
117
  expect(domain1.legacy).to eq(false)
181
118
  expect(domain1.valid).to eq(false)
182
119
  # mail_cname
183
- expect(domain1.dns.mail_cname).to be_a(
184
- SendGrid4r::REST::Whitelabel::Domains::Record
185
- )
120
+ expect(domain1.dns.mail_cname).to be_a(Domains::Record)
186
121
  expect(domain1.dns.mail_cname.valid).to eq(false)
187
122
  expect(domain1.dns.mail_cname.type).to eq('cname')
188
123
  expect(domain1.dns.mail_cname.host).to eq(
@@ -191,29 +126,23 @@ describe SendGrid4r::REST::Whitelabel::Domains do
191
126
  expect(domain1.dns.mail_cname.data).to be_a(String)
192
127
  # dkim1
193
128
  expect(domain1.dns.dkim1).to be_a(
194
- SendGrid4r::REST::Whitelabel::Domains::Record
129
+ Domains::Record
195
130
  )
196
131
  expect(domain1.dns.dkim1.valid).to eq(false)
197
132
  expect(domain1.dns.dkim1.type).to eq('cname')
198
- expect(domain1.dns.dkim1.host).to eq(
199
- "s1._domainkey.#{@domain_name}"
200
- )
133
+ expect(domain1.dns.dkim1.host).to eq("s1._domainkey.#{@domain_name}")
201
134
  expect(domain1.dns.dkim1.data).to be_a(String)
202
135
  # dkim2
203
- expect(domain1.dns.dkim2).to be_a(
204
- SendGrid4r::REST::Whitelabel::Domains::Record
205
- )
136
+ expect(domain1.dns.dkim2).to be_a(Domains::Record)
206
137
  expect(domain1.dns.dkim2.valid).to eq(false)
207
138
  expect(domain1.dns.dkim2.type).to eq('cname')
208
- expect(domain1.dns.dkim2.host).to eq(
209
- "s2._domainkey.#{@domain_name}"
210
- )
139
+ expect(domain1.dns.dkim2.host).to eq("s2._domainkey.#{@domain_name}")
211
140
  expect(domain1.dns.dkim2.data).to be_a(String)
212
141
  domain2 = @client.get_wl_domain(id: @domain2.id)
213
- expect(domain2).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
142
+ expect(domain2).to be_a(Domains::Domain)
214
143
  expect(domain2.domain).to eq(@domain_name)
215
144
  expect(domain2.subdomain).to eq(@subdomain_name + '2')
216
- expect(domain2.username).to eq(@username)
145
+ expect(domain2.username).to eq(@subuser)
217
146
  expect(domain2.user_id).to be_a(Numeric)
218
147
  expect(domain2.ips).to eq([])
219
148
  expect(domain2.automatic_security).to eq(false)
@@ -222,9 +151,7 @@ describe SendGrid4r::REST::Whitelabel::Domains do
222
151
  expect(domain2.legacy).to eq(false)
223
152
  expect(domain2.valid).to eq(false)
224
153
  # mail_server
225
- expect(domain2.dns.mail_server).to be_a(
226
- SendGrid4r::REST::Whitelabel::Domains::Record
227
- )
154
+ expect(domain2.dns.mail_server).to be_a(Domains::Record)
228
155
  expect(domain2.dns.mail_server.valid).to eq(false)
229
156
  expect(domain2.dns.mail_server.type).to eq('mx')
230
157
  expect(domain2.dns.mail_server.host).to eq(
@@ -232,9 +159,7 @@ describe SendGrid4r::REST::Whitelabel::Domains do
232
159
  )
233
160
  expect(domain2.dns.mail_server.data).to eq('mx.sendgrid.net.')
234
161
  # subdomain_spf
235
- expect(domain2.dns.subdomain_spf).to be_a(
236
- SendGrid4r::REST::Whitelabel::Domains::Record
237
- )
162
+ expect(domain2.dns.subdomain_spf).to be_a(Domains::Record)
238
163
  expect(domain2.dns.subdomain_spf.valid).to eq(false)
239
164
  expect(domain2.dns.subdomain_spf.type).to eq('txt')
240
165
  expect(domain2.dns.subdomain_spf.host).to eq(
@@ -244,22 +169,16 @@ describe SendGrid4r::REST::Whitelabel::Domains do
244
169
  'v=spf1 include:sendgrid.net ~all'
245
170
  )
246
171
  # dkim
247
- expect(domain2.dns.dkim).to be_a(
248
- SendGrid4r::REST::Whitelabel::Domains::Record
249
- )
172
+ expect(domain2.dns.dkim).to be_a(Domains::Record)
250
173
  expect(domain2.dns.dkim.valid).to eq(false)
251
174
  expect(domain2.dns.dkim.type).to eq('txt')
252
- expect(domain2.dns.dkim.host).to eq(
253
- "m1._domainkey.#{@domain_name}"
254
- )
255
- expect(domain2.dns.dkim.data).to start_with(
256
- 'k=rsa; t=s; p='
257
- )
175
+ expect(domain2.dns.dkim.host).to eq("m1._domainkey.#{@domain_name}")
176
+ expect(domain2.dns.dkim.data).to start_with('k=rsa; t=s; p=')
258
177
  domain4 = @client.get_wl_domain(id: @domain4.id)
259
- expect(domain4).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
178
+ expect(domain4).to be_a(Domains::Domain)
260
179
  expect(domain4.domain).to eq(@domain_name)
261
180
  expect(domain4.subdomain).to eq(@subdomain_name + '4')
262
- expect(domain4.username).to eq(@username)
181
+ expect(domain4.username).to eq(@subuser)
263
182
  expect(domain4.user_id).to be_a(Numeric)
264
183
  expect(domain4.ips).to eq([@ip])
265
184
  expect(domain4.automatic_security).to eq(false)
@@ -268,9 +187,7 @@ describe SendGrid4r::REST::Whitelabel::Domains do
268
187
  expect(domain4.legacy).to eq(false)
269
188
  expect(domain4.valid).to eq(false)
270
189
  # mail_server
271
- expect(domain4.dns.mail_server).to be_a(
272
- SendGrid4r::REST::Whitelabel::Domains::Record
273
- )
190
+ expect(domain4.dns.mail_server).to be_a(Domains::Record)
274
191
  expect(domain4.dns.mail_server.valid).to eq(false)
275
192
  expect(domain4.dns.mail_server.type).to eq('mx')
276
193
  expect(domain4.dns.mail_server.host).to eq(
@@ -278,41 +195,26 @@ describe SendGrid4r::REST::Whitelabel::Domains do
278
195
  )
279
196
  expect(domain4.dns.mail_server.data).to eq('mx.sendgrid.net.')
280
197
  # subdomain_spf
281
- expect(domain4.dns.subdomain_spf).to be_a(
282
- SendGrid4r::REST::Whitelabel::Domains::Record
283
- )
198
+ expect(domain4.dns.subdomain_spf).to be_a(Domains::Record)
284
199
  expect(domain4.dns.subdomain_spf.valid).to eq(false)
285
200
  expect(domain4.dns.subdomain_spf.type).to eq('txt')
286
201
  expect(domain4.dns.subdomain_spf.host).to eq(
287
202
  "#{@subdomain_name}4.#{@domain_name}"
288
203
  )
289
- expect(domain4.dns.subdomain_spf.data).to eq(
290
- "v=spf1 ip4:#{@ip} -all"
291
- )
204
+ expect(domain4.dns.subdomain_spf.data).to eq("v=spf1 ip4:#{@ip} -all")
292
205
  # dkim
293
- expect(domain4.dns.dkim).to be_a(
294
- SendGrid4r::REST::Whitelabel::Domains::Record
295
- )
206
+ expect(domain4.dns.dkim).to be_a(Domains::Record)
296
207
  expect(domain4.dns.dkim.valid).to eq(false)
297
208
  expect(domain4.dns.dkim.type).to eq('txt')
298
- expect(domain4.dns.dkim.host).to eq(
299
- "m1._domainkey.#{@domain_name}"
300
- )
301
- expect(domain4.dns.dkim.data).to start_with(
302
- 'k=rsa; t=s; p='
303
- )
304
- rescue RestClient::ExceptionWithResponse => e
305
- puts e.inspect
306
- raise e
209
+ expect(domain4.dns.dkim.host).to eq("m1._domainkey.#{@domain_name}")
210
+ expect(domain4.dns.dkim.data).to start_with('k=rsa; t=s; p=')
307
211
  end
308
- end
309
212
 
310
- it '#patch_wl_domain' do
311
- begin
213
+ it '#patch_wl_domain' do
312
214
  domain1 = @client.patch_wl_domain(
313
215
  id: @domain1.id, custom_spf: true, default: nil
314
216
  )
315
- expect(domain1).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
217
+ expect(domain1).to be_a(Domains::Domain)
316
218
  expect(domain1.domain).to eq(@domain_name)
317
219
  expect(domain1.subdomain).to eq(@subdomain_name + '1')
318
220
  expect(domain1.username).to eq(@username)
@@ -321,423 +223,341 @@ describe SendGrid4r::REST::Whitelabel::Domains do
321
223
  expect(domain1.automatic_security).to eq(true)
322
224
  expect(domain1.custom_spf).to eq(true)
323
225
  expect(domain1.default).to eq(false)
324
- rescue RestClient::ExceptionWithResponse => e
325
- puts e.inspect
326
- raise e
327
226
  end
328
- end
329
227
 
330
- it '#delete_wl_domain' do
331
- begin
228
+ it '#delete_wl_domain' do
332
229
  @client.delete_wl_domain(id: @domain1.id)
333
- rescue RestClient::ExceptionWithResponse => e
334
- puts e.inspect
335
- raise e
336
230
  end
337
- end
338
231
 
339
- it '#get_default_wl_domain' do
340
- begin
232
+ it '#get_default_wl_domain' do
341
233
  domain2 = @client.get_default_wl_domain
342
- expect(domain2).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
343
- rescue RestClient::ExceptionWithResponse => e
344
- puts e.inspect
345
- raise e
234
+ expect(domain2).to be_a(Domains::Domain)
346
235
  end
347
- end
348
236
 
349
- it '#add_ip_to_wl_domain' do
350
- begin
237
+ it '#add_ip_to_wl_domain' do
351
238
  domain2 = @client.add_ip_to_wl_domain(id: @domain2.id, ip: @ip)
352
239
  expect(domain2.ips).to eq([@ip])
353
- rescue RestClient::ExceptionWithResponse => e
354
- puts e.inspect
355
- raise e
356
240
  end
357
- end
358
241
 
359
- it '#remove_ip_from_wl_domain' do
360
- begin
242
+ it '#remove_ip_from_wl_domain' do
361
243
  @client.add_ip_to_wl_domain(id: @domain2.id, ip: @ip)
362
- domain2 = @client.remove_ip_from_wl_domain(
363
- id: @domain2.id, ip: @ip
364
- )
244
+ domain2 = @client.remove_ip_from_wl_domain(id: @domain2.id, ip: @ip)
365
245
  expect(domain2.ips).to eq(nil)
366
- rescue RestClient::ExceptionWithResponse => e
367
- puts e.inspect
368
- raise e
369
246
  end
370
- end
371
247
 
372
- it '#validate_wl_domain' do
373
- begin
248
+ it '#validate_wl_domain' do
374
249
  result1 = @client.validate_wl_domain(id: @domain1.id)
375
- expect(result1).to be_a(
376
- SendGrid4r::REST::Whitelabel::Domains::Result
377
- )
250
+ expect(result1).to be_a(Domains::Result)
378
251
  expect(result1.valid).to be(false)
379
- expect(result1.validation_results.mail_cname.valid).to be(
380
- false
381
- )
382
- expect(result1.validation_results.mail_cname.reason).to be_a(
383
- String
384
- )
385
- expect(result1.validation_results.dkim1.valid).to be(
386
- false
387
- )
388
- expect(result1.validation_results.dkim1.reason).to be_a(
389
- String
390
- )
391
- expect(result1.validation_results.dkim2.valid).to be(
392
- false
393
- )
394
- expect(result1.validation_results.dkim2.reason).to be_a(
395
- String
396
- )
252
+ expect(result1.validation_results.mail_cname.valid).to be(false)
253
+ expect(result1.validation_results.mail_cname.reason).to be_a(String)
254
+ expect(result1.validation_results.dkim1.valid).to be(false)
255
+ expect(result1.validation_results.dkim1.reason).to be_a(String)
256
+ expect(result1.validation_results.dkim2.valid).to be(false)
257
+ expect(result1.validation_results.dkim2.reason).to be_a(String)
397
258
  result2 = @client.validate_wl_domain(id: @domain2.id)
398
- expect(result2).to be_a(
399
- SendGrid4r::REST::Whitelabel::Domains::Result
400
- )
259
+ expect(result2).to be_a(Domains::Result)
401
260
  expect(result2.valid).to be(false)
402
- expect(result2.validation_results.mail_server.valid).to be(
403
- false
404
- )
405
- expect(result2.validation_results.mail_server.reason).to be_a(
406
- String
407
- )
408
- expect(result2.validation_results.subdomain_spf.valid).to be(
409
- false
410
- )
261
+ expect(result2.validation_results.mail_server.valid).to be(false)
262
+ expect(result2.validation_results.mail_server.reason).to be_a(String)
263
+ expect(result2.validation_results.subdomain_spf.valid).to be(false)
411
264
  expect(result2.validation_results.subdomain_spf.reason).to be_a(
412
265
  String
413
266
  )
414
- expect(result2.validation_results.dkim.valid).to be(
415
- false
416
- )
417
- expect(result2.validation_results.dkim.reason).to be_a(
418
- String
419
- )
420
- rescue RestClient::ExceptionWithResponse => e
421
- puts e.inspect
422
- raise e
267
+ expect(result2.validation_results.dkim.valid).to be(false)
268
+ expect(result2.validation_results.dkim.reason).to be_a(String)
423
269
  end
424
- end
425
270
 
426
- it '#get_associated_wl_domain' do
427
- begin
428
- domain1 = @client.get_associated_wl_domain(username: @subuser1)
429
- expect(domain1).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
430
- rescue RestClient::ExceptionWithResponse => e
431
- puts e.inspect
432
- raise e
271
+ it '#get_associated_wl_domain' do
272
+ domain1 = @client.get_associated_wl_domain(username: @subuser)
273
+ expect(domain1).to be_a(Domains::Domain)
433
274
  end
434
- end
435
275
 
436
- it '#associate_wl_domain' do
437
- begin
438
- @client.associate_wl_domain(id: @domain2.id, username: @subuser1)
439
- rescue RestClient::ExceptionWithResponse => e
440
- puts e.inspect
441
- raise e
276
+ it '#associate_wl_domain' do
277
+ @client.associate_wl_domain(id: @domain2.id, username: @subuser)
442
278
  end
443
- end
444
279
 
445
- it '#disassociate_wl_domain' do
446
- begin
447
- @client.associate_wl_domain(id: @domain2.id, username: @subuser1)
448
- @client.disassociate_wl_domain(username: @subuser1)
449
- rescue RestClient::ExceptionWithResponse => e
450
- puts e.inspect
451
- raise e
280
+ it '#disassociate_wl_domain' do
281
+ @client.associate_wl_domain(id: @domain2.id, username: @subuser)
282
+ @client.disassociate_wl_domain(username: @subuser)
452
283
  end
453
284
  end
454
285
  end
455
- end
456
286
 
457
- describe 'unit test', :ut do
458
- let(:client) do
459
- SendGrid4r::Client.new(api_key: '')
460
- end
287
+ describe 'unit test', :ut do
288
+ let(:client) do
289
+ SendGrid4r::Client.new(api_key: '')
290
+ end
461
291
 
462
- let(:domains) do
463
- JSON.parse('[]')
464
- end
292
+ let(:domains) do
293
+ JSON.parse('[]')
294
+ end
465
295
 
466
- let(:domain) do
467
- JSON.parse(
468
- '{'\
469
- '"id": 1,'\
470
- '"domain": "example.com",'\
471
- '"subdomain": "mail",'\
472
- '"username": "john@example.com",'\
473
- '"user_id": 7,'\
474
- '"ips": ['\
475
- '"192.168.1.1",'\
476
- '"192.168.1.2"'\
477
- '],'\
478
- '"custom_spf": true,'\
479
- '"default": true,'\
480
- '"legacy": false,'\
481
- '"automatic_security": true,'\
482
- '"valid": true,'\
483
- '"dns": {'\
484
- '"mail_cname": {'\
485
- '"host": "mail.example.com",'\
486
- '"type": "cname",'\
487
- '"data": "u7.wl.sendgrid.net",'\
488
- '"valid": true'\
489
- '},'\
490
- '"dkim1": {'\
491
- '"host": "s1._domainkey.example.com",'\
492
- '"type": "cname",'\
493
- '"data": "s1._domainkey.u7.wl.sendgrid.net",'\
494
- '"valid": true'\
495
- '},'\
496
- '"dkim2": {'\
497
- '"host": "s2._domainkey.example.com",'\
498
- '"type": "cname",'\
499
- '"data": "s2._domainkey.u7.wl.sendgrid.net",'\
500
- '"valid": true'\
296
+ let(:domain) do
297
+ JSON.parse(
298
+ '{'\
299
+ '"id": 1,'\
300
+ '"domain": "example.com",'\
301
+ '"subdomain": "mail",'\
302
+ '"username": "john@example.com",'\
303
+ '"user_id": 7,'\
304
+ '"ips": ['\
305
+ '"192.168.1.1",'\
306
+ '"192.168.1.2"'\
307
+ '],'\
308
+ '"custom_spf": true,'\
309
+ '"default": true,'\
310
+ '"legacy": false,'\
311
+ '"automatic_security": true,'\
312
+ '"valid": true,'\
313
+ '"dns": {'\
314
+ '"mail_cname": {'\
315
+ '"host": "mail.example.com",'\
316
+ '"type": "cname",'\
317
+ '"data": "u7.wl.sendgrid.net",'\
318
+ '"valid": true'\
319
+ '},'\
320
+ '"dkim1": {'\
321
+ '"host": "s1._domainkey.example.com",'\
322
+ '"type": "cname",'\
323
+ '"data": "s1._domainkey.u7.wl.sendgrid.net",'\
324
+ '"valid": true'\
325
+ '},'\
326
+ '"dkim2": {'\
327
+ '"host": "s2._domainkey.example.com",'\
328
+ '"type": "cname",'\
329
+ '"data": "s2._domainkey.u7.wl.sendgrid.net",'\
330
+ '"valid": true'\
331
+ '}'\
501
332
  '}'\
502
- '}'\
503
- '}'
504
- )
505
- end
333
+ '}'
334
+ )
335
+ end
506
336
 
507
- let(:domain2) do
508
- JSON.parse(
509
- '{'\
510
- '"id": 2,'\
511
- '"user_id": 2,'\
512
- '"subdomain": "mail2",'\
513
- '"domain": "example.com",'\
514
- '"username": "john@example.com",'\
515
- '"ips": [],'\
516
- '"custom_spf": true,'\
517
- '"default": false,'\
518
- '"legacy": false,'\
519
- '"automatic_security": false,'\
520
- '"valid": false,'\
521
- '"dns": {'\
522
- '"mail_server": {'\
523
- '"valid": false,'\
524
- '"type": "mx",'\
525
- '"host": "mail2.example.com",'\
526
- '"data": "mx.sendgrid.net."'\
527
- '},'\
528
- '"subdomain_spf": {'\
529
- '"valid": false,'\
530
- '"type": "txt",'\
531
- '"host": "mail2.example.com",'\
532
- '"data": "v=spf1 include:sendgrid.net ~all"'\
533
- '},'\
534
- '"dkim": {'\
535
- '"valid": false,'\
536
- '"type": "txt",'\
537
- '"host": "m1._domainkey.example.com",'\
538
- '"data": "k=rsa; t=s; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ"'\
337
+ let(:domain2) do
338
+ JSON.parse(
339
+ '{'\
340
+ '"id": 2,'\
341
+ '"user_id": 2,'\
342
+ '"subdomain": "mail2",'\
343
+ '"domain": "example.com",'\
344
+ '"username": "john@example.com",'\
345
+ '"ips": [],'\
346
+ '"custom_spf": true,'\
347
+ '"default": false,'\
348
+ '"legacy": false,'\
349
+ '"automatic_security": false,'\
350
+ '"valid": false,'\
351
+ '"dns": {'\
352
+ '"mail_server": {'\
353
+ '"valid": false,'\
354
+ '"type": "mx",'\
355
+ '"host": "mail2.example.com",'\
356
+ '"data": "mx.sendgrid.net."'\
357
+ '},'\
358
+ '"subdomain_spf": {'\
359
+ '"valid": false,'\
360
+ '"type": "txt",'\
361
+ '"host": "mail2.example.com",'\
362
+ '"data": "v=spf1 include:sendgrid.net ~all"'\
363
+ '},'\
364
+ '"dkim": {'\
365
+ '"valid": false,'\
366
+ '"type": "txt",'\
367
+ '"host": "m1._domainkey.example.com",'\
368
+ '"data": "k=rsa; t=s; '\
369
+ 'p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ"'\
370
+ '}'\
539
371
  '}'\
540
- '}'\
541
- '}'
542
- )
543
- end
372
+ '}'
373
+ )
374
+ end
544
375
 
545
- let(:result) do
546
- JSON.parse(
547
- '{'\
548
- '"id": 1,'\
549
- '"valid": true,'\
550
- '"validation_results": {'\
551
- '"mail_cname": {'\
552
- '"valid": false,'\
553
- '"reason": "Expected your MX record to be \"mx.sendgrid.net\" '\
554
- 'but found \"example.com\"."'\
555
- '},'\
556
- '"dkim1": {'\
557
- '"valid": true,'\
558
- '"reason": null'\
559
- '},'\
560
- '"dkim2": {'\
561
- '"valid": true,'\
562
- '"reason": null'\
376
+ let(:result) do
377
+ JSON.parse(
378
+ '{'\
379
+ '"id": 1,'\
380
+ '"valid": true,'\
381
+ '"validation_results": {'\
382
+ '"mail_cname": {'\
383
+ '"valid": false,'\
384
+ '"reason": "Expected your MX record to be \"mx.sendgrid.net\" '\
385
+ 'but found \"example.com\"."'\
386
+ '},'\
387
+ '"dkim1": {'\
388
+ '"valid": true,'\
389
+ '"reason": null'\
390
+ '},'\
391
+ '"dkim2": {'\
392
+ '"valid": true,'\
393
+ '"reason": null'\
394
+ '}'\
563
395
  '}'\
564
- '}'\
565
- '}'
566
- )
567
- end
396
+ '}'
397
+ )
398
+ end
568
399
 
569
- it '#get_domains' do
570
- allow(client).to receive(:execute).and_return(domains)
571
- actual = client.get_wl_domains
572
- expect(actual).to be_a(Array)
573
- end
400
+ it '#get_domains' do
401
+ allow(client).to receive(:execute).and_return(domains)
402
+ actual = client.get_wl_domains
403
+ expect(actual).to be_a(Array)
404
+ end
574
405
 
575
- it '#post_domain' do
576
- allow(client).to receive(:execute).and_return(domain)
577
- actual = client.post_wl_domain(domain: '', subdomain: '')
578
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
579
- end
406
+ it '#post_domain' do
407
+ allow(client).to receive(:execute).and_return(domain)
408
+ actual = client.post_wl_domain(domain: '', subdomain: '')
409
+ expect(actual).to be_a(Domains::Domain)
410
+ end
580
411
 
581
- it '#get_domain' do
582
- allow(client).to receive(:execute).and_return(domain)
583
- actual = client.get_wl_domain(id: '')
584
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
585
- end
412
+ it '#get_domain' do
413
+ allow(client).to receive(:execute).and_return(domain)
414
+ actual = client.get_wl_domain(id: '')
415
+ expect(actual).to be_a(Domains::Domain)
416
+ end
586
417
 
587
- it '#patch_domain' do
588
- allow(client).to receive(:execute).and_return(domain)
589
- actual = client.patch_wl_domain(id: '', custom_spf: true, default: false)
590
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
591
- end
418
+ it '#patch_domain' do
419
+ allow(client).to receive(:execute).and_return(domain)
420
+ actual = client.patch_wl_domain(
421
+ id: '', custom_spf: true, default: false
422
+ )
423
+ expect(actual).to be_a(Domains::Domain)
424
+ end
592
425
 
593
- it '#delete_domain' do
594
- allow(client).to receive(:execute).and_return('')
595
- actual = client.delete_wl_domain(id: '')
596
- expect(actual).to eq('')
597
- end
426
+ it '#delete_domain' do
427
+ allow(client).to receive(:execute).and_return('')
428
+ actual = client.delete_wl_domain(id: '')
429
+ expect(actual).to eq('')
430
+ end
598
431
 
599
- it '#get_default_domain' do
600
- allow(client).to receive(:execute).and_return(domain)
601
- actual = client.get_default_wl_domain(domain: '')
602
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
603
- end
432
+ it '#get_default_domain' do
433
+ allow(client).to receive(:execute).and_return(domain)
434
+ actual = client.get_default_wl_domain(domain: '')
435
+ expect(actual).to be_a(Domains::Domain)
436
+ end
604
437
 
605
- it '#add_ip_to_domain' do
606
- allow(client).to receive(:execute).and_return(domain)
607
- actual = client.add_ip_to_wl_domain(id: '', ip: '')
608
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
609
- end
438
+ it '#add_ip_to_domain' do
439
+ allow(client).to receive(:execute).and_return(domain)
440
+ actual = client.add_ip_to_wl_domain(id: '', ip: '')
441
+ expect(actual).to be_a(Domains::Domain)
442
+ end
610
443
 
611
- it '#remove_ip_from_domain' do
612
- allow(client).to receive(:execute).and_return(domain)
613
- actual = client.remove_ip_from_wl_domain(id: '', ip: '')
614
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
615
- end
444
+ it '#remove_ip_from_domain' do
445
+ allow(client).to receive(:execute).and_return(domain)
446
+ actual = client.remove_ip_from_wl_domain(id: '', ip: '')
447
+ expect(actual).to be_a(Domains::Domain)
448
+ end
616
449
 
617
- it '#validate_domain' do
618
- allow(client).to receive(:execute).and_return(result)
619
- actual = client.validate_wl_domain(id: '')
620
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Result)
621
- end
450
+ it '#validate_domain' do
451
+ allow(client).to receive(:execute).and_return(result)
452
+ actual = client.validate_wl_domain(id: '')
453
+ expect(actual).to be_a(Domains::Result)
454
+ end
622
455
 
623
- it '#get_associated_wl_domain' do
624
- allow(client).to receive(:execute).and_return(domain)
625
- actual = client.get_associated_wl_domain(username: '')
626
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
627
- end
456
+ it '#get_associated_wl_domain' do
457
+ allow(client).to receive(:execute).and_return(domain)
458
+ actual = client.get_associated_wl_domain(username: '')
459
+ expect(actual).to be_a(Domains::Domain)
460
+ end
628
461
 
629
- it '#disassociate_wl_domain' do
630
- allow(client).to receive(:execute).and_return('')
631
- actual = client.disassociate_wl_domain(username: '')
632
- expect(actual).to eq('')
633
- end
462
+ it '#disassociate_wl_domain' do
463
+ allow(client).to receive(:execute).and_return('')
464
+ actual = client.disassociate_wl_domain(username: '')
465
+ expect(actual).to eq('')
466
+ end
634
467
 
635
- it '#associate_wl_domain' do
636
- allow(client).to receive(:execute).and_return(domain)
637
- actual = client.associate_wl_domain(id: '', username: '')
638
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
639
- end
468
+ it '#associate_wl_domain' do
469
+ allow(client).to receive(:execute).and_return(domain)
470
+ actual = client.associate_wl_domain(id: '', username: '')
471
+ expect(actual).to be_a(Domains::Domain)
472
+ end
640
473
 
641
- it 'creates domain instance' do
642
- actual = SendGrid4r::REST::Whitelabel::Domains.create_domain(domain)
643
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
644
- expect(actual.id).to eq(1)
645
- expect(actual.domain).to eq('example.com')
646
- expect(actual.subdomain).to eq('mail')
647
- expect(actual.username).to eq('john@example.com')
648
- expect(actual.user_id).to eq(7)
649
- expect(actual.ips).to be_a(Array)
650
- expect(actual.ips[0]).to eq('192.168.1.1')
651
- expect(actual.ips[1]).to eq('192.168.1.2')
652
- expect(actual.custom_spf).to eq(true)
653
- expect(actual.default).to eq(true)
654
- expect(actual.legacy).to eq(false)
655
- expect(actual.automatic_security).to eq(true)
656
- expect(actual.valid).to eq(true)
657
- expect(actual.dns).to be_a(SendGrid4r::REST::Whitelabel::Domains::Dns)
658
- expect(actual.dns.mail_cname).to be_a(
659
- SendGrid4r::REST::Whitelabel::Domains::Record
660
- )
661
- expect(actual.dns.mail_cname.host).to eq('mail.example.com')
662
- expect(actual.dns.mail_cname.type).to eq('cname')
663
- expect(actual.dns.mail_cname.data).to eq('u7.wl.sendgrid.net')
664
- expect(actual.dns.mail_cname.valid).to eq(true)
665
- expect(actual.dns.dkim1).to be_a(
666
- SendGrid4r::REST::Whitelabel::Domains::Record
667
- )
668
- expect(actual.dns.dkim1.host).to eq('s1._domainkey.example.com')
669
- expect(actual.dns.dkim1.type).to eq('cname')
670
- expect(actual.dns.dkim1.data).to eq('s1._domainkey.u7.wl.sendgrid.net')
671
- expect(actual.dns.dkim1.valid).to eq(true)
672
- expect(actual.dns.dkim2).to be_a(
673
- SendGrid4r::REST::Whitelabel::Domains::Record
674
- )
675
- expect(actual.dns.dkim2.host).to eq('s2._domainkey.example.com')
676
- expect(actual.dns.dkim2.type).to eq('cname')
677
- expect(actual.dns.dkim2.data).to eq('s2._domainkey.u7.wl.sendgrid.net')
678
- expect(actual.dns.dkim2.valid).to eq(true)
679
- end
474
+ it 'creates domain instance' do
475
+ actual = Domains.create_domain(domain)
476
+ expect(actual).to be_a(Domains::Domain)
477
+ expect(actual.id).to eq(1)
478
+ expect(actual.domain).to eq('example.com')
479
+ expect(actual.subdomain).to eq('mail')
480
+ expect(actual.username).to eq('john@example.com')
481
+ expect(actual.user_id).to eq(7)
482
+ expect(actual.ips).to be_a(Array)
483
+ expect(actual.ips[0]).to eq('192.168.1.1')
484
+ expect(actual.ips[1]).to eq('192.168.1.2')
485
+ expect(actual.custom_spf).to eq(true)
486
+ expect(actual.default).to eq(true)
487
+ expect(actual.legacy).to eq(false)
488
+ expect(actual.automatic_security).to eq(true)
489
+ expect(actual.valid).to eq(true)
490
+ expect(actual.dns).to be_a(Domains::Dns)
491
+ expect(actual.dns.mail_cname).to be_a(Domains::Record)
492
+ expect(actual.dns.mail_cname.host).to eq('mail.example.com')
493
+ expect(actual.dns.mail_cname.type).to eq('cname')
494
+ expect(actual.dns.mail_cname.data).to eq('u7.wl.sendgrid.net')
495
+ expect(actual.dns.mail_cname.valid).to eq(true)
496
+ expect(actual.dns.dkim1).to be_a(Domains::Record)
497
+ expect(actual.dns.dkim1.host).to eq('s1._domainkey.example.com')
498
+ expect(actual.dns.dkim1.type).to eq('cname')
499
+ expect(actual.dns.dkim1.data).to eq('s1._domainkey.u7.wl.sendgrid.net')
500
+ expect(actual.dns.dkim1.valid).to eq(true)
501
+ expect(actual.dns.dkim2).to be_a(Domains::Record)
502
+ expect(actual.dns.dkim2.host).to eq('s2._domainkey.example.com')
503
+ expect(actual.dns.dkim2.type).to eq('cname')
504
+ expect(actual.dns.dkim2.data).to eq('s2._domainkey.u7.wl.sendgrid.net')
505
+ expect(actual.dns.dkim2.valid).to eq(true)
506
+ end
680
507
 
681
- it 'creates domain2 instance' do
682
- actual = SendGrid4r::REST::Whitelabel::Domains.create_domain(domain2)
683
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
684
- expect(actual.id).to eq(2)
685
- expect(actual.domain).to eq('example.com')
686
- expect(actual.subdomain).to eq('mail2')
687
- expect(actual.username).to eq('john@example.com')
688
- expect(actual.user_id).to eq(2)
689
- expect(actual.ips).to be_a(Array)
690
- expect(actual.custom_spf).to eq(true)
691
- expect(actual.default).to eq(false)
692
- expect(actual.legacy).to eq(false)
693
- expect(actual.automatic_security).to eq(false)
694
- expect(actual.valid).to eq(false)
695
- expect(actual.dns).to be_a(SendGrid4r::REST::Whitelabel::Domains::Dns)
696
- expect(actual.dns.mail_server).to be_a(
697
- SendGrid4r::REST::Whitelabel::Domains::Record
698
- )
699
- expect(actual.dns.mail_server.host).to eq('mail2.example.com')
700
- expect(actual.dns.mail_server.type).to eq('mx')
701
- expect(actual.dns.mail_server.data).to eq('mx.sendgrid.net.')
702
- expect(actual.dns.mail_server.valid).to eq(false)
703
- expect(actual.dns.subdomain_spf).to be_a(
704
- SendGrid4r::REST::Whitelabel::Domains::Record
705
- )
706
- expect(actual.dns.subdomain_spf.host).to eq('mail2.example.com')
707
- expect(actual.dns.subdomain_spf.type).to eq('txt')
708
- expect(actual.dns.subdomain_spf.data).to eq(
709
- 'v=spf1 include:sendgrid.net ~all'
710
- )
711
- expect(actual.dns.subdomain_spf.valid).to eq(false)
712
- expect(actual.dns.dkim).to be_a(
713
- SendGrid4r::REST::Whitelabel::Domains::Record
714
- )
715
- expect(actual.dns.dkim.host).to eq('m1._domainkey.example.com')
716
- expect(actual.dns.dkim.type).to eq('txt')
717
- expect(actual.dns.dkim.data).to eq(
718
- 'k=rsa; t=s; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ'
719
- )
720
- expect(actual.dns.dkim.valid).to eq(false)
721
- end
508
+ it 'creates domain2 instance' do
509
+ actual = Domains.create_domain(domain2)
510
+ expect(actual).to be_a(Domains::Domain)
511
+ expect(actual.id).to eq(2)
512
+ expect(actual.domain).to eq('example.com')
513
+ expect(actual.subdomain).to eq('mail2')
514
+ expect(actual.username).to eq('john@example.com')
515
+ expect(actual.user_id).to eq(2)
516
+ expect(actual.ips).to be_a(Array)
517
+ expect(actual.custom_spf).to eq(true)
518
+ expect(actual.default).to eq(false)
519
+ expect(actual.legacy).to eq(false)
520
+ expect(actual.automatic_security).to eq(false)
521
+ expect(actual.valid).to eq(false)
522
+ expect(actual.dns).to be_a(Domains::Dns)
523
+ expect(actual.dns.mail_server).to be_a(Domains::Record)
524
+ expect(actual.dns.mail_server.host).to eq('mail2.example.com')
525
+ expect(actual.dns.mail_server.type).to eq('mx')
526
+ expect(actual.dns.mail_server.data).to eq('mx.sendgrid.net.')
527
+ expect(actual.dns.mail_server.valid).to eq(false)
528
+ expect(actual.dns.subdomain_spf).to be_a(Domains::Record)
529
+ expect(actual.dns.subdomain_spf.host).to eq('mail2.example.com')
530
+ expect(actual.dns.subdomain_spf.type).to eq('txt')
531
+ expect(actual.dns.subdomain_spf.data).to eq(
532
+ 'v=spf1 include:sendgrid.net ~all'
533
+ )
534
+ expect(actual.dns.subdomain_spf.valid).to eq(false)
535
+ expect(actual.dns.dkim).to be_a(Domains::Record)
536
+ expect(actual.dns.dkim.host).to eq('m1._domainkey.example.com')
537
+ expect(actual.dns.dkim.type).to eq('txt')
538
+ expect(actual.dns.dkim.data).to eq(
539
+ 'k=rsa; t=s; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ'
540
+ )
541
+ expect(actual.dns.dkim.valid).to eq(false)
542
+ end
722
543
 
723
- it 'creates result instance' do
724
- actual = SendGrid4r::REST::Whitelabel::Domains.create_result(result)
725
- expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Result)
726
- expect(actual.id).to eq(1)
727
- expect(actual.valid).to eq(true)
728
- expect(actual.validation_results).to be_a(
729
- SendGrid4r::REST::Whitelabel::Domains::ValidationResults
730
- )
731
- expect(actual.validation_results.dkim1).to be_a(
732
- SendGrid4r::REST::Whitelabel::Domains::ValidationResult
733
- )
734
- expect(actual.validation_results.dkim1.valid).to be(true)
735
- expect(actual.validation_results.dkim1.reason).to be(nil)
736
- expect(actual.validation_results.dkim2).to be_a(
737
- SendGrid4r::REST::Whitelabel::Domains::ValidationResult
738
- )
739
- expect(actual.validation_results.dkim2.valid).to be(true)
740
- expect(actual.validation_results.dkim2.reason).to be(nil)
544
+ it 'creates result instance' do
545
+ actual = Domains.create_result(result)
546
+ expect(actual).to be_a(Domains::Result)
547
+ expect(actual.id).to eq(1)
548
+ expect(actual.valid).to eq(true)
549
+ expect(actual.validation_results).to be_a(Domains::ValidationResults)
550
+ expect(actual.validation_results.dkim1).to be_a(
551
+ Domains::ValidationResult
552
+ )
553
+ expect(actual.validation_results.dkim1.valid).to be(true)
554
+ expect(actual.validation_results.dkim1.reason).to be(nil)
555
+ expect(actual.validation_results.dkim2).to be_a(
556
+ Domains::ValidationResult
557
+ )
558
+ expect(actual.validation_results.dkim2.valid).to be(true)
559
+ expect(actual.validation_results.dkim2.reason).to be(nil)
560
+ end
741
561
  end
742
562
  end
743
563
  end