sendgrid_webapi 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/.rbenv-version +1 -0
  2. data/README.rdoc +76 -77
  3. data/lib/version.rb +1 -1
  4. data/lib/web_api/blocks.rb +5 -0
  5. data/lib/web_api/bounces.rb +5 -0
  6. data/lib/webapi_client.rb +1 -1
  7. data/sendgrid_webapi.gemspec +1 -1
  8. data/spec/cassettes/client/_modules/_block/should_get_block_emails.yml +29 -41
  9. data/spec/cassettes/client/_modules/_block/should_get_totals_blocks.yml +36 -0
  10. data/spec/cassettes/client/_modules/_block/should_try_delete_not_existing_block_email.yml +29 -42
  11. data/spec/cassettes/client/_modules/_bounce/should_get_bounce_emails.yml +27 -31
  12. data/spec/cassettes/client/_modules/_bounce/should_get_totals_bounces.yml +36 -0
  13. data/spec/cassettes/client/_modules/_bounce/should_try_delete_not_existing_bounce_email.yml +27 -32
  14. data/spec/cassettes/client/_modules/_event_notification/should_delete_event_notification_url.yml +38 -40
  15. data/spec/cassettes/client/_modules/_event_notification/should_get_event_notification_url.yml +38 -40
  16. data/spec/cassettes/client/_modules/_event_notification/should_set_event_notification_url.yml +38 -40
  17. data/spec/cassettes/client/_modules/_invalid_email/should_get_invalid_emails.yml +27 -31
  18. data/spec/cassettes/client/_modules/_invalid_email/should_try_delete_not_existing_invalid_emails.yml +27 -32
  19. data/spec/cassettes/client/_modules/_parse_email/should_delete_parse_email.yml +73 -76
  20. data/spec/cassettes/client/_modules/_parse_email/should_get_parse_email.yml +38 -41
  21. data/spec/cassettes/client/_modules/_parse_email/should_set_parse_email.yml +38 -40
  22. data/spec/cassettes/client/_modules/_profile/should_get_profile.yml +39 -43
  23. data/spec/cassettes/client/_modules/_profile/should_set_first_name.yml +109 -117
  24. data/spec/cassettes/client/_modules/_spam/should_get_spam_emails.yml +27 -31
  25. data/spec/cassettes/client/_modules/_spam/should_try_delete_not_existing_spam_emails.yml +27 -32
  26. data/spec/cassettes/client/_modules/_unsubscribe/should_add_unsubscribe_emails.yml +27 -31
  27. data/spec/cassettes/client/_modules/_unsubscribe/should_delete_unsubscribe_email.yml +27 -31
  28. data/spec/cassettes/client/_modules/_unsubscribe/should_get_unsubscribe_emails.yml +27 -32
  29. data/spec/cassettes/client/_modules/_unsubscribe/should_try_delete_not_existing_unsubscribe_emails.yml +27 -32
  30. data/spec/cassettes/helper/_create_sub_user_account/should_create_sub_user_account.yml +248 -255
  31. data/spec/cassettes/helper/_run_sendgrid_query/should_raise_with_unsucessfull_request.yml +39 -38
  32. data/spec/cassettes/helper/_run_sendgrid_query/should_run_sendgrid_request.yml +38 -40
  33. data/spec/cassettes/sub_user/_apps/should_activate_app.yml +38 -40
  34. data/spec/cassettes/sub_user/_apps/should_deactivate_app.yml +38 -40
  35. data/spec/cassettes/sub_user/_apps/should_get_current_setting_from_one_app.yml +38 -41
  36. data/spec/cassettes/sub_user/_apps/should_return_available_apps.yml +63 -55
  37. data/spec/cassettes/sub_user/_apps/should_set_current_app.yml +73 -72
  38. data/spec/cassettes/sub_user/_authentication/should_auth_a_sub_user.yml +38 -40
  39. data/spec/cassettes/sub_user/_authentication/should_return_error_with_a_bad_sub_user.yml +38 -40
  40. data/spec/cassettes/sub_user/_bounces/should_returns_bounce_emails.yml +38 -39
  41. data/spec/cassettes/sub_user/_bounces/should_tries_to_delete_unexisting_bounce_emails.yml +38 -40
  42. data/spec/cassettes/sub_user/_event_notification/should_add_event_notification_url.yml +38 -40
  43. data/spec/cassettes/sub_user/_event_notification/should_delete_event_notification_url.yml +38 -40
  44. data/spec/cassettes/sub_user/_event_notification/should_get_event_notification_url.yml +38 -40
  45. data/spec/cassettes/sub_user/_invalid_emails/should_return_invalid_emails.yml +38 -39
  46. data/spec/cassettes/sub_user/_invalid_emails/should_tries_to_delete_unexisting_invalid_mail.yml +38 -40
  47. data/spec/cassettes/sub_user/_ip_management/should_return_all_ips_available.yml +38 -40
  48. data/spec/cassettes/sub_user/_ip_management/should_show_ip_subuser.yml +38 -40
  49. data/spec/cassettes/sub_user/_limits/should_decrements_credits_for_a_sub_user.yml +73 -77
  50. data/spec/cassettes/sub_user/_limits/should_delete_all_limits_for_a_sub_user.yml +73 -76
  51. data/spec/cassettes/sub_user/_limits/should_increments_credits_for_a_sub_user.yml +73 -77
  52. data/spec/cassettes/sub_user/_limits/should_list_the_limits_for_a_sub_user.yml +38 -40
  53. data/spec/cassettes/sub_user/_limits/should_reset_all_limits_for_a_sub_user.yml +73 -77
  54. data/spec/cassettes/sub_user/_limits/should_returns_limits_for_a_sub_user.yml +38 -40
  55. data/spec/cassettes/sub_user/_limits/should_set_total_credits.yml +38 -40
  56. data/spec/cassettes/sub_user/_management/should_add_new_subuser.yml +38 -40
  57. data/spec/cassettes/sub_user/_management/should_disable_sub_user_for_send_email.yml +38 -40
  58. data/spec/cassettes/sub_user/_management/should_enable_sub_user_for_access_to_website.yml +38 -40
  59. data/spec/cassettes/sub_user/_management/should_enable_sub_user_for_send_email.yml +38 -40
  60. data/spec/cassettes/sub_user/_management/should_update_sub_user.yml +38 -40
  61. data/spec/cassettes/sub_user/_monitor_records/should_add_existing_sub_user_to_monitor_record.yml +72 -77
  62. data/spec/cassettes/sub_user/_monitor_records/should_create_a_new_monitor_record.yml +72 -77
  63. data/spec/cassettes/sub_user/_monitor_records/should_delete_a_monitor_record.yml +71 -74
  64. data/spec/cassettes/sub_user/_monitor_records/should_edit_a_monitor_record.yml +71 -76
  65. data/spec/cassettes/sub_user/_monitor_records/should_remove_existing_sub_user_from_monitor_record.yml +72 -77
  66. data/spec/cassettes/sub_user/_parse_email/should_delete_parse_email.yml +73 -76
  67. data/spec/cassettes/sub_user/_parse_email/should_get_parse_email.yml +38 -41
  68. data/spec/cassettes/sub_user/_parse_email/should_set_parse_email.yml +38 -40
  69. data/spec/cassettes/sub_user/_spam/should_return_spam_mails.yml +38 -39
  70. data/spec/cassettes/sub_user/_spam/should_tries_to_delete_unexisting_spam_mail.yml +38 -40
  71. data/spec/cassettes/sub_user/_unsubscribes/should_add_bounce_email.yml +38 -40
  72. data/spec/cassettes/sub_user/_unsubscribes/should_delete_existing_bounce_email.yml +38 -40
  73. data/spec/cassettes/sub_user/_unsubscribes/should_delete_unexisting_bounce_email.yml +38 -40
  74. data/spec/cassettes/sub_user/_unsubscribes/should_returns_bounce_emails.yml +38 -40
  75. data/spec/client_spec.rb +5 -2
  76. data/spec/helper_spec.rb +5 -5
  77. data/spec/sub_user_spec.rb +62 -67
  78. data/test.rb +5 -0
  79. metadata +10 -6
  80. data/spec/cassettes/sub_user/_management/should_get_all_subusers.yml +0 -54
