sendgrid-ruby 3.0.4 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,19 +4,6 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Retrieve all recent access attempts #
22
9
  # GET /access_settings/activity #
@@ -0,0 +1,62 @@
1
+ require 'sendgrid-ruby'
2
+
3
+
4
+ sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
+
6
+
7
+ ##################################################
8
+ # Create a new Alert #
9
+ # POST /alerts #
10
+
11
+ data = JSON.parse('{
12
+ "email_to": "example@example.com",
13
+ "frequency": "daily",
14
+ "type": "stats_notification"
15
+ }')
16
+ response = sg.client.alerts.post(request_body: data)
17
+ puts response.status_code
18
+ puts response.body
19
+ puts response.headers
20
+
21
+ ##################################################
22
+ # Retrieve all alerts #
23
+ # GET /alerts #
24
+
25
+ response = sg.client.alerts.get()
26
+ puts response.status_code
27
+ puts response.body
28
+ puts response.headers
29
+
30
+ ##################################################
31
+ # Update an alert #
32
+ # PATCH /alerts/{alert_id} #
33
+
34
+ data = JSON.parse('{
35
+ "email_to": "example@example.com"
36
+ }')
37
+ alert_id = "test_url_param"
38
+ response = sg.client.alerts._(alert_id).patch(request_body: data)
39
+ puts response.status_code
40
+ puts response.body
41
+ puts response.headers
42
+
43
+ ##################################################
44
+ # Retrieve a specific alert #
45
+ # GET /alerts/{alert_id} #
46
+
47
+ alert_id = "test_url_param"
48
+ response = sg.client.alerts._(alert_id).get()
49
+ puts response.status_code
50
+ puts response.body
51
+ puts response.headers
52
+
53
+ ##################################################
54
+ # Delete an alert #
55
+ # DELETE /alerts/{alert_id} #
56
+
57
+ alert_id = "test_url_param"
58
+ response = sg.client.alerts._(alert_id).delete()
59
+ puts response.status_code
60
+ puts response.body
61
+ puts response.headers
62
+
@@ -4,25 +4,13 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Create API keys #
22
9
  # POST /api_keys #
23
10
 
