sendgrid_webapi 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/setup-rubygems.sh +1 -1
  3. data/.rspec +0 -1
  4. data/README.rdoc +27 -2
  5. data/lib/api_key/management.rb +33 -0
  6. data/lib/api_key/modules.rb +10 -0
  7. data/lib/apikey_client.rb +11 -0
  8. data/lib/base.rb +39 -8
  9. data/lib/helper.rb +8 -8
  10. data/lib/sendgrid_webapi.rb +1 -0
  11. data/lib/sub_user/modules.rb +15 -15
  12. data/lib/version.rb +1 -1
  13. data/lib/web_api/modules.rb +15 -11
  14. data/spec/cassettes/client/_modules/_block/should_get_block_emails.yml +1 -1
  15. data/spec/cassettes/client/_modules/_block/should_get_totals_blocks.yml +1 -1
  16. data/spec/cassettes/client/_modules/_block/should_try_delete_not_existing_block_email.yml +1 -1
  17. data/spec/cassettes/client/_modules/_bounce/should_get_bounce_emails.yml +1 -1
  18. data/spec/cassettes/client/_modules/_bounce/should_get_totals_bounces.yml +1 -1
  19. data/spec/cassettes/client/_modules/_bounce/should_try_delete_not_existing_bounce_email.yml +1 -1
  20. data/spec/cassettes/client/_modules/_event_notification/should_delete_event_notification_url.yml +1 -1
  21. data/spec/cassettes/client/_modules/_event_notification/should_get_event_notification_url.yml +1 -1
  22. data/spec/cassettes/client/_modules/_event_notification/should_set_event_notification_url.yml +1 -1
  23. data/spec/cassettes/client/_modules/_invalid_email/should_get_invalid_emails.yml +1 -1
  24. data/spec/cassettes/client/_modules/_invalid_email/should_try_delete_not_existing_invalid_emails.yml +1 -1
  25. data/spec/cassettes/client/_modules/_parse_email/should_delete_parse_email.yml +2 -2
  26. data/spec/cassettes/client/_modules/_parse_email/should_get_parse_email.yml +1 -1
  27. data/spec/cassettes/client/_modules/_parse_email/should_set_parse_email.yml +1 -1
  28. data/spec/cassettes/client/_modules/_profile/should_get_profile.yml +1 -1
  29. data/spec/cassettes/client/_modules/_profile/should_set_first_name.yml +3 -3
  30. data/spec/cassettes/client/_modules/_spam/should_get_spam_emails.yml +1 -1
  31. data/spec/cassettes/client/_modules/_spam/should_try_delete_not_existing_spam_emails.yml +1 -1
  32. data/spec/cassettes/client/_modules/_unsubscribe/should_add_unsubscribe_emails.yml +1 -1
  33. data/spec/cassettes/client/_modules/_unsubscribe/should_delete_unsubscribe_email.yml +1 -1
  34. data/spec/cassettes/client/_modules/_unsubscribe/should_get_unsubscribe_emails.yml +1 -1
  35. data/spec/cassettes/client/_modules/_unsubscribe/should_try_delete_not_existing_unsubscribe_emails.yml +1 -1
  36. data/spec/cassettes/helper/_create_sub_user_account/should_create_sub_user_account.yml +6 -6
  37. data/spec/cassettes/helper/_run_sendgrid_query/should_raise_with_unsucessfull_request.yml +1 -1
  38. data/spec/cassettes/helper/_run_sendgrid_query/should_run_sendgrid_request.yml +1 -1
  39. data/spec/cassettes/sub_user/_apps/should_activate_app.yml +1 -1
  40. data/spec/cassettes/sub_user/_apps/should_deactivate_app.yml +1 -1
  41. data/spec/cassettes/sub_user/_apps/should_get_current_setting_from_one_app.yml +1 -1
  42. data/spec/cassettes/sub_user/_apps/should_return_available_apps.yml +1 -1
  43. data/spec/cassettes/sub_user/_apps/should_set_current_app.yml +1 -1
  44. data/spec/cassettes/sub_user/_authentication/should_auth_a_sub_user.yml +1 -1
  45. data/spec/cassettes/sub_user/_authentication/should_return_error_with_a_bad_sub_user.yml +1 -1
  46. data/spec/cassettes/sub_user/_bounces/should_returns_bounce_emails.yml +1 -1
  47. data/spec/cassettes/sub_user/_bounces/should_tries_to_delete_unexisting_bounce_emails.yml +1 -1
  48. data/spec/cassettes/sub_user/_event_notification/should_add_event_notification_url.yml +1 -1
  49. data/spec/cassettes/sub_user/_event_notification/should_delete_event_notification_url.yml +1 -1
  50. data/spec/cassettes/sub_user/_event_notification/should_get_event_notification_url.yml +1 -1
  51. data/spec/cassettes/sub_user/_invalid_emails/should_return_invalid_emails.yml +1 -1
  52. data/spec/cassettes/sub_user/_invalid_emails/should_tries_to_delete_unexisting_invalid_mail.yml +1 -1
  53. data/spec/cassettes/sub_user/_ip_management/should_return_all_ips_available.yml +1 -1
  54. data/spec/cassettes/sub_user/_ip_management/should_show_ip_subuser.yml +1 -1
  55. data/spec/cassettes/sub_user/_limits/should_decrements_credits_for_a_sub_user.yml +2 -2
  56. data/spec/cassettes/sub_user/_limits/should_delete_all_limits_for_a_sub_user.yml +2 -2
  57. data/spec/cassettes/sub_user/_limits/should_increments_credits_for_a_sub_user.yml +2 -2
  58. data/spec/cassettes/sub_user/_limits/should_list_the_limits_for_a_sub_user.yml +1 -1
  59. data/spec/cassettes/sub_user/_limits/should_reset_all_limits_for_a_sub_user.yml +2 -2
  60. data/spec/cassettes/sub_user/_limits/should_returns_limits_for_a_sub_user.yml +1 -1
  61. data/spec/cassettes/sub_user/_limits/should_set_total_credits.yml +1 -1
  62. data/spec/cassettes/sub_user/_management/should_add_new_subuser.yml +1 -1
  63. data/spec/cassettes/sub_user/_management/should_disable_sub_user_for_send_email.yml +1 -1
  64. data/spec/cassettes/sub_user/_management/should_enable_sub_user_for_access_to_website.yml +1 -1
  65. data/spec/cassettes/sub_user/_management/should_enable_sub_user_for_send_email.yml +1 -1
  66. data/spec/cassettes/sub_user/_management/should_update_sub_user.yml +1 -1
  67. data/spec/cassettes/sub_user/_monitor_records/should_add_existing_sub_user_to_monitor_record.yml +2 -2
  68. data/spec/cassettes/sub_user/_monitor_records/should_create_a_new_monitor_record.yml +2 -2
  69. data/spec/cassettes/sub_user/_monitor_records/should_delete_a_monitor_record.yml +2 -2
  70. data/spec/cassettes/sub_user/_monitor_records/should_edit_a_monitor_record.yml +2 -2
  71. data/spec/cassettes/sub_user/_monitor_records/should_remove_existing_sub_user_from_monitor_record.yml +2 -2
  72. data/spec/cassettes/sub_user/_parse_email/should_delete_parse_email.yml +2 -2
  73. data/spec/cassettes/sub_user/_parse_email/should_get_parse_email.yml +1 -1
  74. data/spec/cassettes/sub_user/_parse_email/should_set_parse_email.yml +1 -1
  75. data/spec/cassettes/sub_user/_spam/should_return_spam_mails.yml +1 -1
  76. data/spec/cassettes/sub_user/_spam/should_tries_to_delete_unexisting_spam_mail.yml +1 -1
  77. data/spec/cassettes/sub_user/_unsubscribes/should_add_bounce_email.yml +1 -1
  78. data/spec/cassettes/sub_user/_unsubscribes/should_delete_existing_bounce_email.yml +1 -1
  79. data/spec/cassettes/sub_user/_unsubscribes/should_delete_unexisting_bounce_email.yml +1 -1
  80. data/spec/cassettes/sub_user/_unsubscribes/should_returns_bounce_emails.yml +1 -1
  81. data/spec/client_spec.rb +2 -2
  82. data/spec/helper_spec.rb +4 -4
  83. data/spec/sub_user_spec.rb +1 -1
  84. data/test.rb +1 -1
  85. metadata +84 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c318215ba8b2b1023891b605e2b47857d7af9ab5592b0f741fa9947b1815af45
4
- data.tar.gz: b39d21419377d4808a0dcd3bddebf838d30f00534cc95fefa5850ac06ab13fc3
3
+ metadata.gz: 87c6ec1a7f2e80f0035f7d2684ddd206f28ced646c849d4a7e96625a92dd0028
4
+ data.tar.gz: 8f22f5a4195044a4d26658094a9c6b677a93471f61c96d96ab4f4fa474e95a8d
5
5
  SHA512:
6
- metadata.gz: 969e60cd620a4397735a996e01050e07300083c09eaa0ac13f7f175262b62d09cf0c282ea28b6bb457ca8a24bb91d5616ef21a1f51f17438d2aa58c4a07696da
7
- data.tar.gz: eac4a40143a43526a572289cedc047dd3813ca3aacd3760cc36437913110945f6222e9a74204d142a1a26a5ed3529084b35b96f7ea40ae457c3ce77a7fae6b94
6
+ metadata.gz: 38bc99e1615e4dd74977421d7a39ead0ec5524f7d95ec80436176058f4beb02afbd40ac9d13a635ba4e2f81c7239b0b529b657a8e444406cbab24f641d182104
7
+ data.tar.gz: 65e22460494c7c7d256df1d8beb06df64edee592b6099612ba305d43dc67a3ef28b76c90668470a7046151b35c33c413a715674b74f2808673536cd96fc08222
@@ -1,5 +1,5 @@
1
1
  #!/bin/sh
