stamps 0.3.0 → 0.3.1

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.
data/.gitignore CHANGED
@@ -7,3 +7,7 @@ pkg/*
7
7
  runner.rb
8
8
  .yardoc/*
9
9
  doc/*
10
+ .floo
11
+ .flooignore
12
+ .sublime-project
13
+ Gemfile.lock
@@ -16,10 +16,10 @@ module Stamps
16
16
  :endpoint].freeze
17
17
 
18
18
  # The endpoint that will be used to connect if none is set
19
- DEFAULT_ENDPOINT = 'https://swsim.stamps.com/swsim/swsimv12.asmx'.freeze
20
-
19
+ DEFAULT_ENDPOINT = 'https://swsim.stamps.com/swsim/swsimv29.asmx'.freeze
20
+
21
21
  # The default namespace used on Stamps.com wsdl
22
- DEFAULT_NAMESPACE = 'http://stamps.com/xml/namespace/2010/11/swsim/swsimv12'
22
+ DEFAULT_NAMESPACE = 'http://stamps.com/xml/namespace/2010/11/swsim/swsimv29'
23
23
 
24
24
  # @note JSON is preferred over XML because it is more concise and faster to parse.
25
25
  DEFAULT_FORMAT = :hash
@@ -46,10 +46,10 @@ module Stamps
46
46
  yield self
47
47
 
48
48
  HTTPI.log = false
49
- Savon.configure do |config|
50
- config.log = self.log_messages
51
- config.raise_errors = self.raise_errors
52
- end
49
+ # Savon.configure do |config|
50
+ # config.log = self.log_messages
51
+ # config.raise_errors = self.raise_errors
52
+ # end
53
53
  end
54
54
 
55
55
  # Create a hash of options and their values
data/lib/stamps/errors.rb CHANGED
@@ -31,4 +31,8 @@ module Stamps
31
31
  # Raised when Stamps.com returns the HTTP status code 503
32
32
  class ServiceUnavailable < Error; end
33
33
 
34
+ # Raised when the get_authenticator_token returns errors
35
+ # See https://github.com/mattsears/stamps/issues/7
36
+ class InvalidIntegrationID < Error; end
37
+
34
38
  end
@@ -73,21 +73,26 @@ module Stamps
73
73
 
74
74
  # Maps :rate to AddOns map
75
75
  def add_ons=(addons)
76
- self[:AddOns] = AddOnsArray.new(:add_on => addons[:add_on])
76
+ self[:AddOns] = AddOnsArray.new(:add_on_v4 => addons[:add_on_v4])
77
77
  end
78
78
  end
79
79
 
80
80
  class AddOnsArray < Hashie::Trash
81
- property :AddOnV2, :from => :add_on
82
- def add_on=(vals)
81
+ property :AddOnV4, :from => :add_on_v4
82
+ def add_on_v4=(vals)
83
83
  return unless vals
84
- self[:AddOnV2] = vals.map{ |value| AddOnV2.new(value).to_hash }
84
+ self[:AddOnV4] = vals.map{ |value| AddOnV4.new(value).to_hash }
85
85
  end
86
86
  end
87
87
 
88
- class AddOnV2 < Hashie::Trash
88
+ class AddOnV4 < Hashie::Trash
89
89
  property :Amount, :from => :amount
90
- property :AddOnType, :from => :type
90
+ property :AddOnType, :from => :add_on_type
91
+ property :ProhibitedWithAnyOf, :from => :prohibited_with
92
+ property :MissingData, :from => :missing_data
93
+ def prohibited_with_any_of; end
94
+ def prohibited_with_any_of=(vals); end
95
+ property :RequiresAllOf, :from => :requires_all_of
91
96
  end
92
97
 
93
98
  class Stamp < Hashie::Trash
@@ -103,7 +108,7 @@ module Stamps
103
108
  property :ImageType, :from => :image_type
104
109
  property :EltronPrinterDPIType, :from => :label_resolution
105
110
  property :memo
106
- property :recipient_email, :from => :recipient_email
111
+ property :recipient_email
107
112
  property :deliveryNotification, :from => :notify
108
113
  property :shipmentNotificationCC, :from => :notify_crates
109
114
  property :shipmentNotificationFromCompany, :from => :notify_from_company
@@ -9,19 +9,20 @@ module Stamps
9
9
 
10
10
  # Perform an HTTP request
11
11
  def request(web_method, params, raw=false)
12
- client = Savon::Client.new do |wsdl, http|
13
- wsdl.endpoint = self.endpoint
14
- wsdl.namespace = self.namespace
12
+ client = Savon.client do |globals|
13
+ globals.endpoint self.endpoint
14
+ globals.namespace self.namespace
15
+ globals.namespaces("xmlns:tns" => self.namespace)
16
+ globals.log false
17
+ globals.logger Logger.new(STDOUT)
18
+ globals.raise_errors false
19
+ globals.headers({ "SoapAction" => formatted_soap_action(web_method) })
20
+ globals.element_form_default :qualified
21
+ globals.namespace_identifier :tns
15
22
  end
16
23
 
17
- response = client.request :tns, web_method do
18
- http.headers = { "SoapAction" => formatted_soap_action(web_method) }
19
- soap.namespace = 'tns'
20
- soap.element_form_default = :qualified
21
- soap.env_namespace = 'soap'
22
- soap.namespaces["xmlns:tns"] = self.namespace
23
- soap.body = params.to_hash
24
- end
24
+ response = client.call(web_method, :message => params.to_hash)
25
+
25
26
  Stamps::Response.new(response).to_hash
26
27
  end
27
28
 
@@ -36,14 +37,19 @@ module Stamps
36
37
  # Make Authentication request for the user
37
38
  #
38
39
  def get_authenticator_token
39
- self.request('AuthenticateUser',
40
+ response_hash = self.request('AuthenticateUser',
40
41
  Stamps::Mapping::AuthenticateUser.new(
41
42
  :credentials => {
42
43
  :integration_id => self.integration_id,
43
44
  :username => self.username,
44
45
  :password => self.password
45
46
  })
46
- )[:authenticate_user_response][:authenticator]
47
+ )
48
+ if response_hash[:authenticate_user_response] != nil
49
+ response_hash[:authenticate_user_response][:authenticator]
50
+ else
51
+ raise Stamps::InvalidIntegrationID.new(response_hash[:errors][0])
52
+ end
47
53
  end
48
54
 
49
55
  # Concatenates namespace and web method in a way the API can understand
@@ -23,7 +23,8 @@ module Stamps
23
23
  self.hash.merge!(:errors => self.errors)
24
24
  self.hash.merge!(:valid? => self.valid)
25
25
  self.hash
26
- Stamps.format.to_s.downcase == 'hashie' ? Hashie::Mash.new(@hash) : self.hash
26
+ # binding.pry
27
+ Stamps.format.to_s.downcase == 'hashie' ? Hashie::Trash.new(@hash) : self.hash
27
28
  end
28
29
 
29
30
  # Um, there's gotta be a better way
@@ -37,7 +38,7 @@ module Stamps
37
38
  #
38
39
  def raise_errors
39
40
  message = 'FIXME: Need to parse http for response message'
40
- return self.format_soap_faults if savon.soap_fault.present?
41
+ return self.format_soap_faults if savon.soap_fault?
41
42
 
42
43
  case http.code.to_i
43
44
  when 200
@@ -62,8 +63,8 @@ module Stamps
62
63
  # Include any errors in the response
63
64
  #
64
65
  def format_soap_faults
65
- fault = self.hash.delete(:fault)
66
- self.errors << fault[:faultstring]
66
+ fault = self.hash.delete("soap:Fault") || self.hash.delete(:fault)
67
+ self.errors << (fault[:faultstring] || fault["faultstring"])
67
68
  self.valid = false
68
69
  end
69
70
 
data/lib/stamps/types.rb CHANGED
@@ -16,17 +16,24 @@ module Stamps
16
16
  'Flat Rate Envelope',
17
17
  'Flat Rate Padded Envelope',
18
18
  'Large Package',
19
- 'Oversized Package'].freeze
19
+ 'Oversized Package',
20
+ 'Regional Rate Box A',
21
+ 'Regional Rate Box B',
22
+ 'Legal Flat Rate Envelope',
23
+ 'Regional Rate Box C'].freeze
20
24
 
21
25
  SERVICE = {
22
26
  'US-FC' => 'USPS First-Class Mail',
23
27
  'US-MM' => 'USPS Media Mail',
24
- 'US-PP' => 'USPS Parcel Post',
25
28
  'US-PM' => 'USPS Priority Mail',
29
+ 'US-BP' => 'USPS BP',
30
+ 'US-LM' => 'USPS LM',
26
31
  'US-XM' => 'USPS Express Mail',
27
32
  'US-EMI' => 'USPS Express Mail International',
28
33
  'US-PMI' => 'USPS Priority Mail International',
29
- 'US-FCI' => 'USPS First Class Mail International'
34
+ 'US-FCI' => 'USPS First Class Mail International',
35
+ 'US-CM' => 'USPS Critical Mail',
36
+ 'US-PS' => 'USPS Parcel Select'
30
37
  }
31
38
 
32
39
  ADD_ONS = {
@@ -46,10 +53,9 @@ module Stamps
46
53
  'US-A-RRM' => 'Return Receipt for Merchandise',
47
54
  'US-A-SC' => 'USPS Signature Confirmation',
48
55
  'US-A-SH' => 'Special Handling',
49
- 'US-A-WDS' => 'USPS Express - Waive Delivery Signature',
50
- 'US-A-NDW' => 'Do not Deliver on Saturday',
51
- 'US-A-ESH' => 'Sunday/Holiday Delivery Guaranteed',
52
56
  'US-A-NND' => 'Notice of non-delivery',
57
+ 'US-A-SR' => 'Unknow Service Name SR',
58
+ 'US-A-RRE' => 'Unknow Service Name RRE'
53
59
  }
54
60
 
55
61
  CARRIER_PICKUP_LOCATION = {
@@ -1,3 +1,3 @@
1
1
  module Stamps
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/stamps.gemspec CHANGED
@@ -26,13 +26,15 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency('awesome_print')
27
27
  s.add_development_dependency('yard')
28
28
  s.add_development_dependency('bluecloth')
29
+ s.add_development_dependency('rake')
30
+ s.add_development_dependency('pry')
29
31
 
30
32
  # We have to use savon 0.8.6 for now since newer versions of savon don't
31
33
  # convert booleans, dates, or decimals consistently.
32
34
  # See: https://github.com/rubiii/savon/issues/301
33
- s.add_runtime_dependency('savon', '0.8.6')
34
- s.add_runtime_dependency('httpi', '0.7.9')
35
- s.add_runtime_dependency('json', '~> 1.5.1')
35
+ s.add_runtime_dependency('savon', '~> 2.3.0')
36
+ s.add_runtime_dependency('httpi', '~> 2.1.0')
37
+ s.add_runtime_dependency('json', '~> 1.0')
36
38
  s.add_runtime_dependency('multi_json', '~> 1.0')
37
39
  s.add_runtime_dependency('hashie', '~> 1.0.0')
38
40
  end
@@ -22,7 +22,7 @@ class StampsTest < Test::Unit::TestCase
22
22
  end
23
23
 
24
24
  should 'return the ship date' do
25
- assert_equal '2011-04-01', @rates.first[:ship_date]
25
+ assert_equal Date.new(2011, 04, 01), @rates.first[:ship_date]
26
26
  end
27
27
 
28
28
  end
@@ -16,141 +16,141 @@
16
16
  <ShipDate>2011-04-21</ShipDate>
17
17
  <DimWeighting>N</DimWeighting>
18
18
  <AddOns>
19
- <AddOnV2>
19
+ <AddOnV4>
20
20
  <AddOnType>US-A-INS</AddOnType>
21
21
  <ProhibitedWithAnyOf>
22
- <AddOnTypeV2>SC-A-HP</AddOnTypeV2>
23
- <AddOnTypeV2>US-A-REG</AddOnTypeV2>
24
- <AddOnTypeV2>US-A-CM</AddOnTypeV2>
25
- <AddOnTypeV2>US-A-COD</AddOnTypeV2>
26
- <AddOnTypeV2>SC-A-INS</AddOnTypeV2>
22
+ <AddOnTypeV4>SC-A-HP</AddOnTypeV4>
23
+ <AddOnTypeV4>US-A-REG</AddOnTypeV4>
24
+ <AddOnTypeV4>US-A-CM</AddOnTypeV4>
25
+ <AddOnTypeV4>US-A-COD</AddOnTypeV4>
26
+ <AddOnTypeV4>SC-A-INS</AddOnTypeV4>
27
27
  </ProhibitedWithAnyOf>
28
28
  <MissingData>InsuredValue</MissingData>
29
- </AddOnV2>
30
- <AddOnV2>
29
+ </AddOnV4>
30
+ <AddOnV4>
31
31
  <AddOnType>US-A-COD</AddOnType>
32
32
  <ProhibitedWithAnyOf>
33
- <AddOnTypeV2>SC-A-HP</AddOnTypeV2>
34
- <AddOnTypeV2>US-A-RRM</AddOnTypeV2>
35
- <AddOnTypeV2>US-A-INS</AddOnTypeV2>
36
- <AddOnTypeV2>US-A-CM</AddOnTypeV2>
33
+ <AddOnTypeV4>SC-A-HP</AddOnTypeV4>
34
+ <AddOnTypeV4>US-A-RRM</AddOnTypeV4>
35
+ <AddOnTypeV4>US-A-INS</AddOnTypeV4>
36
+ <AddOnTypeV4>US-A-CM</AddOnTypeV4>
37
37
  </ProhibitedWithAnyOf>
38
38
  <MissingData>CODValue</MissingData>
39
- </AddOnV2>
40
- <AddOnV2>
39
+ </AddOnV4>
40
+ <AddOnV4>
41
41
  <AddOnType>US-A-DC</AddOnType>
42
42
  <ProhibitedWithAnyOf>
43
- <AddOnTypeV2>US-A-SC</AddOnTypeV2>
44
- <AddOnTypeV2>US-A-CM</AddOnTypeV2>
43
+ <AddOnTypeV4>US-A-SC</AddOnTypeV4>
44
+ <AddOnTypeV4>US-A-CM</AddOnTypeV4>
45
45
  </ProhibitedWithAnyOf>
46
- </AddOnV2>
47
- <AddOnV2>
46
+ </AddOnV4>
47
+ <AddOnV4>
48
48
  <Amount>2.05</Amount>
49
49
  <AddOnType>US-A-SC</AddOnType>
50
50
  <ProhibitedWithAnyOf>
51
- <AddOnTypeV2>US-A-DC</AddOnTypeV2>
52
- <AddOnTypeV2>US-A-CM</AddOnTypeV2>
53
- <AddOnTypeV2>US-A-RRM</AddOnTypeV2>
51
+ <AddOnTypeV4>US-A-DC</AddOnTypeV4>
52
+ <AddOnTypeV4>US-A-CM</AddOnTypeV4>
53
+ <AddOnTypeV4>US-A-RRM</AddOnTypeV4>
54
54
  </ProhibitedWithAnyOf>
55
- </AddOnV2>
56
- <AddOnV2>
55
+ </AddOnV4>
56
+ <AddOnV4>
57
57
  <Amount>2.85</Amount>
58
58
  <AddOnType>US-A-CM</AddOnType>
59
59
  <ProhibitedWithAnyOf>
60
- <AddOnTypeV2>SC-A-HP</AddOnTypeV2>
61
- <AddOnTypeV2>US-A-RRM</AddOnTypeV2>
62
- <AddOnTypeV2>US-A-REG</AddOnTypeV2>
63
- <AddOnTypeV2>US-A-DC</AddOnTypeV2>
64
- <AddOnTypeV2>US-A-COD</AddOnTypeV2>
65
- <AddOnTypeV2>US-A-SC</AddOnTypeV2>
66
- <AddOnTypeV2>US-A-INS</AddOnTypeV2>
60
+ <AddOnTypeV4>SC-A-HP</AddOnTypeV4>
61
+ <AddOnTypeV4>US-A-RRM</AddOnTypeV4>
62
+ <AddOnTypeV4>US-A-REG</AddOnTypeV4>
63
+ <AddOnTypeV4>US-A-DC</AddOnTypeV4>
64
+ <AddOnTypeV4>US-A-COD</AddOnTypeV4>
65
+ <AddOnTypeV4>US-A-SC</AddOnTypeV4>
66
+ <AddOnTypeV4>US-A-INS</AddOnTypeV4>
67
67
  </ProhibitedWithAnyOf>
68
- </AddOnV2>
69
- <AddOnV2>
68
+ </AddOnV4>
69
+ <AddOnV4>
70
70
  <Amount>2.3</Amount>
71
71
  <AddOnType>US-A-RR</AddOnType>
72
72
  <RequiresAllOf>
73
73
  <RequiresOneOf>
74
- <AddOnTypeV2>US-A-COD</AddOnTypeV2>
75
- <AddOnTypeV2>US-A-REG</AddOnTypeV2>
76
- <AddOnTypeV2>US-A-CM</AddOnTypeV2>
77
- <AddOnTypeV2>US-A-INS</AddOnTypeV2>
74
+ <AddOnTypeV4>US-A-COD</AddOnTypeV4>
75
+ <AddOnTypeV4>US-A-REG</AddOnTypeV4>
76
+ <AddOnTypeV4>US-A-CM</AddOnTypeV4>
77
+ <AddOnTypeV4>US-A-INS</AddOnTypeV4>
78
78
  </RequiresOneOf>
79
79
  </RequiresAllOf>
80
80
  <ProhibitedWithAnyOf>
81
- <AddOnTypeV2>SC-A-HP</AddOnTypeV2>
82
- <AddOnTypeV2>US-A-RRM</AddOnTypeV2>
81
+ <AddOnTypeV4>SC-A-HP</AddOnTypeV4>
82
+ <AddOnTypeV4>US-A-RRM</AddOnTypeV4>
83
83
  </ProhibitedWithAnyOf>
84
- </AddOnV2>
85
- <AddOnV2>
84
+ </AddOnV4>
85
+ <AddOnV4>
86
86
  <Amount>10.75</Amount>
87
87
  <AddOnType>US-A-REG</AddOnType>
88
88
  <ProhibitedWithAnyOf>
89
- <AddOnTypeV2>SC-A-HP</AddOnTypeV2>
90
- <AddOnTypeV2>US-A-CM</AddOnTypeV2>
91
- <AddOnTypeV2>US-A-INS</AddOnTypeV2>
92
- <AddOnTypeV2>US-A-RRM</AddOnTypeV2>
93
- <AddOnTypeV2>SC-A-INS</AddOnTypeV2>
89
+ <AddOnTypeV4>SC-A-HP</AddOnTypeV4>
90
+ <AddOnTypeV4>US-A-CM</AddOnTypeV4>
91
+ <AddOnTypeV4>US-A-INS</AddOnTypeV4>
92
+ <AddOnTypeV4>US-A-RRM</AddOnTypeV4>
93
+ <AddOnTypeV4>SC-A-INS</AddOnTypeV4>
94
94
  </ProhibitedWithAnyOf>
95
- </AddOnV2>
96
- <AddOnV2>
95
+ </AddOnV4>
96
+ <AddOnV4>
97
97
  <Amount>4.5</Amount>
98
98
  <AddOnType>US-A-RD</AddOnType>
99
99
  <RequiresAllOf>
100
100
  <RequiresOneOf>
101
- <AddOnTypeV2>US-A-COD</AddOnTypeV2>
102
- <AddOnTypeV2>US-A-REG</AddOnTypeV2>
103
- <AddOnTypeV2>US-A-CM</AddOnTypeV2>
104
- <AddOnTypeV2>US-A-INS</AddOnTypeV2>
101
+ <AddOnTypeV4>US-A-COD</AddOnTypeV4>
102
+ <AddOnTypeV4>US-A-REG</AddOnTypeV4>
103
+ <AddOnTypeV4>US-A-CM</AddOnTypeV4>
104
+ <AddOnTypeV4>US-A-INS</AddOnTypeV4>
105
105
  </RequiresOneOf>
106
106
  </RequiresAllOf>
107
107
  <ProhibitedWithAnyOf>
108
- <AddOnTypeV2>SC-A-HP</AddOnTypeV2>
109
- <AddOnTypeV2>US-A-RRM</AddOnTypeV2>
108
+ <AddOnTypeV4>SC-A-HP</AddOnTypeV4>
109
+ <AddOnTypeV4>US-A-RRM</AddOnTypeV4>
110
110
  </ProhibitedWithAnyOf>
111
- </AddOnV2>
112
- <AddOnV2>
111
+ </AddOnV4>
112
+ <AddOnV4>
113
113
  <AddOnType>SC-A-INS</AddOnType>
114
114
  <ProhibitedWithAnyOf>
115
- <AddOnTypeV2>US-A-REG</AddOnTypeV2>
116
- <AddOnTypeV2>US-A-INS</AddOnTypeV2>
115
+ <AddOnTypeV4>US-A-REG</AddOnTypeV4>
116
+ <AddOnTypeV4>US-A-INS</AddOnTypeV4>
117
117
  </ProhibitedWithAnyOf>
118
118
  <MissingData>InsuredValue</MissingData>
119
- </AddOnV2>
120
- <AddOnV2>
119
+ </AddOnV4>
120
+ <AddOnV4>
121
121
  <AddOnType>SC-A-HP</AddOnType>
122
122
  <ProhibitedWithAnyOf>
123
- <AddOnTypeV2>US-A-RRM</AddOnTypeV2>
124
- <AddOnTypeV2>US-A-INS</AddOnTypeV2>
125
- <AddOnTypeV2>US-A-REG</AddOnTypeV2>
126
- <AddOnTypeV2>US-A-RD</AddOnTypeV2>
127
- <AddOnTypeV2>US-A-COD</AddOnTypeV2>
128
- <AddOnTypeV2>US-A-CM</AddOnTypeV2>
129
- <AddOnTypeV2>US-A-RR</AddOnTypeV2>
123
+ <AddOnTypeV4>US-A-RRM</AddOnTypeV4>
124
+ <AddOnTypeV4>US-A-INS</AddOnTypeV4>
125
+ <AddOnTypeV4>US-A-REG</AddOnTypeV4>
126
+ <AddOnTypeV4>US-A-RD</AddOnTypeV4>
127
+ <AddOnTypeV4>US-A-COD</AddOnTypeV4>
128
+ <AddOnTypeV4>US-A-CM</AddOnTypeV4>
129
+ <AddOnTypeV4>US-A-RR</AddOnTypeV4>
130
130
  </ProhibitedWithAnyOf>
131
- </AddOnV2>
132
- <AddOnV2>
131
+ </AddOnV4>
132
+ <AddOnV4>
133
133
  <Amount>3.9</Amount>
134
134
  <AddOnType>US-A-NND</AddOnType>
135
135
  <RequiresAllOf>
136
136
  <RequiresOneOf>
137
- <AddOnTypeV2>US-A-COD</AddOnTypeV2>
137
+ <AddOnTypeV4>US-A-COD</AddOnTypeV4>
138
138
  </RequiresOneOf>
139
139
  </RequiresAllOf>
140
- </AddOnV2>
141
- <AddOnV2>
140
+ </AddOnV4>
141
+ <AddOnV4>
142
142
  <Amount>3.85</Amount>
143
143
  <AddOnType>US-A-RRM</AddOnType>
144
144
  <ProhibitedWithAnyOf>
145
- <AddOnTypeV2>SC-A-HP</AddOnTypeV2>
146
- <AddOnTypeV2>US-A-REG</AddOnTypeV2>
147
- <AddOnTypeV2>US-A-RD</AddOnTypeV2>
148
- <AddOnTypeV2>US-A-COD</AddOnTypeV2>
149
- <AddOnTypeV2>US-A-SC</AddOnTypeV2>
150
- <AddOnTypeV2>US-A-CM</AddOnTypeV2>
151
- <AddOnTypeV2>US-A-RR</AddOnTypeV2>
145
+ <AddOnTypeV4>SC-A-HP</AddOnTypeV4>
146
+ <AddOnTypeV4>US-A-REG</AddOnTypeV4>
147
+ <AddOnTypeV4>US-A-RD</AddOnTypeV4>
148
+ <AddOnTypeV4>US-A-COD</AddOnTypeV4>
149
+ <AddOnTypeV4>US-A-SC</AddOnTypeV4>
150
+ <AddOnTypeV4>US-A-CM</AddOnTypeV4>
151
+ <AddOnTypeV4>US-A-RR</AddOnTypeV4>
152
152
  </ProhibitedWithAnyOf>
153
- </AddOnV2>
153
+ </AddOnV4>
154
154
  </AddOns>
155
155
  <EffectiveWeightInOunces>8</EffectiveWeightInOunces>
156
156
  <IsIntraBMC>true</IsIntraBMC>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2
+ <soap:Body>
3
+ <soap:Fault>
4
+ <faultcode>soap:Client</faultcode>
5
+ <faultstring>Server did not recognize the value of HTTP Header SOAPAction: http://stamps.com/xml/namespace/2013/05/swsim/swsimv26/AuthenticateUser.</faultstring>
6
+ <detail />
7
+ </soap:Fault>
8
+ </soap:Body>
9
+ </soap:Envelope>
10
+
data/test/helper.rb CHANGED
@@ -35,6 +35,7 @@ end
35
35
  # Stub requests
36
36
  def stub_post(web_method, soap_action = nil)
37
37
  soap_action = web_method if soap_action.nil?
38
+
38
39
  stub_request(:post, Stamps.endpoint).
39
40
  with(:headers => {"SoapAction" => "#{Stamps.namespace}/#{soap_action}"}).
40
41
  to_return(:body => fixture("#{web_method}.xml"))
@@ -42,7 +43,7 @@ end
42
43
 
43
44
  def stub_response(web_method, code = 200)
44
45
  http_response = HTTPI::Response.new(code, {}, fixture("#{web_method}.xml").read)
45
- Stamps::Response.new(Savon::SOAP::Response.new(http_response))
46
+ Stamps::Response.new(Savon::Response.new(http_response, {}, {}))
46
47
  end
47
48
 
48
49
  def fixture_path
@@ -52,7 +53,3 @@ end
52
53
  def fixture(file)
53
54
  File.new(fixture_path + '/' + file)
54
55
  end
55
-
56
- Savon.configure do |config|
57
- config.log = false # disable logging
58
- end
@@ -0,0 +1,18 @@
1
+ $:.unshift File.dirname(__FILE__) # allows command line to execute tests
2
+ require 'helper'
3
+
4
+ class RequestTest < Test::Unit::TestCase
5
+ context "get_authenticator_token" do
6
+ context "with invalid authentication token" do
7
+ setup do
8
+ stub_post("failed_auth", "AuthenticateUser")
9
+ end
10
+
11
+ should "raise an exception" do
12
+ assert_raises Stamps::InvalidIntegrationID do
13
+ Stamps::API.new.get_authenticator_token
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stamps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-30 00:00:00.000000000 Z
12
+ date: 2013-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: simplecov
@@ -123,38 +123,70 @@ dependencies:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rake
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: pry
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
126
158
  - !ruby/object:Gem::Dependency
127
159
  name: savon
128
160
  requirement: !ruby/object:Gem::Requirement
129
161
  none: false
130
162
  requirements:
131
- - - '='
163
+ - - ~>
132
164
  - !ruby/object:Gem::Version
133
- version: 0.8.6
165
+ version: 2.3.0
134
166
  type: :runtime
135
167
  prerelease: false
136
168
  version_requirements: !ruby/object:Gem::Requirement
137
169
  none: false
138
170
  requirements:
139
- - - '='
171
+ - - ~>
140
172
  - !ruby/object:Gem::Version
141
- version: 0.8.6
173
+ version: 2.3.0
142
174
  - !ruby/object:Gem::Dependency
143
175
  name: httpi
144
176
  requirement: !ruby/object:Gem::Requirement
145
177
  none: false
146
178
  requirements:
147
- - - '='
179
+ - - ~>
148
180
  - !ruby/object:Gem::Version
149
- version: 0.7.9
181
+ version: 2.1.0
150
182
  type: :runtime
151
183
  prerelease: false
152
184
  version_requirements: !ruby/object:Gem::Requirement
153
185
  none: false
154
186
  requirements:
155
- - - '='
187
+ - - ~>
156
188
  - !ruby/object:Gem::Version
157
- version: 0.7.9
189
+ version: 2.1.0
158
190
  - !ruby/object:Gem::Dependency
159
191
  name: json
160
192
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +194,7 @@ dependencies:
162
194
  requirements:
163
195
  - - ~>
164
196
  - !ruby/object:Gem::Version
165
- version: 1.5.1
197
+ version: '1.0'
166
198
  type: :runtime
167
199
  prerelease: false
168
200
  version_requirements: !ruby/object:Gem::Requirement
@@ -170,7 +202,7 @@ dependencies:
170
202
  requirements:
171
203
  - - ~>
172
204
  - !ruby/object:Gem::Version
173
- version: 1.5.1
205
+ version: '1.0'
174
206
  - !ruby/object:Gem::Dependency
175
207
  name: multi_json
176
208
  requirement: !ruby/object:Gem::Requirement
@@ -213,9 +245,7 @@ extensions: []
213
245
  extra_rdoc_files: []
214
246
  files:
215
247
  - .gitignore
216
- - .rvmrc
217
248
  - Gemfile
218
- - Gemfile.lock
219
249
  - LICENSE.md
220
250
  - README.md
221
251
  - Rakefile
@@ -251,8 +281,10 @@ files:
251
281
  - test/fixtures/InvalidSoap.xml
252
282
  - test/fixtures/PurchasePostage.xml
253
283
  - test/fixtures/TrackShipment.xml
284
+ - test/fixtures/failed_auth.xml
254
285
  - test/helper.rb
255
286
  - test/mapping_test.rb
287
+ - test/request_test.rb
256
288
  - test/response_test.rb
257
289
  - test/stamps_test.rb
258
290
  - test/types_test.rb
@@ -276,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
308
  version: '0'
277
309
  requirements: []
278
310
  rubyforge_project: stamps
279
- rubygems_version: 1.8.24
311
+ rubygems_version: 1.8.23
280
312
  signing_key:
281
313
  specification_version: 3
282
314
  summary: Ruby wrapper for the Stamps.com Web Services API
@@ -297,8 +329,10 @@ test_files:
297
329
  - test/fixtures/InvalidSoap.xml
298
330
  - test/fixtures/PurchasePostage.xml
299
331
  - test/fixtures/TrackShipment.xml
332
+ - test/fixtures/failed_auth.xml
300
333
  - test/helper.rb
301
334
  - test/mapping_test.rb
335
+ - test/request_test.rb
302
336
  - test/response_test.rb
303
337
  - test/stamps_test.rb
304
338
  - test/types_test.rb
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm 1.9.2@stamps --create
data/Gemfile.lock DELETED
@@ -1,53 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- stamps (0.2.0)
5
- hashie (~> 1.0.0)
6
- httpi (= 0.7.9)
7
- json (~> 1.5.1)
8
- multi_json (~> 1.0)
9
- savon (= 0.8.6)
10
-
11
- GEM
12
- remote: http://rubygems.org/
13
- specs:
14
- addressable (2.2.4)
15
- awesome_print (0.3.2)
16
- bluecloth (2.1.0)
17
- builder (3.0.0)
18
- crack (0.1.8)
19
- gyoku (0.4.5)
20
- builder (>= 2.1.2)
21
- hashie (1.0.0)
22
- httpi (0.7.9)
23
- rack
24
- json (1.5.4)
25
- mocha (0.9.12)
26
- multi_json (1.3.6)
27
- rack (1.4.1)
28
- savon (0.8.6)
29
- builder (>= 2.1.2)
30
- crack (~> 0.1.8)
31
- gyoku (>= 0.3.0)
32
- httpi (>= 0.7.8)
33
- shoulda (2.11.3)
34
- simplecov (0.4.1)
35
- simplecov-html (~> 0.4.3)
36
- simplecov-html (0.4.3)
37
- webmock (1.6.2)
38
- addressable (>= 2.2.2)
39
- crack (>= 0.1.7)
40
- yard (0.6.8)
41
-
42
- PLATFORMS
43
- ruby
44
-
45
- DEPENDENCIES
46
- awesome_print
47
- bluecloth
48
- mocha (~> 0.9.11)
49
- shoulda (~> 2.11.3)
50
- simplecov (~> 0.4.0)
51
- stamps!
52
- webmock (~> 1.6.2)
53
- yard