sendgrid_webapi 0.0.2 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +132 -0
  3. data/.circleci/setup-rubygems.sh +5 -0
  4. data/.gitignore +27 -1
  5. data/.rspec +2 -2
  6. data/.ruby-version +1 -0
  7. data/.tool-versions +1 -0
  8. data/MIT-LICENSE +20 -0
  9. data/README.rdoc +103 -79
  10. data/lib/api_key/management.rb +33 -0
  11. data/lib/api_key/modules.rb +10 -0
  12. data/lib/apikey_client.rb +11 -0
  13. data/lib/base.rb +47 -13
  14. data/lib/helper.rb +8 -8
  15. data/lib/sendgrid_webapi.rb +1 -0
  16. data/lib/sub_user/modules.rb +15 -15
  17. data/lib/version.rb +2 -2
  18. data/lib/web_api/blocks.rb +5 -0
  19. data/lib/web_api/bounces.rb +5 -0
  20. data/lib/web_api/modules.rb +15 -11
  21. data/lib/web_api/version.rb +1 -1
  22. data/lib/webapi_client.rb +1 -1
  23. data/sendgrid_webapi.gemspec +12 -8
  24. data/spec/cassettes/client/_modules/_block/should_get_block_emails.yml +29 -41
  25. data/spec/cassettes/client/_modules/_block/should_get_totals_blocks.yml +36 -0
  26. data/spec/cassettes/client/_modules/_block/should_try_delete_not_existing_block_email.yml +29 -42
  27. data/spec/cassettes/client/_modules/_bounce/should_get_bounce_emails.yml +27 -31
  28. data/spec/cassettes/client/_modules/_bounce/should_get_totals_bounces.yml +36 -0
  29. data/spec/cassettes/client/_modules/_bounce/should_try_delete_not_existing_bounce_email.yml +27 -32
  30. data/spec/cassettes/client/_modules/_event_notification/should_delete_event_notification_url.yml +38 -40
  31. data/spec/cassettes/client/_modules/_event_notification/should_get_event_notification_url.yml +38 -40
  32. data/spec/cassettes/client/_modules/_event_notification/should_set_event_notification_url.yml +38 -40
  33. data/spec/cassettes/client/_modules/_invalid_email/should_get_invalid_emails.yml +27 -31
  34. data/spec/cassettes/client/_modules/_invalid_email/should_try_delete_not_existing_invalid_emails.yml +27 -32
  35. data/spec/cassettes/client/_modules/_parse_email/should_delete_parse_email.yml +73 -76
  36. data/spec/cassettes/client/_modules/_parse_email/should_get_parse_email.yml +38 -41
  37. data/spec/cassettes/client/_modules/_parse_email/should_set_parse_email.yml +38 -40
  38. data/spec/cassettes/client/_modules/_profile/should_get_profile.yml +39 -43
  39. data/spec/cassettes/client/_modules/_profile/should_set_first_name.yml +109 -117
  40. data/spec/cassettes/client/_modules/_spam/should_get_spam_emails.yml +27 -31
  41. data/spec/cassettes/client/_modules/_spam/should_try_delete_not_existing_spam_emails.yml +27 -32
  42. data/spec/cassettes/client/_modules/_unsubscribe/should_add_unsubscribe_emails.yml +27 -31
  43. data/spec/cassettes/client/_modules/_unsubscribe/should_delete_unsubscribe_email.yml +27 -31
  44. data/spec/cassettes/client/_modules/_unsubscribe/should_get_unsubscribe_emails.yml +27 -32
  45. data/spec/cassettes/client/_modules/_unsubscribe/should_try_delete_not_existing_unsubscribe_emails.yml +27 -32
  46. data/spec/cassettes/helper/_create_sub_user_account/should_create_sub_user_account.yml +248 -255
  47. data/spec/cassettes/helper/_run_sendgrid_query/should_raise_with_unsucessfull_request.yml +39 -38
  48. data/spec/cassettes/helper/_run_sendgrid_query/should_run_sendgrid_request.yml +38 -40
  49. data/spec/cassettes/sub_user/_apps/should_activate_app.yml +38 -40
  50. data/spec/cassettes/sub_user/_apps/should_deactivate_app.yml +38 -40
  51. data/spec/cassettes/sub_user/_apps/should_get_current_setting_from_one_app.yml +38 -41
  52. data/spec/cassettes/sub_user/_apps/should_return_available_apps.yml +63 -55
  53. data/spec/cassettes/sub_user/_apps/should_set_current_app.yml +73 -72
  54. data/spec/cassettes/sub_user/_authentication/should_auth_a_sub_user.yml +38 -40
  55. data/spec/cassettes/sub_user/_authentication/should_return_error_with_a_bad_sub_user.yml +38 -40
  56. data/spec/cassettes/sub_user/_bounces/should_returns_bounce_emails.yml +38 -39
  57. data/spec/cassettes/sub_user/_bounces/should_tries_to_delete_unexisting_bounce_emails.yml +38 -40
  58. data/spec/cassettes/sub_user/_event_notification/should_add_event_notification_url.yml +38 -40
  59. data/spec/cassettes/sub_user/_event_notification/should_delete_event_notification_url.yml +38 -40
  60. data/spec/cassettes/sub_user/_event_notification/should_get_event_notification_url.yml +38 -40
  61. data/spec/cassettes/sub_user/_invalid_emails/should_return_invalid_emails.yml +38 -39
  62. data/spec/cassettes/sub_user/_invalid_emails/should_tries_to_delete_unexisting_invalid_mail.yml +38 -40
  63. data/spec/cassettes/sub_user/_ip_management/should_return_all_ips_available.yml +38 -40
  64. data/spec/cassettes/sub_user/_ip_management/should_show_ip_subuser.yml +38 -40
  65. data/spec/cassettes/sub_user/_limits/should_decrements_credits_for_a_sub_user.yml +73 -77
  66. data/spec/cassettes/sub_user/_limits/should_delete_all_limits_for_a_sub_user.yml +73 -76
  67. data/spec/cassettes/sub_user/_limits/should_increments_credits_for_a_sub_user.yml +73 -77
  68. data/spec/cassettes/sub_user/_limits/should_list_the_limits_for_a_sub_user.yml +38 -40
  69. data/spec/cassettes/sub_user/_limits/should_reset_all_limits_for_a_sub_user.yml +73 -77
  70. data/spec/cassettes/sub_user/_limits/should_returns_limits_for_a_sub_user.yml +38 -40
  71. data/spec/cassettes/sub_user/_limits/should_set_total_credits.yml +38 -40
  72. data/spec/cassettes/sub_user/_management/should_add_new_subuser.yml +38 -40
  73. data/spec/cassettes/sub_user/_management/should_disable_sub_user_for_send_email.yml +38 -40
  74. data/spec/cassettes/sub_user/_management/should_enable_sub_user_for_access_to_website.yml +38 -40
  75. data/spec/cassettes/sub_user/_management/should_enable_sub_user_for_send_email.yml +38 -40
  76. data/spec/cassettes/sub_user/_management/should_update_sub_user.yml +38 -40
  77. data/spec/cassettes/sub_user/_monitor_records/should_add_existing_sub_user_to_monitor_record.yml +73 -78
  78. data/spec/cassettes/sub_user/_monitor_records/should_create_a_new_monitor_record.yml +73 -78
  79. data/spec/cassettes/sub_user/_monitor_records/should_delete_a_monitor_record.yml +73 -76
  80. data/spec/cassettes/sub_user/_monitor_records/should_edit_a_monitor_record.yml +73 -78
  81. data/spec/cassettes/sub_user/_monitor_records/should_remove_existing_sub_user_from_monitor_record.yml +73 -78
  82. data/spec/cassettes/sub_user/_parse_email/should_delete_parse_email.yml +73 -76
  83. data/spec/cassettes/sub_user/_parse_email/should_get_parse_email.yml +38 -41
  84. data/spec/cassettes/sub_user/_parse_email/should_set_parse_email.yml +38 -40
  85. data/spec/cassettes/sub_user/_spam/should_return_spam_mails.yml +38 -39
  86. data/spec/cassettes/sub_user/_spam/should_tries_to_delete_unexisting_spam_mail.yml +38 -40
  87. data/spec/cassettes/sub_user/_unsubscribes/should_add_bounce_email.yml +38 -40
  88. data/spec/cassettes/sub_user/_unsubscribes/should_delete_existing_bounce_email.yml +38 -40
  89. data/spec/cassettes/sub_user/_unsubscribes/should_delete_unexisting_bounce_email.yml +38 -40
  90. data/spec/cassettes/sub_user/_unsubscribes/should_returns_bounce_emails.yml +38 -40
  91. data/spec/client_spec.rb +7 -4
  92. data/spec/helper_spec.rb +9 -9
  93. data/spec/sub_user_spec.rb +63 -68
  94. data/test.rb +5 -0
  95. metadata +90 -58
  96. data/.travis.yml +0 -5
  97. data/spec/cassettes/sub_user/_management/should_get_all_subusers.yml +0 -54
