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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17d7c0c5ea350fd8902efaa8e8334dff894fe215
4
- data.tar.gz: 17f7871d1544d69b7cf16d75c4ba260048de182c
3
+ metadata.gz: 55e9f7a191eaed08f4f65b7291d679dbba6665bf
4
+ data.tar.gz: 04cba05dd0d1f5a872a4b408d9ffb0d10511e782
5
5
  SHA512:
6
- metadata.gz: 38df57ae61ce36c80870832444d017083e1bff043901823eb675384ae25df1366f420170abf41059a7601d7a6a2c7e26866a15abf8c5b98fa7fa30b7d8cbeeb8
7
- data.tar.gz: 4dcacb79aec065cf65445da357f0b3e275911da17881291124dacd70b0bccacb1a3d69b4779f34f010692b7667710a0e0b6c8214a00af557b65d86746fc0a499
6
+ metadata.gz: ff849c87686ddf3eae5af58661de0c43888d1e82910081b1c07ac4bc6d8f44a29a18b9e6938c5db020c46145d36dbd35b71bec24383ead16e991757f99829868
7
+ data.tar.gz: 77eaa67674a06887f47584485cfa2e6666d5c6d1f3dd75f969d5af97c38cccbe7109c303cc56aba21d90fc4adc641aaef606e2cb27d014f04012e4f471d5e24d
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ Gemfile.lock
4
4
  pkg/*
5
5
  .rvmrc
6
6
  .idea
7
+ bin/*
@@ -8,6 +8,7 @@ rvm:
8
8
  - 1.8.7
9
9
  - 1.9.3
10
10
  - 2.0.0
11
- - 2.1.0
11
+ - 2.1.6
12
+ - 2.2.2
12
13
  - jruby-19mode
13
14
  script: bundle exec rake spec
@@ -1,5 +1,9 @@
1
1
  = Changelog
2
2
 
3
+ == 1.7.0
4
+
5
+ * Add methods to access stats API endpoints.
6
+
3
7
  == 1.6.0
4
8
 
5
9
  * Add methods to access new templates API endpoints.
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.6.0
1
+ 1.7.0
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Postmark
2
- VERSION = '1.6.0'
2
+ VERSION = '1.7.0'
3
3
  end
@@ -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.6.0
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-08-04 00:00:00.000000000 Z
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.5
144
+ rubygems_version: 2.4.6
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Official Postmark API wrapper.