sendgrid_webapi 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/.rspec +0 -0
  4. data/.ruby-version +0 -0
  5. data/.tekton/Chart.lock +6 -0
  6. data/.tekton/Chart.yaml +14 -0
  7. data/.tekton/templates/pipelinerun.yaml +53 -0
  8. data/.tekton/values-main.yaml +14 -0
  9. data/.tekton/values-pr.yaml +8 -0
  10. data/.tekton/values.yaml +19 -0
  11. data/.tool-versions +0 -0
  12. data/Gemfile +0 -0
  13. data/MIT-LICENSE +0 -0
  14. data/README.rdoc +69 -18
  15. data/Rakefile +0 -0
  16. data/lib/api_key/management.rb +0 -0
  17. data/lib/api_key/modules.rb +0 -0
  18. data/lib/apikey_client.rb +0 -0
  19. data/lib/base.rb +7 -0
  20. data/lib/helper.rb +0 -0
  21. data/lib/middlewares/sendgrid_response.rb +0 -0
  22. data/lib/sendgrid_webapi.rb +0 -0
  23. data/lib/sub_user/apps.rb +0 -0
  24. data/lib/sub_user/auth.rb +0 -0
  25. data/lib/sub_user/bounces.rb +0 -0
  26. data/lib/sub_user/event_notification.rb +0 -0
  27. data/lib/sub_user/iframe.rb +0 -0
  28. data/lib/sub_user/invalid_emails.rb +0 -0
  29. data/lib/sub_user/ip_management.rb +0 -0
  30. data/lib/sub_user/limits.rb +0 -0
  31. data/lib/sub_user/management.rb +0 -0
  32. data/lib/sub_user/modules.rb +0 -0
  33. data/lib/sub_user/monitor_records.rb +0 -0
  34. data/lib/sub_user/parse.rb +0 -0
  35. data/lib/sub_user/spam.rb +0 -0
  36. data/lib/sub_user/stats.rb +0 -0
  37. data/lib/sub_user/unsubscribes.rb +0 -0
  38. data/lib/sub_user/white_label.rb +0 -0
  39. data/lib/subuser_client.rb +0 -0
  40. data/lib/version.rb +1 -1
  41. data/lib/web_api/blocks.rb +20 -7
  42. data/lib/web_api/bounces.rb +19 -6
  43. data/lib/web_api/event_notification.rb +0 -0
  44. data/lib/web_api/invalid_emails.rb +15 -5
  45. data/lib/web_api/mail.rb +0 -0
  46. data/lib/web_api/modules.rb +0 -0
  47. data/lib/web_api/parse.rb +0 -0
  48. data/lib/web_api/profile.rb +0 -0
  49. data/lib/web_api/spam.rb +14 -4
  50. data/lib/web_api/stats.rb +0 -0
  51. data/lib/web_api/unsubscribes.rb +19 -6
  52. data/lib/web_api/version.rb +0 -0
  53. data/lib/webapi_client.rb +0 -0
  54. data/sendgrid_webapi.gemspec +0 -0
  55. data/spec/cassettes/client/_modules/_block/should_get_block_emails.yml +1 -1
  56. data/spec/cassettes/client/_modules/_block/should_get_totals_blocks.yml +2 -2
  57. data/spec/cassettes/client/_modules/_block/should_try_delete_not_existing_block_email.yml +2 -2
  58. data/spec/cassettes/client/_modules/_bounce/should_get_bounce_emails.yml +1 -1
  59. data/spec/cassettes/client/_modules/_bounce/should_get_bounce_emails_using_params.yml +36 -0
  60. data/spec/cassettes/client/_modules/_bounce/should_get_totals_bounces.yml +0 -0
  61. data/spec/cassettes/client/_modules/_bounce/should_try_delete_not_existing_bounce_email.yml +2 -2
  62. data/spec/cassettes/client/_modules/_event_notification/should_delete_event_notification_url.yml +0 -0
  63. data/spec/cassettes/client/_modules/_event_notification/should_get_event_notification_url.yml +0 -0
  64. data/spec/cassettes/client/_modules/_event_notification/should_set_event_notification_url.yml +0 -0
  65. data/spec/cassettes/client/_modules/_invalid_email/should_get_invalid_emails.yml +1 -1
  66. data/spec/cassettes/client/_modules/_invalid_email/should_get_invalid_emails_emails_using_params.yml +37 -0
  67. data/spec/cassettes/client/_modules/_invalid_email/should_get_invalid_emails_using_params.yml +36 -0
  68. data/spec/cassettes/client/_modules/_invalid_email/should_try_delete_not_existing_invalid_emails.yml +2 -2
  69. data/spec/cassettes/client/_modules/_parse_email/should_delete_parse_email.yml +0 -0
  70. data/spec/cassettes/client/_modules/_parse_email/should_get_parse_email.yml +0 -0
  71. data/spec/cassettes/client/_modules/_parse_email/should_set_parse_email.yml +0 -0
  72. data/spec/cassettes/client/_modules/_profile/should_get_profile.yml +0 -0
  73. data/spec/cassettes/client/_modules/_profile/should_set_first_name.yml +0 -0
  74. data/spec/cassettes/client/_modules/_spam/should_get_spam_emails.yml +1 -1
  75. data/spec/cassettes/client/_modules/_spam/should_try_delete_not_existing_spam_emails.yml +2 -2
  76. data/spec/cassettes/client/_modules/_unsubscribe/should_add_unsubscribe_emails.yml +2 -2
  77. data/spec/cassettes/client/_modules/_unsubscribe/should_delete_unsubscribe_email.yml +2 -2
  78. data/spec/cassettes/client/_modules/_unsubscribe/should_get_unsubscribe_emails.yml +1 -1
  79. data/spec/cassettes/client/_modules/_unsubscribe/should_try_delete_not_existing_unsubscribe_emails.yml +3 -3
  80. data/spec/cassettes/helper/_create_sub_user_account/should_create_sub_user_account.yml +0 -0
  81. data/spec/cassettes/helper/_run_sendgrid_query/should_raise_with_unsucessfull_request.yml +0 -0
  82. data/spec/cassettes/helper/_run_sendgrid_query/should_run_sendgrid_request.yml +0 -0
  83. data/spec/cassettes/sub_user/_apps/should_activate_app.yml +0 -0
  84. data/spec/cassettes/sub_user/_apps/should_deactivate_app.yml +0 -0
  85. data/spec/cassettes/sub_user/_apps/should_get_current_setting_from_one_app.yml +0 -0
  86. data/spec/cassettes/sub_user/_apps/should_return_available_apps.yml +0 -0
  87. data/spec/cassettes/sub_user/_apps/should_set_current_app.yml +0 -0
  88. data/spec/cassettes/sub_user/_authentication/should_auth_a_sub_user.yml +0 -0
  89. data/spec/cassettes/sub_user/_authentication/should_return_error_with_a_bad_sub_user.yml +0 -0
  90. data/spec/cassettes/sub_user/_bounces/should_returns_bounce_emails.yml +0 -0
  91. data/spec/cassettes/sub_user/_bounces/should_tries_to_delete_unexisting_bounce_emails.yml +0 -0
  92. data/spec/cassettes/sub_user/_event_notification/should_add_event_notification_url.yml +0 -0
  93. data/spec/cassettes/sub_user/_event_notification/should_delete_event_notification_url.yml +0 -0
  94. data/spec/cassettes/sub_user/_event_notification/should_get_event_notification_url.yml +0 -0
  95. data/spec/cassettes/sub_user/_invalid_emails/should_return_invalid_emails.yml +0 -0
  96. data/spec/cassettes/sub_user/_invalid_emails/should_tries_to_delete_unexisting_invalid_mail.yml +0 -0
  97. data/spec/cassettes/sub_user/_ip_management/should_return_all_ips_available.yml +0 -0
  98. data/spec/cassettes/sub_user/_ip_management/should_show_ip_subuser.yml +0 -0
  99. data/spec/cassettes/sub_user/_limits/should_decrements_credits_for_a_sub_user.yml +0 -0
  100. data/spec/cassettes/sub_user/_limits/should_delete_all_limits_for_a_sub_user.yml +0 -0
  101. data/spec/cassettes/sub_user/_limits/should_increments_credits_for_a_sub_user.yml +0 -0
  102. data/spec/cassettes/sub_user/_limits/should_list_the_limits_for_a_sub_user.yml +0 -0
  103. data/spec/cassettes/sub_user/_limits/should_reset_all_limits_for_a_sub_user.yml +0 -0
  104. data/spec/cassettes/sub_user/_limits/should_returns_limits_for_a_sub_user.yml +0 -0
  105. data/spec/cassettes/sub_user/_limits/should_set_total_credits.yml +0 -0
  106. data/spec/cassettes/sub_user/_management/should_add_new_subuser.yml +0 -0
  107. data/spec/cassettes/sub_user/_management/should_disable_sub_user_for_send_email.yml +0 -0
  108. data/spec/cassettes/sub_user/_management/should_enable_sub_user_for_access_to_website.yml +0 -0
  109. data/spec/cassettes/sub_user/_management/should_enable_sub_user_for_send_email.yml +0 -0
  110. data/spec/cassettes/sub_user/_management/should_update_sub_user.yml +0 -0
  111. data/spec/cassettes/sub_user/_monitor_records/should_add_existing_sub_user_to_monitor_record.yml +0 -0
  112. data/spec/cassettes/sub_user/_monitor_records/should_create_a_new_monitor_record.yml +0 -0
  113. data/spec/cassettes/sub_user/_monitor_records/should_delete_a_monitor_record.yml +0 -0
  114. data/spec/cassettes/sub_user/_monitor_records/should_edit_a_monitor_record.yml +0 -0
  115. data/spec/cassettes/sub_user/_monitor_records/should_remove_existing_sub_user_from_monitor_record.yml +0 -0
  116. data/spec/cassettes/sub_user/_parse_email/should_delete_parse_email.yml +0 -0
  117. data/spec/cassettes/sub_user/_parse_email/should_get_parse_email.yml +0 -0
  118. data/spec/cassettes/sub_user/_parse_email/should_set_parse_email.yml +0 -0
  119. data/spec/cassettes/sub_user/_spam/should_return_spam_mails.yml +0 -0
  120. data/spec/cassettes/sub_user/_spam/should_tries_to_delete_unexisting_spam_mail.yml +0 -0
  121. data/spec/cassettes/sub_user/_unsubscribes/should_add_bounce_email.yml +0 -0
  122. data/spec/cassettes/sub_user/_unsubscribes/should_delete_existing_bounce_email.yml +0 -0
  123. data/spec/cassettes/sub_user/_unsubscribes/should_delete_unexisting_bounce_email.yml +0 -0
  124. data/spec/cassettes/sub_user/_unsubscribes/should_returns_bounce_emails.yml +0 -0
  125. data/spec/client_spec.rb +68 -52
  126. data/spec/helper_spec.rb +2 -3
  127. data/spec/internal/config/database-standard.yml +24 -0
  128. data/spec/spec_helper.rb +0 -4
  129. data/spec/sub_user_spec.rb +0 -0
  130. data/test.rb +0 -0
  131. metadata +17 -80
  132. data/.circleci/config.yml +0 -132
  133. data/.circleci/setup-rubygems.sh +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c4750102028a182ab7e513792ca0f127684c5ce2f59562dbe1997869c7099e9
