endicia_ruby 0.2.2 → 0.2.3
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/.env.example +4 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/config/endicia.yml +4 -4
- data/endicia_ruby.gemspec +1 -0
- data/lib/endicia_ruby/label_response.rb +2 -0
- data/lib/endicia_ruby/refund.rb +4 -0
- data/lib/endicia_ruby/request.rb +15 -11
- data/lib/endicia_ruby/version.rb +1 -1
- data/spec/label_spec.rb +8 -0
- data/spec/refund_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -0
- data/spec/vcr-cassettes/Endicia_Label/_request_label/handles_a_nonsense_request.yml +39 -93
- data/spec/vcr-cassettes/Endicia_Label/_request_label/makes_a_request_and_properly_parses_the_result.yml +4181 -115
- metadata +18 -5
- data/spec/vcr-cassettes/Endicia_Refund/_request_refund/returns_info_about_each_tracking_number.yml +0 -217
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fb91179ab61ca85d2be358f857dc75087705833
|
4
|
+
data.tar.gz: 553918dd580eb1b3f718bbe57d507a4bd3058bb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e269c9314fdfecdbdffe9a7e320ca09e9dec3d3cf5145441c244884740591474fa791e195665184a6e378cd3fc1d3f72789bd1eb06dabc7c3500f945f7b1277
|
7
|
+
data.tar.gz: 825622ba69c2c9184ec65aad7d4fbec2b93305068076883386fbbb6cf0585bb870e2df96e8e34384bccbddbba2f2bf0fc890f5fb5e4ac3cc657cb9b63f590afa
|
data/.env.example
ADDED
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.2
|
data/config/endicia.yml
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
development: &development
|
2
2
|
credentials:
|
3
|
-
AccountID: <%= ENV['ENDICIA_ACCOUNT_ID'] || '
|
4
|
-
RequesterID: <%= ENV['ENDICIA_REQUESTER_ID'] || '
|
5
|
-
PassPhrase: <%= ENV['ENDICIA_PASSPHRASE'] || '
|
6
|
-
environment: <%= ENV['ENDICIA_ENV'] || '
|
3
|
+
AccountID: <%= ENV['ENDICIA_ACCOUNT_ID'] || '' %>
|
4
|
+
RequesterID: <%= ENV['ENDICIA_REQUESTER_ID'] || '' %>
|
5
|
+
PassPhrase: <%= ENV['ENDICIA_PASSPHRASE'] || '' %>
|
6
|
+
environment: <%= ENV['ENDICIA_ENV'] || 'sandbox' %>
|
7
7
|
|
8
8
|
test:
|
9
9
|
<<: *development
|
data/endicia_ruby.gemspec
CHANGED
@@ -10,6 +10,7 @@ module Endicia
|
|
10
10
|
:transaction_id,
|
11
11
|
:postmark_date,
|
12
12
|
:postage_balance,
|
13
|
+
:postage_price,
|
13
14
|
:pic,
|
14
15
|
:error_message,
|
15
16
|
:reference_id,
|
@@ -21,6 +22,7 @@ module Endicia
|
|
21
22
|
:request_body,
|
22
23
|
:request_url,
|
23
24
|
:response_body
|
25
|
+
|
24
26
|
def initialize(result)
|
25
27
|
self.response_body = filter_response_body(result.body.dup)
|
26
28
|
data = result["LabelRequestResponse"] || {}
|
data/lib/endicia_ruby/refund.rb
CHANGED
@@ -6,6 +6,8 @@ require_relative 'refund_response'
|
|
6
6
|
module Endicia
|
7
7
|
class Refund < Request
|
8
8
|
|
9
|
+
# LEGACY - NO LONGER USED
|
10
|
+
|
9
11
|
# Request a refund for the given tracking number(s)
|
10
12
|
#
|
11
13
|
# tracking_numbers can be an array of strings or a single string
|
@@ -13,6 +15,8 @@ module Endicia
|
|
13
15
|
# Returns an Endicia::RefundResponse
|
14
16
|
#
|
15
17
|
def request_refund(tracking_numbers, options = {})
|
18
|
+
raise StandardError.new('Not supported.')
|
19
|
+
|
16
20
|
# Build the options for this method with passed in values overriding defaults
|
17
21
|
options.reverse_merge!(default_options)
|
18
22
|
|
data/lib/endicia_ruby/request.rb
CHANGED
@@ -106,18 +106,22 @@ module Endicia
|
|
106
106
|
nodes.each do |key, value|
|
107
107
|
node_name = key.to_s.sub(/^./,&:upcase) # convert "fooBar" to "FooBar"
|
108
108
|
case value
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
recursive_build_xml_nodes!(xml, v)
|
109
|
+
when Hash
|
110
|
+
if node_name == 'ResponseOptions'
|
111
|
+
xml.ResponseOptions(value)
|
112
|
+
else
|
113
|
+
xml.send(node_name) do
|
114
|
+
recursive_build_xml_nodes!(xml, value)
|
115
|
+
end
|
117
116
|
end
|
118
|
-
|
119
|
-
|
120
|
-
|
117
|
+
when Array
|
118
|
+
xml.send(node_name) do
|
119
|
+
value.each do |v|
|
120
|
+
recursive_build_xml_nodes!(xml, v)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
else
|
124
|
+
xml.send(node_name, value)
|
121
125
|
end
|
122
126
|
end
|
123
127
|
end
|
data/lib/endicia_ruby/version.rb
CHANGED
data/spec/label_spec.rb
CHANGED
@@ -19,6 +19,11 @@ describe Endicia::Label do
|
|
19
19
|
MailpieceShape: "Parcel",
|
20
20
|
ToZIP4: '1234',
|
21
21
|
WeightOz: "32", # 2 pounds
|
22
|
+
DeliveryTimeDays: 'TRUE',
|
23
|
+
EstimatedDeliveryDate: 'TRUE',
|
24
|
+
ResponseOptions: {
|
25
|
+
PostagePrice: 'TRUE',
|
26
|
+
},
|
22
27
|
MailpieceDimensions: {
|
23
28
|
Length: "12",
|
24
29
|
Width: "16",
|
@@ -54,6 +59,9 @@ describe Endicia::Label do
|
|
54
59
|
expect(response.cost_center).to_not be_blank
|
55
60
|
expect(response.request_url).to_not be_blank
|
56
61
|
expect(response.request_body).to_not be_blank
|
62
|
+
expect(response.postage_price['Postage']['Zone']).to_not be_blank
|
63
|
+
expect(response.postage_price['EstimatedDeliveryDate']).to_not be_blank
|
64
|
+
expect(response.postage_price['DeliveryTimeDays']).to_not be_blank
|
57
65
|
end
|
58
66
|
|
59
67
|
it "handles a nonsense request" do
|
data/spec/refund_spec.rb
CHANGED
@@ -44,7 +44,7 @@ describe Endicia::Refund, vcr: { record: :none } do # XXX: Hand-crafted, artisan
|
|
44
44
|
}
|
45
45
|
@response = refund.request_refund(@tracking_numbers)
|
46
46
|
end
|
47
|
-
|
47
|
+
xit "returns info about each tracking number" do # XXX: Do not rename this test as we had to hand-craft
|
48
48
|
# the VCR file, since the test server doesn't support
|
49
49
|
# refund requests
|
50
50
|
expect(@response.success).to eq(true)
|
data/spec/spec_helper.rb
CHANGED
@@ -6,6 +6,9 @@ require 'faker'
|
|
6
6
|
|
7
7
|
require 'endicia_ruby'
|
8
8
|
|
9
|
+
require 'dotenv'
|
10
|
+
Dotenv.load
|
11
|
+
|
9
12
|
WebMock.disable_net_connect!
|
10
13
|
VCR.configure do |c|
|
11
14
|
c.cassette_library_dir = 'spec/vcr-cassettes'
|
@@ -19,6 +22,8 @@ VCR.configure do |c|
|
|
19
22
|
http_message.body.encoding.name == 'ASCII-8BIT' ||
|
20
23
|
!http_message.body.valid_encoding?
|
21
24
|
end
|
25
|
+
c.filter_sensitive_data('PassPhrase') { ENV['ENDICIA_PASSPHRASE'] }
|
26
|
+
c.filter_sensitive_data('AccountID') { ENV['ENDICIA_ACCOUNT_ID'] }
|
22
27
|
end
|
23
28
|
|
24
29
|
RSpec.configure do |config|
|
@@ -8,88 +8,17 @@ http_interactions:
|
|
8
8
|
string: |
|
9
9
|
labelRequestXML=<?xml version="1.0"?>
|
10
10
|
<LabelRequest Test="YES" LabelType="Default">
|
11
|
-
<AccountID>
|
11
|
+
<AccountID>AccountID</AccountID>
|
12
12
|
<RequesterID>lxxx</RequesterID>
|
13
|
-
<PassPhrase>
|
13
|
+
<PassPhrase>PassPhrase</PassPhrase>
|
14
14
|
</LabelRequest>
|
15
|
-
headers: {}
|
16
|
-
response:
|
17
|
-
status:
|
18
|
-
code: 200
|
19
|
-
message: OK500 Internal Server Error
|
20
15
|
headers:
|
21
|
-
|
22
|
-
-
|
23
|
-
|
24
|
-
-
|
25
|
-
|
26
|
-
-
|
27
|
-
X-Powered-By:
|
28
|
-
- ASP.NET
|
29
|
-
X-Aspnet-Version:
|
30
|
-
- 4.0.30319
|
31
|
-
Endicia-Label-Format:
|
32
|
-
- 'Cache-Control: private'
|
33
|
-
Content-Type:
|
34
|
-
- text/html; charset=utf-8
|
35
|
-
Content-Length:
|
36
|
-
- '3042'
|
37
|
-
body:
|
38
|
-
encoding: UTF-8
|
39
|
-
string: "<html>\r\n <head>\r\n <title>Runtime Error</title>\r\n <style>\r\n
|
40
|
-
\ body {font-family:\"Verdana\";font-weight:normal;font-size: .7em;color:black;}
|
41
|
-
\r\n p {font-family:\"Verdana\";font-weight:normal;color:black;margin-top:
|
42
|
-
-5px}\r\n b {font-family:\"Verdana\";font-weight:bold;color:black;margin-top:
|
43
|
-
-5px}\r\n H1 { font-family:\"Verdana\";font-weight:normal;font-size:18pt;color:red
|
44
|
-
}\r\n H2 { font-family:\"Verdana\";font-weight:normal;font-size:14pt;color:maroon
|
45
|
-
}\r\n pre {font-family:\"Lucida Console\";font-size: .9em}\r\n .marker
|
46
|
-
{font-weight: bold; color: black;text-decoration: none;}\r\n .version
|
47
|
-
{color: gray;}\r\n .error {margin-bottom: 10px;}\r\n .expandable
|
48
|
-
{ text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }\r\n
|
49
|
-
\ </style>\r\n </head>\r\n\r\n <body bgcolor=\"white\">\r\n\r\n
|
50
|
-
\ <span><H1>Server Error in '/LabelService' Application.<hr width=100%
|
51
|
-
size=1 color=silver></H1>\r\n\r\n <h2> <i>Runtime Error</i> </h2></span>\r\n\r\n
|
52
|
-
\ <font face=\"Arial, Helvetica, Geneva, SunSans-Regular, sans-serif
|
53
|
-
\">\r\n\r\n <b> Description: </b>An application error occurred
|
54
|
-
on the server. The current custom error settings for this application prevent
|
55
|
-
the details of the application error from being viewed remotely (for security
|
56
|
-
reasons). It could, however, be viewed by browsers running on the local server
|
57
|
-
machine.\r\n <br><br>\r\n\r\n <b>Details:</b> To enable
|
58
|
-
the details of this specific error message to be viewable on remote machines,
|
59
|
-
please create a <customErrors> tag within a "web.config" configuration
|
60
|
-
file located in the root directory of the current web application. This <customErrors>
|
61
|
-
tag should then have its "mode" attribute set to "Off".<br><br>\r\n\r\n
|
62
|
-
\ <table width=100% bgcolor=\"#ffffcc\">\r\n <tr>\r\n
|
63
|
-
\ <td>\r\n <code><pre>\r\n\r\n<!--
|
64
|
-
Web.Config Configuration File -->\r\n\r\n<configuration>\r\n <system.web>\r\n
|
65
|
-
\ <customErrors mode="Off"/>\r\n </system.web>\r\n</configuration></pre></code>\r\n\r\n
|
66
|
-
\ </td>\r\n </tr>\r\n </table>\r\n\r\n
|
67
|
-
\ <br>\r\n\r\n <b>Notes:</b> The current error page you
|
68
|
-
are seeing can be replaced by a custom error page by modifying the "defaultRedirect"
|
69
|
-
attribute of the application's <customErrors> configuration tag
|
70
|
-
to point to a custom error page URL.<br><br>\r\n\r\n <table width=100%
|
71
|
-
bgcolor=\"#ffffcc\">\r\n <tr>\r\n <td>\r\n
|
72
|
-
\ <code><pre>\r\n\r\n<!-- Web.Config Configuration
|
73
|
-
File -->\r\n\r\n<configuration>\r\n <system.web>\r\n <customErrors
|
74
|
-
mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>\r\n
|
75
|
-
\ </system.web>\r\n</configuration></pre></code>\r\n\r\n </td>\r\n
|
76
|
-
\ </tr>\r\n </table>\r\n\r\n <br>\r\n\r\n
|
77
|
-
\ </body>\r\n</html>\r\n"
|
78
|
-
http_version:
|
79
|
-
recorded_at: Wed, 22 Oct 2014 20:50:26 GMT
|
80
|
-
- request:
|
81
|
-
method: post
|
82
|
-
uri: https://www.envmgr.com/LabelService/EwsLabelService.asmx/GetPostageLabelXML
|
83
|
-
body:
|
84
|
-
encoding: UTF-8
|
85
|
-
string: |
|
86
|
-
labelRequestXML=<?xml version="1.0"?>
|
87
|
-
<LabelRequest Test="YES" LabelType="Default">
|
88
|
-
<AccountID>2500334</AccountID>
|
89
|
-
<RequesterID>lxxx</RequesterID>
|
90
|
-
<PassPhrase>endicia.com</PassPhrase>
|
91
|
-
</LabelRequest>
|
92
|
-
headers: {}
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Accept:
|
19
|
+
- "*/*"
|
20
|
+
User-Agent:
|
21
|
+
- Ruby
|
93
22
|
response:
|
94
23
|
status:
|
95
24
|
code: 200
|
@@ -99,26 +28,43 @@ http_interactions:
|
|
99
28
|
- private, max-age=0
|
100
29
|
Content-Type:
|
101
30
|
- text/xml; charset=utf-8
|
31
|
+
Vary:
|
32
|
+
- Accept-Encoding
|
33
|
+
Server:
|
34
|
+
- Microsoft-IIS/7.5
|
35
|
+
Endicia-Partner:
|
36
|
+
- lxxx
|
37
|
+
Endicia-Account:
|
38
|
+
- AccountID
|
39
|
+
Endicia-Response:
|
40
|
+
- failure
|
102
41
|
X-Aspnet-Version:
|
103
42
|
- 4.0.30319
|
104
43
|
X-Powered-By:
|
105
44
|
- ASP.NET
|
106
45
|
Date:
|
107
|
-
-
|
46
|
+
- Wed, 29 Nov 2017 21:33:12 GMT
|
47
|
+
Connection:
|
48
|
+
- close
|
108
49
|
Content-Length:
|
109
|
-
- '
|
110
|
-
Set-Cookie:
|
111
|
-
- TS01f3408d=017b1809615f96bb14189a5af4bc475ddcf412dbb1637c14e6b5ae7d00beae8ac6f59c48c7;
|
112
|
-
Path=/
|
50
|
+
- '466'
|
113
51
|
body:
|
114
|
-
encoding:
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
52
|
+
encoding: ASCII-8BIT
|
53
|
+
base64_string: |
|
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