peat 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41c65100d648379520dc5052704759855a56fa65
4
- data.tar.gz: 85cb807ffd5ec5e054e11e21337b364b34923df1
3
+ metadata.gz: a6458716c3b767d619513a812ae31734feb46cb2
4
+ data.tar.gz: 3c44d3b47f367d2150d2764df01c2b6c5b5ec343
5
5
  SHA512:
6
- metadata.gz: aa237a24c04a8d10f5d63afe3ab9c2d72db5f3d861b5478b8e4aa6e6e474a8d12b681daa580ff789273ee2ac70a13ae27e46fac15630f3bf1ca75fe60fd16bbf
7
- data.tar.gz: 25fdde4566320c272e6f60d2cd67ebb82c01718376f853a7ef6284f54c9a318cc0ec3cafe429aa604a72e4701f8a5da141735586be5e716d79b2f02a78a8d9cb
6
+ metadata.gz: e88ead8d052a1622ba6da04fb9de2360785c7bfdc84701e8c43a76a844a5f8a693ec0f3a24f21dbbaf8987d533a696a8f96f1ef7562b4eccc73f1e1d8650f1b7
7
+ data.tar.gz: 140a8380a08b6be8ee390642cba400e86d44709647e0221495733587839b71ed7fc418a45faf6bfe4f7a65e113d368457479fe527ead4fce2fd15d8c18d4e9bf
data/lib/peat/client.rb CHANGED
@@ -1,18 +1,22 @@
1
1
  module Peat
2
- module Client
3
- module_function
2
+ class Client
3
+
4
+ def initialize(middleware: [], adapter: Faraday.default_adapter)
5
+ @middleware = middleware
6
+ @adapter = adapter
7
+ end
4
8
 
5
9
  def connection
6
10
  @connection ||= Faraday.new(url: "https://www.exacttargetapis.com/messaging/v1/") do |conn|
7
11
  conn.request :json
8
12
 
9
- conn.response :logger
13
+ @middleware.each { |m| conn.use m }
10
14
 
11
- conn.adapter Faraday.default_adapter
15
+ conn.adapter @adapter
12
16
  end
13
17
  end
14
18
 
15
- def deliver(trigger_name, params)
19
+ def deliver(trigger_name, params)
16
20
  resp = connection.post do |req|
17
21
  req.url "messageDefinitionSends/key:#{trigger_name}/send"
18
22
  req.headers['Content-Type'] = 'application/json'
@@ -22,5 +26,9 @@ module Peat
22
26
 
23
27
  resp.success?
24
28
  end
29
+
30
+ def deliver!(trigger_name, params)
31
+ deliver(trigger_name, params) or raise Peat::DeliveryFailed
32
+ end
25
33
  end
26
34
  end
data/lib/peat/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Peat
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/peat.rb CHANGED
@@ -3,6 +3,7 @@ require 'faraday_middleware'
3
3
 
4
4
  module Peat
5
5
  class MissingConfiguration < Exception; end
6
+ class DeliveryFailed < RuntimeError; end
6
7
 
7
8
  autoload :TokenManager, 'peat/token_manager'
8
9
  autoload :Client, 'peat/client'
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.0.5
4
+ version: 0.1.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-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday