endicia_ruby 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d2352e0018c792c02ab16e388921dc2be0c8d83
4
- data.tar.gz: 1a64011a110382bba544e96a6d58a693f6d1cfb7
3
+ metadata.gz: 5fb91179ab61ca85d2be358f857dc75087705833
4
+ data.tar.gz: 553918dd580eb1b3f718bbe57d507a4bd3058bb1
5
5
  SHA512:
6
- metadata.gz: 64e34143b6818f14f0a80ac4c54503845ed9a063c352e57e0c0a87df97ede042723f141a49a5df06a8d47ae4316c9e2d00e9503e430df3503e92c65742405bce
7
- data.tar.gz: 9ee6c205d02d970af776a5355711ca085d8c2b78a9b489ba8b5c6a74a529ab5e3714fbd2184d6be0b116b6ff5414ecf9f74359f0286a0c70792fe396f03dc0ff
6
+ metadata.gz: 2e269c9314fdfecdbdffe9a7e320ca09e9dec3d3cf5145441c244884740591474fa791e195665184a6e378cd3fc1d3f72789bd1eb06dabc7c3500f945f7b1277
7
+ data.tar.gz: 825622ba69c2c9184ec65aad7d4fbec2b93305068076883386fbbb6cf0585bb870e2df96e8e34384bccbddbba2f2bf0fc890f5fb5e4ac3cc657cb9b63f590afa
data/.env.example ADDED
@@ -0,0 +1,4 @@
1
+ ENDICIA_ACCOUNT_ID=
2
+ ENDICIA_REQUESTER_ID=
3
+ ENDICIA_PASSPHRASE=
4
+ ENDICIA_ENV=sandbox
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  *.sw?
19
+ .env
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.0
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'] || '2500334' %>
4
- RequesterID: <%= ENV['ENDICIA_REQUESTER_ID'] || 'lxxx' %>
5
- PassPhrase: <%= ENV['ENDICIA_PASSPHRASE'] || 'endicia.com' %>
6
- environment: <%= ENV['ENDICIA_ENV'] || 'test' %>
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
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "webmock"
28
28
  spec.add_development_dependency "vcr"
29
29
  spec.add_development_dependency "faker"
30
+ spec.add_development_dependency("dotenv")
30
31
  end
@@ -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"] || {}
@@ -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
 
@@ -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
- when Hash
110
- xml.send(node_name) do
111
- recursive_build_xml_nodes!(xml, value)
112
- end
113
- when Array
114
- xml.send(node_name) do
115
- value.each do |v|
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
- end
119
- else
120
- xml.send(node_name, value)
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
@@ -1,3 +1,3 @@
1
1
  module Endicia
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
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
- it "returns info about each tracking number" do # XXX: Do not rename this test as we had to hand-craft
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>2500334</AccountID>
11
+ <AccountID>AccountID</AccountID>
12
12
  <RequesterID>lxxx</RequesterID>
13
- <PassPhrase>endicia.com</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
- Connection:
22
- - close
23
- Date:
24
- - Wed, 22 Oct 2014 20:50:28 GMT
25
- Server:
26
- - Microsoft-IIS/6.0
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 &lt;customErrors&gt; tag within a &quot;web.config&quot; configuration
60
- file located in the root directory of the current web application. This &lt;customErrors&gt;
61
- tag should then have its &quot;mode&quot; attribute set to &quot;Off&quot;.<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&lt;!--
64
- Web.Config Configuration File --&gt;\r\n\r\n&lt;configuration&gt;\r\n &lt;system.web&gt;\r\n
65
- \ &lt;customErrors mode=&quot;Off&quot;/&gt;\r\n &lt;/system.web&gt;\r\n&lt;/configuration&gt;</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 &quot;defaultRedirect&quot;
69
- attribute of the application&#39;s &lt;customErrors&gt; 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&lt;!-- Web.Config Configuration
73
- File --&gt;\r\n\r\n&lt;configuration&gt;\r\n &lt;system.web&gt;\r\n &lt;customErrors
74
- mode=&quot;RemoteOnly&quot; defaultRedirect=&quot;mycustompage.htm&quot;/&gt;\r\n
75
- \ &lt;/system.web&gt;\r\n&lt;/configuration&gt;</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
- - Mon, 27 Oct 2014 16:25:54 GMT
46
+ - Wed, 29 Nov 2017 21:33:12 GMT
47
+ Connection:
48
+ - close
108
49
  Content-Length:
109
- - '572'
110
- Set-Cookie:
111
- - TS01f3408d=017b1809615f96bb14189a5af4bc475ddcf412dbb1637c14e6b5ae7d00beae8ac6f59c48c7;
112
- Path=/
50
+ - '466'
113
51
  body:
114
- encoding: UTF-8
115
- string: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<LabelRequestResponse
116
- xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
117
- xmlns=\"www.envmgr.com/LabelService\">\r\n <Status>1001</Status>\r\n <ErrorMessage>Missing
118
- or invalid data element: MailClassLabelRequest. Error encountered (Log ID:
119
- 34422)</ErrorMessage>\r\n <FinalPostage>0.0</FinalPostage>\r\n <TransactionID>0</TransactionID>\r\n
120
- \ <PostageBalance>0.00</PostageBalance>\r\n <CostCenter>0</CostCenter>\r\n
121
- \ <ReferenceID2 />\r\n <ReferenceID3 />\r\n <ReferenceID4 />\r\n</LabelRequestResponse>"
52
+ encoding: ASCII-8BIT
53
+ base64_string: |
54
+ PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxMYWJl
55
+ bFJlcXVlc3RSZXNwb25zZSB4bWxuczp4c2Q9Imh0dHA6Ly93d3cudzMub3Jn
56
+ LzIwMDEvWE1MU2NoZW1hIiB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3Jn
57
+ LzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiB4bWxucz0id3d3LmVudm1nci5j
58
+ b20vTGFiZWxTZXJ2aWNlIj4NCiAgPFN0YXR1cz40MDU8L1N0YXR1cz4NCiAg
59
+ PEVycm9yTWVzc2FnZT5JbnZhbGlkIG1haWwgY2xhc3MgKE51bGwgb3IgZW1w
60
+ dHkgbWFpbENsYXNzIHBhcmFtZXRlciBub3QgYWxsb3dlZC4pLiBFcnJvciBl
61
+ bmNvdW50ZXJlZCAoTG9nIElEOiA0NTEzMik8L0Vycm9yTWVzc2FnZT4NCiAg
62
+ PEZpbmFsUG9zdGFnZT4wLjA8L0ZpbmFsUG9zdGFnZT4NCiAgPFRyYW5zYWN0
63
+ aW9uSUQ+MDwvVHJhbnNhY3Rpb25JRD4NCiAgPFBvc3RhZ2VCYWxhbmNlPjAu
64
+ MDA8L1Bvc3RhZ2VCYWxhbmNlPg0KICA8Q29zdENlbnRlcj4wPC9Db3N0Q2Vu
65
+ dGVyPg0KICA8UmVmZXJlbmNlSUQyIC8+DQogIDxSZWZlcmVuY2VJRDMgLz4N
66
+ CiAgPFJlZmVyZW5jZUlENCAvPg0KICA8U0RSVmFsdWUgLz4NCjwvTGFiZWxS
67
+ ZXF1ZXN0UmVzcG9uc2U+
122
68
  http_version:
123
- recorded_at: Mon, 27 Oct 2014 16:26:02 GMT
69
+ recorded_at: Wed, 29 Nov 2017 21:33:17 GMT
124
70
  recorded_with: VCR 2.9.3