pew_pew 0.0.1 → 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/.travis.yml +5 -0
- data/Appraisals +7 -0
- data/CHANGELOG.md +14 -0
- data/README.md +18 -1
- data/gemfiles/faraday_2.0.gemfile +7 -0
- data/gemfiles/faraday_2.7.gemfile +7 -0
- data/lib/pew_pew/domain.rb +1 -1
- data/lib/pew_pew/resource.rb +12 -10
- data/lib/pew_pew/version.rb +1 -1
- data/pew_pew.gemspec +21 -15
- data/spec/fixtures/bounces.yml +4 -4
- data/spec/fixtures/campaigns.yml +11 -11
- data/spec/fixtures/complaints.yml +4 -4
- data/spec/fixtures/lists.yml +11 -11
- data/spec/fixtures/logs.yml +1 -1
- data/spec/fixtures/mailboxes.yml +4 -4
- data/spec/fixtures/messages.yml +157 -115
- data/spec/fixtures/routes.yml +6 -6
- data/spec/fixtures/stats.yml +1 -1
- data/spec/fixtures/unsubscribes.yml +6 -6
- 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 +10 -4
- data/spec/support/contexts/domain_resource.rb +1 -1
- data/spec/support/vcr.rb +36 -1
- metadata +85 -49
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/.travis.yml
ADDED
data/Appraisals
ADDED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -4,6 +4,11 @@ A Ruby client library for using the [Mailgun] web service.
|
|
4
4
|
|
5
5
|
[mailgun]: https://mailgun.net/
|
6
6
|
|
7
|
+
[![Build Status][travis-image]][travis]
|
8
|
+
|
9
|
+
[travis]: http://travis-ci.org/tylerhunt/pew_pew
|
10
|
+
[travis-image]: https://secure.travis-ci.org/tylerhunt/pew_pew.png
|
11
|
+
|
7
12
|
|
8
13
|
## Installation
|
9
14
|
|
@@ -67,13 +72,19 @@ PewPew.messages.send_email(
|
|
67
72
|
```
|
68
73
|
|
69
74
|
For resources that require a domain, you may pass it as an option when calling
|
70
|
-
the resource. If a domain has been configured, it will be used as the default
|
75
|
+
the resource. If a domain has been configured, it will be used as the default
|
76
|
+
for all methods called on the resource.
|
71
77
|
|
72
78
|
``` ruby
|
73
79
|
PewPew.stats.all # uses the configured domain
|
74
80
|
PewPew.stats(domain: 'example.com').all # uses example.com
|
75
81
|
```
|
76
82
|
|
83
|
+
See the [documentation][] for the complete [list of resources][resources].
|
84
|
+
|
85
|
+
[documentation]: http://rubydoc.info/gems/pew_pew/frames
|
86
|
+
[resources]: http://rubydoc.info/gems/pew_pew/frames/PewPew/Resources
|
87
|
+
|
77
88
|
|
78
89
|
## Contributing
|
79
90
|
|
@@ -82,3 +93,9 @@ PewPew.stats(domain: 'example.com').all # uses example.com
|
|
82
93
|
3. Commit your changes (`git commit -am 'Add some feature.'`)
|
83
94
|
4. Push to the branch (`git push origin my-new-feature`)
|
84
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/domain.rb
CHANGED
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,20 +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
|
-
gem.add_dependency 'hashie', '~> 1.1'
|
12
|
-
gem.add_dependency 'relax', '~> 0.2.0'
|
13
|
-
gem.add_development_dependency 'rspec', '~> 2.6'
|
14
|
-
gem.add_development_dependency 'vcr', '~> 2.2'
|
11
|
+
spec.required_ruby_version = '>= 2.6'
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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'
|
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']
|
20
26
|
end
|
data/spec/fixtures/bounces.yml
CHANGED
@@ -8,7 +8,7 @@ http_interactions:
|
|
8
8
|
string: address=test%40example.com&code=554&error=Relay+access+denied
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
-
|
11
|
+
- <%= user_agent %>
|
12
12
|
Authorization:
|
13
13
|
- Basic <%= basic_auth %>
|
14
14
|
Content-Type:
|
@@ -44,7 +44,7 @@ http_interactions:
|
|
44
44
|
string: ''
|
45
45
|
headers:
|
46
46
|
User-Agent:
|
47
|
-
-
|
47
|
+
- <%= user_agent %>
|
48
48
|
Authorization:
|
49
49
|
- Basic <%= basic_auth %>
|
50
50
|
response:
|
@@ -79,7 +79,7 @@ http_interactions:
|
|
79
79
|
string: ''
|
80
80
|
headers:
|
81
81
|
User-Agent:
|
82
|
-
-
|
82
|
+
- <%= user_agent %>
|
83
83
|
Authorization:
|
84
84
|
- Basic <%= basic_auth %>
|
85
85
|
response:
|
@@ -115,7 +115,7 @@ http_interactions:
|
|
115
115
|
string: ''
|
116
116
|
headers:
|
117
117
|
User-Agent:
|
118
|
-
-
|
118
|
+
- <%= user_agent %>
|
119
119
|
Authorization:
|
120
120
|
- Basic <%= basic_auth %>
|
121
121
|
response:
|
data/spec/fixtures/campaigns.yml
CHANGED
@@ -8,7 +8,7 @@ http_interactions:
|
|
8
8
|
string: name=Test&id=test
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
-
|
11
|
+
- <%= user_agent %>
|
12
12
|
Authorization:
|
13
13
|
- Basic <%= basic_auth %>
|
14
14
|
Content-Type:
|
@@ -44,7 +44,7 @@ http_interactions:
|
|
44
44
|
string: ''
|
45
45
|
headers:
|
46
46
|
User-Agent:
|
47
|
-
-
|
47
|
+
- <%= user_agent %>
|
48
48
|
Authorization:
|
49
49
|
- Basic <%= basic_auth %>
|
50
50
|
response:
|
@@ -77,7 +77,7 @@ http_interactions:
|
|
77
77
|
string: name=Test
|
78
78
|
headers:
|
79
79
|
User-Agent:
|
80
|
-
-
|
80
|
+
- <%= user_agent %>
|
81
81
|
Authorization:
|
82
82
|
- Basic <%= basic_auth %>
|
83
83
|
Content-Type:
|
@@ -113,7 +113,7 @@ http_interactions:
|
|
113
113
|
string: ''
|
114
114
|
headers:
|
115
115
|
User-Agent:
|
116
|
-
-
|
116
|
+
- <%= user_agent %>
|
117
117
|
Authorization:
|
118
118
|
- Basic <%= basic_auth %>
|
119
119
|
response:
|
@@ -151,7 +151,7 @@ http_interactions:
|
|
151
151
|
string: ''
|
152
152
|
headers:
|
153
153
|
User-Agent:
|
154
|
-
-
|
154
|
+
- <%= user_agent %>
|
155
155
|
Authorization:
|
156
156
|
- Basic <%= basic_auth %>
|
157
157
|
response:
|
@@ -185,7 +185,7 @@ http_interactions:
|
|
185
185
|
string: ''
|
186
186
|
headers:
|
187
187
|
User-Agent:
|
188
|
-
-
|
188
|
+
- <%= user_agent %>
|
189
189
|
Authorization:
|
190
190
|
- Basic <%= basic_auth %>
|
191
191
|
response:
|
@@ -216,7 +216,7 @@ http_interactions:
|
|
216
216
|
string: ''
|
217
217
|
headers:
|
218
218
|
User-Agent:
|
219
|
-
-
|
219
|
+
- <%= user_agent %>
|
220
220
|
Authorization:
|
221
221
|
- Basic <%= basic_auth %>
|
222
222
|
response:
|
@@ -249,7 +249,7 @@ http_interactions:
|
|
249
249
|
string: ''
|
250
250
|
headers:
|
251
251
|
User-Agent:
|
252
|
-
-
|
252
|
+
- <%= user_agent %>
|
253
253
|
Authorization:
|
254
254
|
- Basic <%= basic_auth %>
|
255
255
|
response:
|
@@ -280,7 +280,7 @@ http_interactions:
|
|
280
280
|
string: ''
|
281
281
|
headers:
|
282
282
|
User-Agent:
|
283
|
-
-
|
283
|
+
- <%= user_agent %>
|
284
284
|
Authorization:
|
285
285
|
- Basic <%= basic_auth %>
|
286
286
|
response:
|
@@ -311,7 +311,7 @@ http_interactions:
|
|
311
311
|
string: ''
|
312
312
|
headers:
|
313
313
|
User-Agent:
|
314
|
-
-
|
314
|
+
- <%= user_agent %>
|
315
315
|
Authorization:
|
316
316
|
- Basic <%= basic_auth %>
|
317
317
|
response:
|
@@ -342,7 +342,7 @@ http_interactions:
|
|
342
342
|
string: ''
|
343
343
|
headers:
|
344
344
|
User-Agent:
|
345
|
-
-
|
345
|
+
- <%= user_agent %>
|
346
346
|
Authorization:
|
347
347
|
- Basic <%= basic_auth %>
|
348
348
|
response:
|
@@ -8,7 +8,7 @@ http_interactions:
|
|
8
8
|
string: address=test%40example.com
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
-
|
11
|
+
- <%= user_agent %>
|
12
12
|
Authorization:
|
13
13
|
- Basic <%= basic_auth %>
|
14
14
|
Content-Type:
|
@@ -44,7 +44,7 @@ http_interactions:
|
|
44
44
|
string: ''
|
45
45
|
headers:
|
46
46
|
User-Agent:
|
47
|
-
-
|
47
|
+
- <%= user_agent %>
|
48
48
|
Authorization:
|
49
49
|
- Basic <%= basic_auth %>
|
50
50
|
response:
|
@@ -78,7 +78,7 @@ http_interactions:
|
|
78
78
|
string: ''
|
79
79
|
headers:
|
80
80
|
User-Agent:
|
81
|
-
-
|
81
|
+
- <%= user_agent %>
|
82
82
|
Authorization:
|
83
83
|
- Basic <%= basic_auth %>
|
84
84
|
response:
|
@@ -113,7 +113,7 @@ http_interactions:
|
|
113
113
|
string: ''
|
114
114
|
headers:
|
115
115
|
User-Agent:
|
116
|
-
-
|
116
|
+
- <%= user_agent %>
|
117
117
|
Authorization:
|
118
118
|
- Basic <%= basic_auth %>
|
119
119
|
response:
|
data/spec/fixtures/lists.yml
CHANGED
@@ -8,7 +8,7 @@ http_interactions:
|
|
8
8
|
string: address=newsletter%40pewpew.mailgun.org&description=Weekly+News+and+Updates&name=Newsletter
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
-
|
11
|
+
- <%= user_agent %>
|
12
12
|
Authorization:
|
13
13
|
- Basic <%= basic_auth %>
|
14
14
|
Content-Type:
|
@@ -46,7 +46,7 @@ http_interactions:
|
|
46
46
|
string: ''
|
47
47
|
headers:
|
48
48
|
User-Agent:
|
49
|
-
-
|
49
|
+
- <%= user_agent %>
|
50
50
|
Authorization:
|
51
51
|
- Basic <%= basic_auth %>
|
52
52
|
response:
|
@@ -82,7 +82,7 @@ http_interactions:
|
|
82
82
|
string: ''
|
83
83
|
headers:
|
84
84
|
User-Agent:
|
85
|
-
-
|
85
|
+
- <%= user_agent %>
|
86
86
|
Authorization:
|
87
87
|
- Basic <%= basic_auth %>
|
88
88
|
response:
|
@@ -118,7 +118,7 @@ http_interactions:
|
|
118
118
|
string: description=Monthly+News+and+Updates
|
119
119
|
headers:
|
120
120
|
User-Agent:
|
121
|
-
-
|
121
|
+
- <%= user_agent %>
|
122
122
|
Authorization:
|
123
123
|
- Basic <%= basic_auth %>
|
124
124
|
Content-Type:
|
@@ -156,7 +156,7 @@ http_interactions:
|
|
156
156
|
string: ''
|
157
157
|
headers:
|
158
158
|
User-Agent:
|
159
|
-
-
|
159
|
+
- <%= user_agent %>
|
160
160
|
Authorization:
|
161
161
|
- Basic <%= basic_auth %>
|
162
162
|
response:
|
@@ -190,7 +190,7 @@ http_interactions:
|
|
190
190
|
string: ''
|
191
191
|
headers:
|
192
192
|
User-Agent:
|
193
|
-
-
|
193
|
+
- <%= user_agent %>
|
194
194
|
Authorization:
|
195
195
|
- Basic <%= basic_auth %>
|
196
196
|
response:
|
@@ -227,7 +227,7 @@ http_interactions:
|
|
227
227
|
string: address=member%40example.com&name=Member+Name&vars=%7B%22awesome%22%3Atrue%7D
|
228
228
|
headers:
|
229
229
|
User-Agent:
|
230
|
-
-
|
230
|
+
- <%= user_agent %>
|
231
231
|
Authorization:
|
232
232
|
- Basic <%= basic_auth %>
|
233
233
|
Content-Type:
|
@@ -265,7 +265,7 @@ http_interactions:
|
|
265
265
|
string: ''
|
266
266
|
headers:
|
267
267
|
User-Agent:
|
268
|
-
-
|
268
|
+
- <%= user_agent %>
|
269
269
|
Authorization:
|
270
270
|
- Basic <%= basic_auth %>
|
271
271
|
response:
|
@@ -300,7 +300,7 @@ http_interactions:
|
|
300
300
|
string: ''
|
301
301
|
headers:
|
302
302
|
User-Agent:
|
303
|
-
-
|
303
|
+
- <%= user_agent %>
|
304
304
|
Authorization:
|
305
305
|
- Basic <%= basic_auth %>
|
306
306
|
response:
|
@@ -336,7 +336,7 @@ http_interactions:
|
|
336
336
|
string: subscribed=false
|
337
337
|
headers:
|
338
338
|
User-Agent:
|
339
|
-
-
|
339
|
+
- <%= user_agent %>
|
340
340
|
Authorization:
|
341
341
|
- Basic <%= basic_auth %>
|
342
342
|
Content-Type:
|
@@ -374,7 +374,7 @@ http_interactions:
|
|
374
374
|
string: ''
|
375
375
|
headers:
|
376
376
|
User-Agent:
|
377
|
-
-
|
377
|
+
- <%= user_agent %>
|
378
378
|
Authorization:
|
379
379
|
- Basic <%= basic_auth %>
|
380
380
|
response:
|
data/spec/fixtures/logs.yml
CHANGED
data/spec/fixtures/mailboxes.yml
CHANGED
@@ -8,7 +8,7 @@ http_interactions:
|
|
8
8
|
string: ''
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
-
|
11
|
+
- <%= user_agent %>
|
12
12
|
Authorization:
|
13
13
|
- Basic <%= basic_auth %>
|
14
14
|
response:
|
@@ -43,7 +43,7 @@ http_interactions:
|
|
43
43
|
string: mailbox=test&password=secret
|
44
44
|
headers:
|
45
45
|
User-Agent:
|
46
|
-
-
|
46
|
+
- <%= user_agent %>
|
47
47
|
Authorization:
|
48
48
|
- Basic <%= basic_auth %>
|
49
49
|
Content-Type:
|
@@ -78,7 +78,7 @@ http_interactions:
|
|
78
78
|
string: password=s3cr3t
|
79
79
|
headers:
|
80
80
|
User-Agent:
|
81
|
-
-
|
81
|
+
- <%= user_agent %>
|
82
82
|
Authorization:
|
83
83
|
- Basic <%= basic_auth %>
|
84
84
|
Content-Type:
|
@@ -113,7 +113,7 @@ http_interactions:
|
|
113
113
|
string: ''
|
114
114
|
headers:
|
115
115
|
User-Agent:
|
116
|
-
-
|
116
|
+
- <%= user_agent %>
|
117
117
|
Authorization:
|
118
118
|
- Basic <%= basic_auth %>
|
119
119
|
response:
|