data/spec/client_spec.rb CHANGED
@@ -6,7 +6,7 @@ describe "client" do
6
6
 
7
7
  describe "#base", :vcr do
8
8
  it "should return api url" do
9
- client.base_url.should eql "https://sendgrid.com/api/"
9
+ client.base_url.should eql "https://api.sendgrid.com/api/"
10
10
  end
11
11
 
12
12
  it "should return request url" do
@@ -28,6 +28,9 @@ describe "client" do
28
28
  it "should try delete not existing block email" do
29
29
  client.blocks.delete(:email => "test@example.com").should == {"message"=>"Email does not exist"}
30
30
  end
31
+ it "should get totals blocks" do
32
+ client.blocks.count.should eql({"count"=>0})
33
+ end
31
34
  end
32
35
 
33
36
  describe "#bounce", :vcr do
@@ -115,7 +118,7 @@ describe "client" do
115
118
  describe "#profile", :vcr do
116
119
  it "should get profile" do
117
120
  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"}]
121
+ should == [{"username"=>"user", "email"=>"user", "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
122
  end
120
123
 
121
124
  it "should set first name" do
data/spec/helper_spec.rb CHANGED
@@ -8,14 +8,14 @@ describe "helper" do
8
8
  describe "#run_sendgrid_query" do
9
9
  it "should run sendgrid request", :vcr do
10
10
  run_sendgrid_query("user", "pass") do
11
- @client.sub_user.apps.activate(:user => "test-1", :name => "clicktrack")
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
17
  run_sendgrid_query("user", "pass") do
18
- @client.sub_user.apps.activate(:user => "test-1", :name => "badappname")
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
42
  create_sub_user_account("user", "pass", @users)
43
- client.sub_user.auth.login(:user => "test-3", :password => "somepass").
43
+ client.sub_user.auth.login(:user => "test-6", :password => "somepass").
44
44
  should == {"message" => "success"}
45
45
  end
46
46
  end
@@ -5,68 +5,63 @@ describe "sub_user" do
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("app12240625@heroku.com", "dpj7k9hq")
4
+
5
+ puts client.blocks.get.inspect
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendgrid_webapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-05-28 00:00:00.000000000 Z
13
+ date: 2014-01-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -51,7 +51,7 @@ dependencies:
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 2.1.1
54
+ version: 2.8.0
55
55
  type: :development
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ dependencies:
59
59
  requirements:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
- version: 2.1.1
62
+ version: 2.8.0
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: faraday
65
65
  requirement: !ruby/object:Gem::Requirement
@@ -101,6 +101,7 @@ extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
103
  - .gitignore
104
+ - .rbenv-version
104
105
  - .rspec
105
106
  - .travis.yml
106
107
  - Gemfile
@@ -143,8 +144,10 @@ files:
143
144
  - lib/webapi_client.rb
144
145
  - sendgrid_webapi.gemspec
145
146
  - spec/cassettes/client/_modules/_block/should_get_block_emails.yml
147
+ - spec/cassettes/client/_modules/_block/should_get_totals_blocks.yml
146
148
  - spec/cassettes/client/_modules/_block/should_try_delete_not_existing_block_email.yml
147
149
  - spec/cassettes/client/_modules/_bounce/should_get_bounce_emails.yml
150
+ - spec/cassettes/client/_modules/_bounce/should_get_totals_bounces.yml
148
151
  - spec/cassettes/client/_modules/_bounce/should_try_delete_not_existing_bounce_email.yml
149
152
  - spec/cassettes/client/_modules/_event_notification/should_delete_event_notification_url.yml
150
153
  - spec/cassettes/client/_modules/_event_notification/should_get_event_notification_url.yml
@@ -192,7 +195,6 @@ files:
192
195
  - spec/cassettes/sub_user/_management/should_disable_sub_user_for_send_email.yml
193
196
  - spec/cassettes/sub_user/_management/should_enable_sub_user_for_access_to_website.yml
194
197
  - spec/cassettes/sub_user/_management/should_enable_sub_user_for_send_email.yml
195
- - spec/cassettes/sub_user/_management/should_get_all_subusers.yml
196
198
  - spec/cassettes/sub_user/_management/should_update_sub_user.yml
197
199
  - spec/cassettes/sub_user/_monitor_records/should_add_existing_sub_user_to_monitor_record.yml
198
200
  - spec/cassettes/sub_user/_monitor_records/should_create_a_new_monitor_record.yml
@@ -212,6 +214,7 @@ files:
212
214
  - spec/helper_spec.rb
213
215
  - spec/spec_helper.rb
214
216
  - spec/sub_user_spec.rb
217
+ - test.rb
215
218
  homepage: https://github.com/kylejginavan/sendgrid_smtpapi
216
219
  licenses: []
217
220
  post_install_message:
@@ -238,8 +241,10 @@ specification_version: 3
238
241
  summary: SendGrid WEB API gem fo Rails
239
242
  test_files:
240
243
  - spec/cassettes/client/_modules/_block/should_get_block_emails.yml
244
+ - spec/cassettes/client/_modules/_block/should_get_totals_blocks.yml
241
245
  - spec/cassettes/client/_modules/_block/should_try_delete_not_existing_block_email.yml
242
246
  - spec/cassettes/client/_modules/_bounce/should_get_bounce_emails.yml
247
+ - spec/cassettes/client/_modules/_bounce/should_get_totals_bounces.yml
243
248
  - spec/cassettes/client/_modules/_bounce/should_try_delete_not_existing_bounce_email.yml
244
249
  - spec/cassettes/client/_modules/_event_notification/should_delete_event_notification_url.yml
245
250
  - spec/cassettes/client/_modules/_event_notification/should_get_event_notification_url.yml
@@ -287,7 +292,6 @@ test_files:
287
292
  - spec/cassettes/sub_user/_management/should_disable_sub_user_for_send_email.yml
288
293
  - spec/cassettes/sub_user/_management/should_enable_sub_user_for_access_to_website.yml
289
294
  - spec/cassettes/sub_user/_management/should_enable_sub_user_for_send_email.yml
290
- - spec/cassettes/sub_user/_management/should_get_all_subusers.yml
291
295
  - spec/cassettes/sub_user/_management/should_update_sub_user.yml
292
296
  - spec/cassettes/sub_user/_monitor_records/should_add_existing_sub_user_to_monitor_record.yml
293
297
  - spec/cassettes/sub_user/_monitor_records/should_create_a_new_monitor_record.yml