sendgrid-ruby 6.2.0 → 6.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/config.yml +10 -0
  3. data/.github/workflows/test-and-deploy.yml +120 -0
  4. data/.gitignore +2 -0
  5. data/.rubocop.yml +8 -0
  6. data/.rubocop_todo.yml +127 -0
  7. data/CHANGELOG.md +147 -9
  8. data/CONTRIBUTING.md +11 -21
  9. data/Dockerfile +14 -0
  10. data/FIRST_TIMERS.md +79 -0
  11. data/Gemfile +0 -1
  12. data/ISSUE_TEMPLATE.md +5 -1
  13. data/{LICENSE.md → LICENSE} +1 -1
  14. data/Makefile +9 -2
  15. data/PULL_REQUEST_TEMPLATE.md +5 -5
  16. data/README.md +23 -31
  17. data/Rakefile +2 -3
  18. data/TROUBLESHOOTING.md +17 -5
  19. data/USAGE.md +146 -39
  20. data/examples/accesssettings/accesssettings.rb +9 -12
  21. data/examples/alerts/alerts.rb +8 -11
  22. data/examples/apikeys/apikeys.rb +12 -15
  23. data/examples/asm/asm.rb +27 -30
  24. data/examples/browsers/browsers.rb +0 -3
  25. data/examples/campaigns/campaigns.rb +29 -32
  26. data/examples/categories/categories.rb +0 -3
  27. data/examples/clients/clients.rb +1 -4
  28. data/examples/contactdb/contactdb.rb +63 -66
  29. data/examples/devices/devices.rb +0 -3
  30. data/examples/emailactivity/emailactivity.rb +52 -0
  31. data/examples/geo/geo.rb +0 -3
  32. data/examples/helpers/eventwebhook/example.rb +16 -0
  33. data/examples/helpers/mail/example.rb +24 -13
  34. data/examples/helpers/settings/example.rb +1 -1
  35. data/examples/helpers/stats/example.rb +4 -4
  36. data/examples/ips/ips.rb +19 -22
  37. data/examples/mail/mail.rb +72 -75
  38. data/examples/mailboxproviders/mailboxproviders.rb +0 -3
  39. data/examples/mailsettings/mailsettings.rb +21 -24
  40. data/examples/partnersettings/partnersettings.rb +3 -6
  41. data/examples/scopes/scopes.rb +8 -10
  42. data/examples/senderauthentication/senderauthentication.rb +41 -44
  43. data/examples/senders/senders.rb +28 -31
  44. data/examples/stats/stats.rb +0 -3
  45. data/examples/subusers/subusers.rb +17 -20
  46. data/examples/suppression/suppression.rb +15 -18
  47. data/examples/templates/templates.rb +29 -31
  48. data/examples/trackingsettings/trackingsettings.rb +14 -17
  49. data/examples/user/user.rb +41 -44
  50. data/lib/rack/sendgrid_webhook_verification.rb +55 -0
  51. data/lib/sendgrid/base_interface.rb +8 -4
  52. data/lib/sendgrid/helpers/eventwebhook/eventwebhook.rb +50 -0
  53. data/lib/sendgrid/helpers/inbound/README.md +5 -5
  54. data/lib/sendgrid/helpers/inbound/app.rb +2 -2
  55. data/lib/sendgrid/helpers/inbound/public/index.html +1 -1
  56. data/lib/sendgrid/helpers/inbound/send.rb +3 -3
  57. data/lib/sendgrid/helpers/ip_management/ip_management.rb +1 -1
  58. data/lib/sendgrid/helpers/mail/README.md +3 -3
  59. data/lib/sendgrid/helpers/mail/asm.rb +6 -18
  60. data/lib/sendgrid/helpers/mail/attachment.rb +12 -42
  61. data/lib/sendgrid/helpers/mail/bcc_settings.rb +6 -18
  62. data/lib/sendgrid/helpers/mail/bypass_list_management.rb +8 -18
  63. data/lib/sendgrid/helpers/mail/category.rb +2 -2
  64. data/lib/sendgrid/helpers/mail/click_tracking.rb +6 -18
  65. data/lib/sendgrid/helpers/mail/content.rb +4 -3
  66. data/lib/sendgrid/helpers/mail/custom_arg.rb +6 -10
  67. data/lib/sendgrid/helpers/mail/email.rb +10 -5
  68. data/lib/sendgrid/helpers/mail/footer.rb +7 -27
  69. data/lib/sendgrid/helpers/mail/ganalytics.rb +10 -54
  70. data/lib/sendgrid/helpers/mail/header.rb +6 -10
  71. data/lib/sendgrid/helpers/mail/mail.rb +32 -48
  72. data/lib/sendgrid/helpers/mail/mail_settings.rb +9 -25
  73. data/lib/sendgrid/helpers/mail/open_tracking.rb +6 -18
  74. data/lib/sendgrid/helpers/mail/personalization.rb +40 -27
  75. data/lib/sendgrid/helpers/mail/section.rb +6 -10
  76. data/lib/sendgrid/helpers/mail/spam_check.rb +7 -27
  77. data/lib/sendgrid/helpers/mail/subscription_tracking.rb +8 -36
  78. data/lib/sendgrid/helpers/mail/substitution.rb +6 -10
  79. data/lib/sendgrid/helpers/mail/tracking_settings.rb +8 -20
  80. data/lib/sendgrid/helpers/permissions/scope.rb +2 -2
  81. data/lib/sendgrid/helpers/settings/README.md +2 -2
  82. data/lib/sendgrid/helpers/settings/settings.rb +1 -1
  83. data/lib/sendgrid/helpers/settings/tracking_settings_dto.rb +3 -5
  84. data/lib/sendgrid/helpers/stats/metrics.rb +5 -5
  85. data/lib/sendgrid/sendgrid.rb +4 -3
  86. data/lib/sendgrid/twilio_email.rb +1 -1
  87. data/lib/sendgrid/version.rb +1 -1
  88. data/lib/sendgrid-ruby.rb +2 -0
  89. data/mail_helper_v3.md +12 -12
  90. data/sendgrid-ruby.gemspec +8 -8
  91. data/spec/fixtures/event_webhook.rb +22 -0
  92. data/spec/rack/sendgrid_webhook_verification_spec.rb +142 -0
  93. data/spec/sendgrid/helpers/eventwebhook/eventwebhook_spec.rb +105 -0
  94. data/spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb +3 -3
  95. data/spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb +3 -3
  96. data/spec/sendgrid/helpers/settings/settings_spec.rb +2 -2
  97. data/spec/sendgrid/helpers/settings/tracking_settings_dto_spec.rb +3 -3
  98. data/spec/sendgrid/helpers/settings/user_settings_dto_spec.rb +3 -3
  99. data/spec/sendgrid/helpers/stats/email_stats_spec.rb +22 -23
  100. data/spec/sendgrid/helpers/stats/metrics_spec.rb +19 -20
  101. data/spec/sendgrid/helpers/stats/stats_response_spec.rb +22 -23
  102. data/spec/spec_helper.rb +3 -1
  103. data/static/img/github-fork.png +0 -0
  104. data/static/img/github-sign-up.png +0 -0
  105. data/test/sendgrid/helpers/mail/test_attachment.rb +4 -6
  106. data/test/sendgrid/helpers/mail/test_category.rb +0 -2
  107. data/test/sendgrid/helpers/mail/test_email.rb +17 -10
  108. data/test/sendgrid/helpers/mail/test_mail.rb +101 -102
  109. data/test/sendgrid/helpers/mail/test_personalizations.rb +145 -92
  110. data/test/sendgrid/permissions/test_scopes.rb +1 -3
  111. data/test/sendgrid/test_sendgrid-ruby.rb +1964 -1986
  112. data/twilio_sendgrid_logo.png +0 -0
  113. data/use-cases/README.md +17 -0
  114. data/use-cases/domain-authentication.md +5 -0
  115. data/use-cases/email-statistics.md +52 -0
  116. data/use-cases/legacy-templates.md +98 -0
  117. data/use-cases/personalizations.md +34 -0
  118. data/use-cases/sms.md +39 -0
  119. data/use-cases/transactional-templates.md +111 -0
  120. data/use-cases/twilio-email.md +13 -0
  121. data/use-cases/twilio-setup.md +54 -0
  122. metadata +69 -34
  123. data/.codeclimate.yml +0 -21
  124. data/.travis.yml +0 -40
  125. data/USE_CASES.md +0 -405
  126. data/docker/Dockerfile +0 -12
  127. data/docker/README.md +0 -30
  128. data/test/prism.sh +0 -42
data/examples/ips/ips.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  require 'sendgrid-ruby'
2
2
 
3
-
4
3
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
4
 
6
-
7
5
  ##################################################
8
6
  # Retrieve all IP addresses #
9
7
  # GET /ips #
@@ -18,7 +16,7 @@ puts response.headers
18
16
  # Retrieve all assigned IPs #
19
17
  # GET /ips/assigned #
20
18
 
21
- response = sg.client.ips.assigned.get()
19
+ response = sg.client.ips.assigned.get
22
20
  puts response.status_code
23
21
  puts response.body
24
22
  puts response.headers
@@ -30,7 +28,7 @@ puts response.headers
30
28
  params = {}
31
29
  response = sg.client.ips.get(query_params: params)
32
30
  all_ips = JSON.parse(response.body)
33
- unassigned_ips = all_ips.select {|ip| ip.subusers.empty?}
31
+ unassigned_ips = all_ips.select { |ip| ip.subusers.empty? }
34
32
  puts response.status_code
35
33
  puts response.body
36
34
  puts unassigned_ips
@@ -52,7 +50,7 @@ puts response.headers
52
50
  # Retrieve all IP pools. #
53
51
  # GET /ips/pools #
54
52
 
55
- response = sg.client.ips.pools.get()
53
+ response = sg.client.ips.pools.get
56
54
  puts response.status_code
