sendgrid_webapi 0.0.2 → 0.1.2

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.
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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2c4750102028a182ab7e513792ca0f127684c5ce2f59562dbe1997869c7099e9
4
+ data.tar.gz: 406420e68b953fca19e900acd80ab5914c689941588c4b056239f2f5f64f6971
5
+ SHA512:
6
+ metadata.gz: d912c4463cb6cf6b77d55444e31302450e395c4b2c0eb14bbd4345b77d83dfbba7b3b5b9b563b0e0fff577a5989a00255c69d731d56c08495bd727eb3f15c358
7
+ data.tar.gz: 445d7ef45b7cb2b7325405120ef271ab1c6b13d50a902e83c63e5bebe16f95889c722f06555adedabb08ba4e70eb652eeec810a6a29f4d285dea64ec51def652
@@ -0,0 +1,132 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ defaults: &defaults
6
+ working_directory: ~/repo
7
+ docker:
8
+ - image: circleci/ruby:2.3.6-stretch-node
9
+ environment:
10
+ # - DBHOST: localhost
11
+ # - DBNAME: sendgrid_webapi_test
12
+ # - DBPASSWORD: Vdm9omJt8Z3MCV4N
13
+ # - DBUSER: test_user
14
+ - RACK_ENV: test
15
+ - RAILS_ENV: test
16
+ # - image: circleci/postgres:10.3-alpine-ram
17
+ # environment:
18
+ # - POSTGRES_DB: sendgrid_webapi_test
19
+ # - POSTGRES_USER: test_user
20
+ # - POSTGRES_PASSWORD: Vdm9omJt8Z3MCV4N
21
+
22
+ version: 2
23
+ jobs:
24
+ run_specs:
25
+ <<: *defaults
26
+
27
+ steps:
28
+ - run:
29
+ name: Set up environment
30
+ command: |
31
+ sudo apt-get update && sudo apt-get install -y apt-transport-https apt-utils
32
+
33
+ - checkout
34
+
35
+ - restore_cache:
36
+ keys:
37
+ - sendgrid_webapi-dependencies-v1-{{ checksum "sendgrid_webapi.gemspec" }}
38
+ - sendgrid_webapi-dependencies-v1-
39
+
40
+ - run:
41
+ name: Install dependencies
42
+ command: |
43
+ # curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
44
+ # echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
45
+ # sudo apt-get update && sudo apt-get install postgresql-client-10
46
+ bundle check --path=./vendor/bundle || bundle install --path=./vendor/bundle --jobs=4 --retry=3
47
+
48
+ - save_cache:
49
+ key: sendgrid_webapi-dependencies-v1-{{ checksum "sendgrid_webapi.gemspec" }}
50
+ paths:
51
+ - ./vendor/bundle
52
+
53
+ # - run:
54
+ # name: Set up database
55
+ # command: |
56
+ # cp spec/internal/config/database.docker.yml spec/internal/config/database.yml
57
+
58
+ - run:
59
+ name: Run tests
60
+ command: |
61
+ mkdir /tmp/test-results
62
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
63
+ bundle exec rspec --format progress --format RspecJunitFormatter --out /tmp/test-results/rspec.xml $TEST_FILES
64
+
65
+ - store_test_results:
66
+ path: /tmp/test-results
67
+
68
+ - store_artifacts:
69
+ path: /tmp/test-results
70
+ destination: test-results
71
+
72
+ build_gem:
73
+ <<: *defaults
74
+
75
+ steps:
76
+ - run:
77
+ name: Set up environment
78
+ command: |
79
+ sudo apt-get update && sudo apt-get install -y apt-transport-https apt-utils
80
+
81
+ - checkout
82
+
83
+ - restore_cache:
84
+ keys:
85
+ - sendgrid_webapi-dependencies-v1-{{ checksum "sendgrid_webapi.gemspec" }}
86
+ - sendgrid_webapi-dependencies-v1-
87
+
88
+ - run:
89
+ name: Install dependencies
90
+ command: |
91
+ gem install gemfury
92
+ bundle check --path=./vendor/bundle || bundle install --path=./vendor/bundle --jobs=4 --retry=3
93
+
94
+ - save_cache:
95
+ key: sendgrid_webapi-dependencies-v1-{{ checksum "sendgrid_webapi.gemspec" }}
96
+ paths:
97
+ - ./vendor/bundle
98
+
99
+ - run:
100
+ name: Build gem
101
+ command: |
102
+ gem build sendgrid_webapi.gemspec
103
+
104
+ - run:
105
+ name: Push gem
106
+ command: |
107
+ if [[ "${CIRCLE_PROJECT_USERNAME}" == "OneHQ" && "${CIRCLE_BRANCH}" == "master" && -n "${RUBYGEMS_API_KEY}" ]]; then
108
+ bash .circleci/setup-rubygems.sh
109
+ version=$(ruby -e 'load "lib/version.rb"; puts SendGridWebApi::VERSION')
110
+ grep -q "${version}" <(gem search sendgrid_api) || EXIT_CODE=$? && true
111
+ if [[ $EXIT_CODE == 1 ]]; then
112
+ gem push sendgrid_webapi-${version}.gem
113
+ git tag ${version}
114
+ git push --tags
115
+
116
+ [[ -n "$SLACK_TOKEN" ]] && curl -s -d "sendgrid_webapi ($version) released." "https://onehq.slack.com/services/hooks/slackbot?token=${SLACK_TOKEN}&channel=%23machines"
117
+ fi
118
+ fi
119
+
120
+ workflows:
121
+ version: 2
122
+ build-deploy:
123
+ jobs:
124
+ - run_specs
125
+ - build_gem:
126
+ requires:
127
+ - run_specs
128
+ filters:
129
+ branches:
130
+ only:
131
+ - master
132
+ - staging
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ mkdir -p ~/.gem
4
+ echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
5
+ chmod 0600 /home/circleci/.gem/credentials
data/.gitignore CHANGED
@@ -1,5 +1,31 @@
1
1
  *.gem
