postmaster 1.2.1 → 1.3.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.
@@ -81,6 +81,21 @@ result = shipment.track()
81
81
  result = shipment.void()
82
82
  #puts result.inspect
83
83
 
84
+ # list all created shipments
85
+ result = Postmaster::Shipment.all()
86
+ #puts result.inspect
87
+
88
+ # list 3 newest shipments
89
+ result = Postmaster::Shipment.all(:limit => 3)
90
+ #puts result.inspect
91
+
92
+ # monitor external package
93
+ result = Postmaster::Tracking.monitor_external(
94
+ :tracking_no => "1ZW470V80310800043",
95
+ :url => "http://example.com/your-http-post-listener"
96
+ )
97
+ #puts result.inspect
98
+
84
99
  # create box example
85
100
  result = Postmaster::Package.create(
86
101
  :width => 10,
@@ -1,11 +1,16 @@
1
1
  module Postmaster
2
2
 
3
3
  class Tracking < APIResource
4
-
4
+
5
5
  def self.track(tracking_id)
6
6
  response = Postmaster.request(:get, '/v1/track', {:tracking => tracking_id})
7
7
  self.construct_from(response)
8
8
  end
9
+
10
+ def self.monitor_external(params={})
11
+ response = Postmaster.request(:post, '/v1/track', params)
12
+ return true
13
+ end
9
14
  end
10
15
 
11
16
  class TrackingHistory < APIResource
@@ -1,3 +1,3 @@
1
1
  module Postmaster
2
- VERSION = '1.2.1'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -1,27 +1,36 @@
1
- # -*- coding: utf-8 -*-
2
- require 'test/unit'
3
- require 'postmaster'
4
- require 'rubygems'
5
- require 'shoulda'
6
- require 'mocha'
7
- require 'rest-client'
8
- require 'cgi'
9
- require 'uri'
10
-
11
- class TestTrackingRuby < Test::Unit::TestCase
12
- include Mocha
13
-
14
- context "Tracking" do
15
-
16
- should "return data" do
17
- result = Postmaster::Tracking.track('1ZW470V80310800043')
18
-
19
- assert_instance_of(Postmaster::Tracking, result);
1
+ # -*- coding: utf-8 -*-
2
+ require 'test/unit'
3
+ require 'postmaster'
4
+ require 'rubygems'
5
+ require 'shoulda'
6
+ require 'mocha'
7
+ require 'rest-client'
8
+ require 'cgi'
9
+ require 'uri'
10
+
11
+ class TestTrackingRuby < Test::Unit::TestCase
12
+ include Mocha
13
+
14
+ context "Tracking" do
15
+
16
+ should "return data" do
17
+ result = Postmaster::Tracking.track('1ZW470V80310800043')
18
+
19
+ assert_instance_of(Postmaster::Tracking, result);
20
20
  assert(result.keys.include?(:status))
21
21
  assert(result.keys.include?(:history))
22
22
  assert(!result.history.empty?)
23
- assert_instance_of(Postmaster::TrackingHistory, result.history[0])
24
- end
25
-
26
- end
27
- end
23
+ assert_instance_of(Postmaster::TrackingHistory, result.history[0])
24
+ end
25
+
26
+ should "monitor external packages" do
27
+ result = Postmaster::Tracking.monitor_external(
28
+ :tracking_no => "1ZW470V80310800043",
29
+ :url => "http://example.com/your-http-post-listener"
30
+ )
31
+
32
+ assert_instance_of(TrueClass, result)
33
+ end
34
+
35
+ end
36
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postmaster
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 1
10
- version: 1.2.1
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Postmaster
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-06-26 00:00:00 Z
18
+ date: 2013-08-26 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rest-client