57
55
  puts response.body
58
56
  puts response.headers
@@ -64,7 +62,7 @@ puts response.headers
64
62
  data = JSON.parse('{
65
63
  "name": "new_pool_name"
66
64
  }')
67
- pool_name = "test_url_param"
65
+ pool_name = 'test_url_param'
68
66
  response = sg.client.ips.pools._(pool_name).put(request_body: data)
69
67
  puts response.status_code
70
68
  puts response.body
@@ -74,8 +72,8 @@ puts response.headers
74
72
  # Retrieve all IPs in a specified pool. #
75
73
  # GET /ips/pools/{pool_name} #
76
74
 
77
- pool_name = "test_url_param"
78
- response = sg.client.ips.pools._(pool_name).get()
75
+ pool_name = 'test_url_param'
76
+ response = sg.client.ips.pools._(pool_name).get
79
77
  puts response.status_code
80
78
  puts response.body
81
79
  puts response.headers
@@ -84,8 +82,8 @@ puts response.headers
84
82
  # Delete an IP pool. #
85
83
  # DELETE /ips/pools/{pool_name} #
86
84
 
87
- pool_name = "test_url_param"
88
- response = sg.client.ips.pools._(pool_name).delete()
85
+ pool_name = 'test_url_param'
86
+ response = sg.client.ips.pools._(pool_name).delete
89
87
  puts response.status_code
90
88
  puts response.body
91
89
  puts response.headers
@@ -97,7 +95,7 @@ puts response.headers
97
95
  data = JSON.parse('{
98
96
  "ip": "0.0.0.0"
99
97
  }')
100
- pool_name = "test_url_param"
98
+ pool_name = 'test_url_param'
101
99
  response = sg.client.ips.pools._(pool_name).ips.post(request_body: data)
102
100
  puts response.status_code
103
101
  puts response.body
@@ -107,9 +105,9 @@ puts response.headers
107
105
  # Remove an IP address from a pool. #
108
106
  # DELETE /ips/pools/{pool_name}/ips/{ip} #
109
107
 
110
- pool_name = "test_url_param"
111
- ip = "test_url_param"
112
- response = sg.client.ips.pools._(pool_name).ips._(ip).delete()
108
+ pool_name = 'test_url_param'
109
+ ip = 'test_url_param'
110
+ response = sg.client.ips.pools._(pool_name).ips._(ip).delete
113
111
  puts response.status_code
114
112
  puts response.body
115
113
  puts response.headers
