pew_pew 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +36 -0
- data/.gitignore +1 -0
- data/.rspec +1 -2
- data/Appraisals +7 -0
- data/CHANGELOG.md +7 -2
- data/README.md +6 -0
- data/gemfiles/faraday_2.0.gemfile +7 -0
- data/gemfiles/faraday_2.7.gemfile +7 -0
- data/lib/pew_pew/resource.rb +12 -10
- data/lib/pew_pew/version.rb +1 -1
- data/pew_pew.gemspec +20 -16
- data/spec/fixtures/messages.yml +153 -111
- data/spec/pew_pew/client_spec.rb +47 -39
- data/spec/pew_pew/config_spec.rb +28 -28
- data/spec/pew_pew/resource_spec.rb +42 -36
- data/spec/pew_pew/resources/bounces_spec.rb +57 -53
- data/spec/pew_pew/resources/campaigns_spec.rb +169 -167
- data/spec/pew_pew/resources/complaints_spec.rb +49 -45
- data/spec/pew_pew/resources/lists_spec.rb +209 -195
- data/spec/pew_pew/resources/logs_spec.rb +30 -25
- data/spec/pew_pew/resources/mailboxes_spec.rb +41 -39
- data/spec/pew_pew/resources/messages_spec.rb +49 -45
- data/spec/pew_pew/resources/routes_spec.rb +105 -103
- data/spec/pew_pew/resources/stats_spec.rb +19 -17
- data/spec/pew_pew/resources/unsubscribes_spec.rb +71 -65
- data/spec/pew_pew/response_spec.rb +25 -13
- data/spec/pew_pew_spec.rb +4 -5
- data/spec/spec_helper.rb +1 -1
- data/spec/support/contexts/api_requests.rb +5 -3
- data/spec/support/contexts/domain_resource.rb +1 -1
- data/spec/support/vcr.rb +36 -1
- metadata +84 -50
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0a1bcd1454887394ebff0e731baf87d0e097e6d0f040faf3ca5b21f877e2d733
|
4
|
+
data.tar.gz: 3087c678aaf3575fe6363068a21286aeb0b85960ec615e9cb8d1bb51d0a98d70
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f09dadc7f90f85cdd8184c54f7d12b4fc70b273ab5c4b7b718f94dc5a5108ee15090267b8543e207b87abccdf3d6d9e5023cdf2174740844cb74d86e9f224509
|
7
|
+
data.tar.gz: 2a6bca30ae6e6d35256affb6e694a7acd42f4fed7a0ff73579fea2b955a0f7f752c7ab0b4422b40b65f695345fb536f0b8e0937ea73c9564ef50a63e5bd5048a
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: Build
|
2
|
+
on:
|
3
|
+
- push
|
4
|
+
- pull_request
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
name: Ruby ${{ matrix.ruby }} / Faraday ${{ matrix.faraday }}
|
9
|
+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
10
|
+
strategy:
|
11
|
+
fail-fast: false
|
12
|
+
matrix:
|
13
|
+
ruby:
|
14
|
+
- "2.6"
|
15
|
+
- "2.7"
|
16
|
+
- "3.0"
|
17
|
+
- "3.1"
|
18
|
+
faraday:
|
19
|
+
- "2.0"
|
20
|
+
- "2.7"
|
21
|
+
|
22
|
+
runs-on: "ubuntu-latest"
|
23
|
+
|
24
|
+
env:
|
25
|
+
BUNDLE_GEMFILE: gemfiles/faraday_${{ matrix.faraday }}.gemfile
|
26
|
+
RUBYOPT: "--disable-error_highlight"
|
27
|
+
|
28
|
+
steps:
|
29
|
+
- uses: actions/checkout@v2
|
30
|
+
- uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
33
|
+
- name: Setup project
|
34
|
+
run: bundle install
|
35
|
+
- name: Run tests
|
36
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
--
|
2
|
-
--format progress
|
1
|
+
--require spec_helper
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## Pew Pew 0.0
|
3
|
+
## Pew Pew 0.1.0 - November 18, 2022
|
4
|
+
|
5
|
+
* Support Faraday ~> 2.0
|
6
|
+
* Require Ruby >= 2.6
|
7
|
+
|
8
|
+
## Pew Pew 0.0.2 - June 5, 2012
|
4
9
|
|
5
10
|
* Add support for Ruby < 1.9.3.
|
6
11
|
|
7
|
-
## Pew Pew 0.0.1
|
12
|
+
## Pew Pew 0.0.1 - June 4, 2012
|
8
13
|
|
9
14
|
* Initial release.
|
data/README.md
CHANGED
@@ -93,3 +93,9 @@ See the [documentation][] for the complete [list of resources][resources].
|
|
93
93
|
3. Commit your changes (`git commit -am 'Add some feature.'`)
|
94
94
|
4. Push to the branch (`git push origin my-new-feature`)
|
95
95
|
5. Create a new Pull Request
|
96
|
+
|
97
|
+
|
98
|
+
## Copyright
|
99
|
+
|
100
|
+
Copyright © 2012 Tyler Hunt.
|
101
|
+
Released under the terms of the MIT license. See LICENSE for details.
|
data/lib/pew_pew/resource.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday/mashify'
|
3
|
+
require 'faraday/multipart'
|
2
4
|
|
3
5
|
module PewPew
|
4
6
|
module Resource
|
5
7
|
include Relax::Resource
|
6
8
|
|
7
|
-
class ResponseDecorator < Faraday::
|
9
|
+
class ResponseDecorator < Faraday::Middleware
|
8
10
|
def on_complete(env)
|
9
11
|
if env[:body].is_a?(Array)
|
10
12
|
items = env[:body]
|
@@ -36,16 +38,16 @@ module PewPew
|
|
36
38
|
private :delete
|
37
39
|
|
38
40
|
def connection
|
39
|
-
super
|
40
|
-
builder.
|
41
|
+
super { |builder|
|
42
|
+
builder.set_basic_auth Config::USERNAME, config.api_key
|
41
43
|
|
42
|
-
builder.use
|
43
|
-
builder.response
|
44
|
-
builder.response
|
44
|
+
builder.use ResponseDecorator
|
45
|
+
builder.response :mashify, mash_class: Response
|
46
|
+
builder.response :json, content_type: //
|
45
47
|
|
46
|
-
builder.request
|
47
|
-
builder.request
|
48
|
-
|
48
|
+
builder.request :multipart
|
49
|
+
builder.request :url_encoded
|
50
|
+
}
|
49
51
|
end
|
50
52
|
private :connection
|
51
53
|
end
|
data/lib/pew_pew/version.rb
CHANGED
data/pew_pew.gemspec
CHANGED
@@ -1,22 +1,26 @@
|
|
1
1
|
require './lib/pew_pew/version'
|
2
2
|
|
3
|
-
Gem::Specification.new do |
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'pew_pew'
|
5
|
+
spec.version = PewPew::VERSION
|
6
|
+
spec.authors = ['Tyler Hunt']
|
7
|
+
spec.summary = 'A Ruby client library for using the Mailgun web service.'
|
8
|
+
spec.homepage = 'http://github.com/tylerhunt/pew_pew'
|
9
|
+
spec.license = 'MIT'
|
9
10
|
|
10
|
-
|
11
|
+
spec.required_ruby_version = '>= 2.6'
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
spec.add_dependency 'faraday-mashify'
|
14
|
+
spec.add_dependency 'faraday-multipart'
|
15
|
+
spec.add_dependency 'hashie', '~> 1.1'
|
16
|
+
spec.add_dependency 'relax', '~> 0.3.0'
|
17
|
+
spec.add_development_dependency 'appraisal', '~> 2.4'
|
18
|
+
spec.add_development_dependency 'rspec', '~> 3.12'
|
19
|
+
spec.add_development_dependency 'rspec-its', '~> 1.3'
|
20
|
+
spec.add_development_dependency 'vcr', '~> 6.1'
|
17
21
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
spec.files = `git ls-files`.split($\)
|
23
|
+
spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
24
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
25
|
+
spec.require_paths = ['lib']
|
22
26
|
end
|
data/spec/fixtures/messages.yml
CHANGED
@@ -4,8 +4,8 @@ http_interactions:
|
|
4
4
|
method: post
|
5
5
|
uri: https://api.mailgun.net/v2/<%= domain %>/messages
|
6
6
|
body:
|
7
|
-
encoding:
|
8
|
-
string:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: from=pewpew%40devoh.com&subject=Test&text=This+is+a+test+message.&to=pewpew%40devoh.com
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
11
|
- <%= user_agent %>
|
@@ -16,140 +16,162 @@ http_interactions:
|
|
16
16
|
response:
|
17
17
|
status:
|
18
18
|
code: 200
|
19
|
-
message:
|
19
|
+
message: OK
|
20
20
|
headers:
|
21
|
-
|
22
|
-
-
|
23
|
-
|
24
|
-
-
|
25
|
-
|
26
|
-
-
|
27
|
-
connection:
|
28
|
-
- close
|
21
|
+
access-control-allow-credentials:
|
22
|
+
- 'true'
|
23
|
+
access-control-allow-origin:
|
24
|
+
- "*"
|
25
|
+
cache-control:
|
26
|
+
- no-store
|
29
27
|
content-length:
|
30
|
-
- '
|
31
|
-
content-
|
32
|
-
-
|
28
|
+
- '93'
|
29
|
+
content-type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
date:
|
32
|
+
- Fri, 18 Nov 2022 02:40:49 GMT
|
33
|
+
strict-transport-security:
|
34
|
+
- max-age=63072000; includeSubDomains
|
35
|
+
x-ratelimit-limit:
|
36
|
+
- '4000000'
|
37
|
+
x-ratelimit-remaining:
|
38
|
+
- '3999999'
|
39
|
+
x-ratelimit-reset:
|
40
|
+
- '1668739258933'
|
41
|
+
x-recipient-limit:
|
42
|
+
- '2000000'
|
43
|
+
x-recipient-remaining:
|
44
|
+
- '1999999'
|
45
|
+
x-recipient-reset:
|
46
|
+
- '1668739258933'
|
47
|
+
x-xss-protection:
|
48
|
+
- 1; mode=block
|
33
49
|
body:
|
34
|
-
encoding:
|
35
|
-
string:
|
36
|
-
|
37
|
-
|
50
|
+
encoding: UTF-8
|
51
|
+
string: '{"id":"<20221118024049.bcdf841f319da0e8@pewpew.mailgun.org>","message":"Queued.
|
52
|
+
Thank you."}
|
53
|
+
|
54
|
+
'
|
55
|
+
recorded_at: Fri, 18 Nov 2022 02:40:49 GMT
|
38
56
|
- request:
|
39
57
|
method: post
|
40
58
|
uri: https://api.mailgun.net/v2/<%= domain %>/messages
|
41
59
|
body:
|
42
60
|
encoding: ASCII-8BIT
|
43
61
|
string: !binary |-
|
44
|
-
|
45
|
-
c2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9InRvIg0KDQpwZXdwZXdAZGV2b2gu
|
46
|
-
Y29tDQotLS0tLS0tLS0tLS0tUnVieU11bHRpcGFydFBvc3QNCkNvbnRlbnQt
|
47
|
-
RGlzcG9zaXRpb246IGZvcm0tZGF0YTsgbmFtZT0iZnJvbSINCg0KcGV3cGV3
|
48
|
-
QGRldm9oLmNvbQ0KLS0tLS0tLS0tLS0tLVJ1YnlNdWx0aXBhcnRQb3N0DQpD
|
49
|
-
b250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9InN1YmplY3Qi
|
50
|
-
DQoNClRlc3QNCi0tLS0tLS0tLS0tLS1SdWJ5TXVsdGlwYXJ0UG9zdA0KQ29u
|
51
|
-
dGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJ0ZXh0Ig0KDQpU
|
52
|
-
aGlzIGlzIGEgdGVzdCBtZXNzYWdlLg0KLS0tLS0tLS0tLS0tLVJ1YnlNdWx0
|
53
|
-
aXBhcnRQb3N0DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5h
|
54
|
-
bWU9ImF0dGFjaG1lbnQiOyBmaWxlbmFtZT0iaW1hZ2UucG5nIg0KQ29udGVu
|
55
|
-
dC1MZW5ndGg6IDY3DQpDb250ZW50LVR5cGU6IGltYWdlL3BuZw0KQ29udGVu
|
56
|
-
dC1UcmFuc2Zlci1FbmNvZGluZzogYmluYXJ5DQoNColQTkcNChoKAAAADUlI
|
57
|
-
RFIAAAABAAAAAQgGAAAAHxXEiQAAAApJREFUeJxjAAEAAAUAAQ0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GVudC1UcmFuc2Zlci1FbmNvZGluZzogYmluYXJ5DQoNColQTkcNChoKAAAADUlIRFIAAAABAAAAAQgGAAAAHxXEiQAAAApJREFUeJxjAAEAAAUAAQ0KLbQAAAAASUVORK5CYIINCi0tLS0tLS0tLS0tLS1SdWJ5TXVsdGlwYXJ0UG9zdC1mZDYzMTQ5MGFlNDc1NGYwMzg2N2YwZGVhYWVlM2FlOS0tDQo=
|
60
63
|
headers:
|
61
64
|
User-Agent:
|
62
65
|
- <%= user_agent %>
|
63
66
|
Authorization:
|
64
67
|
- Basic <%= basic_auth %>
|
65
68
|
Content-Type:
|
66
|
-
- multipart/form-data;boundary=-----------RubyMultipartPost
|
69
|
+
- multipart/form-data; boundary=-----------RubyMultipartPost-fd631490ae4754f03867f0deaaee3ae9
|
67
70
|
Content-Length:
|
68
|
-
- '
|
71
|
+
- '872'
|
69
72
|
response:
|
70
73
|
status:
|
71
74
|
code: 200
|
72
|
-
message:
|
75
|
+
message: OK
|
73
76
|
headers:
|
74
|
-
|
75
|
-
-
|
76
|
-
|
77
|
-
-
|
78
|
-
|
79
|
-
-
|
80
|
-
connection:
|
81
|
-
- close
|
77
|
+
access-control-allow-credentials:
|
78
|
+
- 'true'
|
79
|
+
access-control-allow-origin:
|
80
|
+
- "*"
|
81
|
+
cache-control:
|
82
|
+
- no-store
|
82
83
|
content-length:
|
83
|
-
- '
|
84
|
-
content-
|
85
|
-
-
|
84
|
+
- '93'
|
85
|
+
content-type:
|
86
|
+
- application/json; charset=utf-8
|
87
|
+
date:
|
88
|
+
- Fri, 18 Nov 2022 02:40:49 GMT
|
89
|
+
strict-transport-security:
|
90
|
+
- max-age=63072000; includeSubDomains
|
91
|
+
x-ratelimit-limit:
|
92
|
+
- '4000000'
|
93
|
+
x-ratelimit-remaining:
|
94
|
+
- '3999998'
|
95
|
+
x-ratelimit-reset:
|
96
|
+
- '1668739258933'
|
97
|
+
x-recipient-limit:
|
98
|
+
- '2000000'
|
99
|
+
x-recipient-remaining:
|
100
|
+
- '1999998'
|
101
|
+
x-recipient-reset:
|
102
|
+
- '1668739258933'
|
103
|
+
x-xss-protection:
|
104
|
+
- 1; mode=block
|
86
105
|
body:
|
87
|
-
encoding:
|
88
|
-
string:
|
89
|
-
|
90
|
-
|
106
|
+
encoding: UTF-8
|
107
|
+
string: '{"id":"<20221118024049.7a75b8c6cc931f53@pewpew.mailgun.org>","message":"Queued.
|
108
|
+
Thank you."}
|
109
|
+
|
110
|
+
'
|
111
|
+
recorded_at: Fri, 18 Nov 2022 02:40:49 GMT
|
91
112
|
- request:
|
92
113
|
method: post
|
93
114
|
uri: https://api.mailgun.net/v2/<%= domain %>/messages
|
94
115
|
body:
|
95
116
|
encoding: ASCII-8BIT
|
96
117
|
string: !binary |-
|
97
|
-
|
98
|
-
c2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9InRvIg0KDQpwZXdwZXdAZGV2b2gu
|
99
|
-
Y29tDQotLS0tLS0tLS0tLS0tUnVieU11bHRpcGFydFBvc3QNCkNvbnRlbnQt
|
100
|
-
RGlzcG9zaXRpb246IGZvcm0tZGF0YTsgbmFtZT0iZnJvbSINCg0KcGV3cGV3
|
101
|
-
QGRldm9oLmNvbQ0KLS0tLS0tLS0tLS0tLVJ1YnlNdWx0aXBhcnRQb3N0DQpD
|
102
|
-
b250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9InN1YmplY3Qi
|
103
|
-
DQoNClRlc3QNCi0tLS0tLS0tLS0tLS1SdWJ5TXVsdGlwYXJ0UG9zdA0KQ29u
|
104
|
-
dGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJ0ZXh0Ig0KDQpU
|
105
|
-
aGlzIGlzIGEgdGVzdCBtZXNzYWdlLg0KLS0tLS0tLS0tLS0tLVJ1YnlNdWx0
|
106
|
-
aXBhcnRQb3N0DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5h
|
107
|
-
bWU9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S0tLS0tLS1SdWJ5TXVsdGlwYXJ0UG9zdC1hMjBhNmQ4MzM3Y2NiZDIxMjE2OWFjMzg4M2Y0ZDBhZQ0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJ0ZXh0Ig0KDQpUaGlzIGlzIGEgdGVzdCBtZXNzYWdlLg0KLS0tLS0tLS0tLS0tLVJ1YnlNdWx0aXBhcnRQb3N0LWEyMGE2ZDgzMzdjY2JkMjEyMTY5YWMzODgzZjRkMGFlDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9Imh0bWwiDQoNClRoaXMgaXMgYSB0ZXN0IG1lc3NhZ2UuIDxpbWcgc3JjPSJjaWQ6aW1hZ2UucG5nIj4NCi0tLS0tLS0tLS0tLS1SdWJ5TXVsdGlwYXJ0UG9zdC1hMjBhNmQ4MzM3Y2NiZDIxMjE2OWFjMzg4M2Y0ZDBhZQ0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJpbmxpbmUiOyBmaWxlbmFtZT0iaW1hZ2UucG5nIg0KQ29udGVudC1MZW5ndGg6IDY3DQpDb250ZW50LVR5cGU6IGltYWdlL3BuZw0KQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZzogYmluYXJ5DQoNColQTkcNChoKAAAADUlIRFIAAAABAAAAAQgGAAAAHxXEiQAAAApJREFUeJxjAAEAAAUAAQ0KLbQAAAAASUVORK5CYIINCi0tLS0tLS0tLS0tLS1SdWJ5TXVsdGlwYXJ0UG9zdC1hMjBhNmQ4MzM3Y2NiZDIxMjE2OWFjMzg4M2Y0ZDBhZS0tDQo=
|
115
119
|
headers:
|
116
120
|
User-Agent:
|
117
121
|
- <%= user_agent %>
|
118
122
|
Authorization:
|
119
123
|
- Basic <%= basic_auth %>
|
120
124
|
Content-Type:
|
121
|
-
- multipart/form-data;boundary=-----------RubyMultipartPost
|
125
|
+
- multipart/form-data; boundary=-----------RubyMultipartPost-a20a6d8337ccbd212169ac3883f4d0ae
|
122
126
|
Content-Length:
|
123
|
-
- '
|
127
|
+
- '1031'
|
124
128
|
response:
|
125
129
|
status:
|
126
130
|
code: 200
|
127
|
-
message:
|
131
|
+
message: OK
|
128
132
|
headers:
|
129
|
-
|
130
|
-
-
|
131
|
-
|
132
|
-
-
|
133
|
-
|
134
|
-
-
|
135
|
-
connection:
|
136
|
-
- close
|
133
|
+
access-control-allow-credentials:
|
134
|
+
- 'true'
|
135
|
+
access-control-allow-origin:
|
136
|
+
- "*"
|
137
|
+
cache-control:
|
138
|
+
- no-store
|
137
139
|
content-length:
|
138
|
-
- '
|
139
|
-
content-
|
140
|
-
-
|
140
|
+
- '93'
|
141
|
+
content-type:
|
142
|
+
- application/json; charset=utf-8
|
143
|
+
date:
|
144
|
+
- Fri, 18 Nov 2022 02:40:49 GMT
|
145
|
+
strict-transport-security:
|
146
|
+
- max-age=63072000; includeSubDomains
|
147
|
+
x-ratelimit-limit:
|
148
|
+
- '4000000'
|
149
|
+
x-ratelimit-remaining:
|
150
|
+
- '3999997'
|
151
|
+
x-ratelimit-reset:
|
152
|
+
- '1668739258933'
|
153
|
+
x-recipient-limit:
|
154
|
+
- '2000000'
|
155
|
+
x-recipient-remaining:
|
156
|
+
- '1999997'
|
157
|
+
x-recipient-reset:
|
158
|
+
- '1668739258933'
|
159
|
+
x-xss-protection:
|
160
|
+
- 1; mode=block
|
141
161
|
body:
|
142
|
-
encoding:
|
143
|
-
string:
|
144
|
-
|
145
|
-
|
162
|
+
encoding: UTF-8
|
163
|
+
string: '{"id":"<20221118024049.4dd8e5980d33aba1@pewpew.mailgun.org>","message":"Queued.
|
164
|
+
Thank you."}
|
165
|
+
|
166
|
+
'
|
167
|
+
recorded_at: Fri, 18 Nov 2022 02:40:49 GMT
|
146
168
|
- request:
|
147
169
|
method: post
|
148
170
|
uri: https://api.mailgun.net/v2/<%= domain %>/messages.mime
|
149
171
|
body:
|
150
|
-
encoding:
|
151
|
-
string:
|
152
|
-
name=\"to\"\r\n\r\npewpew@devoh.com\r\n-------------RubyMultipartPost\r\nContent-Disposition:
|
172
|
+
encoding: UTF-8
|
173
|
+
string: "-------------RubyMultipartPost-db1e8de197dfbe11e940a63d75da98fa\r\nContent-Disposition:
|
174
|
+
form-data; name=\"to\"\r\n\r\npewpew@devoh.com\r\n-------------RubyMultipartPost-db1e8de197dfbe11e940a63d75da98fa\r\nContent-Disposition:
|
153
175
|
form-data; name=\"message\"; filename=\"mime.eml\"\r\nContent-Length: 931\r\nContent-Type:
|
154
176
|
message/rfc822\r\nContent-Transfer-Encoding: binary\r\n\r\nDate: Thu, 31 May
|
155
177
|
2012 21:17:55 -0700\nFrom: pewpew@devoh.com\nTo: pewpew@devoh.com\nMessage-ID:
|
@@ -161,36 +183,56 @@ http_interactions:
|
|
161
183
|
is a test message.\n\n----==_mimepart_4fc8427374a4_48dd3fe70cc34cd059187\nDate:
|
162
184
|
Thu, 31 May 2012 21:17:55 -0700\nMime-Version: 1.0\nContent-Type: text/html;\n
|
163
185
|
charset=UTF-8\nContent-Transfer-Encoding: 7bit\nContent-ID: <4fc84273b619_48dd3fe70cc34cd05937b@rouge.local.mail>\n\n<p>This
|
164
|
-
is a test message.<p>\n\n----==_mimepart_4fc8427374a4_48dd3fe70cc34cd059187--\n\r\n-------------RubyMultipartPost--\r\n
|
186
|
+
is a test message.<p>\n\n----==_mimepart_4fc8427374a4_48dd3fe70cc34cd059187--\n\r\n-------------RubyMultipartPost-db1e8de197dfbe11e940a63d75da98fa--\r\n"
|
165
187
|
headers:
|
166
188
|
User-Agent:
|
167
189
|
- <%= user_agent %>
|
168
190
|
Authorization:
|
169
191
|
- Basic <%= basic_auth %>
|
170
192
|
Content-Type:
|
171
|
-
- multipart/form-data;boundary=-----------RubyMultipartPost
|
193
|
+
- multipart/form-data; boundary=-----------RubyMultipartPost-db1e8de197dfbe11e940a63d75da98fa
|
172
194
|
Content-Length:
|
173
|
-
- '
|
195
|
+
- '1350'
|
174
196
|
response:
|
175
197
|
status:
|
176
198
|
code: 200
|
177
|
-
message:
|
199
|
+
message: OK
|
178
200
|
headers:
|
179
|
-
|
180
|
-
-
|
181
|
-
|
182
|
-
-
|
183
|
-
|
184
|
-
-
|
185
|
-
connection:
|
186
|
-
- close
|
201
|
+
access-control-allow-credentials:
|
202
|
+
- 'true'
|
203
|
+
access-control-allow-origin:
|
204
|
+
- "*"
|
205
|
+
cache-control:
|
206
|
+
- no-store
|
187
207
|
content-length:
|
188
|
-
- '
|
189
|
-
content-
|
190
|
-
-
|
208
|
+
- '94'
|
209
|
+
content-type:
|
210
|
+
- application/json; charset=utf-8
|
211
|
+
date:
|
212
|
+
- Fri, 18 Nov 2022 02:40:50 GMT
|
213
|
+
strict-transport-security:
|
214
|
+
- max-age=63072000; includeSubDomains
|
215
|
+
x-ratelimit-limit:
|
216
|
+
- '4000000'
|
217
|
+
x-ratelimit-remaining:
|
218
|
+
- '3999996'
|
219
|
+
x-ratelimit-reset:
|
220
|
+
- '1668739258933'
|
221
|
+
x-recipient-limit:
|
222
|
+
- '2000000'
|
223
|
+
x-recipient-remaining:
|
224
|
+
- '1999996'
|
225
|
+
x-recipient-reset:
|
226
|
+
- '1668739258933'
|
227
|
+
x-server:
|
228
|
+
- influx
|
229
|
+
x-xss-protection:
|
230
|
+
- 1; mode=block
|
191
231
|
body:
|
192
|
-
encoding:
|
193
|
-
string:
|
194
|
-
|
195
|
-
|
196
|
-
|
232
|
+
encoding: UTF-8
|
233
|
+
string: '{"id":"<4fc84273c474_48dd3fe70cc34cd05949d@rouge.local.mail>","message":"Queued.
|
234
|
+
Thank you."}
|
235
|
+
|
236
|
+
'
|
237
|
+
recorded_at: Fri, 18 Nov 2022 02:40:50 GMT
|
238
|
+
recorded_with: VCR 6.1.0
|
data/spec/pew_pew/client_spec.rb
CHANGED
@@ -1,51 +1,59 @@
|
|
1
|
-
|
1
|
+
module PewPew
|
2
|
+
RSpec.describe Client do
|
3
|
+
context '#config' do
|
4
|
+
subject { described_class.new.config }
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
+
its(:adapter) { should == Faraday.default_adapter }
|
7
|
+
its(:base_uri) { should == Config::BASE_URI }
|
8
|
+
its(:user_agent) { should == Config::USER_AGENT }
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
its(:api_key) { should be_nil }
|
11
|
+
its(:domain) { should be_nil }
|
12
|
+
end
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
+
context '#configure' do
|
15
|
+
let(:client) { described_class.new }
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
config.user_agent = 'A PewPew Application'
|
17
|
+
before do
|
18
|
+
client.configure do |config|
|
19
|
+
config.adapter = :typhoeus
|
20
|
+
config.base_uri = 'https://api.mailgun.com/v2'
|
21
|
+
config.user_agent = 'A PewPew Application'
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
config.api_key = 'key-02n9f3ijl9sm9u97-8p7r-d7-15q-ui1'
|
24
|
+
config.domain = 'pewpew.mailgun.org'
|
25
|
+
end
|
24
26
|
end
|
25
|
-
end
|
26
27
|
|
27
|
-
|
28
|
-
its(:base_uri) { should == 'https://api.mailgun.com/v2' }
|
29
|
-
its(:user_agent) { should == 'A PewPew Application' }
|
28
|
+
subject { client.config }
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
its(:adapter) { should == :typhoeus }
|
31
|
+
its(:base_uri) { should == 'https://api.mailgun.com/v2' }
|
32
|
+
its(:user_agent) { should == 'A PewPew Application' }
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
34
|
+
its(:api_key) { should == 'key-02n9f3ijl9sm9u97-8p7r-d7-15q-ui1' }
|
35
|
+
its(:domain) { should == 'pewpew.mailgun.org' }
|
36
|
+
end
|
37
|
+
|
38
|
+
{
|
39
|
+
bounces: Resources::Bounces,
|
40
|
+
campaigns: Resources::Campaigns,
|
41
|
+
complaints: Resources::Complaints,
|
42
|
+
lists: Resources::Lists,
|
43
|
+
logs: Resources::Logs,
|
44
|
+
mailboxes: Resources::Mailboxes,
|
45
|
+
messages: Resources::Messages,
|
46
|
+
routes: Resources::Routes,
|
47
|
+
stats: Resources::Stats,
|
48
|
+
unsubscribes: Resources::Unsubscribes,
|
49
|
+
}.each do |method, resource_class|
|
50
|
+
context "##{method}" do
|
51
|
+
specify {
|
52
|
+
resource = subject.send(method)
|
53
|
+
|
54
|
+
expect(resource).to be_a resource_class
|
55
|
+
}
|
56
|
+
end
|
49
57
|
end
|
50
58
|
end
|
51
59
|
end
|