4
- data.tar.gz: 406420e68b953fca19e900acd80ab5914c689941588c4b056239f2f5f64f6971
3
+ metadata.gz: 3d193cbbc918879debc5aee92e0f7397be4f83a4d876bac7a049dd42c9a9a671
4
+ data.tar.gz: ae235e49239b82ed69de5c93654555cc93f702e6905928e6fb89de0fc6427fe5
5
5
  SHA512:
6
- metadata.gz: d912c4463cb6cf6b77d55444e31302450e395c4b2c0eb14bbd4345b77d83dfbba7b3b5b9b563b0e0fff577a5989a00255c69d731d56c08495bd727eb3f15c358
7
- data.tar.gz: 445d7ef45b7cb2b7325405120ef271ab1c6b13d50a902e83c63e5bebe16f95889c722f06555adedabb08ba4e70eb652eeec810a6a29f4d285dea64ec51def652
6
+ metadata.gz: b65c616400aeeaa7e5bfff61f0626635558986679c3f56b4dc9e42c165c68cdf7998a4b8574a1cc60d2b0c96ce3f18982dfb2d69c197ce065ad29a2285e500fa
7
+ data.tar.gz: 12c01121d669de6b3bdc22d5b44b6036152b8e06495f56542acb541f1600b360f154cfdf1dac279bd94648f0be85587009ae70c9a054f75e99f4aec816fd6f73
data/.gitignore CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.ruby-version CHANGED
File without changes
@@ -0,0 +1,6 @@
1
+ dependencies:
2
+ - name: gem-delivery
3
+ repository: oci://us-docker.pkg.dev/onehq-production/onehq-public/
4
+ version: 0.1.0-dev.7
5
+ digest: sha256:b52b9dc05efeb3ce5eaa793726defb2787e0f27baa6effd2040c998f7be0adce
6
+ generated: "2021-03-27T22:26:28.397590199+01:00"
@@ -0,0 +1,14 @@
1
+ apiVersion: v2
2
+ name: pipeline
3
+ description: A Helm chart for Kubernetes
4
+
5
+ type: application
6
+
7
+ version: 0.1.0
8
+
9
+ dependencies:
10
+ - name: ruby-pipelines
11
+ alias: delivery
12
+ version: "0.2.0-dev.2"
13
+ repository: "oci://public.ecr.aws/c6o8b8d1"
14
+
@@ -0,0 +1,53 @@
1
+ apiVersion: tekton.dev/v1beta1
2
+ kind: PipelineRun
3
+ metadata:
4
+ name: {{ .Release.Name }}-{{ .Release.Revision }}
5
+ annotations:
6
+ "helm.sh/hook": post-upgrade,post-install
7
+ spec:
8
+ serviceAccountName: build-bot
9
+ params:
10
+ - name: ci-image-name
11
+ value: 237082684006.dkr.ecr.us-east-2.amazonaws.com/{{ .Values.gem }}-ci
12
+ - name: gem-name
13
+ value: "{{ .Values.gem }}"
14
+ - name: publish
15
+ value: '{{ .Values.publish }}'
16
+ - name: git-url
17
+ value: "https://{{ .Values.git.provider }}/{{ .Values.git.organization }}/{{ .Values.git.repository }}.git"
18
+ - name: git-sha
19
+ value: "{{ .Values.git.sha }}"
20
+ - name: git-ref
21
+ value: "{{ required "Required .Values.git.ref" .Values.git.ref }}"
22
+ - name: rubyVersion
23
+ value: "{{ .Values.global.rubyVersion }}"
24
+ - name: run-rubocop
25
+ value: "{{ .Values.global.runRubocop }}"
26
+ - name: gem-repository
27
+ value: "{{ .Values.global.gemRepository }}"
28
+ workspaces:
29
+
30
+
31
+ pipelineRef:
32
+ name: gem-delivery
33
+ timeout: 1h30m0s
34
+ podTemplate:
35
+ volumes:
36
+ - name: oidc-token
37
+ projected:
38
+ sources:
39
+ - serviceAccountToken:
40
+ path: oidc-token
41
+ expirationSeconds: 1800
42
+
43
+ workspaces:
44
+ - name: git-source
45
+ volumeClaimTemplate:
46
+ spec:
47
+ storageClassName: rwm
48
+ accessModes:
49
+ - ReadWriteMany # access mode may affect how you can use this volume in parallel tasks
50
+ resources:
51
+ requests:
52
+ storage: 1Gi
53
+
@@ -0,0 +1,14 @@
1
+ publish: true
2
+
3
+ delivery:
4
+ rbac:
5
+ rolebindings:
6
+ - role: edit
7
+ subjects:
8
+ - kind: Group
9
+ name: hq-platform
10
+
11
+ - role: view
12
+ subjects:
13
+ - kind: Group
14
+ name: hq-product
@@ -0,0 +1,8 @@
1
+ publish: false
2
+ delivery:
3
+ rbac:
4
+ rolebindings:
5
+ - role: edit
6
+ subjects:
7
+ - kind: Group
8
+ name: hq-product
@@ -0,0 +1,19 @@
1
+ publish: false
2
+
3
+ gem: &gem sendgrid_webapi
4
+ git:
5
+ provider: github.com
6
+ organization: OneHQ
7
+ repository: *gem
8
+
9
+ global:
10
+ taskAnnotations:
11
+ vault.security.banzaicloud.io/vault-addr: "https://vault-onehq.apps.hub.internal.onehq.com"
12
+ vault.security.banzaicloud.io/vault-path: "jwt-hub"
13
+ vault.security.banzaicloud.io/vault-auth-method: "jwt"
14
+ vault.security.banzaicloud.io/vault-tls-secret: "custom-trusted-ca"
15
+ gem: *gem
16
+ rubyVersion: 3.0.2
17
+ mountGemDockerfile: true
18
+ runRubocop: "false"
19
+ gemRepository: rubygems
data/.tool-versions CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/MIT-LICENSE CHANGED
File without changes
data/README.rdoc CHANGED
@@ -26,51 +26,102 @@ for sendgrid v2 support
26
26
  === Bounces
