sendgrid4r 1.8.1 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
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,136 +1,115 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- module SendGrid4r
4
- module REST
3
+ module SendGrid4r::REST
4
+ #
5
+ # SendGrid Web API v3 Whitelabel
6
+ #
7
+ module Whitelabel
5
8
  #
6
- # SendGrid Web API v3 Whitelabel
9
+ # SendGrid Web API v3 Whitelabel Ips
7
10
  #
8
- module Whitelabel
9
- #
10
- # SendGrid Web API v3 Whitelabel Ips
11
- #
12
- module Ips
13
- include SendGrid4r::REST::Request
14
-
15
- Ip = Struct.new(
16
- :id, :ip, :rdns, :users, :subdomain, :domain, :valid, :legacy,
17
- :a_record
11
+ module Ips
12
+ include Request
13
+
14
+ Ip = Struct.new(
15
+ :id, :ip, :rdns, :users, :subdomain, :domain, :valid, :legacy,
16
+ :a_record
17
+ )
18
+ User = Struct.new(:username, :user_id)
19
+ ARecord = Struct.new(:host, :type, :data, :valid)
20
+
21
+ def self.url(id = nil)
22
+ url = "#{BASE_URL}/whitelabel/ips"
23
+ url = "#{url}/#{id}" unless id.nil?
24
+ url
25
+ end
26
+
27
+ def self.create_ips(resp)
28
+ return resp if resp.nil?
29
+ resp.map { |ip| Ips.create_ip(ip) }
30
+ end
31
+
32
+ def self.create_ip(resp)
33
+ return resp if resp.nil?
34
+ Ip.new(
35
+ resp['id'],
36
+ resp['ip'],
37
+ resp['rdns'],
38
+ Ips.create_users(resp['users']),
39
+ resp['subdomain'],
40
+ resp['domain'],
41
+ resp['valid'],
42
+ resp['legacy'],
43
+ Ips.create_a_record(resp['a_record'])
44
+ )
45
+ end
46
+
47
+ def self.create_users(resp)
48
+ return resp if resp.nil?
49
+ resp.map { |user| Ips.create_a_record(user) }
50
+ end
51
+
52
+ def self.create_a_record(resp)
53
+ return resp if resp.nil?
54
+ ARecord.new(resp['host'], resp['type'], resp['data'], resp['valid'])
55
+ end
56
+
57
+ Result = Struct.new(:id, :valid, :validation_results)
58
+ ValidationResults = Struct.new(:a_record)
59
+ ValidationResult = Struct.new(:valid, :reason)
60
+
61
+ def self.create_result(resp)
62
+ return resp if resp.nil?
63
+ Result.new(
64
+ resp['id'],
65
+ resp['valid'],
66
+ Ips.create_validation_results(resp['validation_results'])
18
67
  )
19
- User = Struct.new(:username, :user_id)
20
- ARecord = Struct.new(:host, :type, :data, :valid)
21
-
22
- def self.url(id = nil)
23
- url = "#{BASE_URL}/whitelabel/ips"
24
- url = "#{url}/#{id}" unless id.nil?
25
- url
26
- end
27
-
28
- def self.create_ips(resp)
29
- return resp if resp.nil?
30
- ips = []
31
- resp.each do |ip|
32
- ips.push(
33
- SendGrid4r::REST::Whitelabel::Ips.create_ip(ip)
34
- )
35
- end
36
- ips
37
- end
38
-
39
- def self.create_ip(resp)
40
- return resp if resp.nil?
41
- Ip.new(
42
- resp['id'],
43
- resp['ip'],
44
- resp['rdns'],
45
- SendGrid4r::REST::Whitelabel::Ips.create_users(resp['users']),
46
- resp['subdomain'],
47
- resp['domain'],
48
- resp['valid'],
49
- resp['legacy'],
50
- SendGrid4r::REST::Whitelabel::Ips.create_a_record(resp['a_record'])
51
- )
52
- end
53
-
54
- def self.create_users(resp)
55
- return resp if resp.nil?
56
- users = []
57
- resp.each do |user|
58
- users.push(SendGrid4r::REST::Whitelabel::Ips.create_a_record(user))
59
- end
60
- users
61
- end
62
-
63
- def self.create_a_record(resp)
64
- return resp if resp.nil?
65
- ARecord.new(resp['host'], resp['type'], resp['data'], resp['valid'])
66
- end
67
-
68
- Result = Struct.new(:id, :valid, :validation_results)
69
- ValidationResults = Struct.new(:a_record)
70
- ValidationResult = Struct.new(:valid, :reason)
71
-
72
- def self.create_result(resp)
73
- return resp if resp.nil?
74
- Result.new(
75
- resp['id'],
76
- resp['valid'],
77
- SendGrid4r::REST::Whitelabel::Ips.create_validation_results(
78
- resp['validation_results']
79
- )
80
- )
81
- end
82
-
83
- def self.create_validation_results(resp)
84
- return resp if resp.nil?
85
- ValidationResults.new(
86
- SendGrid4r::REST::Whitelabel::Ips.create_validation_result(
87
- resp['a_record']
88
- )
89
- )
90
- end
91
-
92
- def self.create_validation_result(resp)
93
- return resp if resp.nil?
94
- ValidationResult.new(resp['valid'], resp['reason'])
95
- end
96
-
97
- def get_wl_ips(ip: nil, limit: nil, offset: nil, &block)
98
- params = {}
99
- params['ip'] = ip unless ip.nil?
100
- params['limit'] = limit unless limit.nil?
101
- params['offset'] = offset unless offset.nil?
102
- endpoint = SendGrid4r::REST::Whitelabel::Ips.url
103
- resp = get(@auth, endpoint, params, &block)
104
- SendGrid4r::REST::Whitelabel::Ips.create_ips(resp)
105
- end
106
-
107
- def post_wl_ip(ip:, subdomain:, domain:, &block)
108
- params = {}
109
- params['ip'] = ip
110
- params['subdomain'] = subdomain
111
- params['domain'] = domain
112
- endpoint = SendGrid4r::REST::Whitelabel::Ips.url
113
- resp = post(@auth, endpoint, params, &block)
114
- SendGrid4r::REST::Whitelabel::Ips.create_ip(resp)
115
- end
116
-
117
- def get_wl_ip(id:, &block)
118
- endpoint = SendGrid4r::REST::Whitelabel::Ips.url(id)
119
- resp = get(@auth, endpoint, nil, &block)
120
- SendGrid4r::REST::Whitelabel::Ips.create_ip(resp)
121
- end
122
-
123
- def delete_wl_ip(id:, &block)
124
- endpoint = SendGrid4r::REST::Whitelabel::Ips.url(id)
125
- delete(@auth, endpoint, &block)
126
- end
127
-
128
- def validate_wl_ip(id:, &block)
129
- endpoint = SendGrid4r::REST::Whitelabel::Ips.url(id)
130
- endpoint = "#{endpoint}/validate"
131
- resp = post(@auth, endpoint, &block)
132
- SendGrid4r::REST::Whitelabel::Ips.create_result(resp)
133
- end
68
+ end
69
+
70
+ def self.create_validation_results(resp)
71
+ return resp if resp.nil?
72
+ ValidationResults.new(
73
+ Ips.create_validation_result(resp['a_record'])
74
+ )
75
+ end
76
+
77
+ def self.create_validation_result(resp)
78
+ return resp if resp.nil?
79
+ ValidationResult.new(resp['valid'], resp['reason'])
80
+ end
81
+
82
+ def get_wl_ips(ip: nil, limit: nil, offset: nil, &block)
83
+ params = {}
84
+ params[:ip] = ip unless ip.nil?
85
+ params[:limit] = limit unless limit.nil?
86
+ params[:offset] = offset unless offset.nil?
87
+ resp = get(@auth, Ips.url, params, &block)
88
+ Ips.create_ips(resp)
89
+ end
90
+
91
+ def post_wl_ip(ip:, subdomain:, domain:, &block)
92
+ params = {
93
+ ip: ip,
94
+ subdomain: subdomain,
95
+ domain: domain
96
+ }
97
+ resp = post(@auth, Ips.url, params, &block)
98
+ Ips.create_ip(resp)
99
+ end
100
+
101
+ def get_wl_ip(id:, &block)
102
+ resp = get(@auth, Ips.url(id), nil, &block)
103
+ Ips.create_ip(resp)
104
+ end
105
+
106
+ def delete_wl_ip(id:, &block)
107
+ delete(@auth, Ips.url(id), &block)
108
+ end
109
+
110
+ def validate_wl_ip(id:, &block)
111
+ resp = post(@auth, "#{Ips.url(id)}/validate", &block)
112
+ Ips.create_result(resp)
134
113
  end
135
114
  end
136
115
  end
@@ -1,192 +1,156 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- module SendGrid4r
4
- module REST
3
+ module SendGrid4r::REST
4
+ #
5
+ # SendGrid Web API v3 Whitelabel
6
+ #
7
+ module Whitelabel
5
8
  #
6
- # SendGrid Web API v3 Whitelabel
9
+ # SendGrid Web API v3 Whitelabel Links
7
10
  #
8
- module Whitelabel
9
- #
10
- # SendGrid Web API v3 Whitelabel Links
11
- #
12
- module Links
13
- include SendGrid4r::REST::Request
14
-
15
- Link = Struct.new(
16
- :id, :domain, :subdomain, :username, :user_id, :default,
17
- :valid, :legacy, :dns
18
- )
19
- Dns = Struct.new(:domain_cname, :owner_cname)
20
- Record = Struct.new(:host, :type, :data, :valid)
11
+ module Links
12
+ include Request
13
+
14
+ Link = Struct.new(
15
+ :id, :domain, :subdomain, :username, :user_id, :default,
16
+ :valid, :legacy, :dns
17
+ )
18
+ Dns = Struct.new(:domain_cname, :owner_cname)
19
+ Record = Struct.new(:host, :type, :data, :valid)
20
+
21
+ def self.url(id = nil)
22
+ url = "#{BASE_URL}/whitelabel/links"
23
+ url = "#{url}/#{id}" unless id.nil?
24
+ url
25
+ end
21
26
 
22
- def self.url(id = nil)
23
- url = "#{BASE_URL}/whitelabel/links"
24
- url = "#{url}/#{id}" unless id.nil?
25
- url
26
- end
27
+ def self.create_links(resp)
28
+ return resp if resp.nil?
29
+ resp.map { |link| Links.create_link(link) }
30
+ end
27
31
 
28
- def self.create_links(resp)
29
- return resp if resp.nil?
30
- links = []
31
- resp.each do |link|
32
- links.push(
33
- SendGrid4r::REST::Whitelabel::Links.create_link(link)
34
- )
35
- end
36
- links
37
- end
32
+ def self.create_link(resp)
33
+ return resp if resp.nil?
34
+ Link.new(
35
+ resp['id'],
36
+ resp['domain'],
37
+ resp['subdomain'],
38
+ resp['username'],
39
+ resp['user_id'],
40
+ resp['default'],
41
+ resp['valid'],
42
+ resp['legacy'],
43
+ Links.create_dns(resp['dns'])
44
+ )
45
+ end
38
46
 
39
- def self.create_link(resp)
40
- return resp if resp.nil?
41
- Link.new(
42
- resp['id'],
43
- resp['domain'],
44
- resp['subdomain'],
45
- resp['username'],
46
- resp['user_id'],
47
- resp['default'],
48
- resp['valid'],
49
- resp['legacy'],
50
- SendGrid4r::REST::Whitelabel::Links.create_dns(resp['dns'])
51
- )
52
- end
47
+ def self.create_dns(resp)
48
+ return resp if resp.nil?
49
+ Dns.new(
50
+ Links.create_record(resp['domain_cname']),
51
+ Links.create_record(resp['owner_cname'])
52
+ )
53
+ end
53
54
 
54
- def self.create_dns(resp)
55
- return resp if resp.nil?
56
- Dns.new(
57
- SendGrid4r::REST::Whitelabel::Links.create_record(
58
- resp['domain_cname']
59
- ),
60
- SendGrid4r::REST::Whitelabel::Links.create_record(
61
- resp['owner_cname']
62
- )
63
- )
64
- end
55
+ def self.create_record(resp)
56
+ return resp if resp.nil?
57
+ Record.new(resp['host'], resp['type'], resp['data'], resp['valid'])
58
+ end
65
59
 
66
- def self.create_record(resp)
67
- return resp if resp.nil?
68
- Record.new(resp['host'], resp['type'], resp['data'], resp['valid'])
69
- end
60
+ Result = Struct.new(:id, :valid, :validation_results)
61
+ ValidationResults = Struct.new(:domain_cname, :owner_cname)
62
+ ValidationResult = Struct.new(:valid, :reason)
70
63
 
71
- Result = Struct.new(:id, :valid, :validation_results)
72
- ValidationResults = Struct.new(:domain_cname, :owner_cname)
73
- ValidationResult = Struct.new(:valid, :reason)
74
-
75
- def self.create_result(resp)
76
- return resp if resp.nil?
77
- Result.new(
78
- resp['id'],
79
- resp['valid'],
80
- SendGrid4r::REST::Whitelabel::Links.create_validation_results(
81
- resp['validation_results']
82
- )
83
- )
84
- end
64
+ def self.create_result(resp)
65
+ return resp if resp.nil?
66
+ Result.new(
67
+ resp['id'],
68
+ resp['valid'],
69
+ Links.create_validation_results(resp['validation_results'])
70
+ )
71
+ end
85
72
 
86
- def self.create_validation_results(resp)
87
- return resp if resp.nil?
88
- ValidationResults.new(
89
- SendGrid4r::REST::Whitelabel::Links.create_validation_result(
90
- resp['domain_cname']
91
- ),
92
- SendGrid4r::REST::Whitelabel::Links.create_validation_result(
93
- resp['owner_cname']
94
- )
95
- )
96
- end
73
+ def self.create_validation_results(resp)
74
+ return resp if resp.nil?
75
+ ValidationResults.new(
76
+ Links.create_validation_result(resp['domain_cname']),
77
+ Links.create_validation_result(resp['owner_cname'])
78
+ )
79
+ end
97
80
 
98
- def self.create_validation_result(resp)
99
- return resp if resp.nil?
100
- ValidationResult.new(resp['valid'], resp['reason'])
101
- end
81
+ def self.create_validation_result(resp)
82
+ return resp if resp.nil?
83
+ ValidationResult.new(resp['valid'], resp['reason'])
84
+ end
102
85
 
103
- def get_wl_links(
104
- limit: nil, offset: nil, exclude_subusers: nil, username: nil,
105
- domain: nil, &block
106
- )
107
- params = {}
108
- params['limit'] = limit unless limit.nil?
109
- params['offset'] = offset unless offset.nil?
110
- unless exclude_subusers.nil?
111
- params['exclude_subusers'] = exclude_subusers
112
- end
113
- params['username'] = username unless username.nil?
114
- params['domain'] = domain unless domain.nil?
115
- endpoint = SendGrid4r::REST::Whitelabel::Links.url
116
- resp = get(@auth, endpoint, params, &block)
117
- SendGrid4r::REST::Whitelabel::Links.create_links(resp)
118
- end
86
+ def get_wl_links(
87
+ limit: nil, offset: nil, exclude_subusers: nil, username: nil,
88
+ domain: nil, &block
89
+ )
90
+ params = {}
91
+ params[:limit] = limit unless limit.nil?
92
+ params[:offset] = offset unless offset.nil?
93
+ unless exclude_subusers.nil?
94
+ params[:exclude_subusers] = exclude_subusers
95
+ end
96
+ params[:username] = username unless username.nil?
97
+ params[:domain] = domain unless domain.nil?
98
+ resp = get(@auth, Links.url, params, &block)
99
+ Links.create_links(resp)
100
+ end
119
101
 
120
- def post_wl_link(subdomain:, domain:, default: nil, &block)
121
- params = {}
122
- params['subdomain'] = subdomain
123
- params['domain'] = domain
124
- params['default'] = default unless default.nil?
125
- endpoint = SendGrid4r::REST::Whitelabel::Links.url
126
- resp = post(@auth, endpoint, params, &block)
127
- SendGrid4r::REST::Whitelabel::Links.create_link(resp)
128
- end
102
+ def post_wl_link(subdomain:, domain:, default: nil, &block)
103
+ params = {
104
+ subdomain: subdomain,
105
+ domain: domain
106
+ }
107
+ params[:default] = default unless default.nil?
108
+ resp = post(@auth, Links.url, params, &block)
109
+ Links.create_link(resp)
110
+ end
129
111
 
130
- def get_wl_link(id:, &block)
131
- endpoint = SendGrid4r::REST::Whitelabel::Links.url(id)
132
- resp = get(@auth, endpoint, nil, &block)
133
- SendGrid4r::REST::Whitelabel::Links.create_link(resp)
134
- end
112
+ def get_wl_link(id:, &block)
113
+ resp = get(@auth, Links.url(id), nil, &block)
114
+ Links.create_link(resp)
115
+ end
135
116
 
136
- def patch_wl_link(id:, default:, &block)
137
- endpoint = SendGrid4r::REST::Whitelabel::Links.url(id)
138
- params = {}
139
- params['default'] = default
140
- resp = patch(@auth, endpoint, params, &block)
141
- SendGrid4r::REST::Whitelabel::Links.create_link(resp)
142
- end
117
+ def patch_wl_link(id:, default:, &block)
118
+ params = { default: default }
119
+ resp = patch(@auth, Links.url(id), params, &block)
120
+ Links.create_link(resp)
121
+ end
143
122
 
144
- def delete_wl_link(id:, &block)
145
- endpoint = SendGrid4r::REST::Whitelabel::Links.url(id)
146
- delete(@auth, endpoint, &block)
147
- end
123
+ def delete_wl_link(id:, &block)
124
+ delete(@auth, Links.url(id), &block)
125
+ end
148
126
 
149
- def get_default_wl_link(domain: nil, &block)
150
- params = {}
151
- params['domain'] = domain unless domain.nil?
152
- endpoint = SendGrid4r::REST::Whitelabel::Links.url
153
- endpoint = "#{endpoint}/default"
154
- resp = get(@auth, endpoint, params, &block)
155
- SendGrid4r::REST::Whitelabel::Links.create_link(resp)
156
- end
127
+ def get_default_wl_link(domain: nil, &block)
128
+ params = {}
129
+ params[:domain] = domain unless domain.nil?
130
+ resp = get(@auth, "#{Links.url}/default", params, &block)
131
+ Links.create_link(resp)
132
+ end
157
133
 
158
- def validate_wl_link(id:, &block)
159
- endpoint = SendGrid4r::REST::Whitelabel::Links.url(id)
160
- endpoint = "#{endpoint}/validate"
161
- resp = post(@auth, endpoint, &block)
162
- SendGrid4r::REST::Whitelabel::Links.create_result(resp)
163
- end
134
+ def validate_wl_link(id:, &block)
135
+ resp = post(@auth, "#{Links.url(id)}/validate", &block)
136
+ Links.create_result(resp)
137
+ end
164
138
 
165
- def get_associated_wl_link(username:, &block)
166
- endpoint = SendGrid4r::REST::Whitelabel::Links.url
167
- endpoint = "#{endpoint}/subuser"
168
- params = {}
169
- params['username'] = username
170
- resp = get(@auth, endpoint, params, &block)
171
- SendGrid4r::REST::Whitelabel::Links.create_link(resp)
172
- end
139
+ def get_associated_wl_link(username:, &block)
140
+ params = { username: username }
141
+ resp = get(@auth, "#{Links.url}/subuser", params, &block)
142
+ Links.create_link(resp)
143
+ end
173
144
 
174
- def disassociate_wl_link(username:, &block)
175
- endpoint = SendGrid4r::REST::Whitelabel::Links.url
176
- endpoint = "#{endpoint}/subuser"
177
- params = {}
178
- params['username'] = username
179
- delete(@auth, endpoint, params, &block)
180
- end
145
+ def disassociate_wl_link(username:, &block)
146
+ params = { username: username }
147
+ delete(@auth, "#{Links.url}/subuser", params, &block)
148
+ end
181
149
 
182
- def associate_wl_link(id:, username:, &block)
183
- endpoint = SendGrid4r::REST::Whitelabel::Links.url(id)
184
- endpoint = "#{endpoint}/subuser"
185
- params = {}
186
- params['username'] = username
187
- resp = post(@auth, endpoint, params, &block)
188
- SendGrid4r::REST::Whitelabel::Links.create_link(resp)
189
- end
150
+ def associate_wl_link(id:, username:, &block)
151
+ params = { username: username }
152
+ resp = post(@auth, "#{Links.url(id)}/subuser", params, &block)
153
+ Links.create_link(resp)
190
154
  end
191
155
  end
192
156
  end
@@ -2,5 +2,5 @@
2
2
  # SendGrid API v3 wrapper implementation.
3
3
  #
4
4
  module SendGrid4r
5
- VERSION = '1.8.1'
5
+ VERSION = '1.10.0'
6
6
  end
data/lib/sendgrid4r.rb CHANGED
@@ -6,11 +6,11 @@ require 'sendgrid4r/rest/request'
6
6
  require 'sendgrid4r/rest/subusers'
7
7
  require 'sendgrid4r/rest/users'
8
8
 
9
- require 'sendgrid4r/rest/templates/templates'
10
- require 'sendgrid4r/rest/templates/versions'
9
+ require 'sendgrid4r/rest/transactional_templates/templates'
10
+ require 'sendgrid4r/rest/transactional_templates/versions'
11
11
 
12
- require 'sendgrid4r/rest/api_keys/api_keys'
13
- require 'sendgrid4r/rest/api_keys/permissions'
12
+ require 'sendgrid4r/rest/api_keys_management/api_keys'
13
+ require 'sendgrid4r/rest/api_keys_management/permissions'
14
14
 
15
15
  require 'sendgrid4r/rest/sm/sm'
16
16
  require 'sendgrid4r/rest/sm/global_unsubscribes'
@@ -23,17 +23,17 @@ require 'sendgrid4r/rest/invalid_emails'
23
23
  require 'sendgrid4r/rest/spam_reports'
24
24
  require 'sendgrid4r/rest/cancel_scheduled_sends'
25
25
 
26
- require 'sendgrid4r/rest/campaigns/campaigns'
26
+ require 'sendgrid4r/rest/marketing_campaigns/marketing_campaigns'
27
+ require 'sendgrid4r/rest/marketing_campaigns/senders'
28
+ require 'sendgrid4r/rest/marketing_campaigns/contacts/custom_fields'
29
+ require 'sendgrid4r/rest/marketing_campaigns/contacts/lists'
30
+ require 'sendgrid4r/rest/marketing_campaigns/contacts/recipients'
31
+ require 'sendgrid4r/rest/marketing_campaigns/contacts/reserved_fields'
32
+ require 'sendgrid4r/rest/marketing_campaigns/contacts/segments'
27
33
 
28
- require 'sendgrid4r/rest/categories/categories'
34
+ require 'sendgrid4r/rest/categories'
29
35
 
30
- require 'sendgrid4r/rest/contacts/custom_fields'
31
- require 'sendgrid4r/rest/contacts/lists'
32
- require 'sendgrid4r/rest/contacts/recipients'
33
- require 'sendgrid4r/rest/contacts/reserved_fields'
34
- require 'sendgrid4r/rest/contacts/segments'
35
-
36
- require 'sendgrid4r/rest/email_activity/email_activity'
36
+ require 'sendgrid4r/rest/email_activity'
37
37
 
38
38
  require 'sendgrid4r/rest/ip_access_management'
39
39
 
@@ -61,10 +61,20 @@ require 'sendgrid4r/rest/whitelabel/domains'
61
61
  require 'sendgrid4r/rest/whitelabel/ips'
62
62
  require 'sendgrid4r/rest/whitelabel/links'
63
63
 
64
+ require 'sendgrid4r/rest/mail/attachment'
65
+ require 'sendgrid4r/rest/mail/content'
66
+ require 'sendgrid4r/rest/mail/address'
67
+ require 'sendgrid4r/rest/mail/mail_settings'
68
+ require 'sendgrid4r/rest/mail/mail'
69
+ require 'sendgrid4r/rest/mail/params'
70
+ require 'sendgrid4r/rest/mail/personalization'
71
+ require 'sendgrid4r/rest/mail/tracking_settings'
72
+
64
73
  require 'sendgrid4r/factory/campaign_factory'
65
74
  require 'sendgrid4r/factory/condition_factory'
66
75
  require 'sendgrid4r/factory/segment_factory'
67
76
  require 'sendgrid4r/factory/version_factory'
77
+ require 'sendgrid4r/factory/mail_factory'
68
78
 
69
79
  require 'sendgrid4r/rest/api'
70
80
 
data/sendgrid4r.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency('rest-client', '>=1.8.0', '<1.9.0')
22
22
  spec.add_development_dependency('rubocop', '>=0.29.0', '<0.34.3')
23
- spec.add_development_dependency('bundler', '>=1.6.0', '<1.12.0')
23
+ spec.add_development_dependency('bundler', '>=1.6.0', '<1.13.0')
24
24
  spec.add_development_dependency('rspec', '3.3.0')
25
25
  spec.add_development_dependency('dotenv', '=0.11.0', '<=2.0.2')
26
26
  end