data/spec/helper_spec.rb CHANGED
@@ -3,19 +3,19 @@ require 'spec_helper'
3
3
  describe "helper" do
4
4
  include SendGridWebApi::Helper
5
5
 
6
- let(:client) { SendGridWebApi::Client.new("user", "pass") }
6
+ let(:client) { SendGridWebApi::Client.new("apikey") }
7
7
 
8
8
  describe "#run_sendgrid_query" do
9
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")
10
+ run_sendgrid_query("apikey") do
11
+ @client.sub_user.apps.activate(:user => "sendgrid_testuser3", :name => "clicktrack")
12
12
  end
13
13
  end
14
14
 
15
15
  it "should raise with unsucessfull request", :vcr do
16
16
  lambda do
17
- run_sendgrid_query("user", "pass") do
18
- @client.sub_user.apps.activate(:user => "test-1", :name => "badappname")
17
+ run_sendgrid_query("apikey") do
18
+ @client.sub_user.apps.activate(:user => "sendgrid_testuser3", :name => "badappname")
19
19
  end
20
20
  end.should raise_error
21
21
  end
@@ -29,18 +29,18 @@ describe "helper" do
29
29
 
30
30
  apps = { :opentrack => {:name => "eventnotify", :processed => "0", :dropped => "1", :deferred => "1",
31
31
  :delivered => "0", :bounce => "1", :click => "1", :open => "1", :unsubscribe => "1", :spamreport => "1",
32
- :url => "https://agencieshq.com/sendgrid/v1/listener"},
32
+ :url => "https://example.com"},
33
33
  :clicktrack => {:enable_text => "1"},