27
27
  This module allows you to retrieve and delete email addresses that have bounced from emails that you've delivered.
28
28
 
29
- client.bounces.get(options)
30
-
31
- client.bounces.delete(:email => "email@example.com", :foor => "bar")
32
-
29
+ # Retrieve all of your bounces.
30
+ # A maximum of 500 bounces will be returned per query.
31
+ # You can use the offset and limit parameters to retrieve more or less than 500 results.
32
+ # You can use the start_time and end_time parameters to filter by time frames.
33
+ # * https://docs.sendgrid.com/api-reference/bounces-api/retrieve-all-bounces
34
+ # i.e client.bounces.get({ "on_behalf_of": "sub_user_email"})
35
+ # i.e using limit/offset: client.bounces.get({ on_behalf_of: "sub_user_email", limit: 100, offset: 1 })
36
+ client.bounces.get (options)
37
+
38
+ # This method will delete all bounces from the given email.
39
+ # * https://docs.sendgrid.com/api-reference/bounces-api/delete-a-bounce
40
+ # i.e: client.bounces.delete( { on_behalf_of: "sub_user_email", email: "email@to.delete" })
41
+ client.bounces.delete(options)
42
+
43
+ # Deprecated: Count is no longer supported on SendGrid v3.
44
+ # As an alternative, SendGrid recommends to query depending on time frames since `get` limit is 500.
45
+ # Deprecated, under the hood it's doing a get an returning the count
33
46
  client.blocks.count
