sendgrid-web 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c25529f42cb3b382076bbf57b48be5ae98991bee
4
- data.tar.gz: 91ceedecf727a38be051799fe81932900357d661
3
+ metadata.gz: d55cccb3825dcfc129f5c068cd56dc1c4680c2eb
4
+ data.tar.gz: c18852eb71401b67a4c060de1af8ffe7826fc3f5
5
5
  SHA512:
6
- metadata.gz: 1a26f04093ebc8c51137300f121a3afa0eab6d5edb51dc99f5fc921d855e0c41136a1b6b692911be75e577243a6875cd56530b292d03ba02e9e16a5bf2e149f0
7
- data.tar.gz: 8a56c673cd34b2d4e7cbc535a28097198080af2efb61047f46bec2e332704426df89ccf2661ea60620c5554755f7ce04b19945fb609c655c5238582863497e9b
6
+ metadata.gz: 90fcb041fd4973bcd1033a6875ef900bd77950b47e6d059bda9be7db6addd0093a10ae6a10778fae631ecac998acd214f3983236939f44e15534c54fb8d00ae6
7
+ data.tar.gz: 647714ff3f4a66743eea7550a4d4e19794479e5d0e390f22302e09e234eab4150591500aeffed9e1ba27ccef5bc61cf470685be390d68a437b27befae2353b08
@@ -0,0 +1,77 @@
1
+ class Sendgrid::Web::ParseWebhookSettings < Sendgrid::Web::Client
2
+
3
+ # Retrieve settings already configured for parsing incoming email.
4
+ #
5
+ # @return [Sendgrid::Web::Response] The sendgrid response
6
+ def get
7
+ res = connection.post('/api/parse.get.json', default_params)
8
+ craft_response(res)
9
+ end
10
+
11
+ # Specify the hostname and url for parsing incoming emails.
12
+ #
13
+ # @param hostname [String] The hostname (domain or subdomain) for
14
+ # which you would like to configure a Parse Webhook callback URL.
15
+ # @param url [String] The callback URL to which Parse Webhook
16
+ # payloads will be POSTed.
17
+ # @param spam_check [Integer] If spam check is enabled, messages
18
+ # that look like spam will not be POSTed.
19
+ # @return [Sendgrid::Web::Response] The sendgrid response
20
+ # @note +hostname+ and +url+ are required parameters.
21
+ def set(hostname: nil, url: nil, spam_check: nil)
22
+ if hostname.nil?
23
+ raise ArgumentError.new('Missing required `hostname` option')
24
+ elsif url.nil?
25
+ raise ArgumentError.new('Missing required `url` option')
26
+ end
27
+ res = connection.post(
28
+ '/api/parse.set.json',
29
+ default_params(
30
+ hostname: hostname,
31
+ url: url,
32
+ spam_check: spam_check))
33
+ craft_response(res)
34
+ end
35
+
36
+ # Edit your existing settings for parsing incoming emails.
37
+ #
38
+ # @param hostname [String] The hostname (domain or subdomain) for
39
+ # which you would like to configure a Parse Webhook callback URL.
40
+ # @param url [String] The callback URL to which Parse Webhook
41
+ # payloads will be POSTed.
42
+ # @param spam_check [Integer] If spam check is enabled, messages
43
+ # that look like spam will not be POSTed.
44
+ # @return [Sendgrid::Web::Response] The sendgrid response
45
+ # @note +hostname+ and +url+ are required parameters.
46
+ def edit(hostname: nil, url: nil, spam_check: nil)
47
+ if hostname.nil?
48
+ raise ArgumentError.new('Missing required `hostname` option')
49
+ elsif url.nil?
50
+ raise ArgumentError.new('Missing required `url` option')
51
+ end
52
+ res = connection.post(
53
+ '/api/parse.edit.json',
54
+ default_params(
55
+ hostname: hostname,
56
+ url: url,
57
+ spam_check: spam_check))
58
+ craft_response(res)
59
+ end
60
+
61
+ # Delete the existing settings for parsing incoming emails.
62
+ #
63
+ # @param hostname [String] The hostname (domain or subdomain) for
64
+ # which you would like to configure a Parse Webhook callback URL.
65
+ # @return [Sendgrid::Web::Response] The sendgrid response
66
+ # @note +hostname+ is a required parameter.
67
+ def delete(hostname: nil)
68
+ if hostname.nil?
69
+ raise ArgumentError.new('Missing required `hostname` option')
70
+ end
71
+ res = connection.post(
72
+ '/api/parse.delete.json',
73
+ default_params(hostname: hostname))
74
+ craft_response(res)
75
+ end
76
+
77
+ end
@@ -0,0 +1,110 @@
1
+ class Sendgrid::Web::Profile < Sendgrid::Web::Client
2
+
3
+ # View your SendGrid profile.
4
+ #
5
+ # @return [Sendgrid::Web::Response] the Sendgrid response.
6
+ # @note All parameters are optional
7
+ def get
8
+ res = connection.post('/api/profile.get.json', default_params)
9
+ craft_response(res)
10
+ end
11
+
12
+ # Update your SendGrid profile.
13
+ #
14
+ # @param first_name [String] Your first name.
15
+ # @param last_name [String] Your last name.
16
+ # @param address [String] Your company address.
17
+ # @param city [String] City where your company is located.
18
+ # @param state [String] State where your company is located.
19
+ # @param country [String] Country where your company is located.
20
+ # @param zip [String] Zipcode/Postcode where your company is
21
+ # located.
22
+ # @param phone [String] Valid phone number.
23
+ # @param website [String] Your companies website.
24
+ # @return [Sendgrid::Web::Response] the Sendgrid response.
25
+ # @note All parameters are optional
26
+ def set(
27
+ first_name: nil, last_name: nil, address: nil,
28
+ city: nil, state: nil, country: nil,
29
+ zip: nil, phone: nil, website: nil)
30
+ res = connection.post(
31
+ '/api/profile.set.json',
32
+ default_params(
33
+ first_name: first_name,
34
+ last_name: last_name,
35
+ address: address,
36
+ city: city,
37
+ state: state,
38
+ country: country,
39
+ zip: zip,
40
+ phone: phone,
41
+ website: website))
42
+ craft_response(res)
43
+ end
44
+
45
+ # Update your password.
46
+ #
47
+ # @param password [String] Your new password.
48
+ # @param confirm_password [String] Confirm your new password.
49
+ # @return [Sendgrid::Web::Response] the Sendgrid response.
50
+ # @note +password+ and +confirm_password+ are required.
51
+ # @see #set_username
52
+ # @see #set_email
53
+ def set_password(password: nil, confirm_password: nil)
54
+ if password.nil?
55
+ raise ArgumentError.new('Missing required `password` option')
56
+ elsif confirm_password.nil?
57
+ raise ArgumentError.new(
58
+ 'Missing required `confirm_password` option')
59
+ end
60
+ res = connection.post(
61
+ '/api/password.set.json',
62
+ default_params(
63
+ password: password,
64
+ confirm_password: confirm_password))
65
+ craft_response(res)
66
+ end
67
+
68
+ # Update your username.
69
+ #
70
+ # @param username [String] This is the new username we will be
71
+ # authenticating with our SMTP servers and our website. Changes
72
+ # take effect immediately.
73
+ # @return [Sendgrid::Web::Response] the Sendgrid response.
74
+ # @note Only +username+ is required.
75
+ # @note Your account username is used to login to the SMTP server
76
+ # and the website. Changes will take effect immediately.
77
+ # @see #set_password
78
+ # @see #set_email
79
+ def set_username(username: nil)
80
+ if username.nil?
81
+ raise ArgumentError.new('Missing required `username` option')
82
+ end
83
+ res = connection.post(
84
+ '/api/profile.setUsername.json',
85
+ default_params(username: username))
86
+ craft_response(res)
87
+ end
88
+
89
+ # Update your email address.
90
+ #
91
+ # @param email [String] This is the new email address SendGrid will
92
+ # be contacting you with. Changes take effect immediately.
93
+ # @return [Sendgrid::Web::Response] the Sendgrid response.
94
+ # @note Only +email+ is required.
95
+ # @note SendGrid send out a confirmation email to the new email
96
+ # account in order to be validated. Your email address changes
97
+ # when you click on the confirmation link.
98
+ # @see #set_password
99
+ # @see #set_username
100
+ def set_email(email: nil)
101
+ if email.nil?
102
+ raise ArgumentError.new('Missing required `email` option')
103
+ end
104
+ res = connection.post(
105
+ '/api/profile.setEmail.json',
106
+ default_params(email: email))
107
+ craft_response(res)
108
+ end
109
+
110
+ end
@@ -0,0 +1,49 @@
1
+ class Sendgrid::Web::SpamReports < Sendgrid::Web::Client
2
+
3
+ # Retrieve entries in the Spam Reports list.
4
+ #
5
+ # @param date [Integer] Retrieve the timestamp of the spam reports
6
+ # records.
7
+ # @param days [Integer] Number of days in the past for which to
8
+ # retrieve spam reports (includes today).
9
+ # @param start_date [DateTime] The start of the date range for which
10
+ # to retrieve spam reports.
11
+ # @param end_date [DateTime] The end of the date range for which to
12
+ # retrieve spam reports.
13
+ # @param limit [Integer] Optional field to limit the number of
14
+ # results returned.
15
+ # @param offset [Integer] Optional beginning point in the list to
16
+ # retrieve from.
17
+ # @return [Sendgrid::Web::Response] The SendGrid response.
18
+ # @note All parameters are optional.
19
+ def get(
20
+ date: nil, days: nil, start_date: nil,
21
+ end_date: nil, limit: nil, offset: nil)
22
+ res = connection.post(
23
+ '/api/spamreports.get.json',
24
+ default_params(
25
+ date: date,
26
+ days: days,
27
+ start_date: start_date,
28
+ end_date: end_date,
29
+ limit: limit,
30
+ offset: offset))
31
+ craft_response(res)
32
+ end
33
+
34
+ # Deletes all spam reports associated with the provided email.
35
+ #
36
+ # @param email [String] Email spam reports address to remove.
37
+ # @return [Sendgrid::Web::Response] The SendGrid response.
38
+ # @note +email+ parameter is required.
39
+ def delete(email: nil)
40
+ if email.nil?
41
+ raise ArgumentError.new('Missing required `email` option')
42
+ end
43
+ res = connection.post(
44
+ '/api/spamreports.delete.json',
45
+ default_params(email: email))
46
+ craft_response(res)
47
+ end
48
+
49
+ end
@@ -0,0 +1,70 @@
1
+ class Sendgrid::Web::Unsubscribes < Sendgrid::Web::Client
2
+
3
+ # Retrieve a list of Unsubscribes with addresses and optionally with
4
+ # dates.
5
+ #
6
+ # @param date [Integer] Retrieve the timestamp of the unsubscribe
7
+ # records.
8
+ # @param days [Integer] Number of days in the past for which to
9
+ # retrieve unsubscribe records (includes today).
10
+ # @param start_date [DateTime] The start of the date range for which
11
+ # to retrieve unsubscribe records.
12
+ # @param end_date [DateTime] The end of the date range for which to
13
+ # retrieve unsubscribe records.
14
+ # @param limit [Integer] Optional field to limit the number of
15
+ # results returned.
16
+ # @param offset [Integer] Optional beginning point in the list to
17
+ # retrieve from.
18
+ # @return [Sendgrid::Web::Response] The SendGrid response.
19
+ # @note All parameters are optional.
20
+ def get(
21
+ date: nil, days: nil, start_date: nil,
22
+ end_date: nil, limit: nil, offset: nil)
23
+ res = connection.post(
24
+ '/api/unsubscribes.get.json',
25
+ default_params(
26
+ date: date,
27
+ days: days,
28
+ start_date: start_date,
29
+ end_date: end_date,
30
+ limit: limit,
31
+ offset: offset))
32
+ craft_response(res)
33
+ end
34
+
35
+ # Delete an address from the Unsubscribe list.
36
+ #
37
+ # @param start_date [DateTime] Optional date to start retrieving
38
+ # for.
39
+ # @param end_date [DateTime] Optional date to end retrieving for.
40
+ # @param email [String] Unsubscribed email address to remove.
41
+ # @return [Sendgrid::Web::Response] The SendGrid response.
42
+ # @note If no parameters are provided the ENTIRE list will be
43
+ # removed.
44
+ def delete(
45
+ start_date: nil, end_date: nil, email: nil)
46
+ res = connection.post(
47
+ '/api/unsubscribes.delete.json',
48
+ default_params(
49
+ start_date: start_date,
50
+ end_date: end_date,
51
+ email: email))
52
+ craft_response(res)
53
+ end
54
+
55
+ # Add email addresses to the Unsubscribe list.
56
+ #
57
+ # @param email [String] Email address to add to unsubscribe list.
58
+ # @return [Sendgrid::Web::Response] The SendGrid response.
59
+ # @note +email+ is a required parameter.
60
+ def add(email: nil)
61
+ if email.nil?
62
+ raise ArgumentError.new('Missing required `email` option')
63
+ end
64
+ res = connection.post(
65
+ '/api/unsubscribes.add.json',
66
+ default_params(email: email))
67
+ craft_response(res)
68
+ end
69
+
70
+ end
@@ -1,5 +1,5 @@
1
1
  module Sendgrid