34
34
  :opentrack => {}
35
35
  }
36
36
 
37
- @users = {"test-4" => {:account => user_hash, :applications => apps, :assigned_ips => ["74.63.231.33"]}}
37
+ @users = {"test-6" => {:account => user_hash, :applications => apps, :assigned_ips => ["192.254.126.178"]}}
38
38
 
39
39
  end
40
40
 
41
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").
42
+ create_sub_user_account("apikey", @users)
43
+ client.sub_user.auth.login(:user => "test-6", :password => "somepass").
44
44
  should == {"message" => "success"}
45
45
  end
46
46
  end
@@ -1,72 +1,67 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "sub_user" do
4
- let(:client) { SendGridWebApi::Client.new("user", "pass") }
4
+ let(:client) { SendGridWebApi::Client.new("apikey") }
5
5
 
6
6
  describe "#management", :vcr do
7
7
  it "should add new subuser" do
8
- client.sub_user.management.add(:username => "chebyte3", :website => "example.com", :password => "somepass", :confirm_password => "somepass",
8
+ client.sub_user.management.add(:username => "sendgrid_testuser3", :website => "example.com", :password => "somepass", :confirm_password => "somepass",
9
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").
10
+ :state => "CA", :zip => "91234", :email => "sendgrid_testuser3@example.com", :country => "US", :phone => "555-555").
11
11
  should == {"message"=>"success"}
12
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
-
13
+
19
14
  it "should disable sub_user for send email" do
20
- client.sub_user.management.disable(:user => "chebyte3").
15
+ client.sub_user.management.disable(:user => "sendgrid_testuser3").
21
16
  should == {"message" => "success"}
22
17
  end
23
18
 
24
19
  it "should enable sub_user for send email" do
25
- client.sub_user.management.enable(:user => "chebyte3").
20
+ client.sub_user.management.enable(:user => "sendgrid_testuser3").
26
21
  should == {"message" => "success"}
27
22
  end
28
23
 
29
24
  it "should enable sub_user for access to website" do
30
- client.sub_user.management.website_enable(:user => "chebyte3").
25
+ client.sub_user.management.website_enable(:user => "sendgrid_testuser3").
31
26
  should == {"message" => "success"}
32
27
  end
33
28
 
34
29
  it "should update sub_user" do
35
- client.sub_user.management.update(:user => "chebyte3", :first_name => "change_named").
30
+ client.sub_user.management.update(:user => "sendgrid_testuser3", :first_name => "change_named").
36
31
  should == {"message" => "success"}
37
32
  end
38
33
  end
39
34
 
40
35
  describe "#bounces", :vcr do
41
36
  it "should returns bounce emails" do
42
- client.sub_user.bounces.get(:user => "chebyte3").
37
+ client.sub_user.bounces.get(:user => "sendgrid_testuser3").
43
38
  should == []
44
39
  end
45
40
 
46
41
  it "should tries to delete unexisting bounce emails" do
47
- client.sub_user.bounces.delete(:user => "chebyte3", :email => "test@test.com").
42
+ client.sub_user.bounces.delete(:user => "sendgrid_testuser3", :email => "test@email.com").
48
43
  should == {"message"=>"Email does not exist"}
49
44
  end
50
45
  end
51
46
 
52
47
  describe "#unsubscribes", :vcr do
53
48
  it "should add bounce email" do
54
- client.sub_user.unsubscribes.add(:user => "chebyte3", :email => "test@test.com").
49
+ client.sub_user.unsubscribes.add(:user => "sendgrid_testuser3", :email => "test@email.com").
55
50
  should == {"message"=>"success"}
56
51
  end
57
52
 
58
53
  it "should returns bounce emails" do
59
- client.sub_user.unsubscribes.get(:user => "chebyte3").
60
- should == [{"email"=>"test@test.com"}]
54
+ client.sub_user.unsubscribes.get(:user => "sendgrid_testuser3").
55
+ should == [{"email"=>"test@email.com"}]
61
56
  end
62
57
 
63
58
  it "should delete existing bounce email" do
64
- client.sub_user.unsubscribes.delete(:user => "chebyte3", :email => "test@test.com").
59
+ client.sub_user.unsubscribes.delete(:user => "sendgrid_testuser3", :email => "test@email.com").
65
60
  should == {"message"=>"success"}
66
61
  end
67
62
 
68
63
  it "should delete unexisting bounce email" do
69
- client.sub_user.unsubscribes.delete(:user => "chebyte3", :email => "test@test.com").
64
+ client.sub_user.unsubscribes.delete(:user => "sendgrid_testuser3", :email => "test@email.com").
70
65
  should == {"message"=>"Email does not exist"}
71
66
  end
72
67
 
@@ -74,129 +69,129 @@ describe "sub_user" do
74
69
 
75
70
  describe "#spam", :vcr do
76
71
  it "should return spam mails" do
77
- client.sub_user.spam.get(:user => "chebyte3").
72
+ client.sub_user.spam.get(:user => "sendgrid_testuser3").
78
73
  should == []
79
74
  end
80
75
 
81
76
  it "should tries to delete unexisting spam mail" do
82
- client.sub_user.spam.delete(:user => "chebyte3", :email => "test@test.com").
77
+ client.sub_user.spam.delete(:user => "sendgrid_testuser3", :email => "test@email.com").
83
78
  should == {"message"=>"Email does not exist"}
84
79
  end
85
80
  end
86
81
 
87
82
  describe "#invalid_emails", :vcr do
88
83
  it "should return invalid emails" do
89
- client.sub_user.invalid_emails.get(:user => "chebyte3").
84
+ client.sub_user.invalid_emails.get(:user => "sendgrid_testuser3").
90
85
  should == []
91
86
  end
92
87
 
93
88
  it "should tries to delete unexisting invalid mail" do
94
- client.sub_user.invalid_emails.delete(:user => "chebyte3", :email => "test@testr.com").
89
+ client.sub_user.invalid_emails.delete(:user => "sendgrid_testuser3", :email => "test@testr.com").
95
90
  should == {"message"=>"Email does not exist"}
96
91
  end
97
92
  end
98
93
 
99
94
  describe "#event_notification", :vcr do
100
95
  it "should add event notification url" do
101
- client.sub_user.event_notification.set(:user => "chebyte3", :url => "www.example.com/notification").
96
+ client.sub_user.event_notification.set(:user => "sendgrid_testuser3", :url => "www.example.com/notification").
102
97
  should == {"message"=>"success"}
103
98
  end
104
99
 
105
100
  it "should get event notification url" do
106
- client.sub_user.event_notification.get(:user => "chebyte3").
101
+ client.sub_user.event_notification.get(:user => "sendgrid_testuser3").
107
102
  should == [{"url"=>"www.example.com/notification"}]
108
103
  end
109
104
 
110
105
  it "should delete event notification url" do
111
- client.sub_user.event_notification.delete(:user => "chebyte3", :url => "www.example.com/noti.php").
106
+ client.sub_user.event_notification.delete(:user => "sendgrid_testuser3", :url => "www.example.com/noti.php").
112
107
  should == {"message"=>"success"}
113
108
  end
114
109
  end
115
110
 
116
111
  describe "#limits", :vcr do
117
112
  it "should set total credits" do
118
- client.sub_user.limits.set_credits(:user => "chebyte3", :credits=> "200", :period=> "daily").
113
+ client.sub_user.limits.set_credits(:user => "sendgrid_testuser3", :credits=> "200", :period=> "daily").
119
114
  should == {"message"=>"success"}
120
115
  end
121
116
 
122
117
  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"}]
118
+ client.sub_user.limits.get(:user => "sendgrid_testuser3").
119
+ should == [{"credit"=>"0", "credit_remain"=>"200", "last_reset"=>"2014-01-16"}]
125
120
  end
126
121
 
127
122
  it "should reset all limits for a sub user" do
128
- client.sub_user.limits.reset(:user => "chebyte3", :credits=> "400", :period=> "daily").
123
+ client.sub_user.limits.reset(:user => "sendgrid_testuser3", :credits=> "400", :period=> "daily").
129
124
  should == {"message"=>"success"}
130
- client.sub_user.limits.get(:user => "chebyte3").
131
- should == [{"credit"=>"400", "credit_remain"=>"400", "last_reset"=>"2012-07-02"}]
125
+ client.sub_user.limits.get(:user => "sendgrid_testuser3").
126
+ should == [{"credit"=>"400", "credit_remain"=>"400", "last_reset"=>"2014-01-16"}]
132
127
  end
133
128
 
134
129
  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"}]
130
+ client.sub_user.limits.get(:user => "sendgrid_testuser3").
131
+ should == [{"credit"=>"400", "credit_remain"=>"400", "last_reset"=>"2014-01-16"}]
137
132
  end
138
133
 
139
134
  it "should increments credits for a sub user" do
140
- client.sub_user.limits.increment_credits(:user => "chebyte3", :credits=> "400").
135
+ client.sub_user.limits.increment_credits(:user => "sendgrid_testuser3", :credits=> "400").
141
136
  should == {"message"=>"success"}
142
- client.sub_user.limits.get(:user => "chebyte3").
143
- should == [{"credit"=>"0", "credit_remain"=>"800", "last_reset"=>"2012-07-02"}]
137
+ client.sub_user.limits.get(:user => "sendgrid_testuser3").
138
+ should == [{"credit"=>"0", "credit_remain"=>"800", "last_reset"=>"2014-01-16"}]
144
139
  end
145
140
 
146
141
  it "should decrements credits for a sub user" do
147
- client.sub_user.limits.decrement_credits(:user => "chebyte3", :credits=> "400").
142
+ client.sub_user.limits.decrement_credits(:user => "sendgrid_testuser3", :credits=> "400").
148
143
  should == {"message"=>"success"}
149
- client.sub_user.limits.get(:user => "chebyte3").
150
- should == [{"credit"=>"0", "credit_remain"=>"400", "last_reset"=>"2012-07-02"}]
144
+ client.sub_user.limits.get(:user => "sendgrid_testuser3").
145
+ should == [{"credit"=>"0", "credit_remain"=>"400", "last_reset"=>"2014-01-16"}]
151
146
  end
152
147
 
153
148
  it "should delete all limits for a sub user" do
154
- client.sub_user.limits.delete(:user => "chebyte3").
149
+ client.sub_user.limits.delete(:user => "sendgrid_testuser3").
155
150
  should == {"message"=>"success"}
156
- client.sub_user.limits.get(:user => "chebyte3").
151
+ client.sub_user.limits.get(:user => "sendgrid_testuser3").
157
152
  should == []
158
153
  end
159
154
  end
160
155
 
161
156
  describe "#ip_management", :vcr do
162
157
  it "should return all ips available" do
163
- client.sub_user.ip_management.get(:user => "chebyte3").
164
- should == [{"ip"=>"74.63.231.33"}]
158
+ client.sub_user.ip_management.get(:user => "sendgrid_testuser3").
159
+ should == [{"ip"=>"192.254.126.178"}]
165
160
  end
166
161
 
167
162
  it "should show ip subuser" do
168
- client.sub_user.ip_management.usage_ip(:user => "chebyte3").
163
+ client.sub_user.ip_management.usage_ip(:user => "sendgrid_testuser3").
169
164
  should == {"success"=>"success", "outboundcluster"=>"SendGrid MTA", "ips"=>[]}
170
165
  end
171
166
  end
172
167
 
173
168
  describe "#monitor_records", :vcr do
174
169
  it "should create a new monitor record" do
175
- client.sub_user.monitor_records.create(:name => "testmonitor", :frequency => 10000, :email => "test@test.com").
170
+ client.sub_user.monitor_records.create(:name => "testmonitor", :frequency => 10000, :email => "test@email.com").
176
171
  should == {"message"=>"success"}
177
172
  client.sub_user.monitor_records.get.
178
- should == [{"name"=>"testmonitor", "email"=>"test@test.com", "frequency"=>"10000", "users"=>[]}]
173
+ should == [{"name"=>"testmonitor", "email"=>"test@email.com", "frequency"=>"10000", "users"=>[]}]
179
174
  end
180
175
 
181
176
  it "should edit a monitor record" do
182
177
  client.sub_user.monitor_records.edit(:name => "testmonitor", :new_frequency => 10).
183
178
  should == {"message"=>"success"}
184
179
  client.sub_user.monitor_records.get.
185
- should == [{"name"=>"testmonitor", "email"=>"test@test.com", "frequency"=>"10", "users"=>[]}]
180
+ should == [{"name"=>"testmonitor", "email"=>"test@email.com", "frequency"=>"10", "users"=>[]}]
186
181
  end
187
182
 
188
183
  it "should add existing sub_user to monitor record" do
189
- client.sub_user.monitor_records.add_user(:user => "chebyte3", :name => "testmonitor").
184
+ client.sub_user.monitor_records.add_user(:user => "sendgrid_testuser3", :name => "testmonitor").
190
185
  should == {"message"=>"success"}
191
186
  client.sub_user.monitor_records.get.
192
- should == [{"name"=>"testmonitor", "email"=>"test@test.com", "frequency"=>"10", "users"=>["chebyte3"]}]
187
+ should == [{"name"=>"testmonitor", "email"=>"test@email.com", "frequency"=>"10", "users"=>["sendgrid_testuser3"]}]
193
188
  end
194
189
 
195
190
  it "should remove existing sub_user from monitor record" do
196
- client.sub_user.monitor_records.remove_user(:user => "chebyte3", :name => "testmonitor").
191
+ client.sub_user.monitor_records.remove_user(:user => "sendgrid_testuser3", :name => "testmonitor").
197
192
  should == {"message"=>"success"}
198
193
  client.sub_user.monitor_records.get.
199
- should == [{"name"=>"testmonitor", "email"=>"test@test.com", "frequency"=>"10", "users"=>[]}]
194
+ should == [{"name"=>"testmonitor", "email"=>"test@email.com", "frequency"=>"10", "users"=>[]}]
200
195
  end
201
196
 
202
197
  it "should delete a monitor record" do
@@ -209,62 +204,62 @@ describe "sub_user" do
209
204
 
210
205
  describe "#authentication", :vcr do
211
206
  it "should auth a sub_user" do
212
- client.sub_user.auth.login(:user => "chebyte3", :password => "somepass").
207
+ client.sub_user.auth.login(:user => "sendgrid_testuser3", :password => "somepass").
213
208
  should == {"message"=>"success"}
214
209
  end
215
210
 
216
211
  it "should return error with a bad sub_user" do
217
- client.sub_user.auth.login(:user => "chebyte3", :password => "badpass").
212
+ client.sub_user.auth.login(:user => "sendgrid_testuser3", :password => "badpass").
218
213
  should == {"message"=>"error", "errors"=>["Invalid username and/or password"]}
219
214
  end
220
215
  end
221
216
 
222
217
  describe "#parse_email", :vcr do
223
218
  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").
219
+ client.sub_user.parse_email.set(:user => "sendgrid_testuser3", :hostname => "www.example.com", :url => "www.mydomain.com/parse.php", :spam_check => "1").
225
220
  should == {"message"=>"success"}
226
221
  end
227
222
 
228
223
  it "should get parse email" do
229
- client.sub_user.parse_email.get(:user => "chebyte3").
224
+ client.sub_user.parse_email.get(:user => "sendgrid_testuser3").
230
225
  should == {"parse"=>[{"hostname"=>"www.example.com", "url"=>"www.mydomain.com/parse.php", "spam_check"=>1}]}
231
226
  end
232
227
 
233
228
  it "should delete parse email" do
234
- client.sub_user.parse_email.delete(:user => "chebyte3", :hostname => "www.example.com").
229
+ client.sub_user.parse_email.delete(:user => "sendgrid_testuser3", :hostname => "www.example.com").
235
230
  should == {"message"=>"success"}
236
- client.sub_user.parse_email.get(:user => "chebyte3").
231
+ client.sub_user.parse_email.get(:user => "sendgrid_testuser3").
237
232
  should == {"parse" => []}
238
233
  end
239
234
  end
240
235
 
241
236
  describe "#apps", :vcr do
242
237
  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}]
