shipcloud 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +62 -0
- data/.rubocop.yml +310 -313
- data/.ruby-version +1 -1
- data/CHANGELOG.md +21 -4
- data/Gemfile +2 -1
- data/README.md +3 -1
- data/Rakefile +5 -4
- data/bin/setup +7 -0
- data/lib/shipcloud/address.rb +2 -0
- data/lib/shipcloud/base.rb +5 -5
- data/lib/shipcloud/carrier.rb +2 -0
- data/lib/shipcloud/operations/all.rb +2 -0
- data/lib/shipcloud/operations/create.rb +3 -1
- data/lib/shipcloud/operations/delete.rb +2 -0
- data/lib/shipcloud/operations/find.rb +3 -1
- data/lib/shipcloud/operations/update.rb +19 -13
- data/lib/shipcloud/order.rb +15 -0
- data/lib/shipcloud/pickup_request.rb +2 -0
- data/lib/shipcloud/request/base.rb +2 -0
- data/lib/shipcloud/request/connection.rb +11 -3
- data/lib/shipcloud/request/info.rb +6 -5
- data/lib/shipcloud/shipcloud_error.rb +7 -0
- data/lib/shipcloud/shipment.rb +5 -2
- data/lib/shipcloud/shipment_quote.rb +2 -0
- data/lib/shipcloud/tracker.rb +1 -0
- data/lib/shipcloud/version.rb +3 -1
- data/lib/shipcloud/webhook.rb +2 -0
- data/lib/shipcloud.rb +1 -0
- data/shipcloud.gemspec +7 -6
- data/spec/shipcloud/address_spec.rb +66 -42
- data/spec/shipcloud/carrier_spec.rb +53 -52
- data/spec/shipcloud/order_spec.rb +188 -0
- data/spec/shipcloud/pickup_request_spec.rb +14 -13
- data/spec/shipcloud/request/base_spec.rb +3 -2
- data/spec/shipcloud/request/connection_spec.rb +1 -0
- data/spec/shipcloud/shipcloud_error_spec.rb +8 -7
- data/spec/shipcloud/shipment_quote_spec.rb +5 -4
- data/spec/shipcloud/shipment_spec.rb +135 -78
- data/spec/shipcloud/webhooks_spec.rb +5 -4
- data/spec/shipcloud_spec.rb +5 -2
- data/spec/spec_helper.rb +3 -2
- metadata +22 -21
- data/.hound.yml +0 -12
- data/.travis.yml +0 -27
- data/install-cc-test-reporter.sh +0 -4
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.3
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
## [
|
1
|
+
## [Unreleased]
|
2
2
|
### Added
|
3
|
-
- Support shipments with pickup requests as required for [TNT](https://developers.shipcloud.io/carriers/tnt.html).
|
4
|
-
- Add attr_accessor for `email` to class `Shipcloud::Address` to be able to access the email attribute at the address object.
|
5
3
|
|
6
4
|
### Changed
|
7
5
|
|
@@ -13,19 +11,38 @@
|
|
13
11
|
|
14
12
|
### Security
|
15
13
|
|
16
|
-
## [
|
14
|
+
## [0.12.0] - 2022-12-06
|
17
15
|
### Added
|
16
|
+
- Add order model
|
17
|
+
- Add attr_accessor for `service` to class `Shipcloud::Shipment` to be able to access the service attribute at the shipment object.
|
18
|
+
- Add attr_accessor for `additional_services` to class `Shipcloud::Shipment` to be able to access the additional_services attribute at the shipment object.
|
19
|
+
- Add attr_reader for `label_voucher_url` to class `Shipcloud::Shipment` to be able to read the label_voucher_url (QR Code url) attribute at the shipment object.
|
20
|
+
- Added missing `frozen_string_literal: true` magic comments to files
|
18
21
|
|
19
22
|
### Changed
|
23
|
+
- Ensure compatibility with ruby 2.x and 3.x
|
24
|
+
- Set required ruby version to >= 2.6
|
25
|
+
- Replace Travis CI with CircleCI
|
26
|
+
- Specify simplecov to be ~> 0.21.0
|
27
|
+
- Specify `rubocop` to be `~> 1.10.0`
|
28
|
+
- Specify `rubocop-performance` to be `~> 1.7.0`
|
20
29
|
|
21
30
|
### Deprecated
|
22
31
|
|
23
32
|
### Removed
|
33
|
+
- Drop support for Ruby <= 2.5
|
34
|
+
- Drop support for RBX
|
24
35
|
|
25
36
|
### Fixed
|
37
|
+
- Fix rubocop styling issues
|
26
38
|
|
27
39
|
### Security
|
28
40
|
|
41
|
+
## [0.11.0] - 2020-07-28
|
42
|
+
### Added
|
43
|
+
- Support shipments with pickup requests as required for [TNT](https://developers.shipcloud.io/carriers/tnt.html).
|
44
|
+
- Add attr_accessor for `email` to class `Shipcloud::Address` to be able to access the email attribute at the address object.
|
45
|
+
|
29
46
|
## [0.10.0] - 2019-08-07
|
30
47
|
### Added
|
31
48
|
- Add the possibility to specify custom affiliate_id on every request
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
[![
|
1
|
+
[![CircleCI](https://circleci.com/gh/shipcloud/shipcloud-ruby/tree/master.svg?style=svg)](https://circleci.com/gh/shipcloud/shipcloud-ruby/tree/master)
|
2
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/c8c3cba2068e5d649567/maintainability)](https://codeclimate.com/github/shipcloud/shipcloud-ruby/maintainability)
|
3
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/c8c3cba2068e5d649567/test_coverage)](https://codeclimate.com/github/shipcloud/shipcloud-ruby/test_coverage)
|
2
4
|
|
3
5
|
# shipcloud
|
4
6
|
|
data/Rakefile
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "bundler/gem_tasks"
|
2
|
-
require
|
3
|
+
require "rspec/core/rake_task"
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
7
|
task :console do
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "irb"
|
9
|
+
require "irb/completion"
|
10
|
+
require "shipcloud"
|
10
11
|
ARGV.clear
|
11
12
|
IRB.start
|
12
13
|
end
|
data/bin/setup
ADDED
data/lib/shipcloud/address.rb
CHANGED
data/lib/shipcloud/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Shipcloud
|
2
4
|
class Base
|
3
5
|
include Shipcloud::Operations::Create
|
@@ -28,17 +30,15 @@ module Shipcloud
|
|
28
30
|
end
|
29
31
|
|
30
32
|
def self.class_name
|
31
|
-
|
33
|
+
name.split("::").last
|
32
34
|
end
|
33
35
|
|
34
36
|
def self.base_url
|
35
37
|
"#{class_name.downcase}s"
|
36
38
|
end
|
37
39
|
|
38
|
-
def self.create_response_root
|
39
|
-
end
|
40
|
+
def self.create_response_root; end
|
40
41
|
|
41
|
-
def self.index_response_root
|
42
|
-
end
|
42
|
+
def self.index_response_root; end
|
43
43
|
end
|
44
44
|
end
|
data/lib/shipcloud/carrier.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Shipcloud
|
2
4
|
module Operations
|
3
5
|
module Create
|
@@ -18,7 +20,7 @@ module Shipcloud
|
|
18
20
|
if create_response_root
|
19
21
|
response = response.fetch(create_response_root, {})
|
20
22
|
end
|
21
|
-
|
23
|
+
new(response)
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
@@ -1,18 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Shipcloud
|
2
4
|
module Operations
|
3
5
|
module Update
|
4
|
-
|
5
6
|
module ClassMethods
|
6
|
-
# Updates
|
7
|
+
# Updates an object
|
7
8
|
# @param [String] id The id of the object that should be updated
|
8
9
|
# @param [Hash] attributes The attributes that should be updated
|
9
|
-
# @param
|
10
|
+
# @param [String] optional api_key The api key. If no api key is given, Shipcloud.api_key
|
10
11
|
# will be used for the request
|
11
|
-
|
12
|
+
# @param [String] optional affiliate_id Your affiliate ID. If no affiliate ID is given,
|
13
|
+
# Shipcloud.affiliate_id will be used for the request
|
14
|
+
def update(id, attributes = {}, **kwargs)
|
15
|
+
attributes.merge!(kwargs)
|
16
|
+
options = attributes.slice(:api_key, :affiliate_id) || {}
|
17
|
+
attributes.reject! { |key| [:api_key, :affiliate_id].include?(key) }
|
12
18
|
response = Shipcloud.request(
|
13
|
-
:put, "#{base_url}/#{id}", attributes,
|
19
|
+
:put, "#{base_url}/#{id}", attributes,
|
20
|
+
api_key: options[:api_key], affiliate_id: options[:affiliate_id]
|
14
21
|
)
|
15
|
-
|
22
|
+
new(response)
|
16
23
|
end
|
17
24
|
end
|
18
25
|
|
@@ -20,16 +27,15 @@ module Shipcloud
|
|
20
27
|
base.extend(ClassMethods)
|
21
28
|
end
|
22
29
|
|
23
|
-
# Updates
|
30
|
+
# Updates an object
|
24
31
|
#
|
25
32
|
# @param [Hash] attributes The attributes that should be updated
|
26
|
-
# @param
|
33
|
+
# @param [String] optional api_key The api key. If no api key is given, Shipcloud.api_key
|
27
34
|
# will be used for the request
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
)
|
32
|
-
set_attributes(response)
|
35
|
+
# @param [String] optional affiliate_id Your affiliate ID. If no affiliate ID is given,
|
36
|
+
# Shipcloud.affiliate_id will be used for the request
|
37
|
+
def update(attributes = {}, **kwargs)
|
38
|
+
self.class.update(id, attributes, **kwargs)
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Shipcloud
|
4
|
+
class Order < Base
|
5
|
+
include Shipcloud::Operations::All
|
6
|
+
include Shipcloud::Operations::Find
|
7
|
+
include Shipcloud::Operations::Create
|
8
|
+
include Shipcloud::Operations::Delete
|
9
|
+
|
10
|
+
attr_reader :id
|
11
|
+
attr_accessor :external_customer_id, :external_order_id, :placed_at, :total_price, :total_vat,
|
12
|
+
:currency, :total_weight, :weight_unit, :refundable_until,
|
13
|
+
:refund_deduction_amount, :delivery_address, :order_line_items, :metadata
|
14
|
+
end
|
15
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Shipcloud
|
2
4
|
module Request
|
3
5
|
class Connection
|
@@ -9,12 +11,18 @@ module Shipcloud
|
|
9
11
|
|
10
12
|
def setup_https
|
11
13
|
if Shipcloud.configuration.use_ssl
|
12
|
-
@https
|
14
|
+
@https = Net::HTTP.new(
|
15
|
+
Shipcloud.configuration.api_base,
|
16
|
+
Net::HTTP.https_default_port,
|
17
|
+
)
|
13
18
|
@https.use_ssl = true
|
14
19
|
@https.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
15
20
|
else
|
16
|
-
@https
|
17
|
-
|
21
|
+
@https = Net::HTTP.new(
|
22
|
+
Shipcloud.configuration.api_base,
|
23
|
+
Net::HTTP.http_default_port,
|
24
|
+
)
|
25
|
+
@https.use_ssl = false
|
18
26
|
end
|
19
27
|
@https.set_debug_output $stdout if Shipcloud.configuration.debug
|
20
28
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Shipcloud
|
2
4
|
module Request
|
3
5
|
class Info
|
@@ -12,16 +14,15 @@ module Shipcloud
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def url
|
15
|
-
|
16
|
-
url
|
17
|
+
"/#{API_VERSION}/#{api_url}"
|
17
18
|
end
|
18
19
|
|
19
20
|
def path_with_params(path, params)
|
20
|
-
|
21
|
+
if params.empty?
|
22
|
+
path
|
23
|
+
else
|
21
24
|
encoded_params = URI.encode_www_form(params)
|
22
25
|
[path, encoded_params].join("?")
|
23
|
-
else
|
24
|
-
path
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Shipcloud
|
2
4
|
class ShipcloudError < StandardError
|
3
5
|
attr_reader :errors, :response
|
@@ -59,10 +61,15 @@ module Shipcloud
|
|
59
61
|
|
60
62
|
# Raised on errors in the 400-499 range
|
61
63
|
class ClientError < ShipcloudError; end
|
64
|
+
|
62
65
|
class AuthenticationError < ClientError; end
|
66
|
+
|
63
67
|
class ForbiddenError < ClientError; end
|
68
|
+
|
64
69
|
class InvalidRequestError < ClientError; end
|
70
|
+
|
65
71
|
class TooManyRequests < ClientError; end
|
72
|
+
|
66
73
|
class NotFoundError < ClientError; end
|
67
74
|
|
68
75
|
# Raised on errors in the 500-599 range
|
data/lib/shipcloud/shipment.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Shipcloud
|
2
4
|
class Shipment < Base
|
3
5
|
include Shipcloud::Operations::Delete
|
4
6
|
include Shipcloud::Operations::Update
|
5
7
|
include Shipcloud::Operations::All
|
6
8
|
|
7
|
-
attr_accessor :from, :to, :carrier, :package, :reference_number, :metadata
|
9
|
+
attr_accessor :from, :to, :carrier, :service, :package, :reference_number, :metadata,
|
10
|
+
:additional_services
|
8
11
|
attr_reader :id, :created_at, :carrier_tracking_no, :tracking_url, :label_url,
|
9
|
-
:packages, :price, :customs_declaration, :pickup
|
12
|
+
:packages, :price, :customs_declaration, :pickup, :label_voucher_url
|
10
13
|
|
11
14
|
def self.index_response_root
|
12
15
|
"#{class_name.downcase}s"
|
data/lib/shipcloud/tracker.rb
CHANGED
data/lib/shipcloud/version.rb
CHANGED
data/lib/shipcloud/webhook.rb
CHANGED
data/lib/shipcloud.rb
CHANGED
@@ -21,6 +21,7 @@ module Shipcloud
|
|
21
21
|
autoload :Shipment, "shipcloud/shipment"
|
22
22
|
autoload :Carrier, "shipcloud/carrier"
|
23
23
|
autoload :Address, "shipcloud/address"
|
24
|
+
autoload :Order, "shipcloud/order"
|
24
25
|
autoload :PickupRequest, "shipcloud/pickup_request"
|
25
26
|
autoload :ShipmentQuote, "shipcloud/shipment_quote"
|
26
27
|
autoload :Tracker, "shipcloud/tracker"
|
data/shipcloud.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
lib = File.expand_path("lib", __dir__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
6
|
require "shipcloud/version"
|
@@ -15,18 +17,17 @@ Gem::Specification.new do |spec|
|
|
15
17
|
spec.license = "MIT"
|
16
18
|
|
17
19
|
spec.files = `git ls-files`.split($/)
|
18
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
21
|
spec.require_paths = ["lib"]
|
21
22
|
|
22
|
-
spec.required_ruby_version = ">= 2.
|
23
|
+
spec.required_ruby_version = ">= 2.6"
|
23
24
|
|
24
25
|
spec.add_runtime_dependency "json", ">= 1.8.0"
|
25
26
|
spec.add_development_dependency "pry", "~> 0.10"
|
26
|
-
spec.add_development_dependency "rake", "~>
|
27
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
27
28
|
spec.add_development_dependency "rspec", "~> 3.6"
|
28
|
-
spec.add_development_dependency "rubocop", "~>
|
29
|
-
spec.add_development_dependency "rubocop-performance"
|
30
|
-
spec.add_development_dependency "simplecov"
|
29
|
+
spec.add_development_dependency "rubocop", "~> 1.10.0"
|
30
|
+
spec.add_development_dependency "rubocop-performance", "~> 1.7.0"
|
31
|
+
spec.add_development_dependency "simplecov", "~> 0.21.0"
|
31
32
|
spec.add_development_dependency "webmock", "~> 3.0"
|
32
33
|
end
|
@@ -1,42 +1,43 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Shipcloud::Address do
|
5
6
|
valid_attributes = {
|
6
|
-
company:
|
7
|
-
first_name:
|
8
|
-
last_name:
|
9
|
-
care_of:
|
10
|
-
street:
|
11
|
-
street_no:
|
12
|
-
zip_code:
|
13
|
-
city:
|
14
|
-
state:
|
15
|
-
country:
|
16
|
-
phone:
|
17
|
-
email:
|
7
|
+
company: "shipcloud GmbH",
|
8
|
+
first_name: "Maxi",
|
9
|
+
last_name: "Musterfrau",
|
10
|
+
care_of: "Mustermann",
|
11
|
+
street: "Musterstraße",
|
12
|
+
street_no: "123",
|
13
|
+
zip_code: "12345",
|
14
|
+
city: "Hamburg",
|
15
|
+
state: "Hamburg",
|
16
|
+
country: "DE",
|
17
|
+
phone: "040/123456789",
|
18
|
+
email: "max@mustermail.com",
|
18
19
|
}
|
19
20
|
|
20
|
-
describe
|
21
|
-
it
|
21
|
+
describe "#initialize" do
|
22
|
+
it "initializes all attributes correctly" do
|
22
23
|
address = Shipcloud::Address.new(valid_attributes)
|
23
|
-
expect(address.company).to eq
|
24
|
-
expect(address.first_name).to eq
|
25
|
-
expect(address.last_name).to eq
|
26
|
-
expect(address.care_of).to eq
|
27
|
-
expect(address.street).to eq
|
28
|
-
expect(address.street_no).to eq
|
29
|
-
expect(address.zip_code).to eq
|
30
|
-
expect(address.city).to eq
|
31
|
-
expect(address.state).to eq
|
32
|
-
expect(address.country).to eq
|
33
|
-
expect(address.phone).to eq
|
34
|
-
expect(address.email).to eq
|
24
|
+
expect(address.company).to eq "shipcloud GmbH"
|
25
|
+
expect(address.first_name).to eq "Maxi"
|
26
|
+
expect(address.last_name).to eq "Musterfrau"
|
27
|
+
expect(address.care_of).to eq "Mustermann"
|
28
|
+
expect(address.street).to eq "Musterstraße"
|
29
|
+
expect(address.street_no).to eq "123"
|
30
|
+
expect(address.zip_code).to eq "12345"
|
31
|
+
expect(address.city).to eq "Hamburg"
|
32
|
+
expect(address.state).to eq "Hamburg"
|
33
|
+
expect(address.country).to eq "DE"
|
34
|
+
expect(address.phone).to eq "040/123456789"
|
35
|
+
expect(address.email).to eq "max@mustermail.com"
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
|
-
describe
|
39
|
-
it
|
39
|
+
describe ".create" do
|
40
|
+
it "makes a new POST request using the correct API endpoint" do
|
40
41
|
expect(Shipcloud).to receive(:request).
|
41
42
|
with(:post, "addresses", valid_attributes, api_key: nil, affiliate_id: nil).
|
42
43
|
and_return("data" => {})
|
@@ -65,10 +66,11 @@ describe Shipcloud::Address do
|
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
68
|
-
describe
|
69
|
-
it
|
69
|
+
describe ".find" do
|
70
|
+
it "makes a new GET request using the correct API endpoint to receive a specific address" do
|
70
71
|
expect(Shipcloud).to receive(:request).with(
|
71
|
-
:get, "addresses/123", {}, api_key: nil, affiliate_id: nil
|
72
|
+
:get, "addresses/123", {}, api_key: nil, affiliate_id: nil
|
73
|
+
).and_return("id" => "123")
|
72
74
|
|
73
75
|
Shipcloud::Address.find("123")
|
74
76
|
end
|
@@ -82,8 +84,8 @@ describe Shipcloud::Address do
|
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
85
|
-
describe
|
86
|
-
it
|
87
|
+
describe ".update" do
|
88
|
+
it "makes a new PUT request using the correct API endpoint" do
|
87
89
|
expect(Shipcloud).to receive(:request).with(
|
88
90
|
:put, "addresses/123", { street: "Mittelweg" }, api_key: nil, affiliate_id: nil
|
89
91
|
).and_return("data" => {})
|
@@ -100,15 +102,15 @@ describe Shipcloud::Address do
|
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
103
|
-
describe
|
104
|
-
it
|
105
|
+
describe ".all" do
|
106
|
+
it "makes a new Get request using the correct API endpoint" do
|
105
107
|
expect(Shipcloud).to receive(:request).
|
106
108
|
with(:get, "addresses", {}, api_key: nil, affiliate_id: nil).and_return([])
|
107
109
|
|
108
110
|
Shipcloud::Address.all
|
109
111
|
end
|
110
112
|
|
111
|
-
it
|
113
|
+
it "returns a list of Address objects" do
|
112
114
|
stub_addresses_request
|
113
115
|
|
114
116
|
addresses = Shipcloud::Address.all
|
@@ -129,6 +131,28 @@ describe Shipcloud::Address do
|
|
129
131
|
end
|
130
132
|
end
|
131
133
|
|
134
|
+
describe "#update" do
|
135
|
+
it "makes a new PUT request using the correct API endpoint" do
|
136
|
+
expect(Shipcloud).to receive(:request).with(
|
137
|
+
:put, "addresses/123", { street: "Mittelweg" }, api_key: nil, affiliate_id: nil
|
138
|
+
).and_return("data" => {})
|
139
|
+
|
140
|
+
address = Shipcloud::Address.new(id: "123")
|
141
|
+
|
142
|
+
address.update(street: "Mittelweg")
|
143
|
+
end
|
144
|
+
|
145
|
+
it "uses the affiliate ID provided for the request" do
|
146
|
+
expect(Shipcloud).to receive(:request).with(
|
147
|
+
:put, "addresses/123", { street: "Mittelweg" }, api_key: nil, affiliate_id: "affiliate_id"
|
148
|
+
).and_return("data" => {})
|
149
|
+
|
150
|
+
address = Shipcloud::Address.new(id: "123")
|
151
|
+
|
152
|
+
address.update({ street: "Mittelweg" }, affiliate_id: "affiliate_id")
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
132
156
|
def stub_addresses_request(affiliate_id: nil)
|
133
157
|
allow(Shipcloud).to receive(:request).
|
134
158
|
with(:get, "addresses", {}, api_key: nil, affiliate_id: affiliate_id).
|
@@ -146,7 +170,7 @@ describe Shipcloud::Address do
|
|
146
170
|
"city" => "Musterstadt",
|
147
171
|
"state" => "",
|
148
172
|
"country" => "DE",
|
149
|
-
"phone" => ""
|
173
|
+
"phone" => "",
|
150
174
|
},
|
151
175
|
{
|
152
176
|
"id" => "7ea2a290-b456-4ecf-9010-e82b3da298f0",
|
@@ -160,9 +184,9 @@ describe Shipcloud::Address do
|
|
160
184
|
"city" => "Musterstadt",
|
161
185
|
"state" => "",
|
162
186
|
"country" => "DE",
|
163
|
-
"phone" => ""
|
164
|
-
}
|
165
|
-
]
|
187
|
+
"phone" => "",
|
188
|
+
},
|
189
|
+
],
|
166
190
|
)
|
167
191
|
end
|
168
192
|
|