2
2
  module Web
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
data/lib/sendgrid/web.rb CHANGED
@@ -12,6 +12,10 @@ module Sendgrid
12
12
  autoload :InvalidEmails, 'sendgrid/web/invalid_emails'
13
13
  autoload :Mail, 'sendgrid/web/mail'
14
14
  autoload :Credentials, 'sendgrid/web/credentials'
15
+ autoload :ParseWebhookSettings, 'sendgrid/web/parse_webhook_settings'
16
+ autoload :Profile, 'sendgrid/web/profile'
17
+ autoload :SpamReports, 'sendgrid/web/spam_reports'
18
+ autoload :Unsubscribes, 'sendgrid/web/unsubscribes'
15
19
  autoload :Response, 'sendgrid/web/response'
16
20
  end
17
21
  end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sendgrid::Web::ParseWebhookSettings do
4
+ before(:all) do
5
+ Sendgrid::Web::Client.configure do |config|
6
+ config.username = 'foo'
7
+ config.password = 'bar'
8
+ end
9
+ end
10
+
11
+ describe '#get' do
12
+ it_behaves_like('a sendgrid response', '/api/parse.get.json') do
13
+ let(:action) { subject.get }
14
+ let(:response) do
15
+ '{
16
+ "parse": [
17
+ {
18
+ "hostname": "www.example.com",
19
+ "url": "www.mydomain.com/parse.php",
20
+ "spam_check": 1
21
+ }
22
+ ]
23
+ }'
24
+ end
25
+ end
26
+ end
27
+
28
+ describe '#set' do
29
+ it_behaves_like('a sendgrid response', '/api/parse.set.json') do
30
+ let(:action) { subject.set(
31
+ hostname: 'www.example.com',
32
+ url: 'www.mydomain.com/parse.php') }
33
+ let(:response) do
34
+ '{
35
+ "message": "success"
36
+ }'
37
+ end
38
+ end
39
+ end
40
+
41
+ describe '#edit' do
42
+ it_behaves_like('a sendgrid response', '/api/parse.edit.json') do
43
+ let(:action) { subject.edit(
44
+ hostname: 'www.example.com',
45
+ url: 'www.mydomain.com/parse.php') }
46
+ let(:response) do
47
+ '{
48
+ "message": "success"
49
+ }'
50
+ end
51
+ end
52
+ end
53
+
54
+ describe '#delete' do
55
+ it_behaves_like('a sendgrid response', '/api/parse.delete.json') do
56
+ let(:action) { subject.delete(hostname: 'www.example.com') }
57
+ let(:response) do
58
+ '{
59
+ "message": "success"
60
+ }'
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sendgrid::Web::Profile do
4
+ before(:all) do
5
+ Sendgrid::Web::Client.configure do |config|
6
+ config.username = 'foo'
7
+ config.password = 'bar'
8
+ end
9
+ end
10
+
11
+ describe '#get' do
12
+ it_behaves_like('a sendgrid response', '/api/profile.get.json') do
13
+ let(:action) { subject.get }
14
+ let(:response) do
15
+ '[{
16
+ "username": "sampleuser@example.com",
17
+ "email": "sampleemail@example.com",
18
+ "active": "true",
19
+ "first_name": "john",
20
+ "last_name": "doe",
21
+ "address": "555 any street",
22
+ "city": "any city",
23
+ "state": "CA",
24
+ "zip": "91234",
25
+ "country": "US",
26
+ "phone": "555-555-5555",
27
+ "website": "example.com"
28
+ }]'
29
+ end
30
+ end
31
+ end
32
+
33
+ describe '#set' do
34
+ it_behaves_like('a sendgrid response', '/api/profile.set.json') do
35
+ let(:action) { subject.set }
36
+ let(:response) do
37
+ '{
38
+ "message": "success"
39
+ }'
40
+ end
41
+ end
42
+ end
43
+
44
+ describe '#set_password' do
45
+ it_behaves_like('a sendgrid response', '/api/password.set.json') do
46
+ let(:action) { subject.set_password(
47
+ password: 'foobar',
48
+ confirm_password: 'foobar') }
49
+ let(:response) do
50
+ '{
51
+ "message": "success"
52
+ }'
53
+ end
54
+ end
55
+ end
56
+
57
+ describe '#set_username' do
58
+ it_behaves_like('a sendgrid response', '/api/profile.setUsername.json') do
59
+ let(:action) { subject.set_username(username: 'foobar') }
60
+ let(:response) do
61
+ '{
62
+ "message": "success"
63
+ }'
64
+ end
65
+ end
66
+ end
67
+
68
+ describe '#set_email' do
69
+ it_behaves_like('a sendgrid response', '/api/profile.setEmail.json') do
70
+ let(:action) { subject.set_email(
71
+ email: 'foobar@example.com') }
72
+ let(:response) do
73
+ '{
74
+ "message": "success"
75
+ }'
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sendgrid::Web::SpamReports do
4
+ before(:all) do
5
+ Sendgrid::Web::Client.configure do |config|
6
+ config.username = 'foo'
7
+ config.password = 'bar'
8
+ end
9
+ end
10
+
11
+ describe '#get' do
12
+ it_behaves_like('a sendgrid response', '/api/spamreports.get.json') do
13
+ let(:action) { subject.get }
14
+ let(:response) do
15
+ '[
16
+ {
17
+ "ip": "174.36.80.219",
18
+ "email": "example@aol.com",
19
+ "created": "2009-12-06 15:45:08"
20
+ }
21
+ ]'
22
+ end
23
+ end
24
+ end
25
+
26
+ describe '#delete' do
27
+ it_behaves_like('a sendgrid response', '/api/spamreports.delete.json') do
28
+ let(:action) { subject.delete(email: 'foobar@example.com') }
29
+ let(:response) do
30
+ '{
31
+ "message": "success"
32
+ }'
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sendgrid::Web::Unsubscribes do
4
+ before(:all) do
5
+ Sendgrid::Web::Client.configure do |config|
6
+ config.username = 'foo'
7
+ config.password = 'bar'
8
+ end
9
+ end
10
+
11
+ describe '#get' do
12
+ it_behaves_like('a sendgrid response', '/api/unsubscribes.get.json') do
13
+ let(:action) { subject.get }
14
+ let(:response) do
15
+ '[
16
+ {
17
+ "email": "brandon.west@sendgrid.com",
18
+ "created": "2012-09-06 14:03:18"
19
+ }
20
+ ]'
21
+ end
22
+ end
23
+ end
24
+
25
+ describe '#delete' do
26
+ it_behaves_like('a sendgrid response', '/api/unsubscribes.delete.json') do
27
+ let(:action) { subject.delete }
28
+ let(:response) do
29
+ '{
30
+ "message": "success"
31
+ }'
32
+ end
33
+ end
34
+ end
35
+
36
+ describe '#add' do
37
+ it_behaves_like('a sendgrid response', '/api/unsubscribes.add.json') do
38
+ let(:action) { subject.add(email: 'foobar@example.com') }
39
+ let(:response) do
40
+ '{
41
+ "message": "success"
42
+ }'
43
+ end
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendgrid-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Coxall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-13 00:00:00.000000000 Z
11
+ date: 2013-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -105,7 +105,11 @@ files:
105
105
  - lib/sendgrid/web/filter_commands.rb