238
+ client.sub_user.apps.list(:user => "sendgrid_testuser3").
239
+ 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}, {"name"=>"newrelic", "title"=>"SendGrid for New Relic", "description"=>"Integrate SendGrid with your New Relic account to access your email statistics via the <a target=\"blank\" href=\"https://newrelic.com/sendgrid\">New Relic</a> Dashboard.", "activated"=>false}]
245
240
  end
246
241
 
247
242
  it "should activate app" do
248
- client.sub_user.apps.activate(:user => "chebyte3", :name => "opentrack").
243
+ client.sub_user.apps.activate(:user => "sendgrid_testuser3", :name => "opentrack").
249
244
  should == {"message"=>"success"}
250
245
  end
251
246
 
252
247
  it "should deactivate app" do
253
- client.sub_user.apps.deactivate(:user => "chebyte3", :name => "opentrack").
248
+ client.sub_user.apps.deactivate(:user => "sendgrid_testuser3", :name => "opentrack").
254
249
  should == {"message"=>"success"}
255
250
  end
256
251
 
257
252
  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"=>""}}
253
+ client.sub_user.apps.current_settings(:user => "sendgrid_testuser3", :name => "eventnotify").
254
+ should == {"settings"=>{"processed"=>"", "dropped"=>"", "deferred"=>"", "delivered"=>"", "bounce"=>"", "click"=>"", "open"=>"", "unsubscribe"=>"", "subscribe"=>"", "spamreport"=>"", "url"=>"", "batch"=>"", "version"=>"1"}}
260
255
  end