@@ -130,7 +128,7 @@ puts response.headers
130
128
  # Retrieve all IPs currently in warmup #
131
129
  # GET /ips/warmup #
132
130
 
133
- response = sg.client.ips.warmup.get()
131
+ response = sg.client.ips.warmup.get
134
132
  puts response.status_code
135
133
  puts response.body
136
134
  puts response.headers
@@ -139,8 +137,8 @@ puts response.headers
139
137
  # Retrieve warmup status for a specific IP address #
140
138
  # GET /ips/warmup/{ip_address} #
141
139
 
142
- ip_address = "test_url_param"
143
- response = sg.client.ips.warmup._(ip_address).get()
140
+ ip_address = 'test_url_param'
141
+ response = sg.client.ips.warmup._(ip_address).get
144
142
  puts response.status_code
145
143
  puts response.body
146
144
  puts response.headers
@@ -149,8 +147,8 @@ puts response.headers
149
147
  # Remove an IP from warmup #
150
148
  # DELETE /ips/warmup/{ip_address} #
151
149
 
152
- ip_address = "test_url_param"
153
- response = sg.client.ips.warmup._(ip_address).delete()
150
+ ip_address = 'test_url_param'
151
+ response = sg.client.ips.warmup._(ip_address).delete
154
152
  puts response.status_code
155
153
  puts response.body
156
154
  puts response.headers
@@ -159,9 +157,8 @@ puts response.headers
159
157
  # Retrieve all IP pools an IP address belongs to #
160
158
  # GET /ips/{ip_address} #
161
159
 
162
- ip_address = "test_url_param"
163
- response = sg.client.ips._(ip_address).get()
160
+ ip_address = 'test_url_param'
161
+ response = sg.client.ips._(ip_address).get
164
162
  puts response.status_code
165
163
  puts response.body
166
164
  puts response.headers
167
-
@@ -1,14 +1,12 @@
1
1
  require 'sendgrid-ruby'
2
2
 
3
-
4
3
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
4
 
6
-
7
5
  ##################################################
8
6
  # Create a batch ID #
9
7
  # POST /mail/batch #
10
8
 
11
- response = sg.client.mail.batch.post()
9
+ response = sg.client.mail.batch.post
12
10
  puts response.status_code
13
11
  puts response.body
14
12
  puts response.headers
@@ -17,8 +15,8 @@ puts response.headers
17
15
  # Validate batch ID #
18
16
  # GET /mail/batch/{batch_id} #
19
17
 
20
- batch_id = "test_url_param"
21
- response = sg.client.mail.batch._(batch_id).get()
18
+ batch_id = 'test_url_param'
19
+ response = sg.client.mail.batch._(batch_id).get
22
20
  puts response.status_code
23
21
  puts response.body
24
22
  puts response.headers
@@ -26,148 +24,147 @@ puts response.headers
26
24
  ##################################################
27
25
  # v3 Mail Send #
28
26
  # POST /mail/send #
29
- # This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-ruby/blob/master/lib/helpers/mail/README.md).
27
+ # This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-ruby/blob/HEAD/lib/sendgrid/helpers/mail/README.md).
30
28
 