106
106
  - lib/sendgrid/web/invalid_emails.rb
107
107
  - lib/sendgrid/web/mail.rb
108
+ - lib/sendgrid/web/parse_webhook_settings.rb
109
+ - lib/sendgrid/web/profile.rb
108
110
  - lib/sendgrid/web/response.rb
111
+ - lib/sendgrid/web/spam_reports.rb
112
+ - lib/sendgrid/web/unsubscribes.rb
109
113
  - lib/sendgrid/web/version.rb
110
114
  - sendgrid-web.gemspec
111
115
  - spec/sendgrid/web/blocks_spec.rb
@@ -116,7 +120,11 @@ files:
116
120
  - spec/sendgrid/web/filter_commands_spec.rb
117
121
  - spec/sendgrid/web/invalid_emails_spec.rb
118
122
  - spec/sendgrid/web/mail_spec.rb
123
+ - spec/sendgrid/web/parse_webhook_settings_spec.rb
124
+ - spec/sendgrid/web/profile_spec.rb
119
125
  - spec/sendgrid/web/response_spec.rb
126
+ - spec/sendgrid/web/spam_reports_spec.rb
127
+ - spec/sendgrid/web/unsubscribes_spec.rb
120
128
  - spec/spec_helper.rb
121
129
  - spec/support/shared_sendgrid_response.rb
122
130
  homepage: https://github.com/FreakyDazio/sendgrid-web
@@ -152,6 +160,10 @@ test_files:
152
160
  - spec/sendgrid/web/filter_commands_spec.rb
153
161
  - spec/sendgrid/web/invalid_emails_spec.rb
154
162
  - spec/sendgrid/web/mail_spec.rb
163
+ - spec/sendgrid/web/parse_webhook_settings_spec.rb
164
+ - spec/sendgrid/web/profile_spec.rb
155
165
  - spec/sendgrid/web/response_spec.rb
166
+ - spec/sendgrid/web/spam_reports_spec.rb
167
+ - spec/sendgrid/web/unsubscribes_spec.rb
156
168
  - spec/spec_helper.rb
157
169
  - spec/support/shared_sendgrid_response.rb