2
2
 
3
- mkdir ~/.gem
3
+ mkdir -p ~/.gem
4
4
  echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
5
5
  chmod 0600 /home/circleci/.gem/credentials
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
- --format Fuubar
2
1
  --color
3
2
  --require spec_helper
data/README.rdoc CHANGED
@@ -19,7 +19,7 @@ for sendgrid v2 support
19
19
 
20
20
  === Creating client object:
21
21
 
22
- client = SendGridWebApi::Client.new("user_name", "password")
22
+ client = SendGridWebApi::Client.new("apikey")
23
23
 
24
24
  == Modules
25
25
 
@@ -131,7 +131,7 @@ This module allows you to send email.
131
131
 
132
132
  === Creating client object:
133
133
 
134
- client = SendGridWebApi::Client.new("user_name", "password")
134
+ client = SendGridWebApi::Client.new("apikey")
135
135
 
136
136
  client.sub_user
137
137
 
@@ -340,6 +340,31 @@ This module allows you to setup subusers app settings.
340
340
  * options are available here: http://sendgrid.com/docs/API_Reference/Customer_Subuser_API/apps.html
341
341
 
342
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/
367
+
343
368
  == Helper
344
369
 
345
370
  === Create Sub User
@@ -0,0 +1,33 @@
1
+ module SendGridWebApi::ApiKeyModules
2
+ class Management < SendGridWebApi::ApiKey
3
+ APIKEY_URL = "api_keys"
4
+
5
+ def get options = {}
6
+ management_get_url = APIKEY_URL
7
+ if options.key?(:apikey_id)
8
+ management_get_url += "/#{options[:apikey_id]}"
9
+ options.delete(:apikey_id)
10
+ end
11
+ query_api(management_get_url, process_header_options(options))
12
+ end
13
+
14
+ def create options = {}
15
+ query_post_json_api(APIKEY_URL, process_header_options(options))
16
+ end
17
+
18
+ def delete apikey_id, options = {}
19
+ query_delete_api(APIKEY_URL+"/#{apikey_id}", process_header_options(options))
20
+ end
21
+
22
+ def update apikey_id, options = {}
23
+ query_patch_api(APIKEY_URL+"/#{apikey_id}", process_header_options(options))
24
+ end
25
+
26
+ private
27
+ def process_header_options options
28
+ on_behalf_of = options.delete(:on_behalf_of)
29
+ options.merge!({ headers: { "on-behalf-of" => on_behalf_of } }) unless on_behalf_of.nil?
30
+ options
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+ #loading modules
2
+ %w(management).each do |mod|
3
+ require "api_key/" + mod
4
+ end
5
+
6
+ module SendGridWebApi::ApiKeyModules
7
+ def management
8
+ @management_instance ||= Management.new(@api_key)
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ module SendGridWebApi
2
+ autoload :ApiKeyModules, 'api_key/modules'
3
+
4
+ class ApiKey < Base
5
+ include SendGridWebApi::ApiKeyModules
6
+
7
+ def base_url
8
+ "https://api.sendgrid.com/v3/"
9
+ end
10
+ end
11
+ end
data/lib/base.rb CHANGED
@@ -2,10 +2,9 @@ require 'faraday_middleware'
2
2
 
