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
data/spec/client_spec.rb
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "client" do
|
|
4
|
+
let(:client) { SendGridWebApi::Client.new("user", "pass") }
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
describe "#base", :vcr do
|
|
8
|
+
it "should return api url" do
|
|
9
|
+
client.base_url.should eql "https://sendgrid.com/api/"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should return request url" do
|
|
13
|
+
client.make_request_url("blocks.get.json", {:data => 1}).
|
|
14
|
+
should eql "blocks.get.json?data=1&api_user=user&api_key=pass"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should convert hash to url params" do
|
|
18
|
+
client.to_query({:value_one => "foo_one", :value_two => "foo_two"}).
|
|
19
|
+
should eql "value_one=foo_one&value_two=foo_two"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "#modules", :vcr do
|
|
24
|
+
describe "#block" do
|
|
25
|
+
it "should get block emails" do
|
|
26
|
+
client.blocks.get.should eql []
|
|
27
|
+
end
|
|
28
|
+
it "should try delete not existing block email" do
|
|
29
|
+
client.blocks.delete(:email => "test@example.com").should == {"message"=>"Email does not exist"}
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "#bounce", :vcr do
|
|
34
|
+
it "should get bounce emails" do
|
|
35
|
+
client.bounces.get.should eql []
|
|
36
|
+
end
|
|
37
|
+
it "should try delete not existing bounce email" do
|
|
38
|
+
client.bounces.delete(:email => "test@example.com").should == {"message"=>"Email does not exist"}
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe "#invalid_email", :vcr do
|
|
43
|
+
it "should get invalid emails" do
|
|
44
|
+
client.invalid_emails.get.should eql []
|
|
45
|
+
end
|
|
46
|
+
it "should try delete not existing invalid emails" do
|
|
47
|
+
client.invalid_emails.delete(:email => "test@example.com").should == {"message"=>"Email does not exist"}
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe "#spam" do
|
|
52
|
+
it "should get spam emails", :vcr do
|
|
53
|
+
client.spam.get.should eql []
|
|
54
|
+
end
|
|
55
|
+
it "should try delete not existing spam emails" do
|
|
56
|
+
client.spam.delete(:email => "test@example.com").should == {"message"=>"Email does not exist"}
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe "#unsubscribe", :vcr do
|
|
61
|
+
it "should add unsubscribe emails" do
|
|
62
|
+
client.unsubscribes.add(:email => "test@example.com").
|
|
63
|
+
should == {"message"=>"success"}
|
|
64
|
+
end
|
|
65
|
+
it "should get unsubscribe emails" do
|
|
66
|
+
client.unsubscribes.get.
|
|
67
|
+
should eql [{"email"=>"test@example.com"}]
|
|
68
|
+
end
|
|
69
|
+
it "should delete unsubscribe email" do
|
|
70
|
+
client.unsubscribes.delete(:email => "test@example.com").
|
|
71
|
+
should == {"message"=>"success"}
|
|
72
|
+
end
|
|
73
|
+
it "should try delete not existing unsubscribe emails" do
|
|
74
|
+
client.unsubscribes.delete(:email => "test@example.com").
|
|
75
|
+
should == {"message"=>"Email does not exist"}
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe "#parse_email", :vcr do
|
|
80
|
+
it "should set parse email" do
|
|
81
|
+
client.parse_email.set(:hostname => "www.example.com", :url => "www.mydomain.com/parse.php", :spam_check => "1").
|
|
82
|
+
should == {"message"=>"success"}
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should get parse email", :vcr do
|
|
86
|
+
client.parse_email.get.
|
|
87
|
+
should == {"parse"=>[{"hostname"=>"www.example.com", "url"=>"www.mydomain.com/parse.php", "spam_check"=>1}]}
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "should delete parse email", :vcr do
|
|
91
|
+
client.parse_email.delete(:hostname => "www.example.com").
|
|
92
|
+
should == {"message"=>"success"}
|
|
93
|
+
client.parse_email.get.
|
|
94
|
+
should == {"parse" => []}
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe "#event_notification", :vcr do
|
|
99
|
+
it "should set event notification url" do
|
|
100
|
+
client.event_notification.set(:url => "http://www.yourposturlhere.com").
|
|
101
|
+
should == {"message"=>"success"}
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "should get event notification url" do
|
|
105
|
+
client.event_notification.get.
|
|
106
|
+
should == [{"url" => "http:\/\/www.yourposturlhere.com"}]
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "should delete event notification url" do
|
|
110
|
+
client.event_notification.delete.
|
|
111
|
+
should == {"message"=>"success"}
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
describe "#profile", :vcr do
|
|
116
|
+
it "should get profile" do
|
|
117
|
+
client.profile.get.
|
|
118
|
+
should == [{"username"=>"app4238669@heroku.com", "email"=>"app4238669@heroku.com", "active"=>"true", "first_name"=>"Reseller", "last_name"=>"Customer", "address"=>"555 Any Street", "address2"=>"", "city"=>"City", "state"=>"State", "zip"=>"90000", "country"=>"US", "phone"=>"555-555-5555", "website"=>"http://Website", "website_access"=>"true"}]
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "should set first name" do
|
|
122
|
+
client.profile.set(:first_name => "test").
|
|
123
|
+
should == {"message" => "success"}
|
|
124
|
+
client.profile.get.first["first_name"].
|
|
125
|
+
should == "test"
|
|
126
|
+
client.profile.set(:first_name => "Reseller").
|
|
127
|
+
should == {"message" => "success"}
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
data/spec/helper_spec.rb
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "helper" do
|
|
4
|
+
include SendGridWebApi::Helper
|
|
5
|
+
|
|
6
|
+
let(:client) { SendGridWebApi::Client.new("user", "pass") }
|
|
7
|
+
|
|
8
|
+
describe "#run_sendgrid_query" do
|
|
9
|
+
it "should run sendgrid request", :vcr do
|
|
10
|
+
run_sendgrid_query("user", "pass") do
|
|
11
|
+
@client.sub_user.apps.activate(:user => "test-1", :name => "clicktrack")
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should raise with unsucessfull request", :vcr do
|
|
16
|
+
lambda do
|
|
17
|
+
run_sendgrid_query("user", "pass") do
|
|
18
|
+
@client.sub_user.apps.activate(:user => "test-1", :name => "badappname")
|
|
19
|
+
end
|
|
20
|
+
end.should raise_error
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "#create_sub_user_account", :vcr do
|
|
25
|
+
before(:each) do
|
|
26
|
+
user_hash = {:website => "someurl.com", :password => "somepass", :confirm_password => "somepass",
|
|
27
|
+
:first_name => "home", :last_name => "simpson", :address => "555 anystreet", :city => "any city",
|
|
28
|
+
:state => "CA" , :zip => "91234", :email => "email@email.com", :country => "US", :phone => "555-555"}
|
|
29
|
+
|
|
30
|
+
apps = { :opentrack => {:name => "eventnotify", :processed => "0", :dropped => "1", :deferred => "1",
|
|
31
|
+
:delivered => "0", :bounce => "1", :click => "1", :open => "1", :unsubscribe => "1", :spamreport => "1",
|
|
32
|
+
:url => "https://agencieshq.com/sendgrid/v1/listener"},
|
|
33
|
+
:clicktrack => {:enable_text => "1"},
|
|
34
|
+
:opentrack => {}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@users = {"test-4" => {:account => user_hash, :applications => apps, :assigned_ips => ["74.63.231.33"]}}
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should create sub_user_account" do
|
|
42
|
+
create_sub_user_account("user", "pass", @users)
|
|
43
|
+
client.sub_user.auth.login(:user => "test-3", :password => "somepass").
|
|
44
|
+
should == {"message" => "success"}
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'sendgrid_webapi'
|
|
2
|
+
require 'webmock'
|
|
3
|
+
require 'vcr'
|
|
4
|
+
|
|
5
|
+
VCR.configure do |c|
|
|
6
|
+
c.cassette_library_dir = 'spec/cassettes'
|
|
7
|
+
c.hook_into :webmock
|
|
8
|
+
c.configure_rspec_metadata!
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
RSpec.configure do |c|
|
|
12
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
|
13
|
+
end
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "sub_user" do
|
|
4
|
+
let(:client) { SendGridWebApi::Client.new("user", "pass") }
|
|
5
|
+
|
|
6
|
+
describe "#management", :vcr do
|
|
7
|
+
it "should add new subuser" do
|
|
8
|
+
client.sub_user.management.add(:username => "chebyte3", :website => "example.com", :password => "somepass", :confirm_password => "somepass",
|
|
9
|
+
:first_name => "homero", :last_name => "simpson", :address => "555 anystreet", :city => "any city",
|
|
10
|
+
:state => "CA", :zip => "91234", :email => "chebyte3@example.com", :country => "US", :phone => "555-555").
|
|
11
|
+
should == {"message"=>"success"}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should get all subusers" do
|
|
15
|
+
client.sub_user.management.get.
|
|
16
|
+
should == [{"username"=>"chebyte", "email"=>"chebyte@example.com", "active"=>"true", "first_name"=>"change_named", "last_name"=>"simpson", "address"=>"555 anystreet", "address2"=>"", "city"=>"any city", "state"=>"CA", "zip"=>"91234", "country"=>"US", "phone"=>"555-555", "website"=>"http://example.com", "website_access"=>"true"}, {"username"=>"chebyte2", "email"=>"chebyte@example.com", "active"=>"true", "first_name"=>"test", "last_name"=>"test", "address"=>"test address", "address2"=>"", "city"=>"kansas", "state"=>"CA", "zip"=>"91234", "country"=>"US", "phone"=>"111 1111111", "website"=>"http://notengo.com", "website_access"=>"true"}, {"username"=>"boris", "email"=>"boris@example.com", "active"=>"true", "first_name"=>"homero", "last_name"=>"simpson", "address"=>"555 anystreet", "address2"=>"", "city"=>"any city", "state"=>"CA", "zip"=>"91234", "country"=>"US", "phone"=>"555-555", "website"=>"http://example.com", "website_access"=>"true"}, {"username"=>"chebyte3", "email"=>"chebyte3@example.com", "active"=>"true", "first_name"=>"homero", "last_name"=>"simpson", "address"=>"555 anystreet", "address2"=>"", "city"=>"any city", "state"=>"CA", "zip"=>"91234", "country"=>"US", "phone"=>"555-555", "website"=>"http://example.com", "website_access"=>"true"}]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should disable sub_user for send email" do
|
|
20
|
+
client.sub_user.management.disable(:user => "chebyte3").
|
|
21
|
+
should == {"message" => "success"}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should enable sub_user for send email" do
|
|
25
|
+
client.sub_user.management.enable(:user => "chebyte3").
|
|
26
|
+
should == {"message" => "success"}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should enable sub_user for access to website" do
|
|
30
|
+
client.sub_user.management.website_enable(:user => "chebyte3").
|
|
31
|
+
should == {"message" => "success"}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should update sub_user" do
|
|
35
|
+
client.sub_user.management.update(:user => "chebyte3", :first_name => "change_named").
|
|
36
|
+
should == {"message" => "success"}
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "#bounces", :vcr do
|
|
41
|
+
it "should returns bounce emails" do
|
|
42
|
+
client.sub_user.bounces.get(:user => "chebyte3").
|
|
43
|
+
should == []
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should tries to delete unexisting bounce emails" do
|
|
47
|
+
client.sub_user.bounces.delete(:user => "chebyte3", :email => "test@test.com").
|
|
48
|
+
should == {"message"=>"Email does not exist"}
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe "#unsubscribes", :vcr do
|
|
53
|
+
it "should add bounce email" do
|
|
54
|
+
client.sub_user.unsubscribes.add(:user => "chebyte3", :email => "test@test.com").
|
|
55
|
+
should == {"message"=>"success"}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should returns bounce emails" do
|
|
59
|
+
client.sub_user.unsubscribes.get(:user => "chebyte3").
|
|
60
|
+
should == [{"email"=>"test@test.com"}]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should delete existing bounce email" do
|
|
64
|
+
client.sub_user.unsubscribes.delete(:user => "chebyte3", :email => "test@test.com").
|
|
65
|
+
should == {"message"=>"success"}
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should delete unexisting bounce email" do
|
|
69
|
+
client.sub_user.unsubscribes.delete(:user => "chebyte3", :email => "test@test.com").
|
|
70
|
+
should == {"message"=>"Email does not exist"}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe "#spam", :vcr do
|
|
76
|
+
it "should return spam mails" do
|
|
77
|
+
client.sub_user.spam.get(:user => "chebyte3").
|
|
78
|
+
should == []
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should tries to delete unexisting spam mail" do
|
|
82
|
+
client.sub_user.spam.delete(:user => "chebyte3", :email => "test@test.com").
|
|
83
|
+
should == {"message"=>"Email does not exist"}
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe "#invalid_emails", :vcr do
|
|
88
|
+
it "should return invalid emails" do
|
|
89
|
+
client.sub_user.invalid_emails.get(:user => "chebyte3").
|
|
90
|
+
should == []
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "should tries to delete unexisting invalid mail" do
|
|
94
|
+
client.sub_user.invalid_emails.delete(:user => "chebyte3", :email => "test@testr.com").
|
|
95
|
+
should == {"message"=>"Email does not exist"}
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
describe "#event_notification", :vcr do
|
|
100
|
+
it "should add event notification url" do
|
|
101
|
+
client.sub_user.event_notification.set(:user => "chebyte3", :url => "www.example.com/notification").
|
|
102
|
+
should == {"message"=>"success"}
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "should get event notification url" do
|
|
106
|
+
client.sub_user.event_notification.get(:user => "chebyte3").
|
|
107
|
+
should == [{"url"=>"www.example.com/notification"}]
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "should delete event notification url" do
|
|
111
|
+
client.sub_user.event_notification.delete(:user => "chebyte3", :url => "www.example.com/noti.php").
|
|
112
|
+
should == {"message"=>"success"}
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe "#limits", :vcr do
|
|
117
|
+
it "should set total credits" do
|
|
118
|
+
client.sub_user.limits.set_credits(:user => "chebyte3", :credits=> "200", :period=> "daily").
|
|
119
|
+
should == {"message"=>"success"}
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "should returns limits for a sub user" do
|
|
123
|
+
client.sub_user.limits.get(:user => "chebyte3").
|
|
124
|
+
should == [{"credit"=>"0", "credit_remain"=>"200", "last_reset"=>"2012-07-02"}]
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "should reset all limits for a sub user" do
|
|
128
|
+
client.sub_user.limits.reset(:user => "chebyte3", :credits=> "400", :period=> "daily").
|
|
129
|
+
should == {"message"=>"success"}
|
|
130
|
+
client.sub_user.limits.get(:user => "chebyte3").
|
|
131
|
+
should == [{"credit"=>"400", "credit_remain"=>"400", "last_reset"=>"2012-07-02"}]
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "should list the limits for a sub user" do
|
|
135
|
+
client.sub_user.limits.get(:user => "chebyte3").
|
|
136
|
+
should == [{"credit"=>"400", "credit_remain"=>"400", "last_reset"=>"2012-07-02"}]
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it "should increments credits for a sub user" do
|
|
140
|
+
client.sub_user.limits.increment_credits(:user => "chebyte3", :credits=> "400").
|
|
141
|
+
should == {"message"=>"success"}
|
|
142
|
+
client.sub_user.limits.get(:user => "chebyte3").
|
|
143
|
+
should == [{"credit"=>"0", "credit_remain"=>"800", "last_reset"=>"2012-07-02"}]
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it "should decrements credits for a sub user" do
|
|
147
|
+
client.sub_user.limits.decrement_credits(:user => "chebyte3", :credits=> "400").
|
|
148
|
+
should == {"message"=>"success"}
|
|
149
|
+
client.sub_user.limits.get(:user => "chebyte3").
|
|
150
|
+
should == [{"credit"=>"0", "credit_remain"=>"400", "last_reset"=>"2012-07-02"}]
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it "should delete all limits for a sub user" do
|
|
154
|
+
client.sub_user.limits.delete(:user => "chebyte3").
|
|
155
|
+
should == {"message"=>"success"}
|
|
156
|
+
client.sub_user.limits.get(:user => "chebyte3").
|
|
157
|
+
should == []
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
describe "#ip_management", :vcr do
|
|
162
|
+
it "should return all ips available" do
|
|
163
|
+
client.sub_user.ip_management.get(:user => "chebyte3").
|
|
164
|
+
should == [{"ip"=>"74.63.231.33"}]
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it "should show ip subuser" do
|
|
168
|
+
client.sub_user.ip_management.usage_ip(:user => "chebyte3").
|
|
169
|
+
should == {"success"=>"success", "outboundcluster"=>"SendGrid MTA", "ips"=>[]}
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
describe "#monitor_records", :vcr do
|
|
174
|
+
it "should create a new monitor record" do
|
|
175
|
+
client.sub_user.monitor_records.create(:name => "testmonitor", :frequency => 10000, :email => "test@test.com").
|
|
176
|
+
should == {"message"=>"success"}
|
|
177
|
+
client.sub_user.monitor_records.get.
|
|
178
|
+
should == [{"name"=>"testmonitor", "email"=>"test@test.com", "frequency"=>"10000", "users"=>[]}]
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it "should edit a monitor record" do
|
|
182
|
+
client.sub_user.monitor_records.edit(:name => "testmonitor", :new_frequency => 10).
|
|
183
|
+
should == {"message"=>"success"}
|
|
184
|
+
client.sub_user.monitor_records.get.
|
|
185
|
+
should == [{"name"=>"testmonitor", "email"=>"test@test.com", "frequency"=>"10", "users"=>[]}]
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it "should add existing sub_user to monitor record" do
|
|
189
|
+
client.sub_user.monitor_records.add_user(:user => "chebyte3", :name => "testmonitor").
|
|
190
|
+
should == {"message"=>"success"}
|
|
191
|
+
client.sub_user.monitor_records.get.
|
|
192
|
+
should == [{"name"=>"testmonitor", "email"=>"test@test.com", "frequency"=>"10", "users"=>["chebyte3"]}]
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it "should remove existing sub_user from monitor record" do
|
|
196
|
+
client.sub_user.monitor_records.remove_user(:user => "chebyte3", :name => "testmonitor").
|
|
197
|
+
should == {"message"=>"success"}
|
|
198
|
+
client.sub_user.monitor_records.get.
|
|
199
|
+
should == [{"name"=>"testmonitor", "email"=>"test@test.com", "frequency"=>"10", "users"=>[]}]
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it "should delete a monitor record" do
|
|
203
|
+
client.sub_user.monitor_records.delete(:name => "testmonitor").
|
|
204
|
+
should == {"message"=>"success"}
|
|
205
|
+
client.sub_user.monitor_records.get.
|
|
206
|
+
should == []
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
describe "#authentication", :vcr do
|
|
211
|
+
it "should auth a sub_user" do
|
|
212
|
+
client.sub_user.auth.login(:user => "chebyte3", :password => "somepass").
|
|
213
|
+
should == {"message"=>"success"}
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
it "should return error with a bad sub_user" do
|
|
217
|
+
client.sub_user.auth.login(:user => "chebyte3", :password => "badpass").
|
|
218
|
+
should == {"message"=>"error", "errors"=>["Invalid username and/or password"]}
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
describe "#parse_email", :vcr do
|
|
223
|
+
it "should set parse email" do
|
|
224
|
+
client.sub_user.parse_email.set(:user => "chebyte3", :hostname => "www.example.com", :url => "www.mydomain.com/parse.php", :spam_check => "1").
|
|
225
|
+
should == {"message"=>"success"}
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it "should get parse email" do
|
|
229
|
+
client.sub_user.parse_email.get(:user => "chebyte3").
|
|
230
|
+
should == {"parse"=>[{"hostname"=>"www.example.com", "url"=>"www.mydomain.com/parse.php", "spam_check"=>1}]}
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
it "should delete parse email" do
|
|
234
|
+
client.sub_user.parse_email.delete(:user => "chebyte3", :hostname => "www.example.com").
|
|
235
|
+
should == {"message"=>"success"}
|
|
236
|
+
client.sub_user.parse_email.get(:user => "chebyte3").
|
|
237
|
+
should == {"parse" => []}
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
describe "#apps", :vcr do
|
|
242
|
+
it "should return available apps" do
|
|
243
|
+
client.sub_user.apps.list(:user => "chebyte3").
|
|
244
|
+
should == [{"name"=>"gravatar", "title"=>"Gravatar", "description"=>"Appends your gravatar to each HTML email.", "activated"=>false}, {"name"=>"clicktrack", "title"=>"Click Tracking", "description"=>"Overwrites every link to track every click in emails.", "activated"=>false}, {"name"=>"subscriptiontrack", "title"=>"Subscription Tracking", "description"=>"Adds unsubscribe links to the bottom of the text and HTML emails. Future emails won't be delivered to unsubscribed users.", "activated"=>false}, {"name"=>"opentrack", "title"=>"Open Tracking", "description"=>"Appends an invisible image to HTML emails to track emails that have been opened.", "activated"=>false}, {"name"=>"footer", "title"=>"Footer", "description"=>"Allows you to add a custom footer to outgoing email.", "activated"=>false}, {"name"=>"spamcheck", "title"=>"Spam Checker", "description"=>"Check outbound messages for spam content.", "activated"=>false}, {"name"=>"ganalytics", "title"=>"Google Analytics", "description"=>"Track your conversion rates and ROI with Google Analytics.", "activated"=>false}, {"name"=>"template", "title"=>"Email Template", "description"=>"Allows you to customize your outgoing HTML emails.", "activated"=>false}, {"name"=>"domainkeys", "title"=>"Domain Keys", "description"=>"Allows email to be signed with DomainKeys.", "activated"=>false}, {"name"=>"bcc", "title"=>"BCC", "description"=>"Automatically BCC an address for every e-mail sent.", "activated"=>false}, {"name"=>"eventnotify", "title"=>"Event Notification", "description"=>"Controls notifications for events, such as bounces, clicks, and opens.", "activated"=>false}, {"name"=>"seedlist", "title"=>"Return Path Seedlist", "description"=>"For Return Path customers, with your seedlist for delivery monitoring.", "activated"=>false}, {"name"=>"forwardspam", "title"=>"Forward Spam", "description"=>"Allows for a copy of spam reports to be forwarded to an email address.", "activated"=>false}, {"name"=>"addresswhitelist", "title"=>"Address Whitelist", "description"=>"Address / domains that should never have email suppressed.", "activated"=>false}, {"name"=>"dkim", "title"=>"DKIM", "description"=>"Allows email to be signed with DKIM. Cannot be disabled.", "activated"=>true}]
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
it "should activate app" do
|
|
248
|
+
client.sub_user.apps.activate(:user => "chebyte3", :name => "opentrack").
|
|
249
|
+
should == {"message"=>"success"}
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
it "should deactivate app" do
|
|
253
|
+
client.sub_user.apps.deactivate(:user => "chebyte3", :name => "opentrack").
|
|
254
|
+
should == {"message"=>"success"}
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
it "should get current setting from one app" do
|
|
258
|
+
client.sub_user.apps.current_settings(:user => "chebyte3", :name => "eventnotify").
|
|
259
|
+
should == {"settings"=>{"processed"=>"", "dropped"=>"", "deferred"=>"", "delivered"=>"", "bounce"=>"", "click"=>"", "open"=>"", "unsubscribe"=>"", "spamreport"=>"", "url"=>""}}
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
it "should set current app" do
|
|
263
|
+
client.sub_user.apps.customize(:user => "chebyte3", :name => "eventnotify", :processed => "1", :dropped => "1", :deferred => "1",
|
|
264
|
+
:delivered => "1", :delivered => "1", :bounce => "1", :click => "1", :open => "1", :unsubscribe => "1", :spamreport => "1", :url => "http://yourdomain.com/event.php").
|
|
265
|
+
should == {"message"=>"success"}
|
|
266
|
+
client.sub_user.apps.current_settings(:user => "chebyte3", :name => "eventnotify").
|
|
267
|
+
should == {"settings"=>{"processed"=>"1", "dropped"=>"1", "deferred"=>"1", "delivered"=>"1", "bounce"=>"1", "click"=>"1", "open"=>"1", "unsubscribe"=>"1", "spamreport"=>"1", "url"=>"http://yourdomain.com/event.php"}}
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
end
|