31
29
  data = JSON.parse('{
32
30
  "asm": {
33
- "group_id": 1,
31
+ "group_id": 1,
34
32
  "groups_to_display": [
35
- 1,
36
- 2,
33
+ 1,
34
+ 2,
37
35
  3
38
36
  ]
39
- },
37
+ },
40
38
  "attachments": [
41
39
  {
42
- "content": "[BASE64 encoded content block here]",
43
- "content_id": "ii_139db99fdb5c3704",
44
- "disposition": "inline",
45
- "filename": "file1.jpg",
46
- "name": "file1",
40
+ "content": "[BASE64 encoded content block here]",
41
+ "content_id": "ii_139db99fdb5c3704",
42
+ "disposition": "inline",
43
+ "filename": "file1.jpg",
44
+ "name": "file1",
47
45
  "type": "jpg"
48
46
  }
49
- ],
50
- "batch_id": "[YOUR BATCH ID GOES HERE]",
47
+ ],
48
+ "batch_id": "[YOUR BATCH ID GOES HERE]",
51
49
  "categories": [
52
- "category1",
50
+ "category1",
53
51
  "category2"
54
- ],
52
+ ],
55
53
  "content": [
56
54
  {
57
- "type": "text/html",
55
+ "type": "text/html",
58
56
  "value": "<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>"
59
57
  }
60
- ],
58
+ ],
61
59
  "custom_args": {
62
- "New Argument 1": "New Value 1",
63
- "activationAttempt": "1",
60
+ "New Argument 1": "New Value 1",
61
+ "activationAttempt": "1",
64
62
  "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
65
- },
63
+ },
66
64
  "from": {
67
- "email": "sam.smith@example.com",
65
+ "email": "sam.smith@example.com",
68
66
  "name": "Sam Smith"
69
- },
70
- "headers": {},
71
- "ip_pool_name": "[YOUR POOL NAME GOES HERE]",
67
+ },
68
+ "headers": {},
69
+ "ip_pool_name": "[YOUR POOL NAME GOES HERE]",
72
70
  "mail_settings": {
73
71
  "bcc": {
74
- "email": "ben.doe@example.com",
72
+ "email": "ben.doe@example.com",
75
73
  "enable": true
76
- },
74
+ },
77
75
  "bypass_list_management": {
78
76
  "enable": true
79
- },
77
+ },
80
78
  "footer": {
81
- "enable": true,
82
- "html": "<p>Thanks</br>The Twilio SendGrid Team</p>",
79
+ "enable": true,
80
+ "html": "<p>Thanks</br>The Twilio SendGrid Team</p>",
83
81
  "text": "Thanks,/n The Twilio SendGrid Team"
84
- },
82
+ },
85
83
  "sandbox_mode": {
86
84
  "enable": false
87
- },
85
+ },
88
86
  "spam_check": {
89
- "enable": true,
90
- "post_to_url": "http://example.com/compliance",
87
+ "enable": true,
88
+ "post_to_url": "http://example.com/compliance",
91
89
  "threshold": 3
92
90
  }
93
- },
91
+ },
94
92
  "personalizations": [
95
93
  {
96
94
  "bcc": [
97
95
  {
98
- "email": "sam.doe@example.com",
96
+ "email": "sam.doe@example.com",
99
97
  "name": "Sam Doe"
100
98
  }
101
- ],
99
+ ],
102
100
  "cc": [
103
101
  {
104
- "email": "jane.doe@example.com",
102
+ "email": "jane.doe@example.com",
105
103
  "name": "Jane Doe"
106
104
  }
107
- ],
105
+ ],
108
106
  "custom_args": {
109
- "New Argument 1": "New Value 1",
110
- "activationAttempt": "1",
107
+ "New Argument 1": "New Value 1",
108
+ "activationAttempt": "1",
111
109
  "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
112
- },
110
+ },
113
111
  "headers": {
114
- "X-Accept-Language": "en",
112
+ "X-Accept-Language": "en",
115
113
  "X-Mailer": "MyApp"
116
- },
117
- "send_at": 1409348513,
118
- "subject": "Hello, World!",
114
+ },
115
+ "send_at": 1409348513,
116
+ "subject": "Hello, World!",
119
117
  "substitutions": {
120
- "id": "substitutions",
118
+ "id": "substitutions",
121
119
  "type": "object"
122
- },
120
+ },
123
121
  "to": [
124
122
  {
125
- "email": "john.doe@example.com",
123
+ "email": "john.doe@example.com",
126
124
  "name": "John Doe"
127
125
  }
128
126
  ]
129
127
  }
130
- ],
128
+ ],
131
129
  "reply_to": {
132
- "email": "sam.smith@example.com",
130
+ "email": "sam.smith@example.com",
133
131
  "name": "Sam Smith"
134
- },
132
+ },
135
133
  "sections": {
136
134
  "section": {
137
- ":sectionName1": "section 1 text",
135
+ ":sectionName1": "section 1 text",
138
136
  ":sectionName2": "section 2 text"
139
137
  }
140
- },
141
- "send_at": 1409348513,
142
- "subject": "Hello, World!",
143
- "template_id": "[YOUR TEMPLATE ID GOES HERE]",
138
+ },
139
+ "send_at": 1409348513,
140
+ "subject": "Hello, World!",
141
+ "template_id": "[YOUR TEMPLATE ID GOES HERE]",
144
142
  "tracking_settings": {
145
143
  "click_tracking": {
146
- "enable": true,
144
+ "enable": true,
147
145
  "enable_text": true
148
- },
146
+ },
149
147
  "ganalytics": {
150
- "enable": true,
151
- "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
152
- "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
153
- "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
154
- "utm_name": "[NAME OF YOUR CAMPAIGN]",
148
+ "enable": true,
149
+ "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
150
+ "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
151
+ "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
152
+ "utm_name": "[NAME OF YOUR CAMPAIGN]",
155
153
  "utm_term": "[IDENTIFY PAID KEYWORDS HERE]"
156
- },
154
+ },
157
155
  "open_tracking": {
158
- "enable": true,
156
+ "enable": true,
159
157
  "substitution_tag": "%opentrack"
160
- },
158
+ },
161
159
  "subscription_tracking": {
162
- "enable": true,
163
- "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
164
- "substitution_tag": "<%click here%>",
160
+ "enable": true,
161
+ "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
162
+ "substitution_tag": "<%click here%>",
165
163
  "text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>."
166
164
  }
167
165
  }
168
166
  }')
169
- response = sg.client.mail._("send").post(request_body: data)
167
+ response = sg.client.mail._('send').post(request_body: data)
170
168
  puts response.status_code
171
169
  puts response.body
172
170
  puts response.headers
173
-
@@ -1,9 +1,7 @@
1
1
  require 'sendgrid-ruby'
2
2
 
3
-
4
3
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
4
 
6
-
7
5
  ##################################################
8
6
  # Retrieve email statistics by mailbox provider. #
9
7
  # GET /mailbox_providers/stats #
@@ -13,4 +11,3 @@ response = sg.client.mailbox_providers.stats.get(query_params: params)
13
11
  puts response.status_code
14
12
  puts response.body
15
13
  puts response.headers
16
-
@@ -1,9 +1,7 @@
1
1
  require 'sendgrid-ruby'
2
2
 
3
-
4
3
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
4
 
6
-
7
5
  ##################################################
8
6
  # Retrieve all mail settings #
9
7
  # GET /mail_settings #
@@ -19,9 +17,9 @@ puts response.headers
19
17
  # PATCH /mail_settings/address_whitelist #
20
18
 
21
19
  data = JSON.parse('{
22
- "enabled": true,
20
+ "enabled": true,
23
21
  "list": [
24
- "email1@example.com",
22
+ "email1@example.com",
25
23
  "example.com"
26
24
  ]
27
25
  }')
@@ -34,7 +32,7 @@ puts response.headers
34
32
  # Retrieve address whitelist mail settings #
35
33
  # GET /mail_settings/address_whitelist #
36
34
 
37
- response = sg.client.mail_settings.address_whitelist.get()
35
+ response = sg.client.mail_settings.address_whitelist.get
38
36
  puts response.status_code
39
37
  puts response.body
40
38
  puts response.headers
@@ -44,7 +42,7 @@ puts response.headers
44
42
  # PATCH /mail_settings/bcc #
45
43
 
46
44
  data = JSON.parse('{
47
- "email": "email@example.com",
45
+ "email": "email@example.com",
48
46
  "enabled": false
49
47
  }')
50
48
  response = sg.client.mail_settings.bcc.patch(request_body: data)
@@ -56,7 +54,7 @@ puts response.headers
56
54
  # Retrieve all BCC mail settings #
57
55
  # GET /mail_settings/bcc #
58
56
 
59
- response = sg.client.mail_settings.bcc.get()
57
+ response = sg.client.mail_settings.bcc.get
60
58
  puts response.status_code
61
59
  puts response.body
62
60
  puts response.headers
@@ -66,8 +64,8 @@ puts response.headers
66
64
  # PATCH /mail_settings/bounce_purge #
67
65
 
68
66
  data = JSON.parse('{
69
- "enabled": true,
70
- "hard_bounces": 5,
67
+ "enabled": true,
68
+ "hard_bounces": 5,
71
69
  "soft_bounces": 5
72
70
  }')