3
3
  module SendGridWebApi
4
4
  class Base
5
- attr_accessor :api_user, :api_key
5
+ attr_accessor :api_key
6
6
 
7
- def initialize api_user, api_key
8
- @api_user = api_user
7
+ def initialize api_key
9
8
  @api_key = api_key
10
9
  end
11
10
 
@@ -14,17 +13,46 @@ module SendGridWebApi
14
13
  end
15
14
 
16
15
  def builder_options options
17
- options.merge!(:api_user => @api_user, :api_key => @api_key)
18
16
  to_query(options)
19
17
  end
20
18
 
21
19
  def query_api url, options
22
- session.get(make_request_url(url, options)).body
20
+ headers = options.delete(:headers)
21
+ (session.get(make_request_url(url, options)) do |req|
22
+ req.headers.merge!(headers) unless headers.nil?
23
+ end).body
23
24
  end
24
25
 
25
26
  def query_post_api url, options
26
- builder_options(options)
27
- session.post(url, builder_options(options)).body
27
+ headers = options.delete(:headers)
28
+ (session.post(url, builder_options(options)) do |req|
29
+ req.headers.merge!(headers) unless headers.nil?
30
+ end).body
31
+ end
32
+
33
+ def query_post_json_api url, options
34
+ headers = options.delete(:headers)
35
+ (session.post(url) do |req|
36
+ req.headers[:content_type] = 'application/json'
37
+ req.headers.merge!(headers) unless headers.nil?
38
+ req.body = options.to_json
39
+ end).body
40
+ end
41
+
42
+ def query_patch_api url, options
43
+ headers = options.delete(:headers)
44
+ (session.patch(url) do |req|
45
+ req.headers[:content_type] = 'application/json'
46
+ req.headers.merge!(headers) unless headers.nil?
47
+ req.body = options.to_json
48
+ end).body
49
+ end
50
+
51
+ def query_delete_api url, options
52
+ headers = options.delete(:headers)
53
+ (session.delete(make_request_url(url, options)) do |req|
54
+ req.headers.merge!(headers) unless headers.nil?
55
+ end).body
28
56
  end
29
57
 
30
58
  def to_query(options)
@@ -32,7 +60,10 @@ module SendGridWebApi
32
60
  end
33
61
 
34
62
  def session
35
- @connection ||= ::Faraday.new base_url do |conn|
63
+ @connection ||= ::Faraday.new(
64
+ url: base_url,
65
+ headers: {"Authorization" => "Bearer #{@api_key}"}
66
+ ) do |conn|
36
67
  # Forces the connection request and response to be JSON even though
37
68
  # Sendgrids API headers do not specify the content type is JSON
38
69
  conn.request :url_encoded
data/lib/helper.rb CHANGED
@@ -1,33 +1,33 @@
1
1
  module SendGridWebApi::Helper
2
2
  extend self
3
3
 
4
- def run_sendgrid_query(username, password)
5
- @client = SendGridWebApi::Client.new(username, password)
4
+ def run_sendgrid_query(apikey)
5
+ @client = SendGridWebApi::Client.new(apikey)
6
6
  result = yield
7
7
  raise "it returns the following errors: #{result}" unless result.eql?({"message"=>"success"})
8
8
  end
9
9
 
10
10
  ###this accepts subuser array
