postmark 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +2 -1
- data/CHANGELOG.rdoc +4 -0
- data/README.md +5 -0
- data/VERSION +1 -1
- data/lib/postmark/api_client.rb +16 -0
- data/lib/postmark/version.rb +1 -1
- data/spec/unit/postmark/api_client_spec.rb +81 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55e9f7a191eaed08f4f65b7291d679dbba6665bf
|
4
|
+
data.tar.gz: 04cba05dd0d1f5a872a4b408d9ffb0d10511e782
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff849c87686ddf3eae5af58661de0c43888d1e82910081b1c07ac4bc6d8f44a29a18b9e6938c5db020c46145d36dbd35b71bec24383ead16e991757f99829868
|
7
|
+
data.tar.gz: 77eaa67674a06887f47584485cfa2e6666d5c6d1f3dd75f969d5af97c38cccbe7109c303cc56aba21d90fc4adc641aaef606e2cb27d014f04012e4f471d5e24d
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.rdoc
CHANGED
data/README.md
CHANGED
@@ -564,6 +564,11 @@ If you ever need to access your messages or their metadata (i.e. open tracking i
|
|
564
564
|
|
565
565
|
[The Templates API](https://github.com/wildbit/postmark-gem/wiki/The-Templates-API-support) can be used to fully manage your templates.
|
566
566
|
|
567
|
+
## The Stats API Support
|
568
|
+
|
569
|
+
[The Stats API](https://github.com/wildbit/postmark-gem/wiki/) can be used to access statistics on your emails sent by date and tag.
|
570
|
+
|
571
|
+
|
567
572
|
## ActiveModel-like Interface For Bounces
|
568
573
|
|
569
574
|
To provide an interface similar to ActiveModel for bounces, the Postmark gem adds
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.7.0
|
data/lib/postmark/api_client.rb
CHANGED
@@ -221,6 +221,22 @@ module Postmark
|
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
224
|
+
def get_stats_totals(options = {})
|
225
|
+
format_response(http_client.get('stats/outbound', options))
|
226
|
+
end
|
227
|
+
|
228
|
+
def get_stats_counts(stat, options = {})
|
229
|
+
url = "stats/outbound/#{stat}"
|
230
|
+
|
231
|
+
url << "/#{options[:type]}" if options.has_key?(:type)
|
232
|
+
|
233
|
+
response = format_response(http_client.get(url, options))
|
234
|
+
|
235
|
+
response[:days].map! { |d| HashHelper.to_ruby(d) }
|
236
|
+
|
237
|
+
response
|
238
|
+
end
|
239
|
+
|
224
240
|
protected
|
225
241
|
|
226
242
|
def in_batches(messages)
|
data/lib/postmark/version.rb
CHANGED
@@ -409,7 +409,7 @@ describe Postmark::ApiClient do
|
|
409
409
|
expect(subject.opens.first(5).count).to eq(1)
|
410
410
|
end
|
411
411
|
|
412
|
-
end
|
412
|
+
end
|
413
413
|
|
414
414
|
describe '#get_opens' do
|
415
415
|
let(:http_client) { subject.http_client }
|
@@ -827,4 +827,84 @@ describe Postmark::ApiClient do
|
|
827
827
|
r.should have_key(:message_id)
|
828
828
|
end
|
829
829
|
end
|
830
|
+
|
831
|
+
describe '#get_stats_totals' do
|
832
|
+
let(:response) do
|
833
|
+
{
|
834
|
+
"Sent" => 615,
|
835
|
+
"BounceRate" => 10.406,
|
836
|
+
}
|
837
|
+
end
|
838
|
+
let(:http_client) { subject.http_client }
|
839
|
+
|
840
|
+
it 'converts response to ruby format' do
|
841
|
+
http_client.should_receive(:get).with('stats/outbound', { :tag => 'foo' }) { response }
|
842
|
+
r = subject.get_stats_totals(:tag => 'foo')
|
843
|
+
r.should have_key(:sent)
|
844
|
+
r.should have_key(:bounce_rate)
|
845
|
+
end
|
846
|
+
end
|
847
|
+
|
848
|
+
describe '#get_stats_counts' do
|
849
|
+
let(:response) do
|
850
|
+
{
|
851
|
+
"Days" => [
|
852
|
+
{
|
853
|
+
"Date" => "2014-01-01",
|
854
|
+
"Sent" => 140
|
855
|
+
},
|
856
|
+
{
|
857
|
+
"Date" => "2014-01-02",
|
858
|
+
"Sent" => 160
|
859
|
+
},
|
860
|
+
{
|
861
|
+
"Date" => "2014-01-04",
|
862
|
+
"Sent" => 50
|
863
|
+
},
|
864
|
+
{
|
865
|
+
"Date" => "2014-01-05",
|
866
|
+
"Sent" => 115
|
867
|
+
}
|
868
|
+
],
|
869
|
+
"Sent" => 615
|
870
|
+
}
|
871
|
+
end
|
872
|
+
let(:http_client) { subject.http_client }
|
873
|
+
|
874
|
+
it 'converts response to ruby format' do
|
875
|
+
http_client.should_receive(:get).with('stats/outbound/sends', { :tag => 'foo' }) { response }
|
876
|
+
r = subject.get_stats_counts(:sends, :tag => 'foo')
|
877
|
+
r.should have_key(:days)
|
878
|
+
r.should have_key(:sent)
|
879
|
+
|
880
|
+
first_day = r[:days].first
|
881
|
+
|
882
|
+
first_day.should have_key(:date)
|
883
|
+
first_day.should have_key(:sent)
|
884
|
+
end
|
885
|
+
|
886
|
+
it 'uses fromdate that is passed in' do
|
887
|
+
http_client.should_receive(:get).with('stats/outbound/sends', { :tag => 'foo', :fromdate => '2015-01-01' }) { response }
|
888
|
+
r = subject.get_stats_counts(:sends, :tag => 'foo', :fromdate => '2015-01-01')
|
889
|
+
r.should have_key(:days)
|
890
|
+
r.should have_key(:sent)
|
891
|
+
|
892
|
+
first_day = r[:days].first
|
893
|
+
|
894
|
+
first_day.should have_key(:date)
|
895
|
+
first_day.should have_key(:sent)
|
896
|
+
end
|
897
|
+
|
898
|
+
it 'uses stats type that is passed in' do
|
899
|
+
http_client.should_receive(:get).with('stats/outbound/opens/readtimes', { :tag => 'foo', :type => :readtimes }) { response }
|
900
|
+
r = subject.get_stats_counts(:opens, :type => :readtimes, :tag => 'foo')
|
901
|
+
r.should have_key(:days)
|
902
|
+
r.should have_key(:sent)
|
903
|
+
|
904
|
+
first_day = r[:days].first
|
905
|
+
|
906
|
+
first_day.should have_key(:date)
|
907
|
+
first_day.should have_key(:sent)
|
908
|
+
end
|
909
|
+
end
|
830
910
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postmark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petyo Ivanov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-09-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
version: 1.3.7
|
142
142
|
requirements: []
|
143
143
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.4.
|
144
|
+
rubygems_version: 2.4.6
|
145
145
|
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: Official Postmark API wrapper.
|