73
71
  response = sg.client.mail_settings.bounce_purge.patch(request_body: data)
@@ -79,7 +77,7 @@ puts response.headers
79
77
  # Retrieve bounce purge mail settings #
80
78
  # GET /mail_settings/bounce_purge #
81
79
 
82
- response = sg.client.mail_settings.bounce_purge.get()
80
+ response = sg.client.mail_settings.bounce_purge.get
83
81
  puts response.status_code
84
82
  puts response.body
85
83
  puts response.headers
@@ -89,8 +87,8 @@ puts response.headers
89
87
  # PATCH /mail_settings/footer #
90
88
 
91
89
  data = JSON.parse('{
92
- "enabled": true,
93
- "html_content": "...",
90
+ "enabled": true,
91
+ "html_content": "...",
94
92
  "plain_content": "..."
95
93
  }')
96
94
  response = sg.client.mail_settings.footer.patch(request_body: data)
@@ -102,7 +100,7 @@ puts response.headers
102
100
  # Retrieve footer mail settings #
103
101
  # GET /mail_settings/footer #
104
102
 
105
- response = sg.client.mail_settings.footer.get()
103
+ response = sg.client.mail_settings.footer.get
106
104
  puts response.status_code
107
105
  puts response.body
108
106
  puts response.headers
@@ -112,7 +110,7 @@ puts response.headers
112
110
  # PATCH /mail_settings/forward_bounce #
113
111
 
114
112
  data = JSON.parse('{
115
- "email": "example@example.com",
113
+ "email": "example@example.com",
116
114
  "enabled": true
117
115
  }')
118
116
  response = sg.client.mail_settings.forward_bounce.patch(request_body: data)
@@ -124,7 +122,7 @@ puts response.headers
124
122
  # Retrieve forward bounce mail settings #
125
123
  # GET /mail_settings/forward_bounce #
126
124
 
127
- response = sg.client.mail_settings.forward_bounce.get()
125
+ response = sg.client.mail_settings.forward_bounce.get
128
126
  puts response.status_code
129
127
  puts response.body
130
128
  puts response.headers
@@ -134,7 +132,7 @@ puts response.headers
134
132
  # PATCH /mail_settings/forward_spam #
135
133
 
136
134
  data = JSON.parse('{
137
- "email": "",
135
+ "email": "",
138
136
  "enabled": false
139
137
  }')
140
138
  response = sg.client.mail_settings.forward_spam.patch(request_body: data)
@@ -146,7 +144,7 @@ puts response.headers
146
144
  # Retrieve forward spam mail settings #
147
145
  # GET /mail_settings/forward_spam #
148
146
 
149
- response = sg.client.mail_settings.forward_spam.get()
147
+ response = sg.client.mail_settings.forward_spam.get
150
148
  puts response.status_code
151
149
  puts response.body
152
150
  puts response.headers
@@ -167,7 +165,7 @@ puts response.headers
167
165
  # Retrieve plain content mail settings #
168
166
  # GET /mail_settings/plain_content #
169
167
 
170
- response = sg.client.mail_settings.plain_content.get()
168
+ response = sg.client.mail_settings.plain_content.get
171
169
  puts response.status_code
172
170
  puts response.body
173
171
  puts response.headers
@@ -177,8 +175,8 @@ puts response.headers
177
175
  # PATCH /mail_settings/spam_check #
178
176
 
179
177
  data = JSON.parse('{
180
- "enabled": true,
181
- "max_score": 5,
178
+ "enabled": true,
179
+ "max_score": 5,
182
180
  "url": "url"
183
181
  }')
184
182
  response = sg.client.mail_settings.spam_check.patch(request_body: data)
@@ -190,7 +188,7 @@ puts response.headers
190
188
  # Retrieve spam check mail settings #
191
189
  # GET /mail_settings/spam_check #
192
190
 
193
- response = sg.client.mail_settings.spam_check.get()
191
+ response = sg.client.mail_settings.spam_check.get
194
192
  puts response.status_code
195
193
  puts response.body
196
194
  puts response.headers
@@ -200,7 +198,7 @@ puts response.headers
200
198
  # PATCH /mail_settings/template #
201
199
 