261
256
 
262
257
  it "should set current app" do
263
- client.sub_user.apps.customize(:user => "chebyte3", :name => "eventnotify", :processed => "1", :dropped => "1", :deferred => "1",
258
+ client.sub_user.apps.customize(:user => "sendgrid_testuser3", :name => "eventnotify", :processed => "1", :dropped => "1", :deferred => "1",
264
259
  :delivered => "1", :delivered => "1", :bounce => "1", :click => "1", :open => "1", :unsubscribe => "1", :spamreport => "1", :url => "http://yourdomain.com/event.php").
265
260
  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"}}
261
+ client.sub_user.apps.current_settings(:user => "sendgrid_testuser3", :name => "eventnotify").
262
+ should == {"settings"=>{"processed"=>"1", "dropped"=>"1", "deferred"=>"1", "delivered"=>"1", "bounce"=>"1", "click"=>"1", "open"=>"1", "unsubscribe"=>"1", "subscribe"=>"", "spamreport"=>"1", "url"=>"http://yourdomain.com/event.php", "batch"=>"", "version"=>"3"}}
268
263
  end
269
264
  end
270
265
  end
data/test.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "sendgrid_webapi"
2
+
3
+ client = SendGridWebApi::Client.new("dpj7k9hq")
4
+
5
+ puts client.blocks.get.inspect