2
+ *.pgz
3
+ *.tmproj
2
4
  .bundle
5
+ .DS_Store
6
+ .gitconfig
7
+ .idea
3
8
  .rvmrc
9
+ .sass-cache
10
+ /.ey_local_data
11
+ /.ruby-gemset
12
+ /.vagrant
13
+ bin/*
14
+ config/*.sphinx.conf
15
+ config/database.yml
16
+ config/sphinx.yml
17
+ db/sphinx/
18
+ Gemfile.lock
19
+ log
20
+ log/*.log
21
+ project.rvmrc
22
+ public/assets
23
+ public/flash/*.swf
24
+ public/javascripts/packaged/*.js
25
+ public/packages/*
26
+ public/stylesheets/packaged/*.css
27
+ spec/internal/config/database.yml
28
+ sphinx/**/*
29
+ tmp
30
+ tmp/**/*
4
31
  Gemfile.lock
5
- pkg/*
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --colour
2
- --format nested
1
+ --color
2
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.0
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.3.6
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2021 Kyle Ginavan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc CHANGED
@@ -1,4 +1,5 @@
1
- = SendGrid WEB API gem for Rails 3 {<img src="https://secure.travis-ci.org/kylejginavan/sendgrid_webapi.png"/>}[http://travis-ci.org/kylejginavan/sendgrid_webapi]
1
+ = SendGrid WEB API gem for Rails 3
2
+ {<img src="https://secure.travis-ci.org/kylejginavan/sendgrid_webapi.png"/>}[http://travis-ci.org/kylejginavan/sendgrid_webapi] {<img src="https://badge.fury.io/rb/sendgrid_webapi.png" alt="Gem Version" />}[http://badge.fury.io/rb/sendgrid_webapi] {<img src="https://codeclimate.com/github/kylejginavan/sendgrid_webapi.png" />}[https://codeclimate.com/github/kylejginavan/sendgrid_webapi]
2
3
 
3
4
  SendGrid WEB API gem allow you to retrieve information such as statistics, bounces, spam reports, unsubscribes, send email and other information.
4
5
 
@@ -6,13 +7,19 @@ SendGrid WEB API gem allow you to retrieve information such as statistics, bounc
6
7
 
7
8
  In your Gemfile:
8
9
 
9
- gem 'sendgrid_webapi'
10
+ for sendgrid v3 support
11
+
12
+ gem 'sendgrid_webapi', '0.0.3'
13
+
14
+ for sendgrid v2 support
15
+
16
+ gem 'sendgrid_webapi', '0.0.2'
10
17
 
11
18
  == Usage examples
12
19
 
13
20
  === Creating client object:
14
21
 
15
- client = SendGridWebApi::Client.new("user_name", "password")
22
+ client = SendGridWebApi::Client.new("apikey")
16
23
 
17
24
  == Modules
18
25
 
@@ -23,7 +30,9 @@ This module allows you to retrieve and delete email addresses that have bounced
23
30
 
24
31
  client.bounces.delete(:email => "email@example.com", :foor => "bar")
25
32
 
26
- * options are available here: http://docs.sendgrid.com/documentation/api/web-api/webapibounces
33
+ client.blocks.count
34
+
35
+ * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/bounces.html
27
36
 
28
37
  === Blocks
29
38
  This module allows you to retrieve and delete email addresses that were blocked by their ISP. These emails are not suppressed and are just for information.
@@ -32,7 +41,9 @@ This module allows you to retrieve and delete email addresses that were blocked
32
41
 
33
42
  client.blocks.delete(:email => "email@example.com", :foor => "bar")
34
43
 
35
- * options are available here: http://docs.sendgrid.com/documentation/api/web-api/webapiblocks
44
+ client.blocks.count
45
+
46
+ * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/blocks.html
36
47
 
37
48
  === Invalid Email
38
49
  This module allows you to retrieve and delete email addresses that you've sent to that are invalid email addresses.
@@ -41,7 +52,7 @@ This module allows you to retrieve and delete email addresses that you've sent t
41
52
 
42
53
  client.invalid_emails.delete(:email => "email@example.com", :foor => "bar")
43
54
 
44
- * options are available here: http://docs.sendgrid.com/documentation/api/web-api/webapiinvalidemails
55
+ * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/invalid_emails.html
45
56
 
46
57
  === Spam Report
47
58
  This module allows you to retrieve and delete email addresses that have marked your emails as SPAM.
@@ -50,7 +61,7 @@ This module allows you to retrieve and delete email addresses that have marked y
50
61
 
51
62
  client.spam.delete(:email => "email@example.com", :foor => "bar")
52
63
 
53
- * options are available here: http://docs.sendgrid.com/documentation/api/web-api/webapispamreports
64
+ * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/spam_reports.html
54
65
 
55
66
  === Unsubscribes
56
67
  This module allows you to add, retrieve and delete email addresses that were unsubscribed from your emails.
@@ -61,18 +72,18 @@ This module allows you to add, retrieve and delete email addresses that were uns
61
72
 
62
73
  client.unsubscribes.delete(:email => "email@example.com", :foor => "bar")
63
74
 
64
- * options are available here: http://docs.sendgrid.com/documentation/api/web-api/webapiunsubscribes
75
+ * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/unsubscribes.html
65
76
 
66
77
  === Parse Email
67
78
  This module allows you to add, edit, or delete your email parse settings.
68
79
 
69
- client.parse_emails.add(:hostname => "www.example.com", :url => "www.domain.com/parse.php", :spam_check => 1)
80
+ client.parse_email.add(:hostname => "www.example.com", :url => "www.domain.com/parse.php", :spam_check => 1)
70
81
 
71
- client.parse_emails.get(options)
82
+ client.parse_email.get(options)
72
83
 
73
- client.parse_emails.delete(:hostname => "www.example.com")
84
+ client.parse_email.delete(:hostname => "www.example.com")
74
85
 
75
- * options are available here: http://docs.sendgrid.com/documentation/api/web-api/webapiparse
86
+ * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/parse_settings.html
76
87
 
77
88
  === Event Notification URL
78
89
  This module allows you to add, edit, or delete an event notification URL for your account.
@@ -83,7 +94,7 @@ This module allows you to add, edit, or delete an event notification URL for you
83
94
 
84
95
  client.event_notification.delete(options)
85
96
 
86
- * options are available here: http://docs.sendgrid.com/documentation/api/web-api/event-notification-url
97
+ * options are available here: http://sendgrid.com/docs/API_Reference/Webhooks/event.html
87
98
 
88
99
 
89
100
  === Stats
@@ -91,36 +102,36 @@ This module allows you to retrieve statistical data on a range of metrics includ
91
102
 
92
103
  client.stats.get(options)
93
104
 
94
- * options are available here: http://docs.sendgrid.com/documentation/api/web-api/event-notification-url
105
+ * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/Statistics/index.html
95
106
 
96
107
  === Profile
97
108
  This module allows you to retrieve and update your profile information such as credentials and email address.
98
109
 
99
110
  client.profile.get(options)
100
-
111
+
101
112
  client.profile.set(options)
102
-
113
+
103
114
  client.profile.set_password(:password => "foo", :confirm_password => "foo")
104
115
 
105
116
  client.profile.set_username(:username => "yournewusername@domain.com")
106
-
117
+
107
118
  client.profile.set_email(:email => "yournewusername@domain.com")
108
119
 
109
- * options are available here: http://docs.sendgrid.com/documentation/api/web-api/webapiprofile
120
+ * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/profile.html
110
121
 
111
122
 
112
123
  === Mail
113
124
  This module allows you to send email.
114
-
125
+
115
126
  client.mail.send(:to => "test@test.com", :subject => "test", :text => "some body", :from => "test@example.com")
116
-
117
- * options are available here: http://docs.sendgrid.com/documentation/api/web-api/mail/
127
+
128
+ * options are available here: http://sendgrid.com/docs/Code_Examples/ruby.html
118
129
 
119
130
  == SubUser
120
131
 
121
132
  === Creating client object:
122
133
 
123
- client = SendGridWebApi::Client.new("user_name", "password")
134
+ client = SendGridWebApi::Client.new("apikey")
124
135
 
125
136
  client.sub_user
126
137
 
@@ -128,7 +139,7 @@ This module allows you to send email.
128
139
  == Modules
129
140
 
130
141
  === Management SubUsers
131
- Retrieve/Create/Enable/Disable your subusers. Change a subuser email address and username.
142
+ Retrieve/Create/Enable/Disable your subusers. Change a subuser email address and username. Docs can be found here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/index.html
132
143
 
133
144
  Create a sub_user
134
145
 
@@ -157,14 +168,14 @@ Disable a subuser to login to the SendGrid.com website
157
168
  Allows you to update your subusers profile information
158
169
 
159
170
  client.sub_user.management.update(:user => "sub_user", :first_name => "change_named")
160
-
171
+
161
172
  client.sub_user.management.update_password(:user => "sub_user", :password => "somepassword", :confirm_password => "somepassword")
162
173
 
163
174
  client.sub_user.management.update_username(:user => "sub_user", :username => "newusername")
164
-
175
+
165
176
  client.sub_user.management.update_email(:user => "sub_user", :email => "newemail")
166
-
167
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/subusers/
177
+
178
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/subusers.html
168
179
 
169
180
  === Bounces
170
181
  This module allows you to manage bounce records of your subusers.
@@ -173,7 +184,7 @@ This module allows you to manage bounce records of your subusers.
173
184
 
174
185
  client.sub_user.bounces.delete(:user => "sub_user", :email => "email@example.com")
175
186
 
176
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-subuser-api-v1/email-list-management/subuser-bounces/
187
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/subuser_bounces.html
177
188
 
178
189
  === Invalid Email
179
190
  This module allows you to manage invalid emails of your subusers.
@@ -182,7 +193,7 @@ This module allows you to manage invalid emails of your subusers.
182
193
 
183
194
  client.sub_user.invalid_emails.delete(:user => "sub_user", :email => "email@example.com")
184
195
 
185
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/subuser-invalid-emails/
196
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/invalid_emails.html
186
197
 
187
198
  === Spam Report
188
199
  This module allows you to manage spam reports of your subusers.
@@ -191,7 +202,7 @@ This module allows you to manage spam reports of your subusers.
191
202
 
192
203
  client.sub_user.spam.delete(:user => "sub_user", :email => "email@example.com")
193
204
 
194
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-subuser-api-v1/email-list-management/subuser-spam-reports/
205
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/subuser_spam_reports.html
195
206
 
196
207
  === Unsubscribes
197
208
  This module allows you to manage unsubscribes of your subusers.
@@ -202,18 +213,18 @@ This module allows you to manage unsubscribes of your subusers.
202
213
 
203
214
  client.sub_user.unsubscribes.delete(:user => "sub_user", :email => "email@example.com")
204
215
 
205
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-subuser-api-v1/email-list-management/subusers-unsubscribes/
216
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/subuser_unsubscribes.html
206
217
 
207
218
  === Parse Email
208
219
  This module allows you to setup subusers parse settings
209
220
 
210
- client.sub_user.parse_emails.add(:user => "sub_user", :hostname => "www.example.com", :url => "www.domain.com/parse.php", :spam_check => 1)
221
+ client.sub_user.parse_email.add(:user => "sub_user", :hostname => "www.example.com", :url => "www.domain.com/parse.php", :spam_check => 1)
211
222
 
212
- client.sub_user.parse_emails.get(:user => "sub_user")
223
+ client.sub_user.parse_email.get(:user => "sub_user")
213
224
 
214
- client.sub_user.parse_emails.delete(:user => "sub_user", :hostname => "www.example.com")
225
+ client.sub_user.parse_email.delete(:user => "sub_user", :hostname => "www.example.com")
215
226
 
216
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/parse-settings/
227
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/parse_settings.html
217
228
 
218
229
  === Event Notification URL
219
230
  This module allows you to manage subusers event notification url.
@@ -224,7 +235,7 @@ This module allows you to manage subusers event notification url.
224
235
 
225
236
  client.sub_user.event_notification.delete(:user => "sub_user", :url => "http://www.yourposturlhere.com")
226
237
 
227
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/event-notification-url/
238
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/event_notification_url.html
228
239
 
229
240
 
230
241
  === Stats
@@ -232,38 +243,38 @@ This module allows you to see statistics regarding your subusers.
232
243
 
233
244
  client.sub_user.stats.get(:user => "sub_user")
234
245
 
235
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/statistics/
246
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/statistics.html
236
247
 
237
248
  === Limits
238
249
  This module allows you to manage the rate of emails your subusers are able to send
239
250
 
240
251
  client.sub_user.limits.get(:user => "sub_user")
241
-
252
+
242
253
  client.sub_user.limits.set_credits(:user => "sub_user", :credits=> "200", :period=> "daily")
243
-
254
+
244
255
  client.sub_user.limits.reset(:user => "sub_user", :credits=> "400", :period=> "daily")
245
-
256
+
246
257
  client.sub_user.limits.increment_credits(:user => "sub_user", :credits=> "400")
247
-
258
+
248
259
  client.sub_user.limits.decrement_credits(:user => "sub_user", :credits=> "400")
249
260
 
250
261
  To remove all limits from your sub_user
251
262
 
252
263
  client.sub_user.limits.delete(:user => "sub_user")
253
264
 
254
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/account-limits/
265
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/account_limits.html
255
266
 
256
267
 
257
268
  === Monitor Records
258
269
  Make sure your subusers arent sending out spam by getting a sample of their outgoing messages
259
270
 
260
271
  client.sub_user.monitor_records.create(:name => "testmonitor", :frequency => 10000, :email => "test@test.com")
261
-
272
+
262
273
  client.sub_user.monitor_records.edit(:name => "testmonitor", :new_frequency => 10)
263
-
274
+
264
275
  client.sub_user.monitor_records.add_user(:user => "sub_user", :name => "testmonitor")
265
-
266
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/monitor-records/
276
+
277
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/monitor_records.html
267
278
 
268
279
  === IP Management
269
280
  List all IP addresses you have under your account and retrieve details about them
@@ -273,14 +284,14 @@ To obtain a complete list of all IP's and which are free, taken or available. Se
273
284
  client.sub_user.ip_management.get(:user => "sub_user")
274
285
 
275
286
  To get the ip that is using your sub_user
276
-
287
+
277
288
  client.sub_user.ip_management.usage_ip(:user => "sub_user")
278
-
279
- To assign one ip to your sub_user
280
-
289
+
290
+ To assign one ip to your sub_user
291
+
281
292
  client.sub_user.ip_management.assign_ip(:user => "sub_user", :ip => ["IP1", "IP2"])
282
293
 
283
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/ip-management/
294
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/ip_management.html
284
295
 
285
296
  === WhiteLabel
286
297
  Manage whitelabel settings for your subusers
@@ -294,52 +305,65 @@ To set a subusers whitelabel domain
294
305
  client.sub_user.whitelabel.add(:user => "sub_user", :mail_domain => "email.sendgrid.com")
295
306
 
296
307
 
297
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/whitelabel/
298
-
308
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/whitelabel.html
309
+
299
310
 
300
311
  === IFrame
301
312
  Allow users to manage your subusers via iframe using our site
302
313
 
303
314
  client.sub_user.iframe.get(:user => "sub_user")
304
315
 
305
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/automatic-login/
306
-
307
-
308
- === Parse Email
309
- This module allows you to setup subusers parse settings.
310
-
311
- client.sub_user.parse_emails.add(:user => "sub_user", :hostname => "www.example.com", :url => "www.domain.com/parse.php", :spam_check => 1)
312
-
313
- client.sub_user.parse_emails.get(:user => "sub_user")
314
-
315
- client.sub_user.parse_emails.delete(:user => "sub_user", :hostname => "www.example.com")
316
-
317
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/parse-settings/
316
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/automatic_login.html
318
317
 
319
318
 
320
319
  === Authentication
321
320
  This module allows you to check subusers password to see if its valid.
322
321
 
323
322
  client.sub_user.auth.login(:user => "sub_user", :password => "somepass").
324
-
325
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/authenticate-a-subuser/
323
+
324
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/authenticate_a_subuser.html
326
325
 
327
326
 
328
327
  === Apps
329
328
  This module allows you to setup subusers app settings.
330
329
 
331
330
  client.sub_user.apps.list(:user => "sub_user")
332
-
331
+
333
332
  client.sub_user.apps.activate(:user => "sub_user", :name => "opentrack")
334
333
 
335
334
  client.sub_user.apps.deactivate(:user => "sub_user", :name => "opentrack")
336
-
335
+
337
336
  client.sub_user.apps.current_settings(:user => "sub_user", :name => "eventnotify")
338
-
339
- client.sub_user.apps.customize(:user => "sub_user", :name => "eventnotify", :processed => "0", :dropped => "1", :deferred => "1", :delivered => "0", :bounce => "1", :click => "1", :open => "1", :unsubscribe => "1", :spamreport => "1", :url => "http://someurl.com/listener"))
340
-
341
- * options are available here: http://docs.sendgrid.com/documentation/api/customer-subuser-api/customer-api/filter-apps/
342
337
 
338
+ client.sub_user.apps.customize(:user => "sub_user", :name => "eventnotify", :processed => "0", :dropped => "1", :deferred => "1", :delivered => "0", :bounce => "1", :click => "1", :open => "1", :unsubscribe => "1", :spamreport => "1", :url => "http://someurl.com/listener"))
339
+
340
+ * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/apps.html
341
+
342
+
343
+ === Apikey
344
+ This module allows you to manage apikeys
345
+
346
+ client.apikey.management.get
347
+
348
+ client.apikey.management.get({ on_behalf_of: "SUB_USERNAME" })
349
+
350
+ client.apikey.management.get({ apikey_id: "APIKEY_ID" })
351
+
352
+ client.apikey.management.get({ on_behalf_of: "SUB_USERNAME" })
353
+
354
+ client.apikey.management.create({ "name" => "APIKEY NAME", "scopes" => ["mail.send"] })
355
+
356
+ client.apikey.management.create({ on_behalf_of: "SUB_USERNAME", "name" => "APIKEY NAME", "scopes" => ["mail.send"] })
357
+
358
+ client.apikey.management.update("APIKEY_ID", { "name" => "NEW APIKEY NAME"})
359
+
360
+ client.apikey.management.update("APIKEY_ID", { on_behalf_of: "SUB_USERNAME", "name" => "NEW APIKEY NAME"})
361
+
362
+ client.apikey.management.delete("APIKEY_ID")
363
+
364
+ client.apikey.management.delete("APIKEY_ID", { on_behalf_of: "SUB_USERNAME" })
365
+
366
+ * options are available here: https://sendgrid.com/docs/api-reference/
343
367
 
344
368
  == Helper
345
369
 
@@ -351,18 +375,18 @@ define the data
351
375
  user_hash = {:website => "someurl.com", :password => "somepass", :confirm_password => "somepass",
352
376
  :first_name => "home", :last_name => "simpson", :address => "555 anystreet", :city => "any city",
353
377
  :state => "CA" , :zip => "91234", :email => "email@email.com", :country => "US", :phone => "555-555"}
354
-
378
+
355
379
  apps = { :opentrack => {:name => "eventnotify", :processed => "0", :dropped => "1", :deferred => "1",
356
- :delivered => "0", :bounce => "1", :click => "1", :open => "1", :unsubscribe => "1", :spamreport => "1",
380
+ :delivered => "0", :bounce => "1", :click => "1", :open => "1", :unsubscribe => "1", :spamreport => "1",
357
381
  :url => "https://agencieshq.com/sendgrid/v1/listener"},
358
382
  :clicktrack => {:enable_text => "1"},
359
383
  :opentrack => {}
360
384
  }
361
385
 
362
386
  users = {"username" => {:account => user_hash, :applications => apps, :assigned_ips => ["IP"]}}
363
-
387
+
364
388
  call the helper
365
-
389
+
366
390
  create_sub_user_account("sendgrid user", "sendgrid pass", users)
367
391
 
368
392
  === Run SendGrid Query
@@ -386,4 +410,4 @@ The API call was unsuccessful. The gem will return ApiException raise.
386
410
  == CONTRIBUTORS:
387
411
 
388
412
  * Kyle J. Ginavan.
389
- * Mauro Torres - http://github.com/chebyte
413
+ * Mauro Torres - http://github.com/chebyte