tnt.rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f4f770cad66b5effdc71ccbde72a23034caf19f042e7db8002e04573c70b9feb
4
+ data.tar.gz: f487517aeb0ac27b5d1f66a1a81ca4f31440784a2478a9661ccce4c56eeb2eeb
5
+ SHA512:
6
+ metadata.gz: 52bc0061e860510554bde0809c36ad5518c355a06346199233a6b2d1cac24b341e43c7302b1b087c983abf2034c6a103ce647546022d5594c02d672fc7b5285d
7
+ data.tar.gz: 2290e6e3ef470b375c91d914372197361e5a5ca3be567e25520e4f30086d4580877a6ba327affa6d87ac4aaaae4955967c993c2846ddc2b6f8bed799a7e01b04
@@ -0,0 +1,26 @@
1
+ name: CI
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ ruby_rails_test_matrix:
7
+ runs-on: ubuntu-18.04
8
+
9
+ strategy:
10
+ matrix:
11
+ ruby: [2.4, 2.6]
12
+
13
+ steps:
14
+ - uses: actions/checkout@master
15
+
16
+ - name: Sets up the environment
17
+ uses: actions/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby }}
20
+
21
+ - name: Runs code QA and tests
22
+ run: |
23
+ rm -rf Gemfile.lock
24
+ gem install bundler -v '~> 1'
25
+ bundle
26
+ rake
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ *.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,53 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+
5
+ RSpec:
6
+ Enabled: true
7
+
8
+ Performance:
9
+ Enabled: true
10
+
11
+ Bundler:
12
+ Enabled: true
13
+
14
+ Gemspec:
15
+ Enabled: true
16
+
17
+ Style/StringLiterals:
18
+ Enabled: true
19
+ EnforcedStyle: single_quotes
20
+
21
+ Style/FrozenStringLiteralComment:
22
+ Enabled: false
23
+
24
+ Layout/LineLength:
25
+ Max: 80
26
+
27
+ Metrics/MethodLength:
28
+ Max: 12
29
+
30
+ Metrics/BlockLength:
31
+ Exclude:
32
+ - 'spec/**/*_spec.rb'
33
+ - '**/*.gemspec'
34
+
35
+ Layout/IndentationConsistency:
36
+ EnforcedStyle: normal
37
+
38
+ Style/BlockDelimiters:
39
+ Enabled: true
40
+
41
+ RSpec/ExampleLength:
42
+ Enabled: false
43
+
44
+ RSpec/MultipleExpectations:
45
+ Enabled: false
46
+
47
+ RSpec/ContextWording:
48
+ Enabled: false
49
+
50
+ Style/MutableConstant:
51
+ Enabled: true
52
+ Exclude:
53
+ - 'lib/tnt.rb'
data/.yardstick.yml ADDED
@@ -0,0 +1,30 @@
1
+ ---
2
+ path: ['lib/**/*.rb']
3
+ threshold: 100
4
+ rules:
5
+ ApiTag::Presence:
6
+ enabled: false
7
+ ApiTag::Inclusion:
8
+ enabled: false
9
+ ApiTag::ProtectedMethod:
10
+ enabled: false
11
+ ApiTag::PrivateMethod:
12
+ enabled: false
13
+ ExampleTag:
14
+ enabled: false
15
+ ReturnTag:
16
+ enabled: true
17
+ exclude: []
18
+ Summary::Presence:
19
+ enabled: true
20
+ exclude: []
21
+ Summary::Length:
22
+ enabled: true
23
+ exclude: []
24
+ Summary::Delimiter:
25
+ enabled: true
26
+ exclude: []
27
+ Summary::SingleLine:
28
+ enabled: true
29
+ exclude: []
30
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Stas SUȘCOV
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # TNT (Express Web Services) 🅣🅝🅣
2
+
3
+ Ruby SDK for working with
4
+ [TNT](https://express.tnt.com/expresswebservices-website/app/landing.html)
5
+ Express Web Services.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'tnt.rb'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install tnt.rb
22
+
23
+ Note, consider using the `gyoku` unreleased version directly from:
24
+ https://github.com/savonrb/gyoku
25
+
26
+ ## Usage
27
+
28
+ A subset of the TNT resources are provided with this SDK:
29
+
30
+ * `TNT::Shipment`
31
+ * `TNT::Label`
32
+ * `TNT::Manifest`
33
+
34
+ These resources have implemented the following methods to allow API operations:
35
+ * `find`
36
+ * `create`
37
+
38
+ Here's an example on how to create a transaction, capture it, and refund it:
39
+ ```ruby
40
+ require 'tnt'
41
+
42
+ address = {
43
+ companyname: 'Lunet Studio SRL',
44
+ streetaddress1: 'Bld. Lascar Catargiu 15A, 12, Sector 1',
45
+ city: 'Bucharest',
46
+ postcode: '010661',
47
+ country: 'RO',
48
+ account: ENV['TNT_ACCOUNT_ID'],
49
+ contactname: 'Lunet Studio SRL',
50
+ contactdialcode: '+40',
51
+ contacttelephone: '728547184',
52
+ contactemail: 'hello@luneteyewear.com',
53
+ }.transform_values(&:to_s)
54
+
55
+ shipment = TNT::Shipment.create(
56
+ login: TNT::Shipment.credentials,
57
+ consignmentbatch: {
58
+ sender: address.dup.merge(
59
+ collection: {
60
+ collectionaddress: address.dup.except(:account),
61
+ shipdate: DateTime.tomorrow.strftime('%d/%m/%Y'),
62
+ prefcollecttime: { from: '09:00', to: '16:00' },
63
+ collinstructions: ''
64
+ }
65
+ ),
66
+ consignment: {
67
+ conref: 'LNT_TNT',
68
+ details: {
69
+ receiver: address.dup,
70
+ delivery: address.dup,
71
+ customerref: 'LNT_ORDER_ID',
72
+ contype: 'N',
73
+ paymentind: 'S',
74
+ items: 1,
75
+ totalweight: 0.3,
76
+ totalvolume: 0.0025,
77
+ service: '15N',
78
+ option: '',
79
+ description: '',
80
+ deliveryinst: '',
81
+ package: [
82
+ {
83
+ items: 1,
84
+ description: 'GLASSES',
85
+ length: 0.25,
86
+ height: 0.05,
87
+ width: 0.20,
88
+ weight: 0.4
89
+ }
90
+ ]
91
+ }
92
+ }
93
+ },
94
+ activity: {
95
+ create: { conref: 'LNT_TNT' },
96
+ book: { conref: 'LNT_TNT', '@ShowBookingRef': 'Y' },
97
+ ship: { conref: 'LNT_TNT' }
98
+ }
99
+ )
100
+ ```
101
+
102
+ ### Configuration
103
+
104
+ The API keys will be loaded from your environment variables:
105
+
106
+ * `TNT_USERNAME`
107
+ * `TNT_PASSWORD`
108
+
109
+ Please remember, TNT will provide you separately with an **account ID**
110
+ based on your location and the type of services you opted for.
111
+
112
+ ## Development
113
+
114
+ To install this gem onto your local machine, run `bundle exec rake install`. To
115
+ release a new version, update the version number in `version.rb`, and then run
116
+ `bundle exec rake release`, which will create a git tag for the version, push
117
+ git commits and tags, and push the `.gem` file to
118
+ [rubygems.org](https://rubygems.org).
119
+
120
+ ## Contributing
121
+
122
+ Bug reports and pull requests are welcome on GitHub at
123
+ https://github.com/luneteyewear/tnt.rb. This project is intended to be a safe,
124
+ welcoming space for collaboration, and contributors are expected to adhere to
125
+ the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
126
+
127
+ ## License
128
+
129
+ The gem is available as open source under the terms of the [MIT
130
+ License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+ require 'yaml'
5
+ require 'yardstick/rake/verify'
6
+
7
+ desc('Documentation stats and measurements')
8
+ task('qa:docs') do
9
+ yaml = YAML.load_file('.yardstick.yml')
10
+ config = Yardstick::Config.coerce(yaml)
11
+ measure = Yardstick.measure(config)
12
+ measure.puts
13
+ coverage = Yardstick.round_percentage(measure.coverage * 100)
14
+ exit(1) if coverage < config.threshold
15
+ end
16
+
17
+ RuboCop::RakeTask.new('qa:code')
18
+
19
+ desc('Run QA tasks')
20
+ task(qa: ['qa:docs', 'qa:code'])
21
+
22
+ RSpec::Core::RakeTask.new(spec: :qa)
23
+ task(default: :spec)
data/lib/tnt.rb ADDED
@@ -0,0 +1,121 @@
1
+ require 'active_support/core_ext/hash/conversions'
2
+ require 'active_support/core_ext/hash/keys'
3
+ require 'http/rest_client'
4
+ require 'gyoku'
5
+
6
+ # TNT HTTP API Client
7
+ module TNT
8
+ # Base endpoint resources class
9
+ class Resource < OpenStruct
10
+ extend HTTP::RestClient::DSL
11
+
12
+ endpoint 'https://express.tnt.com'
13
+
14
+ XML_HEADER = '<?xml version="1.0" encoding="UTF-8"?>'.freeze
15
+ XML_RENDER_OPTIONS = {
16
+ unwrap: false, key_converter: :upcase, pretty_print: true
17
+ }
18
+
19
+ # Returns a payload with service credentials
20
+ #
21
+ # @return [Hash]
22
+ def self.credentials
23
+ {
24
+ company: ENV['TNT_USERNAME'],
25
+ password: ENV['TNT_PASSWORD'],
26
+ appid: :EC,
27
+ appversion: 3.0
28
+ }
29
+ end
30
+
31
+ # Renders a dictionary to XML
32
+ #
33
+ # @param data [Hash] object to be rendered
34
+ # @return [String]
35
+ def self.to_xml(data)
36
+ XML_HEADER + Gyoku.xml({ eshipper: data }, XML_RENDER_OPTIONS)
37
+ end
38
+
39
+ # Validate error response
40
+ #
41
+ # Looks at the response code by default.
42
+ #
43
+ # @param response [HTTP::Response] the server response
44
+ # @param parsed [Object] the parsed server response
45
+ #
46
+ # @return [TrueClass] if status code is not a successful standard value
47
+ def self.error_response?(response, parsed)
48
+ parsed.is_a?(Hash) && (
49
+ parsed.dig('parse_error') ||
50
+ parsed.dig('runtime_error') ||
51
+ parsed.dig('document', 'error')
52
+ ) || super
53
+ end
54
+
55
+ # Extracts the error message from the response
56
+ #
57
+ # @param response [HTTP::Response] the server response
58
+ # @param parsed [Object] the parsed server response
59
+ #
60
+ # @return [String]
61
+ def self.extract_error(response, parsed)
62
+ parsed&.dig('runtime_error') ||
63
+ parsed&.dig('parse_error') ||
64
+ parsed&.dig('document', 'error')&.first ||
65
+ super
66
+ end
67
+
68
+ # Parses response (from XML)
69
+ #
70
+ # @param response [HTTP::Response] object
71
+ # @return [Object]
72
+ def self.parse_response(response)
73
+ Hash.from_xml(response.body.to_s).deep_transform_keys(&:downcase)
74
+ rescue StandardError
75
+ [response.body.to_s.split(':')].to_h.deep_transform_keys(&:downcase)
76
+ end
77
+ end
78
+
79
+ # Shipments endpoint resource
80
+ class Shipment < Resource
81
+ path '/expressconnect/shipping/ship'
82
+
83
+ # Handles the shipment label creation
84
+ #
85
+ # @return [TNT::Shipment]
86
+ def self.create(payload)
87
+ opts = { form: { xml_in: to_xml(payload) } }
88
+ pre_response = request(:post, uri, opts)
89
+
90
+ # Use the token and get the real response...
91
+ opts = { form: { xml_in: 'GET_RESULT:' + pre_response['complete'] } }
92
+ response = request(:post, uri, opts)
93
+
94
+ new((response['document'] || response).merge(pre_response))
95
+ end
96
+ end
97
+
98
+ # Label endpoint resource
99
+ class Label < Resource
100
+ path '/expressconnect/shipping/ship'
101
+
102
+ # Handles the shipment label fetching request
103
+ #
104
+ # @return [TNT::Response]
105
+ def self.find(ref)
106
+ new(request(:post, uri, form: { xml_in: 'GET_LABEL:' + ref.to_s }))
107
+ end
108
+ end
109
+
110
+ # Manifest endpoint resource
111
+ class Manifest < Resource
112
+ path '/expressconnect/shipping/ship'
113
+
114
+ # Handles the shipment manifest fetching request
115
+ #
116
+ # @return [TNT::Response]
117
+ def self.find(ref)
118
+ new(request(:post, uri, form: { xml_in: 'GET_MANIFEST:' + ref.to_s }))
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,3 @@
1
+ module TNT
2
+ VERSION = '0.1.0'.freeze
3
+ end
data/tnt.rb.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'tnt/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'tnt.rb'
7
+ spec.version = TNT::VERSION
8
+ spec.authors = ['Stas SUȘCOV']
9
+ spec.email = ['stas@nerd.ro']
10
+
11
+ spec.summary = 'TNT (Express Web Services) Ruby SDK'
12
+ spec.description = 'Ruby SDK for working with TNT shipping web services.'
13
+ spec.homepage = 'https://github.com/luneteyewear/tnt.rb'
14
+ spec.license = 'MIT'
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
19
+ end
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'activesupport'
23
+ spec.add_dependency 'gyoku'
24
+ spec.add_dependency 'http-rest_client'
25
+
26
+ spec.add_development_dependency 'bundler'
27
+ spec.add_development_dependency 'ffaker'
28
+ spec.add_development_dependency 'rake'
29
+ spec.add_development_dependency 'rspec'
30
+ spec.add_development_dependency 'rubocop-performance'
31
+ spec.add_development_dependency 'rubocop-rspec'
32
+ spec.add_development_dependency 'simplecov'
33
+ spec.add_development_dependency 'vcr'
34
+ spec.add_development_dependency 'webmock'
35
+ spec.add_development_dependency 'yardstick'
36
+ end
@@ -0,0 +1,101 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://express.tnt.com/expressconnect/shipping/ship
6
+ body:
7
+ encoding: UTF-8
8
+ string: xml_in=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3CESHIPPER%3E%3CLOGIN%3E%3CCOMPANY%3E~TNT_USERNAME~%3C%2FCOMPANY%3E%3CPASSWORD%3E~TNT_PASSWORD~%3C%2FPASSWORD%3E%3CAPPID%3EEC%3C%2FAPPID%3E%3CAPPVERSION%3E3.0%3C%2FAPPVERSION%3E%3C%2FLOGIN%3E%3CCONSIGNMENTBATCH%3E%3CSENDER%3E%3CCOMPANYNAME%3ELunet+Studio+SRL%3C%2FCOMPANYNAME%3E%3CSTREETADDRESS1%3EBld.+Lascar+Catargiu+15A%2C+12%2C+Sector+1%3C%2FSTREETADDRESS1%3E%3CCITY%3EBucharest%3C%2FCITY%3E%3CPOSTCODE%3E010661%3C%2FPOSTCODE%3E%3CCOUNTRY%3ERO%3C%2FCOUNTRY%3E%3CACCOUNT%3E~TNT_ACCOUNT_ID~%3C%2FACCOUNT%3E%3CCONTACTNAME%3ELunet+Studio+SRL%3C%2FCONTACTNAME%3E%3CCONTACTDIALCODE%3E%2B40%3C%2FCONTACTDIALCODE%3E%3CCONTACTTELEPHONE%3E728547184%3C%2FCONTACTTELEPHONE%3E%3CCONTACTEMAIL%3Ehello%40luneteyewear.com%3C%2FCONTACTEMAIL%3E%3CCOLLECTION%3E%3CCOLLECTIONADDRESS%3E%3CCOMPANYNAME%3ELunet+Studio+SRL%3C%2FCOMPANYNAME%3E%3CSTREETADDRESS1%3EBld.+Lascar+Catargiu+15A%2C+12%2C+Sector+1%3C%2FSTREETADDRESS1%3E%3CCITY%3EBucharest%3C%2FCITY%3E%3CPOSTCODE%3E010661%3C%2FPOSTCODE%3E%3CCOUNTRY%3ERO%3C%2FCOUNTRY%3E%3CCONTACTNAME%3ELunet+Studio+SRL%3C%2FCONTACTNAME%3E%3CCONTACTDIALCODE%3E%2B40%3C%2FCONTACTDIALCODE%3E%3CCONTACTTELEPHONE%3E728547184%3C%2FCONTACTTELEPHONE%3E%3CCONTACTEMAIL%3Ehello%40luneteyewear.com%3C%2FCONTACTEMAIL%3E%3C%2FCOLLECTIONADDRESS%3E%3CSHIPDATE%3E17%2F01%2F2020%3C%2FSHIPDATE%3E%3CPREFCOLLECTTIME%3E%3CFROM%3E09%3A00%3C%2FFROM%3E%3CTO%3E16%3A00%3C%2FTO%3E%3C%2FPREFCOLLECTTIME%3E%3CCOLLINSTRUCTIONS%3E%3C%2FCOLLINSTRUCTIONS%3E%3C%2FCOLLECTION%3E%3C%2FSENDER%3E%3CCONSIGNMENT%3E%3CCONREF%3ELNT_REF%3C%2FCONREF%3E%3CDETAILS%3E%3CRECEIVER%3E%3CCOMPANYNAME%3ELunet+Studio+SRL%3C%2FCOMPANYNAME%3E%3CSTREETADDRESS1%3EBld.+Lascar+Catargiu+15A%2C+12%2C+Sector+1%3C%2FSTREETADDRESS1%3E%3CCITY%3EBucharest%3C%2FCITY%3E%3CPOSTCODE%3E010661%3C%2FPOSTCODE%3E%3CCOUNTRY%3ERO%3C%2FCOUNTRY%3E%3CCONTACTNAME%3ELunet+Studio+SRL%3C%2FCONTACTNAME%3E%3CCONTACTDIALCODE%3E%2B40%3C%2FCONTACTDIALCODE%3E%3CCONTACTTELEPHONE%3E728547184%3C%2FCONTACTTELEPHONE%3E%3CCONTACTEMAIL%3Ehello%40luneteyewear.com%3C%2FCONTACTEMAIL%3E%3C%2FRECEIVER%3E%3CDELIVERY%3E%3CCOMPANYNAME%3ELunet+Studio+SRL%3C%2FCOMPANYNAME%3E%3CSTREETADDRESS1%3EBld.+Lascar+Catargiu+15A%2C+12%2C+Sector+1%3C%2FSTREETADDRESS1%3E%3CCITY%3EBucharest%3C%2FCITY%3E%3CPOSTCODE%3E010661%3C%2FPOSTCODE%3E%3CCOUNTRY%3ERO%3C%2FCOUNTRY%3E%3CCONTACTNAME%3ELunet+Studio+SRL%3C%2FCONTACTNAME%3E%3CCONTACTDIALCODE%3E%2B40%3C%2FCONTACTDIALCODE%3E%3CCONTACTTELEPHONE%3E728547184%3C%2FCONTACTTELEPHONE%3E%3CCONTACTEMAIL%3Ehello%40luneteyewear.com%3C%2FCONTACTEMAIL%3E%3C%2FDELIVERY%3E%3CCUSTOMERREF%3ELNT_CREF%3C%2FCUSTOMERREF%3E%3CCONTYPE%3EN%3C%2FCONTYPE%3E%3CPAYMENTIND%3ES%3C%2FPAYMENTIND%3E%3CITEMS%3E1%3C%2FITEMS%3E%3CTOTALWEIGHT%3E0.3%3C%2FTOTALWEIGHT%3E%3CTOTALVOLUME%3E0.0025%3C%2FTOTALVOLUME%3E%3CSERVICE%3E15N%3C%2FSERVICE%3E%3COPTION%3E%3C%2FOPTION%3E%3CDESCRIPTION%3E%3C%2FDESCRIPTION%3E%3CDELIVERYINST%3E%3C%2FDELIVERYINST%3E%3CPACKAGE%3E%3CITEMS%3E1%3C%2FITEMS%3E%3CDESCRIPTION%3EGLASSES%3C%2FDESCRIPTION%3E%3CLENGTH%3E0.25%3C%2FLENGTH%3E%3CHEIGHT%3E0.05%3C%2FHEIGHT%3E%3CWIDTH%3E0.2%3C%2FWIDTH%3E%3CWEIGHT%3E0.4%3C%2FWEIGHT%3E%3C%2FPACKAGE%3E%3C%2FDETAILS%3E%3C%2FCONSIGNMENT%3E%3C%2FCONSIGNMENTBATCH%3E%3CACTIVITY%3E%3CCREATE%3E%3CCONREF%3ELNT_REF%3C%2FCONREF%3E%3C%2FCREATE%3E%3CBOOK+ShowBookingRef%3D%22Y%22%3E%3CCONREF%3ELNT_REF%3C%2FCONREF%3E%3C%2FBOOK%3E%3CSHIP%3E%3CCONREF%3ELNT_REF%3C%2FCONREF%3E%3C%2FSHIP%3E%3C%2FACTIVITY%3E%3C%2FESHIPPER%3E
9
+ headers:
10
+ Connection:
11
+ - close
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Host:
15
+ - express.tnt.com
16
+ User-Agent:
17
+ - http.rb/4.3.0
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Thu, 16 Jan 2020 12:04:42 GMT
25
+ Server:
26
+ - IBM_HTTP_Server
27
+ X-Wily-Info:
28
+ - Clear guid=AE3DCADA0AD2EA8C2C5A2C5AFACC3480
29
+ X-Wily-Servlet:
30
+ - Encrypt1 hR/KG2GOR16aRfvv3/q1Ad5uT+eFRPmbRRHNC83W4p9tTEDx66jFEaWXoX0soevZxvVLPT4M8/QqDNhqtwsasrd3VIbriJ05hX8ChkxfBgekWJuBKLXEPeGST6LGOdRj8Yri2fQJK5GzqALGicm2zxQKjjHgt6R8XGi/4LVifbgGM7HsRR0CmaBFRO/EkQXO
31
+ Content-Length:
32
+ - '19'
33
+ Content-Type:
34
+ - application/x-www-form-urlencoded
35
+ Content-Language:
36
+ - en-GB
37
+ Proxy-Connection:
38
+ - Keep-Alive
39
+ Connection:
40
+ - close
41
+ Set-Cookie:
42
+ - BC_HA_055537e49f10c20f_773D3E04=4A586875; Domain=.tnt.com; expires=Thu, 16-Jan-20
43
+ 12:34:43 GMT; Path=/
44
+ - BIGipServerbluecoat_pool=2552833956.20480.0000; path=/
45
+ - BIGipServergb_ccc_cit_2_pool=4259893770.20480.0000; path=/
46
+ body:
47
+ encoding: ASCII-8BIT
48
+ string: COMPLETE:8591504415
49
+ http_version:
50
+ recorded_at: Thu, 16 Jan 2020 12:04:43 GMT
51
+ - request:
52
+ method: post
53
+ uri: https://express.tnt.com/expressconnect/shipping/ship
54
+ body:
55
+ encoding: UTF-8
56
+ string: xml_in=GET_RESULT%3A8591504415
57
+ headers:
58
+ Connection:
59
+ - close
60
+ Content-Type:
61
+ - application/x-www-form-urlencoded
62
+ Host:
63
+ - express.tnt.com
64
+ User-Agent:
65
+ - http.rb/4.3.0
66
+ response:
67
+ status:
68
+ code: 200
69
+ message: OK
70
+ headers:
71
+ Date:
72
+ - Thu, 16 Jan 2020 12:04:43 GMT
73
+ Server:
74
+ - IBM_HTTP_Server
75
+ X-Wily-Info:
76
+ - Clear guid=AE3DCEF60AD2EA8C2C5A2C5A1AC0796B
77
+ X-Wily-Servlet:
78
+ - Encrypt1 hR/KG2GOR16aRfvv3/q1Ad5uT+eFRPmbRRHNC83W4p9tTEDx66jFEaWXoX0soevZxvVLPT4M8/QqDNhqtwsasrd3VIbriJ05hX8ChkxfBgekWJuBKLXEPeGST6LGOdRj8Yri2fQJK5GzqALGicm2zxQKjjHgt6R8XGi/4LVifbgGM7HsRR0CmaBFRO/EkQXO
79
+ Content-Length:
80
+ - '413'
81
+ Content-Type:
82
+ - application/x-www-form-urlencoded
83
+ Content-Language:
84
+ - en-GB
85
+ Cache-Control:
86
+ - proxy-revalidate
87
+ Proxy-Connection:
88
+ - Keep-Alive
89
+ Connection:
90
+ - close
91
+ Set-Cookie:
92
+ - BC_HA_055537e49f10c20f_773D3E04=0; Domain=.tnt.com; expires=Thu, 16-Jan-20
93
+ 12:34:44 GMT; Path=/
94
+ - BIGipServerbluecoat_pool=2552833956.20480.0000; path=/
95
+ - BIGipServergb_ccc_cit_2_pool=4259893770.20480.0000; path=/
96
+ body:
97
+ encoding: ASCII-8BIT
98
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><document><CREATE><CONREF>LNT_REF</CONREF><CONNUMBER>GE526967072RO</CONNUMBER><SUCCESS>Y</SUCCESS></CREATE><BOOK><CONSIGNMENT><CONREF>LNT_REF</CONREF><CONNUMBER>GE526967072RO</CONNUMBER><SUCCESS>Y</SUCCESS></CONSIGNMENT></BOOK><SHIP><CONSIGNMENT><CONREF>LNT_REF</CONREF><CONNUMBER>GE526967072RO</CONNUMBER><SUCCESS>Y</SUCCESS></CONSIGNMENT></SHIP></document>
99
+ http_version:
100
+ recorded_at: Thu, 16 Jan 2020 12:04:43 GMT
101
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,105 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://express.tnt.com/expressconnect/shipping/ship
6
+ body:
7
+ encoding: UTF-8
8
+ string: xml_in=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3CESHIPPER%3E%3CLOGIN%3E%3CCOMPANY%3E~TNT_USERNAME~%3C%2FCOMPANY%3E%3CPASSWORD%3E~TNT_PASSWORD~%3C%2FPASSWORD%3E%3CAPPID%3EEC%3C%2FAPPID%3E%3CAPPVERSION%3E3.0%3C%2FAPPVERSION%3E%3C%2FLOGIN%3E%3CCONSIGNMENTBATCH%3E%3CSENDER%3E%3CCOLLECTION%3E%3CCOLLECTIONADDRESS%3E%3C%2FCOLLECTIONADDRESS%3E%3CSHIPDATE%3E17%2F01%2F2020%3C%2FSHIPDATE%3E%3CPREFCOLLECTTIME%3E%3CFROM%3E09%3A00%3C%2FFROM%3E%3CTO%3E16%3A00%3C%2FTO%3E%3C%2FPREFCOLLECTTIME%3E%3CCOLLINSTRUCTIONS%3E%3C%2FCOLLINSTRUCTIONS%3E%3C%2FCOLLECTION%3E%3C%2FSENDER%3E%3CCONSIGNMENT%3E%3CCONREF%3ELNT_REF%3C%2FCONREF%3E%3CDETAILS%3E%3CRECEIVER%3E%3C%2FRECEIVER%3E%3CDELIVERY%3E%3C%2FDELIVERY%3E%3CCUSTOMERREF%3ELNT_CREF%3C%2FCUSTOMERREF%3E%3CCONTYPE%3EN%3C%2FCONTYPE%3E%3CPAYMENTIND%3ES%3C%2FPAYMENTIND%3E%3CITEMS%3E1%3C%2FITEMS%3E%3CTOTALWEIGHT%3E0.3%3C%2FTOTALWEIGHT%3E%3CTOTALVOLUME%3E0.0025%3C%2FTOTALVOLUME%3E%3CSERVICE%3E15N%3C%2FSERVICE%3E%3COPTION%3E%3C%2FOPTION%3E%3CDESCRIPTION%3E%3C%2FDESCRIPTION%3E%3CDELIVERYINST%3E%3C%2FDELIVERYINST%3E%3CPACKAGE%3E%3CITEMS%3E1%3C%2FITEMS%3E%3CDESCRIPTION%3EGLASSES%3C%2FDESCRIPTION%3E%3CLENGTH%3E0.25%3C%2FLENGTH%3E%3CHEIGHT%3E0.05%3C%2FHEIGHT%3E%3CWIDTH%3E0.2%3C%2FWIDTH%3E%3CWEIGHT%3E0.4%3C%2FWEIGHT%3E%3C%2FPACKAGE%3E%3C%2FDETAILS%3E%3C%2FCONSIGNMENT%3E%3C%2FCONSIGNMENTBATCH%3E%3CACTIVITY%3E%3CCREATE%3E%3CCONREF%3ELNT_REF%3C%2FCONREF%3E%3C%2FCREATE%3E%3CBOOK+ShowBookingRef%3D%22Y%22%3E%3CCONREF%3ELNT_REF%3C%2FCONREF%3E%3C%2FBOOK%3E%3CSHIP%3E%3CCONREF%3ELNT_REF%3C%2FCONREF%3E%3C%2FSHIP%3E%3C%2FACTIVITY%3E%3C%2FESHIPPER%3E
9
+ headers:
10
+ Connection:
11
+ - close
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Host:
15
+ - express.tnt.com
16
+ User-Agent:
17
+ - http.rb/4.3.0
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Thu, 16 Jan 2020 12:04:44 GMT
25
+ Server:
26
+ - IBM_HTTP_Server
27
+ X-Wily-Info:
28
+ - Clear guid=AE3DD08A0AD2EA8B6D546D548C6CECD5
29
+ X-Wily-Servlet:
30
+ - Encrypt1 hR/KG2GOR16aRfvv3/q1AUcQzrfQC+6Lhow3Jh2MjRB8n1MG21jGeNjetRCJFVUTrLS3FZR1huRdLFXpqtmQGaPbkWUkrh2gdk+taQVWxKcma1ahNCdsXVK6ZeqszKkcfzKHb2koq7Wey/XTHM3jwzaYXowyKTQbBOD87IYJkuozWLwGKiXGscuS4TQdbENO
31
+ Content-Length:
32
+ - '19'
33
+ Content-Type:
34
+ - application/x-www-form-urlencoded
35
+ Content-Language:
36
+ - en-GB
37
+ Cache-Control:
38
+ - proxy-revalidate
39
+ Proxy-Connection:
40
+ - Keep-Alive
41
+ Connection:
42
+ - close
43
+ Set-Cookie:
44
+ - BC_HA_055537e49f10c20f_773D3E04=0; Domain=.tnt.com; expires=Thu, 16-Jan-20
45
+ 12:34:44 GMT; Path=/
46
+ - BIGipServerbluecoat_pool=2552833956.20480.0000; path=/
47
+ - BIGipServergb_ccc_cit_2_pool=4259893770.20480.0000; path=/
48
+ body:
49
+ encoding: ASCII-8BIT
50
+ string: COMPLETE:4509504419
51
+ http_version:
52
+ recorded_at: Thu, 16 Jan 2020 12:04:44 GMT
53
+ - request:
54
+ method: post
55
+ uri: https://express.tnt.com/expressconnect/shipping/ship
56
+ body:
57
+ encoding: UTF-8
58
+ string: xml_in=GET_RESULT%3A4509504419
59
+ headers:
60
+ Connection:
61
+ - close
62
+ Content-Type:
63
+ - application/x-www-form-urlencoded
64
+ Host:
65
+ - express.tnt.com
66
+ User-Agent:
67
+ - http.rb/4.3.0
68
+ response:
69
+ status:
70
+ code: 200
71
+ message: OK
72
+ headers:
73
+ Date:
74
+ - Thu, 16 Jan 2020 12:04:45 GMT
75
+ Server:
76
+ - IBM_HTTP_Server
77
+ X-Wily-Info:
78
+ - Clear guid=AE3DD4F60AD2EA8C2C5A2C5A697AEB42
79
+ X-Wily-Servlet:
80
+ - Encrypt1 hR/KG2GOR16aRfvv3/q1Ad5uT+eFRPmbRRHNC83W4p9tTEDx66jFEaWXoX0soevZxvVLPT4M8/QqDNhqtwsasrd3VIbriJ05hX8ChkxfBgekWJuBKLXEPeGST6LGOdRj8Yri2fQJK5GzqALGicm2zxQKjjHgt6R8XGi/4LVifbgGM7HsRR0CmaBFRO/EkQXO
81
+ Content-Length:
82
+ - '323'
83
+ Content-Type:
84
+ - application/x-www-form-urlencoded
85
+ Content-Language:
86
+ - en-GB
87
+ Cache-Control:
88
+ - proxy-revalidate
89
+ Proxy-Connection:
90
+ - Keep-Alive
91
+ Connection:
92
+ - close
93
+ Set-Cookie:
94
+ - BC_HA_055537e49f10c20f_773D3E04=0; Domain=.tnt.com; expires=Thu, 16-Jan-20
95
+ 12:34:45 GMT; Path=/
96
+ - BIGipServerbluecoat_pool=2552833956.20480.0000; path=/
97
+ - BIGipServergb_ccc_cit_2_pool=4259893770.20480.0000; path=/
98
+ body:
99
+ encoding: ASCII-8BIT
100
+ string: '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><parse_error><error_reason>cvc-complex-type.2.4.a:
101
+ Invalid content was found starting with element ''COLLECTION''. One of ''{COMPANYNAME}''
102
+ is expected.</error_reason><error_line>1</error_line><error_linepos>201</error_linepos><error_srcText></error_srcText></parse_error>'
103
+ http_version:
104
+ recorded_at: Thu, 16 Jan 2020 12:04:45 GMT
105
+ recorded_with: VCR 5.0.0
metadata ADDED
@@ -0,0 +1,238 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tnt.rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stas SUȘCOV
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: gyoku
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: http-rest_client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ffaker
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: vcr
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: webmock
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: yardstick
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ description: Ruby SDK for working with TNT shipping web services.
196
+ email:
197
+ - stas@nerd.ro
198
+ executables: []
199
+ extensions: []
200
+ extra_rdoc_files: []
201
+ files:
202
+ - ".github/workflows/ci.yml"
203
+ - ".gitignore"
204
+ - ".rubocop.yml"
205
+ - ".yardstick.yml"
206
+ - Gemfile
207
+ - LICENSE.txt
208
+ - README.md
209
+ - Rakefile
210
+ - lib/tnt.rb
211
+ - lib/tnt/version.rb
212
+ - tnt.rb.gemspec
213
+ - vcr_cassettes/tnt_create.yml
214
+ - vcr_cassettes/tnt_error.yml
215
+ homepage: https://github.com/luneteyewear/tnt.rb
216
+ licenses:
217
+ - MIT
218
+ metadata: {}
219
+ post_install_message:
220
+ rdoc_options: []
221
+ require_paths:
222
+ - lib
223
+ required_ruby_version: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - ">="
226
+ - !ruby/object:Gem::Version
227
+ version: '0'
228
+ required_rubygems_version: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: '0'
233
+ requirements: []
234
+ rubygems_version: 3.0.1
235
+ signing_key:
236
+ specification_version: 4
237
+ summary: TNT (Express Web Services) Ruby SDK
238
+ test_files: []