34
47
 
35
- * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/bounces.html
48
+ * options are available here: https://docs.sendgrid.com/api-reference/bounces-api
36
49
 
37
50
  === Blocks
38
51
  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.
39
-
52
+ # Retrieve all of your blocks.
53
+ # A maximum of 500 blocks will be returned per query.
54
+ # You can use the offset and limit parameters to retrieve more or less than 500 results.
55
+ # You can use the start_time and end_time parameters to filter by time frames.
56
+ #* https://docs.sendgrid.com/api-reference/blocks-api/retrieve-all-blocks
57
+ # i.e: client.blocks.get({ on_behalf_of: "sub_user_email", limit: 100, offset: 1 })
40
58
  client.blocks.get(options)
41
-
42
- client.blocks.delete(:email => "email@example.com", :foor => "bar")
43
-
59
+
60
+
61
+ # This method will delete all blocks from the given email
62
+ # * https://docs.sendgrid.com/api-reference/blocks-api/delete-blocks
63
+ # i.e: client.blocks.delete( { on_behalf_of: "sub_user_email", email: "email@example.com" })
64
+ client.blocks.delete(options)
65
+
66
+ # Deprecated: Count is no longer supported on SendGrid v3.
67
+ # As an alternative, SendGrid recommends to query depending on time frames since `get` limit is 500.
44
68
  client.blocks.count
