newgistics 2.1.0 → 2.5.0

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: 531b711f00ce955b4cd22a6b2e9e9f33faa50506
4
- data.tar.gz: 611c887de7ba5cdb4989857218b7bfbfdbf82a01
3
+ metadata.gz: a7102bd462733a83d1d2feb94572a2e21923b6ba
4
+ data.tar.gz: 2cc9355b5df9e998f7bf45925de7fe1c5951831b
5
5
  SHA512:
6
- metadata.gz: 566e377c9306a88b8dd218afc100ccfadaa64d4cb4bb467c0c5e12f927dc815764c9786af3393e8bc916e6cb23e128b169835a3d8586dc10768160858280baf7
7
- data.tar.gz: 7e131edb758105bae9051d639c52bf56d84011b7da67f0765522d03ad0dd98dd0e755e8cbc59ceb39207ded8e946e7e8e30caf16f169b760842ab616f75b2e60
6
+ metadata.gz: 0b4882f4bfab7b5233f739c3a031b9a7e29ffdaed5af1f095b0e42041ceeacc2817743e59af3c0f8bd0676d6f3b23137d3bd28219ded0d0af5edf6ba6fd1a38c
7
+ data.tar.gz: 0cd0c053dbbb127cbe95d6ae16b58af81e7593285bf6a240392c3d487c41dc53e18f1846dfa8b555ce0ff3f44b416ebdd56df25ae3e44ec267d8fb0086c15442
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- [![Code Climate](https://codeclimate.com/repos/5991e52637216b02640002d4/badges/9e19d346f6da0db0783c/gpa.svg)](https://codeclimate.com/repos/5991e52637216b02640002d4/feed)
2
- [![Test Coverage](https://codeclimate.com/repos/5991e52637216b02640002d4/badges/9e19d346f6da0db0783c/coverage.svg)](https://codeclimate.com/repos/5991e52637216b02640002d4/coverage)
1
+ [![Maintainability](https://api.codeclimate.com/v1/badges/ed9b1c5905ae5547414e/maintainability)](https://codeclimate.com/github/rocketsofawesome/newgistics-ruby/maintainability)
2
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/ed9b1c5905ae5547414e/test_coverage)](https://codeclimate.com/github/rocketsofawesome/newgistics-ruby/test_coverage)
3
3
  [ ![Codeship Status for rocketsofawesome/newgistics-ruby](https://app.codeship.com/projects/63cb9a70-68b6-0135-a28b-5ec5668067cc/status?branch=master)](https://app.codeship.com/projects/241459)
4
4
  # Newgistics
5
5
 
@@ -71,6 +71,16 @@ shipment_update.save
71
71
 
72
72
  `shipment_update.save` will return `true` if the order is updated successfully and `false` otherwise, any errors or warnings generated when updating the shipment are available under `shipment_update.errors` and `shipment_update.warnings` respectively. `shipment_update.success` or also `shipment_update.success?` will also be updated to the corresponding value.
73
73
 
74
+ #### Updating a shipment's address in Newgistics
75
+ ```ruby
76
+ address_update = Newgistics::ShipmentAddressUpdate.new(update_attributes)
77
+ address_update.save
78
+ ```
79
+
80
+ `update_attributes` is a `Hash` with the updates you want to perform on the shipment, for a list of available attributes you can look at the [Newgistics::ShipmentAddressUpdate model](lib/newgistics/shipment_address_update.rb)
81
+
82
+ `address_update.save` will return `true` if the shipment is updated successfully and `false` otherwise, any errors or warnings generated when updating the shipment are available under `address_update.errors` and `address_update.warnings` respectively. `address_update.success` or also `address_update.success?` will also be updated to the corresponding value.
83
+
74
84
  #### Cancelling a shipment/order on Newgistics
75
85
  ```ruby
76
86
  shipment_cancellation = Newgistics::ShipmentCancellation.new(shipment_id: SHIPMENT_ID)
@@ -15,6 +15,8 @@ require "newgistics/model"
15
15
  require "newgistics/customer"
16
16
  require "newgistics/item"
17
17
  require "newgistics/order"
18
+ require "newgistics/package_item"
19
+ require "newgistics/package"
18
20
  require "newgistics/product"
19
21
  require "newgistics/return"
20
22
  require "newgistics/inbound_return"
@@ -23,6 +25,7 @@ require "newgistics/query"
23
25
  require "newgistics/errors"
24
26
  require "newgistics/string_helper"
25
27
  require "newgistics/shipment_cancellation"
28
+ require "newgistics/shipment_address_update"
26
29
  require "newgistics/shipment_update"
27
30
  require "newgistics/warehouse"
28
31
  require "newgistics/requests/cancel_shipment"
@@ -31,12 +34,14 @@ require "newgistics/requests/post_inbound_return"
31
34
  require "newgistics/requests/search"
32
35
  require "newgistics/requests/post_manifest"
33
36
  require "newgistics/requests/cancel_manifest"
37
+ require "newgistics/requests/update_shipment_address"
34
38
  require "newgistics/requests/update_shipment_contents"
35
39
  require "newgistics/response_handlers/cancel_shipment"
36
40
  require "newgistics/response_handlers/post_shipment"
37
41
  require "newgistics/response_handlers/post_inbound_return"
38
42
  require "newgistics/response_handlers/post_errors"
39
43
  require "newgistics/response_handlers/search"
44
+ require "newgistics/response_handlers/update_shipment_address"
40
45
  require "newgistics/response_handlers/update_shipment_contents"
41
46
  require "newgistics/response_handlers/post_manifest"
42
47
  require "newgistics/response_handlers/cancel_manifest"
@@ -5,6 +5,9 @@ module Newgistics
5
5
  attribute :id, String
6
6
 
7
7
  attribute :sku, String
8
+ attribute :upc, String
9
+ attribute :description, String
10
+ attribute :lot, String
8
11
  attribute :qty, Integer
9
12
  attribute :is_gift_wrapped, Boolean
10
13
  attribute :custom_fields, Hash
@@ -18,6 +18,8 @@ module Newgistics
18
18
  attribute :custom_fields, Hash
19
19
  attribute :allow_duplicate, Boolean
20
20
  attribute :items, Array[Item]
21
+ attribute :reference_1, String
22
+ attribute :reference_2, String
21
23
 
22
24
  attribute :errors, Array[String], default: []
23
25
  attribute :warnings, Array[String], default: []
@@ -0,0 +1,13 @@
1
+ module Newgistics
2
+ class Package
3
+ include Newgistics::Model
4
+
5
+ attribute :tracking_number, String
6
+ attribute :weight, Float
7
+ attribute :billable_weight, Float
8
+ attribute :height, Float
9
+ attribute :width, Float
10
+ attribute :depth, Float
11
+ attribute :items, Array[PackageItem]
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module Newgistics
2
+ class PackageItem
3
+ include Newgistics::Model
4
+
5
+ attribute :sku, String
6
+ attribute :qty, Integer
7
+
8
+ def self.element_selector
9
+ 'Item'
10
+ end
11
+ end
12
+ end
@@ -54,6 +54,8 @@ module Newgistics
54
54
  xml.GiftMessage order.gift_message
55
55
  xml.HoldForAllInventory order.hold_for_all_inventory
56
56
  xml.AllowDuplicate order.allow_duplicate
57
+ xml.Reference1 order.reference_1
58
+ xml.Reference2 order.reference_2
57
59
 
58
60
  order_date_xml(order, xml)
59
61
  customer_xml(order.customer, xml)
@@ -0,0 +1,74 @@
1
+ module Newgistics
2
+ module Requests
3
+ class UpdateShipmentAddress
4
+ attr_reader :shipment_address_update, :response_handler
5
+
6
+ def initialize(shipment_address_update, response_handler: nil)
7
+ @shipment_address_update = shipment_address_update
8
+ @response_handler = response_handler || default_response_handler
9
+ end
10
+
11
+ def path
12
+ '/update_shipment_address.aspx'
13
+ end
14
+
15
+ def body
16
+ xml_builder.to_xml
17
+ end
18
+
19
+ def perform
20
+ Newgistics.api.post(self, response_handler)
21
+ end
22
+
23
+ private
24
+
25
+ def default_response_handler
26
+ ResponseHandlers::UpdateShipmentAddress.new(shipment_address_update)
27
+ end
28
+
29
+ def xml_builder
30
+ Nokogiri::XML::Builder.new do |xml|
31
+ shipment_address_update_xml(xml)
32
+ end
33
+ end
34
+
35
+ def shipment_address_update_xml(xml)
36
+ xml.updateShipment(shipment_address_update_attributes) do
37
+ xml_field(xml, 'FirstName', :first_name)
38
+ xml_field(xml, 'LastName', :last_name)
39
+ xml_field(xml, 'Company', :company)
40
+ xml_field(xml, 'Address1', :address1)
41
+ xml_field(xml, 'Address2', :address2)
42
+ xml_field(xml, 'City', :city)
43
+ xml_field(xml, 'State', :state)
44
+ xml_field(xml, 'PostalCode', :postal_code)
45
+ xml_field(xml, 'Country', :country)
46
+ xml_field(xml, 'Email', :email)
47
+ xml_field(xml, 'Phone', :phone)
48
+ xml_field(xml, 'Fax', :fax)
49
+ xml_field(xml, 'IsResidential', :is_residential)
50
+ xml_field(xml, 'Status', :status)
51
+ xml_field(xml, 'StatusNotes', :status_notes)
52
+ xml_field(xml, 'ShipMethod', :ship_method)
53
+ end
54
+ end
55
+
56
+ def xml_field(xml, xml_node, attribute_name)
57
+ value = shipment_address_update.send(attribute_name)
58
+ xml.send(xml_node, value) unless value.nil?
59
+ end
60
+
61
+ def api_key
62
+ Newgistics.configuration.api_key
63
+ end
64
+
65
+ def shipment_address_update_attributes
66
+ {
67
+ apiKey: api_key,
68
+ id: shipment_address_update.id,
69
+ orderID: shipment_address_update.order_id
70
+ }.reject { |_k, v| v.nil? || v.empty? }
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,25 @@
1
+ module Newgistics
2
+ module ResponseHandlers
3
+ class UpdateShipmentAddress
4
+ attr_reader :shipment_address_update
5
+
6
+ def initialize(shipment_address_update)
7
+ @shipment_address_update = shipment_address_update
8
+ end
9
+
10
+ def handle(response)
11
+ PostErrors.new(shipment_address_update).handle(response)
12
+ if shipment_address_update.errors.empty?
13
+ handle_successful_response(response)
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def handle_successful_response(response)
20
+ xml = Nokogiri::XML(response.body)
21
+ shipment_address_update.success = xml.at_css('success').text
22
+ end
23
+ end
24
+ end
25
+ end
@@ -35,6 +35,7 @@ module Newgistics
35
35
  attribute :weight, Float
36
36
  attribute :postage, Float
37
37
  attribute :fees, Array[Fee]
38
+ attribute :packages, Array[Package]
38
39
 
39
40
  def backordered?
40
41
  shipment_status == 'BACKORDER'
@@ -0,0 +1,39 @@
1
+ module Newgistics
2
+ class ShipmentAddressUpdate
3
+ include Newgistics::Model
4
+
5
+ attribute :id, String
6
+ attribute :order_id, String
7
+
8
+ attribute :company, String
9
+ attribute :first_name, String
10
+ attribute :last_name, String
11
+ attribute :address1, String
12
+ attribute :address2, String
13
+ attribute :city, String
14
+ attribute :state, String
15
+ attribute :postal_code, String
16
+ attribute :country, String
17
+ attribute :email, String
18
+ attribute :phone, String
19
+ attribute :fax, String
20
+ attribute :is_residential, Boolean
21
+
22
+ attribute :status, String
23
+ attribute :status_notes, String
24
+ attribute :ship_method, String
25
+
26
+ attribute :success, Boolean
27
+ attribute :errors, Array[String], default: []
28
+ attribute :warnings, Array[String], default: []
29
+
30
+ def success?
31
+ !!success
32
+ end
33
+
34
+ def save
35
+ Requests::UpdateShipmentAddress.new(self).perform
36
+ errors.empty? && success?
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module Newgistics
2
- VERSION = "2.1.0"
2
+ VERSION = "2.5.0".freeze
3
3
  end
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
31
  spec.add_development_dependency "rspec", "~> 3.0"
32
32
  spec.add_development_dependency "pry"
33
- spec.add_development_dependency "simplecov"
33
+ spec.add_development_dependency "simplecov", "~> 0.17.1"
34
34
  spec.add_development_dependency "dotenv"
35
35
  spec.add_development_dependency "vcr", "~> 3.0.3"
36
36
  spec.add_development_dependency "timecop", "~> 0.9"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newgistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Martinez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-10-25 00:00:00.000000000 Z
12
+ date: 2020-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: virtus
@@ -127,16 +127,16 @@ dependencies:
127
127
  name: simplecov
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - ">="
130
+ - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '0'
132
+ version: 0.17.1
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ">="
137
+ - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: '0'
139
+ version: 0.17.1
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: dotenv
142
142
  requirement: !ruby/object:Gem::Requirement
@@ -216,6 +216,8 @@ files:
216
216
  - lib/newgistics/manifest_slip.rb
217
217
  - lib/newgistics/model.rb
218
218
  - lib/newgistics/order.rb
219
+ - lib/newgistics/package.rb
220
+ - lib/newgistics/package_item.rb
219
221
  - lib/newgistics/product.rb
220
222
  - lib/newgistics/query.rb
221
223
  - lib/newgistics/requests/cancel_manifest.rb
@@ -224,6 +226,7 @@ files:
224
226
  - lib/newgistics/requests/post_manifest.rb
225
227
  - lib/newgistics/requests/post_shipment.rb
226
228
  - lib/newgistics/requests/search.rb
229
+ - lib/newgistics/requests/update_shipment_address.rb
227
230
  - lib/newgistics/requests/update_shipment_contents.rb
228
231
  - lib/newgistics/response_handlers/cancel_manifest.rb
229
232
  - lib/newgistics/response_handlers/cancel_shipment.rb
@@ -232,9 +235,11 @@ files:
232
235
  - lib/newgistics/response_handlers/post_manifest.rb
233
236
  - lib/newgistics/response_handlers/post_shipment.rb
234
237
  - lib/newgistics/response_handlers/search.rb
238
+ - lib/newgistics/response_handlers/update_shipment_address.rb
235
239
  - lib/newgistics/response_handlers/update_shipment_contents.rb
236
240
  - lib/newgistics/return.rb
237
241
  - lib/newgistics/shipment.rb
242
+ - lib/newgistics/shipment_address_update.rb
238
243
  - lib/newgistics/shipment_cancellation.rb
239
244
  - lib/newgistics/shipment_update.rb
240
245
  - lib/newgistics/string_helper.rb