dpd 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a93166bbf6b0d981aa6e5a37bfa2a796ab30a67f1b892da78b9c80e914adbb26
4
+ data.tar.gz: 3a7f1455cff57158c7cf2301fb4dfc9113e4fb47c7b64a2ee5d5b8b322d3b391
5
+ SHA512:
6
+ metadata.gz: 10195158096f5d5aa11f9c4603cb9393a59e0bbeb6a802a69f1184147070cccbf73ae05eda0416545cf70c730e9bf93c7ae3c4aef8ef7167802f818beb4d9a2d
7
+ data.tar.gz: 849644274bb4418f2380986dd1a33412e0b680e8661b79651fe1915ce15dff47bdaa36af9989268cc2c3e160c0852902a2f7976c5fcf3aeba9f47842a97090ba
@@ -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
@@ -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
@@ -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'
@@ -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
@@ -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.
@@ -0,0 +1,110 @@
1
+ # DPD (Shipping Web API) 📦
2
+
3
+ Ruby SDK for working with [DPD](https://api.dpd.ro/web-api.html) Web API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'dpd'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install dpd
20
+
21
+ ## Usage
22
+
23
+ A subset of the DPD resources are provided with this SDK:
24
+
25
+ * `DPD::Shipment`
26
+ * `DPD::Printout`
27
+ * `DPD::Voucher`
28
+ * `DPD::Pickup`
29
+ * `DPD::Track`
30
+
31
+ These resources have implemented the following methods to allow API operations:
32
+ * `find`
33
+ * `create`
34
+
35
+ Here's an example on how to create a shipment, request it's pickup and cancel
36
+ it.
37
+ ```ruby
38
+ require 'dpd'
39
+
40
+ shipment = DPD::Shipment.create(
41
+ service: {
42
+ serviceId: ENV['DPD_SERVICE_ID'],
43
+ autoAdjustPickupDate: true,
44
+ saturdayDelivery: true
45
+ },
46
+ payment: { courierServicePayer: 'SENDER' },
47
+ ref1: 'LNT_ORDER_ID',
48
+ sender: { clientId: 'DPD_CLIENT_ID' },
49
+ recipient: {
50
+ privatePerson: true,
51
+ contactName: 'Lunet Studio SRL',
52
+ clientName: 'Lunet Studio SRL',
53
+ phone1: {
54
+ number: '+40728547184'
55
+ },
56
+ address: {
57
+ countryId: ENV['DPD_COUNTRY_ID'],
58
+ siteName: 'Bucharest',
59
+ addressNote: 'Bld. Lascar Catargiu 15A, 12, Sector 1, 010661 Bucharest',
60
+ addressLine1: 'Bld. Lascar Catargiu 15A, 12',
61
+ addressLine2: 'Sector 1, 010661 Bucharest',
62
+ postCode: '010661'
63
+ }
64
+ },
65
+ content: {
66
+ parcelsCount: 1,
67
+ totalWeight: 0.5,
68
+ contents: 'GLASSES',
69
+ package: 'BOX'
70
+ }
71
+ )
72
+
73
+ DPD::Pickup.create(
74
+ explicitShipmentIdList: [shipment.id],
75
+ visitEndTime: '19:00'
76
+ )
77
+
78
+ shipment.cancel('Customer request.')
79
+ ```
80
+
81
+ ### Configuration
82
+
83
+ The API keys will be loaded from your environment variables:
84
+
85
+ * `DPD_USERNAME`
86
+ * `DPD_PASSWORD`
87
+
88
+ Please remember, DPD will provide you separately with a **DPD_CLIENT_ID**,
89
+ **DPD_SERVICE_ID** and the **DPD_COUNTRY_ID**, based on your location and the
90
+ type of services you opted for.
91
+
92
+ ## Development
93
+
94
+ To install this gem onto your local machine, run `bundle exec rake install`. To
95
+ release a new version, update the version number in `version.rb`, and then run
96
+ `bundle exec rake release`, which will create a git tag for the version, push
97
+ git commits and tags, and push the `.gem` file to
98
+ [rubygems.org](https://rubygems.org).
99
+
100
+ ## Contributing
101
+
102
+ Bug reports and pull requests are welcome on GitHub at
103
+ https://github.com/luneteyewear/dpd. This project is intended to be a safe,
104
+ welcoming space for collaboration, and contributors are expected to adhere to
105
+ the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
106
+
107
+ ## License
108
+
109
+ The gem is available as open source under the terms of the [MIT
110
+ License](https://opensource.org/licenses/MIT).
@@ -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)
@@ -0,0 +1,34 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'dpd/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'dpd'
7
+ spec.version = DPD::VERSION
8
+ spec.authors = ['Stas SUȘCOV']
9
+ spec.email = ['stas@nerd.ro']
10
+
11
+ spec.summary = 'DPD (Web API) Ruby SDK'
12
+ spec.description = 'Ruby SDK for working with DPD shipping web services.'
13
+ spec.homepage = 'https://github.com/luneteyewear/dpd'
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 'http-rest_client'
23
+
24
+ spec.add_development_dependency 'bundler'
25
+ spec.add_development_dependency 'ffaker'
26
+ spec.add_development_dependency 'rake'
27
+ spec.add_development_dependency 'rspec'
28
+ spec.add_development_dependency 'rubocop-performance'
29
+ spec.add_development_dependency 'rubocop-rspec'
30
+ spec.add_development_dependency 'simplecov'
31
+ spec.add_development_dependency 'vcr'
32
+ spec.add_development_dependency 'webmock'
33
+ spec.add_development_dependency 'yardstick'
34
+ end
@@ -0,0 +1,133 @@
1
+ require 'ostruct'
2
+ require 'tempfile'
3
+ require 'http/rest_client'
4
+
5
+ # DPD HTTP API Client
6
+ module DPD
7
+ # Base endpoint resources class
8
+ class Resource < OpenStruct
9
+ extend HTTP::RestClient::DSL
10
+ extend HTTP::RestClient::CRUD
11
+
12
+ endpoint 'https://api.dpd.ro'
13
+ content_type 'application/json'
14
+
15
+ # Returns a payload with service credentials
16
+ #
17
+ # @return [Hash]
18
+ def self.credentials
19
+ {
20
+ userName: ENV['DPD_USER'],
21
+ password: ENV['DPD_PASSWORD']
22
+ }
23
+ end
24
+
25
+ # Patched request handler to include the credentials
26
+ #
27
+ # @param verb [String] the HTTP method.
28
+ # @param uri [URI] the HTTP URI.
29
+ # @param options [Hash] the params/json-payload/form to include.
30
+ # @return [DPD::Response]
31
+ def self.request(verb, uri, options = {})
32
+ options[:json] ||= {}
33
+ options[:json].merge!(credentials)
34
+ super(verb, uri, options)
35
+ end
36
+
37
+ # Validate error response
38
+ #
39
+ # Looks at the response code by default.
40
+ #
41
+ # @param response [HTTP::Response] the server response
42
+ # @param parsed [Object] the parsed server response
43
+ #
44
+ # @return [TrueClass] if status code is not a successful standard value
45
+ def self.error_response?(response, parsed)
46
+ super || parsed.is_a?(Hash) && parsed.dig('error')
47
+ end
48
+
49
+ # Extracts the error message from the response
50
+ #
51
+ # @param response [HTTP::Response] the server response
52
+ # @param parsed [Object] the parsed server response
53
+ #
54
+ # @return [String]
55
+ def self.extract_error(response, parsed)
56
+ parsed&.dig('error', 'message') || super
57
+ end
58
+
59
+ # Will try to parse the response or return an IO if it's a PDF
60
+ #
61
+ # Will return nothing on failure.
62
+ #
63
+ # @param response [HTTP::Response] the server response
64
+ #
65
+ # @return [Object] upon success
66
+ def self.parse_response(response)
67
+ if response.mime_type == 'application/pdf'
68
+ io = Tempfile.new([name.underscore, '.pdf'])
69
+ io.write(response.body)
70
+ io.seek(0)
71
+
72
+ { data: io }
73
+ else
74
+ super
75
+ end
76
+ end
77
+ end
78
+
79
+ # Shipments endpoint resource
80
+ class Shipment < Resource
81
+ path 'v1/shipment'
82
+
83
+ # Handles the shipment fetching request
84
+ #
85
+ # @return [DPD::Response]
86
+ def self.find(id)
87
+ params = { shipmentIds: [id] }
88
+ params.merge!(credentials)
89
+ new(request(:post, uri('info'), json: params).values.flatten.first)
90
+ end
91
+
92
+ # Handles the shipment cancellation request
93
+ #
94
+ # @return [DPD::Response]
95
+ def cancel(comment)
96
+ params = { shipmentId: id, comment: comment }
97
+ self.class.request(
98
+ :post,
99
+ self.class.uri('cancel'),
100
+ json: params.merge(self.class.credentials)
101
+ )
102
+ end
103
+ end
104
+
105
+ # Printouts endpoint resource
106
+ class Printout < Resource
107
+ path 'v1/print'
108
+ end
109
+
110
+ # Return vouchers endpoint resource
111
+ class Voucher < Resource
112
+ path 'v1/print/voucher'
113
+ end
114
+
115
+ # Pickup request endpoint resource
116
+ class Pickup < Resource
117
+ path 'v1/pickup'
118
+ end
119
+
120
+ # Tracking endpoint resource
121
+ class Track < Resource
122
+ path 'v1/track'
123
+
124
+ # Handles the shipment fetching request
125
+ #
126
+ # @return [DPD::Response]
127
+ def self.find(id)
128
+ params = { parcels: [{ id: id }] }
129
+ params.merge!(credentials)
130
+ super('', params).values.flatten.first
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,3 @@
1
+ module DPD
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,85 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.dpd.ro/v1/shipment/info
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"shipmentIds":[80147286562],"userName":"<DPD_USERNAME>","password":"<DPD_PASSWORD>"}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Connection:
13
+ - close
14
+ Host:
15
+ - api.dpd.ro
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 13:24:34 GMT
25
+ Server:
26
+ - Apache/2.4.25 (Win64) OpenSSL/1.0.2k
27
+ Content-Type:
28
+ - application/json;charset=UTF-8
29
+ Content-Length:
30
+ - '4007'
31
+ Set-Cookie:
32
+ - SERVERID_8084=server124-8084-81; path=/
33
+ Connection:
34
+ - close
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"shipments":[{"id":"80147286562","sender":{"clientId":<DPD_CLIENT_ID>,"clientName":"LUNET
38
+ STUDIO SRL","contactName":"STEFAN GUGUREL","address":{"countryId":642,"siteId":642279132,"siteType":"or.","siteName":"BUCURESTI","postCode":"011813","streetId":642076636,"streetType":"str.","streetName":"PARIS","streetNo":"9","floorNo":"3","x":26.087824,"y":44.454414,"fullAddressString":"or.
39
+ BUCURESTI [011813], str. PARIS Nr. 9 et. 3","siteAddressString":"or. BUCURESTI
40
+ [011813]","localAddressString":"str. PARIS Nr. 9 et. 3"},"email":"hello@luneteyewear.com","privatePerson":false,"phones":[{"number":"0723763332"}],"dropoffOfficeId":0},"recipient":{"clientName":"LUNET
41
+ STUDIO SRL","address":{"countryId":642,"siteId":642279132,"siteType":"or.","siteName":"BUCURESTI","postCode":"010661","streetId":642075756,"streetType":"bld.","streetName":"LASCAR
42
+ CATARGIU","streetNo":"15A12","blockNo":"15A","x":26.094288,"y":44.447853,"fullAddressString":"or.
43
+ BUCURESTI [010661], bld. LASCAR CATARGIU Nr. 15A12 bl. 15A","siteAddressString":"or.
44
+ BUCURESTI [010661]","localAddressString":"bld. LASCAR CATARGIU Nr. 15A12 bl.
45
+ 15A"},"privatePerson":true,"phones":[{"number":"0728547184"}]},"service":{"pickupDate":"2020-01-16","serviceId":<DPD_SERVICE_ID>,"additionalServices":{"returns":{}},"deferredDays":0,"saturdayDelivery":true,"autoAdjustPickupDate":false},"content":{"parcelsCount":1,"declaredWeight":0.5,"calculationWeight":0.5,"contents":"GLASSES","documents":false,"palletized":false,"parcels":[{"id":"80147286562","seqNo":1,"declaredSize":{"width":0,"height":0,"depth":0},"measuredSize":{"width":0,"height":0,"depth":0},"calculationSize":{"width":0,"height":0,"depth":0},"declaredWeight":0.5,"calculationWeight":0.5,"externalCarrierParcelNumbers":[]}],"pendingParcels":false,"package":"BOX"},"payment":{"courierServicePayer":"SENDER"},"ref1":"LNT_ORD_ID","price":{"amount":12.17,"vat":2.31,"total":14.48,"details":{"netAmount":{"amount":7.85,"vatPercent":0.19},"addressPickupSurcharge":{"amount":1.59,"percent":0.0,"vatPercent":0.19},"addressDeliverySurcharge":{"amount":2.38,"percent":0.0,"vatPercent":0.19},"fixedDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"dropOffDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"pickUpDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"additionalDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"fuelSurcharge":{"amount":0.35,"percent":3.0,"vatPercent":0.19},"nonStandardDeliveryDateSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"islandSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"optionsBeforePaymentSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"codPremium":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"insurancePremium":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"voucherDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19}},"amountLocal":12.17,"vatLocal":2.31,"totalLocal":14.48,"currencyLocal":"RON","detailsLocal":{"netAmount":{"amount":7.85,"vatPercent":0.19},"addressPickupSurcharge":{"amount":1.59,"percent":0.0,"vatPercent":0.19},"addressDeliverySurcharge":{"amount":2.38,"percent":0.0,"vatPercent":0.19},"fixedDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"dropOffDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"pickUpDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"additionalDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"fuelSurcharge":{"amount":0.35,"percent":3.0,"vatPercent":0.19},"nonStandardDeliveryDateSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"islandSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"optionsBeforePaymentSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"codPremium":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"insurancePremium":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"voucherDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19}},"currencyExchangeRateUnit":1,"currencyExchangeRate":1.0},"delivery":{"deadline":"2020-01-17T00:00:00+0200"},"primaryShipment":{},"pendingShipment":false}]}'
46
+ http_version:
47
+ recorded_at: Thu, 16 Jan 2020 13:24:35 GMT
48
+ - request:
49
+ method: post
50
+ uri: https://api.dpd.ro/v1/shipment/cancel
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"shipmentId":"80147286562","comment":"Customer request.","userName":"<DPD_USERNAME>","password":"<DPD_PASSWORD>"}'
54
+ headers:
55
+ Content-Type:
56
+ - application/json
57
+ Connection:
58
+ - close
59
+ Host:
60
+ - api.dpd.ro
61
+ User-Agent:
62
+ - http.rb/4.3.0
63
+ response:
64
+ status:
65
+ code: 200
66
+ message: OK
67
+ headers:
68
+ Date:
69
+ - Thu, 16 Jan 2020 13:24:35 GMT
70
+ Server:
71
+ - Apache/2.4.25 (Win64) OpenSSL/1.0.2k
72
+ Content-Type:
73
+ - application/json;charset=UTF-8
74
+ Content-Length:
75
+ - '2'
76
+ Set-Cookie:
77
+ - SERVERID_8084=server123-8084-81; path=/
78
+ Connection:
79
+ - close
80
+ body:
81
+ encoding: UTF-8
82
+ string: "{}"
83
+ http_version:
84
+ recorded_at: Thu, 16 Jan 2020 13:24:35 GMT
85
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.dpd.ro/v1/shipment
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"service":{"serviceId":"<DPD_SERVICE_ID>","autoAdjustPickupDate":true,"saturdayDelivery":true},"payment":{"courierServicePayer":"SENDER"},"ref1":"LNT_ORD_ID","sender":{"clientId":"<DPD_CLIENT_ID>"},"recipient":{"privatePerson":true,"contactName":"Lunet
9
+ Studio SRL","clientName":"Lunet Studio SRL","phone1":{"number":"+40728547184"},"address":{"countryId":642,"siteName":"Bucharest","addressNote":"Bld.
10
+ Lascar Catargiu 15A, 12, Sector 1, 010661 Bucharest","addressLine1":"Bld.
11
+ Lascar Catargiu 15A, 12, Sector 1, 0","addressLine2":"010661 Bucharest","postCode":"010661"}},"content":{"parcelsCount":1,"totalWeight":0.5,"contents":"GLASSES","package":"BOX"},"userName":"<DPD_USERNAME>","password":"<DPD_PASSWORD>"}'
12
+ headers:
13
+ Content-Type:
14
+ - application/json
15
+ Connection:
16
+ - close
17
+ Host:
18
+ - api.dpd.ro
19
+ User-Agent:
20
+ - http.rb/4.3.0
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: OK
25
+ headers:
26
+ Date:
27
+ - Thu, 16 Jan 2020 13:14:57 GMT
28
+ Server:
29
+ - Apache/2.4.25 (Win64) OpenSSL/1.0.2k
30
+ Content-Type:
31
+ - application/json;charset=UTF-8
32
+ Content-Length:
33
+ - '2217'
34
+ Set-Cookie:
35
+ - SERVERID_8084=server123-8084-81; path=/
36
+ Connection:
37
+ - close
38
+ body:
39
+ encoding: UTF-8
40
+ string: '{"id":"80147286562","parcels":[{"id":"80147286562","seqNo":1}],"pickupDate":"2020-01-16","price":{"amount":12.17,"vat":2.31,"total":14.48,"details":{"netAmount":{"amount":7.85,"vatPercent":0.19},"addressPickupSurcharge":{"amount":1.59,"percent":0.0,"vatPercent":0.19},"addressDeliverySurcharge":{"amount":2.38,"percent":0.0,"vatPercent":0.19},"fixedDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"dropOffDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"pickUpDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"additionalDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"fuelSurcharge":{"amount":0.35,"percent":3.0,"vatPercent":0.19},"nonStandardDeliveryDateSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"islandSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"optionsBeforePaymentSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"codPremium":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"insurancePremium":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"voucherDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19}},"amountLocal":12.17,"vatLocal":2.31,"totalLocal":14.48,"currencyLocal":"RON","detailsLocal":{"netAmount":{"amount":7.85,"vatPercent":0.19},"addressPickupSurcharge":{"amount":1.59,"percent":0.0,"vatPercent":0.19},"addressDeliverySurcharge":{"amount":2.38,"percent":0.0,"vatPercent":0.19},"fixedDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"dropOffDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"pickUpDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"additionalDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"fuelSurcharge":{"amount":0.35,"percent":3.0,"vatPercent":0.19},"nonStandardDeliveryDateSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"islandSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"optionsBeforePaymentSurcharge":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"codPremium":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"insurancePremium":{"amount":0.0,"percent":0.0,"vatPercent":0.19},"voucherDiscount":{"amount":0.0,"percent":0.0,"vatPercent":0.19}},"currencyExchangeRateUnit":1,"currencyExchangeRate":1.0},"deliveryDeadline":"2020-01-17T19:00:00+0200"}'
41
+ http_version:
42
+ recorded_at: Thu, 16 Jan 2020 13:14:57 GMT
43
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.dpd.ro/v1/shipment/info
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"shipmentIds":["wrong"],"userName":"<DPD_USERNAME>","password":"<DPD_PASSWORD>"}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Connection:
13
+ - close
14
+ Host:
15
+ - api.dpd.ro
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 13:43:12 GMT
25
+ Server:
26
+ - Apache/2.4.25 (Win64) OpenSSL/1.0.2k
27
+ Content-Type:
28
+ - application/json;charset=UTF-8
29
+ Content-Length:
30
+ - '60'
31
+ Set-Cookie:
32
+ - SERVERID_8084=server123-8084-81; path=/
33
+ Connection:
34
+ - close
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"error":{"context":"","message":"Barcode wrong not found"}}'
38
+ http_version:
39
+ recorded_at: Thu, 16 Jan 2020 13:43:13 GMT
40
+ recorded_with: VCR 5.0.0
metadata ADDED
@@ -0,0 +1,211 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dpd
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: http-rest_client
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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: ffaker
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: rake
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: rspec
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: rubocop-performance
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: rubocop-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: simplecov
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: vcr
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: webmock
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: yardstick
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
+ description: Ruby SDK for working with DPD shipping web services.
168
+ email:
169
+ - stas@nerd.ro
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".github/workflows/ci.yml"
175
+ - ".gitignore"
176
+ - ".rubocop.yml"
177
+ - ".yardstick.yml"
178
+ - Gemfile
179
+ - LICENSE.txt
180
+ - README.md
181
+ - Rakefile
182
+ - dpd.gemspec
183
+ - lib/dpd.rb
184
+ - lib/dpd/version.rb
185
+ - vcr_cassettes/dpd_cancel.yml
186
+ - vcr_cassettes/dpd_create.yml
187
+ - vcr_cassettes/dpd_error.yml
188
+ homepage: https://github.com/luneteyewear/dpd
189
+ licenses:
190
+ - MIT
191
+ metadata: {}
192
+ post_install_message:
193
+ rdoc_options: []
194
+ require_paths:
195
+ - lib
196
+ required_ruby_version: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ required_rubygems_version: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ requirements: []
207
+ rubygems_version: 3.0.1
208
+ signing_key:
209
+ specification_version: 4
210
+ summary: DPD (Web API) Ruby SDK
211
+ test_files: []