11
- def create_sub_user_account(username, password, users)
11
+ def create_sub_user_account(apikey, users)
12
12
  users.each do |user, data|
13
13
  #load users
14
- run_sendgrid_query(username, password) do
14
+ run_sendgrid_query(apikey) do
15
15
  @client.sub_user.management.add(data[:account].merge!(:username => user))
16
16
  end
17
17
 
18
18
  #active user for send email
19
- run_sendgrid_query(username, password){@client.sub_user.management.enable(:user => user)}
19
+ run_sendgrid_query(apikey){@client.sub_user.management.enable(:user => user)}
20
20
 
21
21
  #assign ip
22
22
  unless data[:assigned_ips].empty?
23
- run_sendgrid_query(username, password){@client.sub_user.ip_management.assign_ip :user => user, :ip => data[:assigned_ips]}
23
+ run_sendgrid_query(apikey){@client.sub_user.ip_management.assign_ip :user => user, :ip => data[:assigned_ips]}
24
24
  end
25
25
  #load apps
26
26
  unless data[:applications].empty?
27
27
  data[:applications].each do |app_name, options|
28
- run_sendgrid_query(username, password){@client.sub_user.apps.activate(:user => user, :name => app_name)}
28
+ run_sendgrid_query(apikey){@client.sub_user.apps.activate(:user => user, :name => app_name)}
29
29
  unless options.empty?
30
- run_sendgrid_query(username, password){@client.sub_user.apps.customize(options.merge!(:user => user, :name => app_name))}
30
+ run_sendgrid_query(apikey){@client.sub_user.apps.customize(options.merge!(:user => user, :name => app_name))}
31
31
  end
32
32
  end
33
33
  end
@@ -3,3 +3,4 @@ require 'base'
3
3
  require 'helper'
4
4
  require 'webapi_client'
5
5
  require 'subuser_client'
6
+ require 'apikey_client'
@@ -6,63 +6,63 @@ end
6
6
 
7
7
  module SendGridWebApi::SubUserModules
8
8
  def management
9
- @management_instance ||= Management.new(@api_user, @api_key)
9
+ @management_instance ||= Management.new(@api_key)
10
10
  end
11
11
 
12
12
  def bounces
13
- @bounce_instance ||= Bounce.new(@api_user, @api_key)
13
+ @bounce_instance ||= Bounce.new(@api_key)
14
14
  end
15
15
 
16
16
  def unsubscribes
17
- @unsubscribe_instance ||= Unsubscribe.new(@api_user, @api_key)
17
+ @unsubscribe_instance ||= Unsubscribe.new(@api_key)
18
18
  end
19
19
 
20
20
  def spam
21
- @spam_instance ||= Spam.new(@api_user, @api_key)
21
+ @spam_instance ||= Spam.new(@api_key)
22
22
  end
23
23
 
24
24
  def invalid_emails
25
- @invalid_email_instance ||= InvalidEmail.new(@api_user, @api_key)
25
+ @invalid_email_instance ||= InvalidEmail.new(@api_key)
26
26
  end
27
27
 
28
28
  def event_notification
29
- @event_notification_instance ||= EventNotification.new(@api_user, @api_key)
29
+ @event_notification_instance ||= EventNotification.new(@api_key)
30
30
  end
31
31
 
32
32
  def parse_email
33
- @parse_instance ||= ParseEmail.new(@api_user, @api_key)
33
+ @parse_instance ||= ParseEmail.new(@api_key)
34
34
  end
35
35
 
36
36
  def limits
37
- @limit_instance ||= Limit.new(@api_user, @api_key)
37
+ @limit_instance ||= Limit.new(@api_key)
38
38
  end
39
39
 
40
40
  def stats
41
- @stats_instance ||= Stats.new(@api_user, @api_key)
41
+ @stats_instance ||= Stats.new(@api_key)
42
42
  end
43
43
 
44
44
  def ip_management
45
- @ip_management_instance ||= IpManagement.new(@api_user, @api_key)
45
+ @ip_management_instance ||= IpManagement.new(@api_key)
46
46
  end
47
47
 
48
48
  def monitor_records
49
- @monitor_record_instance ||= MonitorRecord.new(@api_user, @api_key)
49
+ @monitor_record_instance ||= MonitorRecord.new(@api_key)
50
50
  end