45
69
 
46
- * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/blocks.html
70
+ * options are available here: https://docs.sendgrid.com/api-reference/blocks-api
47
71
 
48
72
  === Invalid Email
49
73
  This module allows you to retrieve and delete email addresses that you've sent to that are invalid email addresses.
50
-
74
+ # Retrieve a list of all invalid email addresses.
75
+ # You can use the offset and limit parameters to retrieve a custom number of results.
76
+ # You can use the start_time and end_time parameters to filter by time frames.
77
+ # * https://docs.sendgrid.com/api-reference/invalid-e-mails-api/retrieve-all-invalid-emails
78
+ # i.e: client.invalid_emails.get({ on_behalf_of: "sub_user_email", limit: 100, offset: 1 })
51
79
  client.invalid_emails.get(options)
52
80
 
53
- client.invalid_emails.delete(:email => "email@example.com", :foor => "bar")
81
+ # This method will delete all invalid_emails from the given email
82
+ # * https://docs.sendgrid.com/api-reference/invalid-e-mails-api/delete-a-specific-invalid-email
83
+ # i.e: client.invalid_emails.delete( { on_behalf_of: "sub_user_email", email: "email@example.com" })
84
+ client.invalid_emails.delete(options)
54
85
 
55
- * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/invalid_emails.html
86
+ * options are available here: https://docs.sendgrid.com/api-reference/invalid-e-mails-api
56
87
 