24
11
  data = JSON.parse('{
25
12
  "name": "My API Key",
13
+ "sample": "data",
26
14
  "scopes": [
27
15
  "mail.send",
28
16
  "alerts.create",
@@ -38,7 +26,8 @@ puts response.headers
38
26
  # Retrieve all API Keys belonging to the authenticated user #
39
27
  # GET /api_keys #
40
28
 
41
- response = sg.client.api_keys.get()
29
+ params = JSON.parse('{"limit": 1}')
30
+ response = sg.client.api_keys.get(query_params: params)
42
31
  puts response.status_code
43
32
  puts response.body
44
33
  puts response.headers
@@ -4,19 +4,6 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Create a new suppression group #
22
9
  # POST /asm/groups #
@@ -102,6 +89,23 @@ puts response.status_code
102
89
  puts response.body
103
90
  puts response.headers
104
91
 
92
+ ##################################################
93
+ # Search for suppressions within a group #
94
+ # POST /asm/groups/{group_id}/suppressions/search #
95
+
96
+ data = JSON.parse('{
97
+ "recipient_emails": [
98
+ "exists1@example.com",
99
+ "exists2@example.com",
100
+ "doesnotexists@example.com"
101
+ ]
102
+ }')
103
+ group_id = "test_url_param"
104
+ response = sg.client.asm.groups._(group_id).suppressions.search.post(request_body: data)
105
+ puts response.status_code
106
+ puts response.body
107
+ puts response.headers
108
+
105
109
  ##################################################
106
110
  # Delete a suppression from a suppression group #
107
111
  # DELETE /asm/groups/{group_id}/suppressions/{email} #
@@ -4,19 +4,6 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Retrieve email statistics by browser. #
22
9
  # GET /browsers/stats #
@@ -4,19 +4,6 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Create a Campaign #
22
9
  # POST /campaigns #
@@ -50,7 +37,7 @@ puts response.headers
50
37
  # Retrieve all Campaigns #
51
38
  # GET /campaigns #
52
39
 
53
- params = JSON.parse('{"limit": 0, "offset": 0}')
40
+ params = JSON.parse('{"limit": 1, "offset": 1}')
54
41
  response = sg.client.campaigns.get(query_params: params)
55
42
  puts response.status_code
56
43
  puts response.body
@@ -4,19 +4,6 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Retrieve all categories #
22
9
  # GET /categories #
@@ -4,19 +4,6 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Retrieve email statistics by client type. #
22
9
  # GET /clients/stats #
@@ -4,19 +4,6 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Create a Custom Field #
22
9
  # POST /contactdb/custom_fields #
@@ -96,7 +83,7 @@ puts response.headers
96
83
  data = JSON.parse('{
97
84
  "name": "newlistname"
98
85
  }')
99
- params = JSON.parse('{"list_id": 0}')
86
+ params = JSON.parse('{"list_id": 1}')
100
87
  list_id = "test_url_param"
101
88
  response = sg.client.contactdb.lists._(list_id).patch(request_body: data, query_params: params)
102
89
  puts response.status_code
@@ -107,7 +94,7 @@ puts response.headers
107
94
  # Retrieve a single list #
108
95
  # GET /contactdb/lists/{list_id} #
109
96
 
110
- params = JSON.parse('{"list_id": 0}')
97
+ params = JSON.parse('{"list_id": 1}')
111
98
  list_id = "test_url_param"
112
99
  response = sg.client.contactdb.lists._(list_id).get(query_params: params)
113
100
  puts response.status_code
@@ -143,7 +130,7 @@ puts response.headers
143
130
  # Retrieve all recipients on a List #
144
131
  # GET /contactdb/lists/{list_id}/recipients #
145
132
 
146
- params = JSON.parse('{"page": 1, "page_size": 1, "list_id": 0}')
133
+ params = JSON.parse('{"page": 1, "page_size": 1, "list_id": 1}')
147
134
  list_id = "test_url_param"
148
135
  response = sg.client.contactdb.lists._(list_id).recipients.get(query_params: params)
149
136
  puts response.status_code
@@ -165,7 +152,7 @@ puts response.headers
165
152
  # Delete a Single Recipient from a Single List #
166
153
  # DELETE /contactdb/lists/{list_id}/recipients/{recipient_id} #
167
154
 
168
- params = JSON.parse('{"recipient_id": 0, "list_id": 0}')
155
+ params = JSON.parse('{"recipient_id": 1, "list_id": 1}')
169
156
  list_id = "test_url_param"
170
157
  recipient_id = "test_url_param"
171
158
  response = sg.client.contactdb.lists._(list_id).recipients._(recipient_id).delete(query_params: params)
@@ -253,7 +240,7 @@ puts response.headers
253
240
  # Retrieve recipients matching search criteria #
254
241
  # GET /contactdb/recipients/search #
255
242
 
256
- params = JSON.parse('{"{field_name}": "test_string"}')
243
+ params = JSON.parse('{"%7Bfield_name%7D": "test_string", "{field_name}": "test_string"}')
257
244
  response = sg.client.contactdb.recipients.search.get(query_params: params)
258
245
  puts response.status_code
259
246
  puts response.body
@@ -367,7 +354,7 @@ puts response.headers
367
354
  # Retrieve a segment #
368
355
  # GET /contactdb/segments/{segment_id} #
369
356
 
370
- params = JSON.parse('{"segment_id": 0}')
357
+ params = JSON.parse('{"segment_id": 1}')
371
358
  segment_id = "test_url_param"
372
359
  response = sg.client.contactdb.segments._(segment_id).get(query_params: params)
373
360
  puts response.status_code
@@ -4,19 +4,6 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Retrieve email statistics by device type. #
22
9
  # GET /devices/stats #
@@ -4,19 +4,6 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Retrieve email statistics by country and state/province. #
22
9
  # GET /geo/stats #
@@ -4,19 +4,6 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Retrieve all IP addresses #
22
9
  # GET /ips #
@@ -4,19 +4,6 @@ require 'sendgrid-ruby'
4
4
  sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
5
 
6
6
 
7
- import com.fasterxml.jackson.databind.JsonNode;
8
- import com.fasterxml.jackson.databind.ObjectMapper;
9
-
10
- import com.sendgrid.Client;
11
- import com.sendgrid.Method;
12
- import com.sendgrid.Request;
13
- import com.sendgrid.Response;
14
- import com.sendgrid.SendGrid;
15
-
16
- import java.io.IOException;
17
- import java.util.HashMap;
18
- import java.util.Map;
19
-
20
7
  ##################################################
21
8
  # Create a batch ID #
22
9
  # POST /mail/batch #
@@ -43,143 +30,138 @@ puts response.headers
43
30
 
44
31
  data = JSON.parse('{
45
32
  "asm": {
46
- "group_id": 1,
33
+ "group_id": 1,
47
34
  "groups_to_display": [
48
- 1,
49
- 2,
35
+ 1,
36
+ 2,
50
37
  3
51
38
  ]
52
- },
39
+ },
53
40
  "attachments": [
54
41
  {
55
- "content": "[BASE64 encoded content block here]",
56
- "content_id": "ii_139db99fdb5c3704",
57
- "disposition": "inline",
58
- "filename": "file1.jpg",
59
- "name": "file1",
42
+ "content": "[BASE64 encoded content block here]",
43
+ "content_id": "ii_139db99fdb5c3704",
44
+ "disposition": "inline",
45
+ "filename": "file1.jpg",
46
+ "name": "file1",
60
47
  "type": "jpg"
61
48
  }
62
- ],
63
- "batch_id": "[YOUR BATCH ID GOES HERE]",
49
+ ],
50
+ "batch_id": "[YOUR BATCH ID GOES HERE]",
64
51
  "categories": [
65
- "category1",
52
+ "category1",
66
53
  "category2"
67
- ],
54
+ ],
68
55
  "content": [
69
56
  {
70
- "type": "text/html",
57
+ "type": "text/html",
71
58
  "value": "<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>"
72
59
  }
73
- ],
60
+ ],
74
61
  "custom_args": {
75
- "New Argument 1": "New Value 1",
76
- "activationAttempt": "1",
62
+ "New Argument 1": "New Value 1",
63
+ "activationAttempt": "1",
77
64
  "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
78
- },
65
+ },
79
66
  "from": {
80
- "email": "sam.smith@example.com",
67
+ "email": "sam.smith@example.com",
81
68
  "name": "Sam Smith"
82
- },
83
- "headers": {},
84
- "ip_pool_name": "[YOUR POOL NAME GOES HERE]",
69
+ },
70
+ "headers": {},
71
+ "ip_pool_name": "[YOUR POOL NAME GOES HERE]",
85
72
  "mail_settings": {
86
73
  "bcc": {
87
- "email": "ben.doe@example.com",
74
+ "email": "ben.doe@example.com",
88
75
  "enable": true
89
- },
76
+ },
90
77
  "bypass_list_management": {
91
78
  "enable": true
92
- },
79
+ },
93
80
  "footer": {
94
- "enable": true,
95
- "html": "<p>Thanks</br>The SendGrid Team</p>",
81
+ "enable": true,
82
+ "html": "<p>Thanks</br>The SendGrid Team</p>",
96
83
  "text": "Thanks,/n The SendGrid Team"
97
- },
84
+ },
98
85
  "sandbox_mode": {
99
86
  "enable": false
100
- },
87
+ },
101
88
  "spam_check": {
102
- "enable": true,
103
- "post_to_url": "http://example.com/compliance",
89
+ "enable": true,
90
+ "post_to_url": "http://example.com/compliance",
104
91
  "threshold": 3
105
92
  }
