peat 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -1
- data/lib/peat/client.rb +4 -0
- data/lib/peat/version.rb +1 -1
- data/spec/client_spec.rb +39 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/vcr_cassettes/peat.yml +51 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f18ccc9a6d39e4fc1bbdabd00d66ec9f3f3dc952
|
4
|
+
data.tar.gz: 865c919192a754f7e8722e1ce46a43032d28742e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94752332abb63450259015db70bd8a35dc13071a94328540ff4c929e3f0663c8e7ec8536ca52952570f33bb13ce06e5227004932419fd8c80ac8ad0f59876240
|
7
|
+
data.tar.gz: 6ef7118062f556d5570cce0af88a9dc3c7ab0be1c85d526f4ef308b04f2016fcb1d9bb1612328e544d8d92c7a1b453f38b94a220a54b39dece696dd898cf6298
|
data/README.md
CHANGED
@@ -56,9 +56,38 @@ mail_params = {
|
|
56
56
|
}
|
57
57
|
}
|
58
58
|
}
|
59
|
-
|
59
|
+
|
60
|
+
# simple one-off send
|
61
|
+
Peat::Client.deliver('name_of_my_triggered_send', mail_params)
|
62
|
+
```
|
63
|
+
|
64
|
+
You can also initiate a client to use throughout:
|
65
|
+
|
66
|
+
```
|
67
|
+
peat_client = Peat::Client.new
|
68
|
+
peat_client.deliver('name_of_triggered_send', maii_params)
|
60
69
|
```
|
61
70
|
|
71
|
+
## Advanced Usage
|
72
|
+
|
73
|
+
Peat is built on top of Faraday and gives you the ability to
|
74
|
+
customize the adapter, as well as insert faraday middleware
|
75
|
+
to be used when making the request to Exact Target.
|
76
|
+
|
77
|
+
```
|
78
|
+
class MyAwesomeMiddleware < Faraday::Middleware
|
79
|
+
def call(env)
|
80
|
+
...
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
peat_client = Peat::Client.new(middleware: [MyAwesomeMiddleware], adapter: :net_http_persistent)
|
85
|
+
peat_client.deliver('name_of_triggered_send', maii_params)
|
86
|
+
```
|
87
|
+
|
88
|
+
Middleware are inserted in the order they are specified. By default,
|
89
|
+
the json middlware and the Net::HTTP adapter are used.
|
90
|
+
|
62
91
|
## Contributing
|
63
92
|
|
64
93
|
1. Fork it
|
data/lib/peat/client.rb
CHANGED
data/lib/peat/version.rb
CHANGED
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Peat
|
4
|
+
describe Client do
|
5
|
+
before do
|
6
|
+
FooMiddleware = Class.new(Faraday::Middleware) do
|
7
|
+
def call(req_env)
|
8
|
+
@app.call(req_env).on_complete do |resp_env|
|
9
|
+
resp_env.status = 200
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.deliver' do
|
16
|
+
it 'proxies calls to peat client' do
|
17
|
+
VCR.use_cassette 'peat' do
|
18
|
+
expect(Peat::Client.deliver(:foo, {})).to be_falsey
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#deliver' do
|
24
|
+
it 'allows configuration of middleware' do
|
25
|
+
client = Peat::Client.new(middleware: [FooMiddleware])
|
26
|
+
VCR.use_cassette 'peat' do
|
27
|
+
expect(client.deliver!(:foo, {})).to be_truthy
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'defaults to no middleware' do
|
32
|
+
client = Peat::Client.new
|
33
|
+
VCR.use_cassette 'peat' do
|
34
|
+
expect { client.deliver!(:foo, {}) }.to raise_exception Peat::DeliveryFailed
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
VCR.configure do |c|
|
3
|
+
c.cassette_library_dir = 'spec/vcr_cassettes'
|
4
|
+
c.hook_into :webmock # or :fakeweb
|
5
|
+
#c.allow_http_connections_when_no_cassette = true
|
6
|
+
c.default_cassette_options = {
|
7
|
+
match_requests_on: [:method, :path],
|
8
|
+
allow_playback_repeats: true,
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'faraday_middleware'
|
13
|
+
|
14
|
+
require 'peat'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://www.exacttargetapis.com/messaging/v1/messageDefinitionSends/key:foo/send
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: "{}"
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Authorization:
|
15
|
+
- Bearer valid
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Accept:
|
19
|
+
- "*/*"
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 401
|
23
|
+
message: Unauthorized
|
24
|
+
headers:
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Date:
|
28
|
+
- Tue, 28 Jul 2015 21:59:00 GMT
|
29
|
+
Server:
|
30
|
+
- Mashery Proxy
|
31
|
+
Www-Authenticate:
|
32
|
+
- Bearer realm="www.exacttargetapis.com", error="invalid_token"
|
33
|
+
X-Error-Detail-Header:
|
34
|
+
- Not Authorized
|
35
|
+
X-Mashery-Error-Code:
|
36
|
+
- ERR_403_NOT_AUTHORIZED
|
37
|
+
X-Mashery-Message-Id:
|
38
|
+
- 74bd23c8-a58c-4b39-94d6-2ce55be02b06
|
39
|
+
X-Mashery-Responder:
|
40
|
+
- prod-j-worker-us-west-1c-47.mashery.com
|
41
|
+
Content-Length:
|
42
|
+
- '110'
|
43
|
+
Connection:
|
44
|
+
- keep-alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"documentation":"https://code.docs.exacttarget.com/rest/errors/403","errorcode":0,"message":"Not
|
48
|
+
Authorized"}'
|
49
|
+
http_version:
|
50
|
+
recorded_at: Tue, 28 Jul 2015 21:59:01 GMT
|
51
|
+
recorded_with: VCR 2.9.3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hubert Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -111,7 +111,10 @@ files:
|
|
111
111
|
- lib/peat/token_manager.rb
|
112
112
|
- lib/peat/version.rb
|
113
113
|
- peat.gemspec
|
114
|
+
- spec/client_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
114
116
|
- spec/token_manager_spec.rb
|
117
|
+
- spec/vcr_cassettes/peat.yml
|
115
118
|
homepage: ''
|
116
119
|
licenses:
|
117
120
|
- MIT
|
@@ -137,4 +140,7 @@ signing_key:
|
|
137
140
|
specification_version: 4
|
138
141
|
summary: Wrapper for the Exact Target fuel api
|
139
142
|
test_files:
|
143
|
+
- spec/client_spec.rb
|
144
|
+
- spec/spec_helper.rb
|
140
145
|
- spec/token_manager_spec.rb
|
146
|
+
- spec/vcr_cassettes/peat.yml
|