57
88
  === Spam Report
58
89
  This module allows you to retrieve and delete email addresses that have marked your emails as SPAM.
59
-
90
+ # Retrieve a list of all spam reports.
91
+ # You can use the offset and limit parameters to retrieve a custom number of results.
92
+ # You can use the start_time and end_time parameters to filter by time frames.
93
+ # * https://docs.sendgrid.com/api-reference/spam-reports-api/retrieve-all-spam-reports
94
+ # i.e: client.spam.get({ on_behalf_of: "sub_user_email", limit: 100, offset: 1 })
60
95
  client.spam.get(options)
61
96
 
62
- client.spam.delete(:email => "email@example.com", :foor => "bar")
97
+ # This method will delete all spam_reports from the given email.
98
+ # * https://docs.sendgrid.com/api-reference/spam-reports-api/delete-a-specific-spam-report
99
+ # i.e: client.spam.delete( { on_behalf_of: "sub_user_email", email: "email@example.com" })
100
+ client.spam.delete(options)
63
101
 
64
102
  * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/spam_reports.html
65
103
 
66
104
  === Unsubscribes
67
105
  This module allows you to add, retrieve and delete email addresses that were unsubscribed from your emails.
68
106
 
69
- client.unsubscribes.add(:email => "email@example.com", :foor => "bar")
70
-
107
+
108
+ # Example @email_client.send(:unsubscribes).delete( { email: "test@example.com", on_behalf_of: "sub_user_email" })
109
+ # * https://docs.sendgrid.com/api-reference/suppressions-global-suppressions/add-recipient-addresses-to-the-global-suppression-group
110
+ # i.e: client.unsubscribes.add( { on_behalf_of: "sub_user_email, recipient_emails: ["test@example.com"] })
111
+ client.unsubscribes.add(options)
112
+
113
+ # Retrieve a list of all email address that are globally suppressed.
114
+ # You can use the offset and limit parameters to retrieve a custom number of results.
115
+ # You can use the start_time and end_time parameters to filter by time frames.
116
+ # * https://docs.sendgrid.com/api-reference/suppressions-global-suppressions/retrieve-all-global-suppressions
117
+ # client.unsubscribes.get({ on_behalf_of: "sub_user_email", limit: 100, offset: 1 })
71
118
  client.unsubscribes.get(options)
72
119
 
73
- client.unsubscribes.delete(:email => "email@example.com", :foor => "bar")
120
+
121
+ # This method will delete all unsubscribes from the given email
122
+ # * https://docs.sendgrid.com/api-reference/suppressions-global-suppressions/delete-a-global-suppression
123
+ # i.e: client.unsubscribes.delete( { on_behalf_of: "sub_user_email", email: "email@example.com" })
124
+ client.unsubscribes.delete(options)
74
125
 
75
126
  * options are available here: http://sendgrid.com/docs/API_Reference/Web_API/unsubscribes.html
76
127
 
data/Rakefile CHANGED
File without changes
File without changes
File without changes
data/lib/apikey_client.rb CHANGED
File without changes
data/lib/base.rb CHANGED
@@ -71,5 +71,12 @@ module SendGridWebApi
71
71
  conn.adapter Faraday.default_adapter
72
72
  end
73
73
  end
74
+
75
+ private
76
+ def process_header_options options
77
+ on_behalf_of = options.delete(:on_behalf_of)
78
+ options.merge!({ headers: { "on-behalf-of" => on_behalf_of } }) unless on_behalf_of.nil?
79
+ options
80
+ end
74
81
  end
75
82
  end
data/lib/helper.rb CHANGED
File without changes
File without changes
File without changes
data/lib/sub_user/apps.rb CHANGED
File without changes
data/lib/sub_user/auth.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/lib/sub_user/spam.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SendGridWebApi
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,18 +1,31 @@
1
1
  module SendGridWebApi::Modules
2
2
  class Block < SendGridWebApi::Client
3
+ BLOCKS_URL = "suppression/blocks"
4
+
5
+ def base_url
6
+ "https://api.sendgrid.com/v3/"
7
+ end
8
+
9
+ # Retrieve all of your blocks.
10
+ # A maximum of 500 blocks will be returned per query.
11
+ # You can use the offset and limit parameters to retrieve more or less than 500 results.
12
+ # You can use the start_time and end_time parameters to filter by time frames.
3
13
  def get options = {}