106
- },
93
+ },
107
94
  "personalizations": [
108
95
  {
109
96
  "bcc": [
110
97
  {
111
- "email": "sam.doe@example.com",
98
+ "email": "sam.doe@example.com",
112
99
  "name": "Sam Doe"
113
100
  }
114
- ],
101
+ ],
115
102
  "cc": [
116
103
  {
117
- "email": "jane.doe@example.com",
104
+ "email": "jane.doe@example.com",
118
105
  "name": "Jane Doe"
119
106
  }
120
- ],
107
+ ],
121
108
  "custom_args": {
122
- "New Argument 1": "New Value 1",
123
- "activationAttempt": "1",
109
+ "New Argument 1": "New Value 1",
110
+ "activationAttempt": "1",
124
111
  "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
125
- },
112
+ },
126
113
  "headers": {
127
- "X-Accept-Language": "en",
114
+ "X-Accept-Language": "en",
128
115
  "X-Mailer": "MyApp"
129
- },
130
- "send_at": 1409348513,
131
- "subject": "Hello, World!",
116
+ },
117
+ "send_at": 1409348513,
118
+ "subject": "Hello, World!",
132
119
  "substitutions": {
133
- "sub": {
134
- "%name%": [
135
- "John",
136
- "Jane",
137
- "Sam"
138
- ]
139
- }
140
- },
120
+ "id": "substitutions",
121
+ "type": "object"
122
+ },
141
123
  "to": [
142
124
  {
143
- "email": "john.doe@example.com",
125
+ "email": "john.doe@example.com",
144
126
  "name": "John Doe"
145
127
  }
146
128
  ]
147
129
  }
148
- ],
130
+ ],
149
131
  "reply_to": {
150
- "email": "sam.smith@example.com",
132
+ "email": "sam.smith@example.com",
151
133
  "name": "Sam Smith"
152
- },
134
+ },
153
135
  "sections": {
154
136
  "section": {
155
- ":sectionName1": "section 1 text",
137
+ ":sectionName1": "section 1 text",
156
138
  ":sectionName2": "section 2 text"
157
139
  }
158
- },
159
- "send_at": 1409348513,
160
- "subject": "Hello, World!",
161
- "template_id": "[YOUR TEMPLATE ID GOES HERE]",
140
+ },
141
+ "send_at": 1409348513,
142
+ "subject": "Hello, World!",
143
+ "template_id": "[YOUR TEMPLATE ID GOES HERE]",
162
144
  "tracking_settings": {
163
145
  "click_tracking": {
164
- "enable": true,
146
+ "enable": true,
165
147
  "enable_text": true
166
- },
148
+ },
167
149
  "ganalytics": {
168
- "enable": true,
169
- "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
170
- "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
171
- "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
172
- "utm_name": "[NAME OF YOUR CAMPAIGN]",
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]",
173
155
  "utm_term": "[IDENTIFY PAID KEYWORDS HERE]"
174
- },
156
+ },
175
157
  "open_tracking": {
176
- "enable": true,
158
+ "enable": true,
177
159
  "substitution_tag": "%opentrack"
178
- },
160
+ },
179
161
  "subscription_tracking": {
180
- "enable": true,
181
- "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
182
- "substitution_tag": "<%click here%>",
162
+ "enable": true,
163
+ "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
164
+ "substitution_tag": "<%click here%>",
183
165
  "text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>."
184
166
  }
185
167
  }