51
51
 
52
52
  def white_label
53
- @white_label_instance ||= WhiteLabel.new(@api_user, @api_key)
53
+ @white_label_instance ||= WhiteLabel.new(@api_key)
54
54
  end
55
55
 
56
56
  def iframe
57
- @iframe_instance ||= Iframe.new(@api_user, @api_key)
57
+ @iframe_instance ||= Iframe.new(@api_key)
58
58
  end
59
59
 
60
60
  def auth
61
- @auth_instance ||= Auth.new(@api_user, @api_key)
61
+ @auth_instance ||= Auth.new(@api_key)
62
62
  end
63
63
 
64
64
  def apps
65
- @app_instance ||= App.new(@api_user, @api_key)
65
+ @app_instance ||= App.new(@api_key)
66
66
  end
67
67
 
68
68
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SendGridWebApi
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -5,46 +5,50 @@ end
5
5
 
6
6
  module SendGridWebApi::Modules
7
7
  def bounces
8
- @bounce_instance ||= Bounce.new(@api_user, @api_key)
8
+ @bounce_instance ||= Bounce.new(@api_key)
9
9
  end
10
10
 
11
11
  def blocks
12
- @block_instance ||= Block.new(@api_user, @api_key)
12
+ @block_instance ||= Block.new(@api_key)
13
13
  end
14
14
 
15
15
  def spam
16
- @spam_instance ||= Spam.new(@api_user, @api_key)
16
+ @spam_instance ||= Spam.new(@api_key)
17
17
  end
18
18
 
19
19
  def invalid_emails
20
- @invalid_email_instance ||= InvalidEmail.new(@api_user, @api_key)
20
+ @invalid_email_instance ||= InvalidEmail.new(@api_key)
21
21
  end
22
22
 
23
23
  def unsubscribes
24
- @unsubscribe_instance ||= Unsubscribe.new(@api_user, @api_key)
24
+ @unsubscribe_instance ||= Unsubscribe.new(@api_key)
25
25
  end
26
26
 
27
27
  def parse_email
28
- @parse_email_instance ||= ParseEmail.new(@api_user, @api_key)
28
+ @parse_email_instance ||= ParseEmail.new(@api_key)
29
29
  end
30
30
 
31
31
  def event_notification
32
- @event_notification_instance ||= EventNotification.new(@api_user, @api_key)
32
+ @event_notification_instance ||= EventNotification.new(@api_key)
33
33
  end
34
34
 
35
35
  def stats
36
- @stats_instance ||= Stats.new(@api_user, @api_key)
36
+ @stats_instance ||= Stats.new(@api_key)
37
37
  end
38
38
 
39
39
  def profile
40
- @profile_instance ||= Profile.new(@api_user, @api_key)
40
+ @profile_instance ||= Profile.new(@api_key)
41
41
  end
42
42
 
43
43
  def mail
44
- @mail_instance ||= Mail.new(@api_user, @api_key)
44
+ @mail_instance ||= Mail.new(@api_key)
45
45
  end
46
46
 
47
47
  def sub_user
48
- @sub_user ||= SendGridWebApi::SubUser.new(@api_user, @api_key)
48
+ @sub_user ||= SendGridWebApi::SubUser.new(@api_key)
49
+ end
50
+
51
+ def apikey
52
+ @apikey ||= SendGridWebApi::ApiKey.new(@api_key)
49
53
  end
50
54
  end
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.sendgrid.com/api/blocks.get.json?api_key=pass&api_user=user
5
+ uri: https://api.sendgrid.com/api/blocks.get.json
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.sendgrid.com/api/blocks.count.json?api_key=pass&api_user=user
5
+ uri: https://api.sendgrid.com/api/blocks.count.json
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.sendgrid.com/api/blocks.delete.json?api_key=pass&api_user=user&email=test@example.com
5
+ uri: https://api.sendgrid.com/api/blocks.delete.json?email=test@example.com
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.sendgrid.com/api/bounces.get.json?api_key=pass&api_user=user
5
+ uri: https://api.sendgrid.com/api/bounces.get.json
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''