4
- block_get_url = "blocks.get.json"
5
- query_api(block_get_url, options)
14
+ query_api(BLOCKS_URL, process_header_options(options))
6
15
  end
7
16
 
17
+ # This method will delete all blocks from the given email
8
18
  def delete options = {}
9
- block_delete_url = "blocks.delete.json"
10
- query_api(block_delete_url, options)
19
+ delete_url = BLOCKS_URL+"/#{options[:email]}"
20
+ options.delete(:email)
21
+ query_delete_api(delete_url, process_header_options(options))
11
22
  end
12
23
 
24
+ # Deprecated: Count is no longer supported on SendGrid v3.
25
+ # As an alternative, SendGrid recommends to query depending on time frames since `get` limit is 500.
13
26
  def count options = {}
14
- block_count_url = "blocks.count.json"
15
- query_api(block_count_url, options)
27
+ count = query_api(BLOCKS_URL, process_header_options(options)).count
28
+ {count: count}
16
29
  end
17
30
  end
18
- end
31
+ end
@@ -1,18 +1,31 @@
1
1
  module SendGridWebApi::Modules
2
2
  class Bounce < SendGridWebApi::Client
3
+ BOUNCES_URL = "suppression/bounces"
4
+
5
+ def base_url
6
+ "https://api.sendgrid.com/v3/"
7
+ end
8
+
9
+ # Retrieve all of your bounces.
10
+ # A maximum of 500 bounces will be returned per query.
11
+ # You can use the offset and limit parameters to retrieve more or less than 500 results.
12
+ # You can use the start_time and end_time parameters to filter by time frames.
3
13
  def get options = {}
4
- bounce_get_url = "bounces.get.json"
5
- query_api(bounce_get_url, options)
14
+ query_api(BOUNCES_URL, process_header_options(options))
6
15
  end
7
16
 
17
+ # This method will delete all bounces from the given email.
8
18
  def delete options = {}
9
- bounce_delete_url = "bounces.delete.json"
10
- query_api(bounce_delete_url, options)
19
+ delete_url = BOUNCES_URL+"/#{options[:email]}"
20
+ options.delete(:email)
21
+ query_delete_api(delete_url, process_header_options(options))
11
22
  end
12
23
 
24
+ # Deprecated: Count is no longer supported on SendGrid v3.
25
+ # As an alternative, SendGrid recommends to query depending on time frames since `get` limit is 500.
13
26
  def count options = {}
14
- bounces_count_url = "bounces.count.json"
15
- query_api(bounces_count_url, options)
27
+ count = query_api(BOUNCES_URL, process_header_options(options)).count
28
+ {count: count}
16
29
  end
17
30
  end
18
31
  end
File without changes
@@ -1,13 +1,23 @@
1
1
  module SendGridWebApi::Modules
2
2
  class InvalidEmail < SendGridWebApi::Client
3
+ INVALID_EMAILS_URL = "suppression/invalid_emails"
4
+
5
+ def base_url
6
+ "https://api.sendgrid.com/v3/"
7
+ end
8
+
9
+ # Retrieve a list of all invalid email addresses.
10
+ # You can use the offset and limit parameters to retrieve a custom number of results.
11
+ # You can use the start_time and end_time parameters to filter by time frames.
3
12
  def get options = {}
4
- invalid_email_get_url = "invalidemails.get.json"
5
- query_api(invalid_email_get_url, options)
13
+ query_api(INVALID_EMAILS_URL, process_header_options(options))
6
14
  end
7
15
 
16
+ # This method will delete all invalid_emails from the given email
8
17
  def delete options = {}
9
- invalid_email_delete_url = "invalidemails.delete.json"
10
- query_api(invalid_email_delete_url, options)
11
- end
18
+ delete_url = INVALID_EMAILS_URL+"/#{options[:email]}"
19
+ options.delete(:email)
20
+ query_delete_api(delete_url, process_header_options(options))
21
+ end
12
22
  end
13
23
  end
data/lib/web_api/mail.rb CHANGED
File without changes
File without changes
data/lib/web_api/parse.rb CHANGED
File without changes
File without changes
data/lib/web_api/spam.rb CHANGED
@@ -1,13 +1,23 @@
1
1
  module SendGridWebApi::Modules
2
2
  class Spam < SendGridWebApi::Client
