sendgrid_webapi 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.rdoc +389 -0
- data/Rakefile +5 -0
- data/lib/base.rb +41 -0
- data/lib/helper.rb +36 -0
- data/lib/middlewares/sendgrid_response.rb +42 -0
- data/lib/sendgrid_webapi.rb +5 -0
- data/lib/sub_user/apps.rb +31 -0
- data/lib/sub_user/auth.rb +10 -0
- data/lib/sub_user/bounces.rb +15 -0
- data/lib/sub_user/event_notification.rb +20 -0
- data/lib/sub_user/iframe.rb +8 -0
- data/lib/sub_user/invalid_emails.rb +15 -0
- data/lib/sub_user/ip_management.rb +23 -0
- data/lib/sub_user/limits.rb +35 -0
- data/lib/sub_user/management.rb +57 -0
- data/lib/sub_user/modules.rb +68 -0
- data/lib/sub_user/monitor_records.rb +35 -0
- data/lib/sub_user/parse.rb +20 -0
- data/lib/sub_user/spam.rb +15 -0
- data/lib/sub_user/stats.rb +8 -0
- data/lib/sub_user/unsubscribes.rb +21 -0
- data/lib/sub_user/white_label.rb +16 -0
- data/lib/subuser_client.rb +11 -0
- data/lib/web_api/blocks.rb +13 -0
- data/lib/web_api/bounces.rb +13 -0
- data/lib/web_api/event_notification.rb +18 -0
- data/lib/web_api/invalid_emails.rb +13 -0
- data/lib/web_api/mail.rb +8 -0
- data/lib/web_api/modules.rb +50 -0
- data/lib/web_api/parse.rb +18 -0
- data/lib/web_api/profile.rb +29 -0
- data/lib/web_api/spam.rb +13 -0
- data/lib/web_api/stats.rb +8 -0
- data/lib/web_api/unsubscribes.rb +18 -0
- data/lib/web_api/version.rb +3 -0
- data/lib/webapi_client.rb +12 -0
- data/sendgrid_webapi.gemspec +27 -0
- data/spec/cassettes/client/_modules/_block/should_get_block_emails.yml +48 -0
- data/spec/cassettes/client/_modules/_block/should_try_delete_not_existing_block_email.yml +49 -0
- data/spec/cassettes/client/_modules/_bounce/should_get_bounce_emails.yml +40 -0
- data/spec/cassettes/client/_modules/_bounce/should_try_delete_not_existing_bounce_email.yml +41 -0
- data/spec/cassettes/client/_modules/_event_notification/should_delete_event_notification_url.yml +49 -0
- data/spec/cassettes/client/_modules/_event_notification/should_get_event_notification_url.yml +49 -0
- data/spec/cassettes/client/_modules/_event_notification/should_set_event_notification_url.yml +49 -0
- data/spec/cassettes/client/_modules/_invalid_email/should_get_invalid_emails.yml +40 -0
- data/spec/cassettes/client/_modules/_invalid_email/should_try_delete_not_existing_invalid_emails.yml +41 -0
- data/spec/cassettes/client/_modules/_parse_email/should_delete_parse_email.yml +94 -0
- data/spec/cassettes/client/_modules/_parse_email/should_get_parse_email.yml +50 -0
- data/spec/cassettes/client/_modules/_parse_email/should_set_parse_email.yml +49 -0
- data/spec/cassettes/client/_modules/_profile/should_get_profile.yml +52 -0
- data/spec/cassettes/client/_modules/_profile/should_set_first_name.yml +144 -0
- data/spec/cassettes/client/_modules/_spam/should_get_spam_emails.yml +40 -0
- data/spec/cassettes/client/_modules/_spam/should_try_delete_not_existing_spam_emails.yml +41 -0
- data/spec/cassettes/client/_modules/_unsubscribe/should_add_unsubscribe_emails.yml +40 -0
- data/spec/cassettes/client/_modules/_unsubscribe/should_delete_unsubscribe_email.yml +40 -0
- data/spec/cassettes/client/_modules/_unsubscribe/should_get_unsubscribe_emails.yml +41 -0
- data/spec/cassettes/client/_modules/_unsubscribe/should_try_delete_not_existing_unsubscribe_emails.yml +41 -0
- data/spec/cassettes/helper/_create_sub_user_account/should_create_sub_user_account.yml +318 -0
- data/spec/cassettes/helper/_run_sendgrid_query/should_raise_with_unsucessfull_request.yml +46 -0
- data/spec/cassettes/helper/_run_sendgrid_query/should_run_sendgrid_request.yml +49 -0
- data/spec/cassettes/sub_user/_apps/should_activate_app.yml +49 -0
- data/spec/cassettes/sub_user/_apps/should_deactivate_app.yml +49 -0
- data/spec/cassettes/sub_user/_apps/should_get_current_setting_from_one_app.yml +50 -0
- data/spec/cassettes/sub_user/_apps/should_return_available_apps.yml +64 -0
- data/spec/cassettes/sub_user/_apps/should_set_current_app.yml +90 -0
- data/spec/cassettes/sub_user/_authentication/should_auth_a_sub_user.yml +49 -0
- data/spec/cassettes/sub_user/_authentication/should_return_error_with_a_bad_sub_user.yml +49 -0
- data/spec/cassettes/sub_user/_bounces/should_returns_bounce_emails.yml +48 -0
- data/spec/cassettes/sub_user/_bounces/should_tries_to_delete_unexisting_bounce_emails.yml +49 -0
- data/spec/cassettes/sub_user/_event_notification/should_add_event_notification_url.yml +49 -0
- data/spec/cassettes/sub_user/_event_notification/should_delete_event_notification_url.yml +49 -0
- data/spec/cassettes/sub_user/_event_notification/should_get_event_notification_url.yml +49 -0
- data/spec/cassettes/sub_user/_invalid_emails/should_return_invalid_emails.yml +48 -0
- data/spec/cassettes/sub_user/_invalid_emails/should_tries_to_delete_unexisting_invalid_mail.yml +49 -0
- data/spec/cassettes/sub_user/_ip_management/should_return_all_ips_available.yml +49 -0
- data/spec/cassettes/sub_user/_ip_management/should_show_ip_subuser.yml +49 -0
- data/spec/cassettes/sub_user/_limits/should_decrements_credits_for_a_sub_user.yml +95 -0
- data/spec/cassettes/sub_user/_limits/should_delete_all_limits_for_a_sub_user.yml +94 -0
- data/spec/cassettes/sub_user/_limits/should_increments_credits_for_a_sub_user.yml +95 -0
- data/spec/cassettes/sub_user/_limits/should_list_the_limits_for_a_sub_user.yml +49 -0
- data/spec/cassettes/sub_user/_limits/should_reset_all_limits_for_a_sub_user.yml +95 -0
- data/spec/cassettes/sub_user/_limits/should_returns_limits_for_a_sub_user.yml +49 -0
- data/spec/cassettes/sub_user/_limits/should_set_total_credits.yml +49 -0
- data/spec/cassettes/sub_user/_management/should_add_new_subuser.yml +49 -0
- data/spec/cassettes/sub_user/_management/should_disable_sub_user_for_send_email.yml +49 -0
- data/spec/cassettes/sub_user/_management/should_enable_sub_user_for_access_to_website.yml +49 -0
- data/spec/cassettes/sub_user/_management/should_enable_sub_user_for_send_email.yml +49 -0
- data/spec/cassettes/sub_user/_management/should_get_all_subusers.yml +54 -0
- data/spec/cassettes/sub_user/_management/should_update_sub_user.yml +49 -0
- data/spec/cassettes/sub_user/_monitor_records/should_add_existing_sub_user_to_monitor_record.yml +96 -0
- data/spec/cassettes/sub_user/_monitor_records/should_create_a_new_monitor_record.yml +96 -0
- data/spec/cassettes/sub_user/_monitor_records/should_delete_a_monitor_record.yml +94 -0
- data/spec/cassettes/sub_user/_monitor_records/should_edit_a_monitor_record.yml +96 -0
- data/spec/cassettes/sub_user/_monitor_records/should_remove_existing_sub_user_from_monitor_record.yml +96 -0
- data/spec/cassettes/sub_user/_parse_email/should_delete_parse_email.yml +94 -0
- data/spec/cassettes/sub_user/_parse_email/should_get_parse_email.yml +50 -0
- data/spec/cassettes/sub_user/_parse_email/should_set_parse_email.yml +49 -0
- data/spec/cassettes/sub_user/_spam/should_return_spam_mails.yml +48 -0
- data/spec/cassettes/sub_user/_spam/should_tries_to_delete_unexisting_spam_mail.yml +49 -0
- data/spec/cassettes/sub_user/_unsubscribes/should_add_bounce_email.yml +49 -0
- data/spec/cassettes/sub_user/_unsubscribes/should_delete_existing_bounce_email.yml +49 -0
- data/spec/cassettes/sub_user/_unsubscribes/should_delete_unexisting_bounce_email.yml +49 -0
- data/spec/cassettes/sub_user/_unsubscribes/should_returns_bounce_emails.yml +49 -0
- data/spec/client_spec.rb +132 -0
- data/spec/helper_spec.rb +47 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/sub_user_spec.rb +270 -0
- metadata +290 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module SendGridWebApi::SubUserModules
|
|
2
|
+
class Limit < SendGridWebApi::SubUser
|
|
3
|
+
LIMIT_URL = "apiv2/customer.limit.json"
|
|
4
|
+
|
|
5
|
+
def get options = {}
|
|
6
|
+
options.merge!({:task => "retrieve"}) unless options[:task]
|
|
7
|
+
query_api(LIMIT_URL, options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def delete options = {}
|
|
11
|
+
options.merge!({:task => "none"}) unless options[:task]
|
|
12
|
+
query_api(LIMIT_URL, options)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def reset options = {}
|
|
16
|
+
options.merge!({:task => "recurring"}) unless options[:task]
|
|
17
|
+
query_api(LIMIT_URL, options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def set_credits options = {}
|
|
21
|
+
options.merge!({:task => "total"}) unless options[:task]
|
|
22
|
+
query_api(LIMIT_URL, options)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def increment_credits options = {}
|
|
26
|
+
options.merge!({:task => "increment"}) unless options[:task]
|
|
27
|
+
query_api(LIMIT_URL, options)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def decrement_credits options = {}
|
|
31
|
+
options.merge!({:task => "decrement"}) unless options[:task]
|
|
32
|
+
query_api(LIMIT_URL, options)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module SendGridWebApi::SubUserModules
|
|
2
|
+
class Management < SendGridWebApi::SubUser
|
|
3
|
+
def get options = {}
|
|
4
|
+
options.merge!({:task => "get"}) unless options[:task]
|
|
5
|
+
management_get_url = "apiv2/customer.profile.json"
|
|
6
|
+
query_api(management_get_url, options)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def add options = {}
|
|
10
|
+
management_add_url = "apiv2/customer.add.json"
|
|
11
|
+
query_api(management_add_url, options)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def enable options = {}
|
|
15
|
+
management_enable_url = "apiv2/customer.enable.json"
|
|
16
|
+
query_api(management_enable_url, options)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def disable options = {}
|
|
20
|
+
management_disable_url = "apiv2/customer.disable.json"
|
|
21
|
+
query_api(management_disable_url, options)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def website_enable options = {}
|
|
25
|
+
management_website_enable_url = "apiv2/customer.website_enable.json"
|
|
26
|
+
query_api(management_website_enable_url, options)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def website_disable options = {}
|
|
30
|
+
management_website_disable_url = "apiv2/customer.website_disable.json"
|
|
31
|
+
query_api(management_website_disable_url, options)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def update options = {}
|
|
35
|
+
options.merge!(:task => "set") unless options[:task]
|
|
36
|
+
management_update_url = "apiv2/customer.profile.json"
|
|
37
|
+
query_api(management_update_url, options)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def update_password options = {}
|
|
41
|
+
management_set_password_url = "apiv2/customer.password.json"
|
|
42
|
+
query_api(management_set_password_url, options)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def update_username options = {}
|
|
46
|
+
options.merge!({:task => "setUsername"}) unless options[:task]
|
|
47
|
+
management_update_url = "apiv2/customer.profile.json"
|
|
48
|
+
query_api(management_update_url, options)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def update_email options = {}
|
|
52
|
+
options.merge!({:task => "setEmail"}) unless options[:task]
|
|
53
|
+
management_update_url = "apiv2/customer.profile.json"
|
|
54
|
+
query_api(management_update_url, options)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#loading modules
|
|
2
|
+
%w(management bounces unsubscribes spam invalid_emails event_notification parse
|
|
3
|
+
limits stats ip_management monitor_records white_label iframe auth apps).each do |mod|
|
|
4
|
+
require "sub_user/" + mod
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
module SendGridWebApi::SubUserModules
|
|
8
|
+
def management
|
|
9
|
+
@management_instance ||= Management.new(@api_user, @api_key)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def bounces
|
|
13
|
+
@bounce_instance ||= Bounce.new(@api_user, @api_key)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def unsubscribes
|
|
17
|
+
@unsubscribe_instance ||= Unsubscribe.new(@api_user, @api_key)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def spam
|
|
21
|
+
@spam_instance ||= Spam.new(@api_user, @api_key)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def invalid_emails
|
|
25
|
+
@invalid_email_instance ||= InvalidEmail.new(@api_user, @api_key)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def event_notification
|
|
29
|
+
@event_notification_instance ||= EventNotification.new(@api_user, @api_key)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def parse_email
|
|
33
|
+
@parse_instance ||= ParseEmail.new(@api_user, @api_key)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def limits
|
|
37
|
+
@limit_instance ||= Limit.new(@api_user, @api_key)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def stats
|
|
41
|
+
@stats_instance ||= Stats.new(@api_user, @api_key)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def ip_management
|
|
45
|
+
@ip_management_instance ||= IpManagement.new(@api_user, @api_key)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def monitor_records
|
|
49
|
+
@monitor_record_instance ||= MonitorRecord.new(@api_user, @api_key)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def white_label
|
|
53
|
+
@white_label_instance ||= WhiteLabel.new(@api_user, @api_key)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def iframe
|
|
57
|
+
@iframe_instance ||= Iframe.new(@api_user, @api_key)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def auth
|
|
61
|
+
@auth_instance ||= Auth.new(@api_user, @api_key)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def apps
|
|
65
|
+
@app_instance ||= App.new(@api_user, @api_key)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module SendGridWebApi::SubUserModules
|
|
2
|
+
class MonitorRecord < SendGridWebApi::SubUser
|
|
3
|
+
MONITOR_RECORD_URL = "apiv2/customer.monitor.json"
|
|
4
|
+
|
|
5
|
+
def get options = {}
|
|
6
|
+
options.merge!({:task => "list"}) unless options[:task]
|
|
7
|
+
query_api(MONITOR_RECORD_URL, options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def create options = {}
|
|
11
|
+
options.merge!({:task => "create"}) unless options[:task]
|
|
12
|
+
query_api(MONITOR_RECORD_URL, options)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def edit options = {}
|
|
16
|
+
options.merge!({:task => "edit"}) unless options[:task]
|
|
17
|
+
query_api(MONITOR_RECORD_URL, options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def delete options = {}
|
|
21
|
+
options.merge!({:task => "delete"}) unless options[:task]
|
|
22
|
+
query_api(MONITOR_RECORD_URL, options)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def add_user options = {}
|
|
26
|
+
options.merge!({:task => "append"}) unless options[:task]
|
|
27
|
+
query_api(MONITOR_RECORD_URL, options)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def remove_user options = {}
|
|
31
|
+
options.merge!({:task => "detach"}) unless options[:task]
|
|
32
|
+
query_api(MONITOR_RECORD_URL, options)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module SendGridWebApi::SubUserModules
|
|
2
|
+
class ParseEmail < SendGridWebApi::SubUser
|
|
3
|
+
PARSE_URL = "apiv2/customer.parse.json"
|
|
4
|
+
|
|
5
|
+
def get options = {}
|
|
6
|
+
options.merge!({:task => "get"}) unless options[:task]
|
|
7
|
+
query_api(PARSE_URL, options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def set options = {}
|
|
11
|
+
options.merge!({:task => "set"}) unless options[:task]
|
|
12
|
+
query_api(PARSE_URL, options)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def delete options = {}
|
|
16
|
+
options.merge!({:task => "delete"}) unless options[:task]
|
|
17
|
+
query_api(PARSE_URL, options)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module SendGridWebApi::SubUserModules
|
|
2
|
+
class Spam < SendGridWebApi::SubUser
|
|
3
|
+
SPAM_URL = "api/user.spamreports.json"
|
|
4
|
+
|
|
5
|
+
def get options = {}
|
|
6
|
+
options.merge!({:task => "get"}) unless options[:task]
|
|
7
|
+
query_api(SPAM_URL, options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def delete options = {}
|
|
11
|
+
options.merge!({:task => "delete"}) unless options[:task]
|
|
12
|
+
query_api(SPAM_URL, options)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module SendGridWebApi::SubUserModules
|
|
2
|
+
class Unsubscribe < SendGridWebApi::SubUser
|
|
3
|
+
UNSUBSCRIBE_URL = "api/user.unsubscribes.json"
|
|
4
|
+
|
|
5
|
+
def get options = {}
|
|
6
|
+
options.merge!({:task => "get"}) unless options[:task]
|
|
7
|
+
query_api(UNSUBSCRIBE_URL, options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def add options = {}
|
|
11
|
+
options.merge!({:task => "add"}) unless options[:task]
|
|
12
|
+
query_api(UNSUBSCRIBE_URL, options)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def delete options = {}
|
|
17
|
+
options.merge!({:task => "delete"}) unless options[:task]
|
|
18
|
+
query_api(UNSUBSCRIBE_URL, options)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module SendGridWebApi::SubUserModules
|
|
2
|
+
class WhiteLabel < SendGridWebApi::SubUser
|
|
3
|
+
WHITE_LABEL_URL = "apiv2/customer.whitelabel.json"
|
|
4
|
+
|
|
5
|
+
def get options = {}
|
|
6
|
+
options.merge!({:task => "list"}) unless options[:task]
|
|
7
|
+
query_api(WHITE_LABEL_URL, options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def add options = {}
|
|
11
|
+
options.merge!({:task => "append"}) unless options[:task]
|
|
12
|
+
query_api(WHITE_LABEL_URL, options)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module SendGridWebApi::Modules
|
|
2
|
+
class Block < SendGridWebApi::Client
|
|
3
|
+
def get options = {}
|
|
4
|
+
block_get_url = "blocks.get.json"
|
|
5
|
+
query_api(block_get_url, options)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def delete options = {}
|
|
9
|
+
block_delete_url = "blocks.delete.json"
|
|
10
|
+
query_api(block_delete_url, options)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module SendGridWebApi::Modules
|
|
2
|
+
class Bounce < SendGridWebApi::Client
|
|
3
|
+
def get options = {}
|
|
4
|
+
bounce_get_url = "bounces.get.json"
|
|
5
|
+
query_api(bounce_get_url, options)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def delete options = {}
|
|
9
|
+
bounce_delete_url = "bounces.delete.json"
|
|
10
|
+
query_api(bounce_delete_url, options)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module SendGridWebApi::Modules
|
|
2
|
+
class EventNotification < SendGridWebApi::Client
|
|
3
|
+
def get options = {}
|
|
4
|
+
event_get_url = "eventposturl.get.json"
|
|
5
|
+
query_api(event_get_url, options)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def set options = {}
|
|
9
|
+
event_set_url = "eventposturl.set.json"
|
|
10
|
+
query_api(event_set_url, options)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def delete options = {}
|
|
14
|
+
event_delete_url = "eventposturl.delete.json"
|
|
15
|
+
query_api(event_delete_url, options)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module SendGridWebApi::Modules
|
|
2
|
+
class InvalidEmail < SendGridWebApi::Client
|
|
3
|
+
def get options = {}
|
|
4
|
+
invalid_email_get_url = "invalidemails.get.json"
|
|
5
|
+
query_api(invalid_email_get_url, options)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def delete options = {}
|
|
9
|
+
invalid_email_delete_url = "invalidemails.delete.json"
|
|
10
|
+
query_api(invalid_email_delete_url, options)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/web_api/mail.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#loading modules
|
|
2
|
+
%w(bounces spam blocks invalid_emails unsubscribes parse event_notification stats profile mail).each do |mod|
|
|
3
|
+
require "web_api/" + mod
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
module SendGridWebApi::Modules
|
|
7
|
+
def bounces
|
|
8
|
+
@bounce_instance ||= Bounce.new(@api_user, @api_key)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def blocks
|
|
12
|
+
@block_instance ||= Block.new(@api_user, @api_key)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def spam
|
|
16
|
+
@spam_instance ||= Spam.new(@api_user, @api_key)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def invalid_emails
|
|
20
|
+
@invalid_email_instance ||= InvalidEmail.new(@api_user, @api_key)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def unsubscribes
|
|
24
|
+
@unsubscribe_instance ||= Unsubscribe.new(@api_user, @api_key)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def parse_email
|
|
28
|
+
@parse_email_instance ||= ParseEmail.new(@api_user, @api_key)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def event_notification
|
|
32
|
+
@event_notification_instance ||= EventNotification.new(@api_user, @api_key)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def stats
|
|
36
|
+
@stats_instance ||= Stats.new(@api_user, @api_key)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def profile
|
|
40
|
+
@profile_instance ||= Profile.new(@api_user, @api_key)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def mail
|
|
44
|
+
@mail_instance ||= Mail.new(@api_user, @api_key)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def sub_user
|
|
48
|
+
@sub_user ||= SendGridWebApi::SubUser.new(@api_user, @api_key)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module SendGridWebApi::Modules
|
|
2
|
+
class ParseEmail < SendGridWebApi::Client
|
|
3
|
+
def get options = {}
|
|
4
|
+
parse_email_get_url = "parse.get.json"
|
|
5
|
+
query_api(parse_email_get_url, options)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def set options = {}
|
|
9
|
+
parse_email_set_url = "parse.set.json"
|
|
10
|
+
query_api(parse_email_set_url, options)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def delete options = {}
|
|
14
|
+
parse_email_delete_url = "parse.delete.json"
|
|
15
|
+
query_api(parse_email_delete_url, options)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module SendGridWebApi::Modules
|
|
2
|
+
class Profile < SendGridWebApi::Client
|
|
3
|
+
def get options = {}
|
|
4
|
+
profile_get_url = "profile.get.json"
|
|
5
|
+
query_api(profile_get_url, options)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def set options = {}
|
|
9
|
+
profile_set_url = "profile.set.json"
|
|
10
|
+
query_api(profile_set_url, options)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def set_password options = {}
|
|
14
|
+
profile_set_password_url = "password.set.json"
|
|
15
|
+
query_api(profile_set_password_url, options)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def set_username options = {}
|
|
19
|
+
profile_set_username_url = "profile.setUsername.json"
|
|
20
|
+
query_api(profile_set_username_url, options)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def set_email options = {}
|
|
24
|
+
profile_set_email_url = "profile.setEmail.json"
|
|
25
|
+
query_api(profile_set_email_url, options)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/web_api/spam.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module SendGridWebApi::Modules
|
|
2
|
+
class Spam < SendGridWebApi::Client
|
|
3
|
+
def get options = {}
|
|
4
|
+
spam_get_url = "spamreports.get.json"
|
|
5
|
+
query_api(spam_get_url, options)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def delete options = {}
|
|
9
|
+
spam_delete_url = "spamreports.delete.json"
|
|
10
|
+
query_api(spam_delete_url, options)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module SendGridWebApi::Modules
|
|
2
|
+
class Unsubscribe < SendGridWebApi::Client
|
|
3
|
+
def get options = {}
|
|
4
|
+
unsubscribe_get_url = "unsubscribes.get.json"
|
|
5
|
+
query_api(unsubscribe_get_url, options)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def add options = {}
|
|
9
|
+
unsubscribe_add_url = "unsubscribes.add.json"
|
|
10
|
+
query_api(unsubscribe_add_url, options)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def delete options = {}
|
|
14
|
+
unsubscribe_delete_url = "unsubscribes.delete.json"
|
|
15
|
+
query_api(unsubscribe_delete_url, options)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require 'version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "sendgrid_webapi"
|
|
7
|
+
s.version = SendGridWebApi::VERSION
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.authors = ["kylejginavan", "chebyte"]
|
|
10
|
+
s.email = ["kylejginavan@gmail.com", "maurotorres@gmail.com"]
|
|
11
|
+
s.homepage = "https://github.com/kylejginavan/sendgrid_smtpapi"
|
|
12
|
+
s.summary = %q{SendGrid WEB API gem fo Rails}
|
|
13
|
+
s.description = %q{Gem for access to SendGrid WEB API from rails}
|
|
14
|
+
|
|
15
|
+
s.rubyforge_project = "sendgrid_webapi"
|
|
16
|
+
|
|
17
|
+
s.files = `git ls-files`.split("\n")
|
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
20
|
+
s.require_paths = ["lib"]
|
|
21
|
+
s.add_development_dependency "rspec", "~> 2.10.0"
|
|
22
|
+
s.add_development_dependency "webmock", "~> 1.8.7"
|
|
23
|
+
s.add_development_dependency "vcr", "~> 2.1.1"
|
|
24
|
+
s.add_dependency "faraday", "~> 0.8.0"
|
|
25
|
+
s.add_dependency "json", "~> 1.7.3"
|
|
26
|
+
|
|
27
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://sendgrid.com/api/blocks.get.json?api_key=pass&api_user=user
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ""
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Server:
|
|
22
|
+
- nginx/0.7.65
|
|
23
|
+
Date:
|
|
24
|
+
- Mon, 02 Jul 2012 14:42:51 GMT
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json
|
|
27
|
+
Connection:
|
|
28
|
+
- keep-alive
|
|
29
|
+
X-Powered-By:
|
|
30
|
+
- PHP/5.3.2-1ubuntu4.14
|
|
31
|
+
Cache-Control:
|
|
32
|
+
- private
|
|
33
|
+
Set-Cookie:
|
|
34
|
+
- sendgrid_frontend=f0e7344786a2d782f7bab47e30ecf283:de5a5348f999469fb4a7e2216d67fa03459c9f52; expires=Wed, 01-Aug-2012 14:42:27 GMT; path=/; httponly
|
|
35
|
+
Content-Encoding:
|
|
36
|
+
- gzip
|
|
37
|
+
Vary:
|
|
38
|
+
- Accept-Encoding
|
|
39
|
+
Content-Length:
|
|
40
|
+
- "28"
|
|
41
|
+
body:
|
|
42
|
+
encoding: ASCII-8BIT
|
|
43
|
+
string: !binary |
|
|
44
|
+
H4sIAAAAAAAAA4qOBQAAAP//AwApu0wNAgAAAA==
|
|
45
|
+
|
|
46
|
+
http_version:
|
|
47
|
+
recorded_at: Mon, 02 Jul 2012 14:42:51 GMT
|
|
48
|
+
recorded_with: VCR 2.1.1
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://sendgrid.com/api/blocks.delete.json?api_key=pass&api_user=user&email=test@example.com
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ""
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Server:
|
|
22
|
+
- nginx/0.7.65
|
|
23
|
+
Date:
|
|
24
|
+
- Mon, 02 Jul 2012 14:42:53 GMT
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json
|
|
27
|
+
Connection:
|
|
28
|
+
- keep-alive
|
|
29
|
+
X-Powered-By:
|
|
30
|
+
- PHP/5.3.2-1ubuntu4.14
|
|
31
|
+
Cache-Control:
|
|
32
|
+
- private
|
|
33
|
+
Set-Cookie:
|
|
34
|
+
- sendgrid_frontend=b1552d80418879e57ecce9ff13f7e16c:60b4e990d7fa4abbf759b653ee408ab726e8db97; expires=Wed, 01-Aug-2012 14:42:29 GMT; path=/; httponly
|
|
35
|
+
Content-Encoding:
|
|
36
|
+
- gzip
|
|
37
|
+
Vary:
|
|
38
|
+
- Accept-Encoding
|
|
39
|
+
Content-Length:
|
|
40
|
+
- "60"
|
|
41
|
+
body:
|
|
42
|
+
encoding: ASCII-8BIT
|
|
43
|
+
string: !binary |
|
|
44
|
+
H4sIAAAAAAAAA6pWyk0tLk5MT1WyUnLNTczMUUjJTy1WyMsvUUityCwuUaoF
|
|
45
|
+
AAAA//8DACrxmdciAAAA
|
|
46
|
+
|
|
47
|
+
http_version:
|
|
48
|
+
recorded_at: Mon, 02 Jul 2012 14:42:53 GMT
|
|
49
|
+
recorded_with: VCR 2.1.1
|