202
200
  data = JSON.parse('{
203
- "enabled": true,
201
+ "enabled": true,
204
202
  "html_content": "<% body %>"
205
203
  }')
206
204
  response = sg.client.mail_settings.template.patch(request_body: data)
@@ -212,8 +210,7 @@ puts response.headers
212
210
  # Retrieve legacy template mail settings #
213
211
  # GET /mail_settings/template #
214
212
 
215
- response = sg.client.mail_settings.template.get()
213
+ response = sg.client.mail_settings.template.get
216
214
  puts response.status_code
217
215
  puts response.body
218
216
  puts response.headers
219
-
@@ -1,9 +1,7 @@
1
1
  require 'sendgrid-ruby'
2
2
 
3
-
4
3
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
4
 
6
-
7
5
  ##################################################
8
6
  # Returns a list of all partner settings. #
9
7
  # GET /partner_settings #
@@ -19,8 +17,8 @@ puts response.headers
19
17
  # PATCH /partner_settings/new_relic #
20
18
 
21
19
  data = JSON.parse('{
22
- "enable_subuser_statistics": true,
23
- "enabled": true,
20
+ "enable_subuser_statistics": true,
21
+ "enabled": true,
24
22
  "license_key": ""
25
23
  }')
26
24
  response = sg.client.partner_settings.new_relic.patch(request_body: data)
@@ -32,8 +30,7 @@ puts response.headers
32
30
  # Returns all New Relic partner settings. #
33
31
  # GET /partner_settings/new_relic #
34
32
 
35
- response = sg.client.partner_settings.new_relic.get()
33
+ response = sg.client.partner_settings.new_relic.get
36
34
  puts response.status_code
37
35
  puts response.body
38
36
  puts response.headers
39
-
@@ -1,12 +1,11 @@
1
- require_relative '../../lib/sendgrid-ruby.rb'
2
-
1
+ require_relative '../../lib/sendgrid-ruby'
3
2
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
4
3
 
5
4
  ##################################################
6
5
  # Retrieve a list of scopes for which this user has access. #
7
6
  # GET /scopes #
8
7
 
9
- response = sg.client.scopes.get()
8
+ response = sg.client.scopes.get
10
9
  puts response.status_code
11
10
  puts response.body
12
11
  puts response.headers
@@ -15,14 +14,13 @@ puts response.headers
15
14
  # Update the name & scopes of an API Key #
16
15
  # PUT /api_keys/{api_key_id} #
17
16
 
18
-
19
17
  scopes = [
20
- "user.profile.read",
18
+ "user.profile.read",
21
19
  "user.profile.update"
22
20
  ]
23
21
 
24
22
  data = {
25
- "name": "A New Hope",
23
+ "name": "A New Hope",
26
24
  "scopes": scopes
27
25
  }
28
26
  api_key_id = "test_url_param"
@@ -44,8 +42,8 @@ scopes = SendGrid::Scope.read_only_permissions
44
42
  # {endpoint}_read_only_permissions and {endpoint}_full_access_permissions
45
43
 
46
44
  # These are the endpoints :
47
- # alerts, api_keys, asm_groups, billing, categories, credentials, stats, ips, mail_settings, mail,
48
- # marketing_campaigns, partner_settings, scheduled_sends, subusers, suppression, teammates,
45
+ # alerts, api_keys, asm_groups, billing, categories, credentials, stats, ips, mail_settings, mail,
46
+ # marketing_campaigns, partner_settings, scheduled_sends, subusers, suppression, teammates,
49
47
  # templates, tracking_settings, user_settings, webhooks, whitelabel, access_settings
50
48
 
51
49
  # read only permissions for alerts
@@ -54,8 +52,8 @@ scopes = SendGrid::Scope.alerts_read_only_permissions
54
52
  # full access permissions for alerts
55
53
  scopes = SendGrid::Scope.alerts_full_access_permissions
56
54
 
57
- # read only permissions for billing
55
+ # read only permissions for billing
58
56
  scopes = SendGrid::Scope.billing_read_only_permissions
59
57
 
60
58
  # full access permissions for billing
61
- scopes = SendGrid::Scope.billing_full_access_permissions
59
+ scopes = SendGrid::Scope.billing_full_access_permissions