3
+ SPAM_REPORTS_URL = "suppression/spam_reports"
4
+
5
+ def base_url
6
+ "https://api.sendgrid.com/v3/"
7
+ end
8
+
9
+ # Retrieve a list of all spam reports.
10
+ # You can use the offset and limit parameters to retrieve a custom number of results.
11
+ # You can use the start_time and end_time parameters to filter by time frames.
3
12
  def get options = {}
4
- spam_get_url = "spamreports.get.json"
5
- query_api(spam_get_url, options)
13
+ query_api(SPAM_REPORTS_URL, process_header_options(options))
6
14
  end
7
15
 
16
+ # This method will delete all spam_reports from the given email.
8
17
  def delete options = {}
9
- spam_delete_url = "spamreports.delete.json"
10
- query_api(spam_delete_url, options)
18
+ delete_url = SPAM_REPORTS_URL+"/#{options[:email]}"
19
+ options.delete(:email)
20
+ query_delete_api(delete_url, process_header_options(options))
11
21
  end
12
22
  end
13
23
  end
data/lib/web_api/stats.rb CHANGED
File without changes
@@ -1,18 +1,31 @@
1
1
  module SendGridWebApi::Modules
2
2
  class Unsubscribe < SendGridWebApi::Client
3
+ def base_url
4
+ "https://api.sendgrid.com/v3/"
5
+ end
6
+
7
+ # Retrieve a list of all email address that are globally suppressed.
8
+ # You can use the offset and limit parameters to retrieve a custom number of results.
9
+ # You can use the start_time and end_time parameters to filter by time frames.
3
10
  def get options = {}
4
- unsubscribe_get_url = "unsubscribes.get.json"
5
- query_api(unsubscribe_get_url, options)
11
+ unsubscribe_url = "suppression/unsubscribes"
12
+ query_api(unsubscribe_url, process_header_options(options))
6
13
  end
7
14
 
15
+ # Add one or more email addresses to the global suppressions group.
16
+ # Expects options => recipient_emails: ["test@example.com"]
8
17
  def add options = {}
9
- unsubscribe_add_url = "unsubscribes.add.json"
10
- query_api(unsubscribe_add_url, options)
18
+ unsubscribe_url = "asm/suppressions/global"
19
+ query_post_json_api(unsubscribe_url, process_header_options(options))
11
20
  end
12
21
 
22
+ # This method will delete all unsubscribes from the given email
13
23
  def delete options = {}
14
- unsubscribe_delete_url = "unsubscribes.delete.json"
15
- query_api(unsubscribe_delete_url, options)
24
+ unsubscribe_url = "asm/suppressions/global"
25
+ delete_url = unsubscribe_url + "/#{options[:email]}"
26
+ options.delete(:email)
27
+
28
+ query_delete_api(delete_url, process_header_options(options))
16
29
  end
17
30
  end
18
31
  end
File without changes
data/lib/webapi_client.rb CHANGED
File without changes
File without changes
@@ -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
5
+ uri: https://api.sendgrid.com/v3/suppression/blocks
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
5
+ uri: https://api.sendgrid.com/v3/suppression/blocks
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -30,7 +30,7 @@ http_interactions:
30
30
  - keep-alive
31
31
  body:
32
32
  encoding: UTF-8
33
- string: '{"count": 0}'
33
+ string: '[]'
34
34
  http_version:
35
35
  recorded_at: Fri, 17 Jan 2014 01:37:40 GMT
36
36
  recorded_with: VCR 2.8.0
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  http_interactions:
3
3
  - request:
4
- method: get
5
- uri: https://api.sendgrid.com/api/blocks.delete.json?email=test@example.com
4
+ method: delete
5
+ uri: https://api.sendgrid.com/v3/suppression/blocks/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
5
+ uri: https://api.sendgrid.com/v3/suppression/bounces
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.sendgrid.com/v3/suppression/bounces?limit=2&offset=1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.9
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx/1.4.2
23
+ Date:
24
+ - Fri, 17 Jan 2014 01:39:31 GMT
25
+ Content-Type:
26
+ - text/html
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ body:
32
+ encoding: UTF-8
33
+ string: '["email1@test.com", "email2@test.com"]'
34
+ http_version:
35
+ recorded_at: Fri, 17 Jan 2014 01:39:31 GMT
36
+ recorded_with: VCR 2.8.0