erp_integration 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10feefb3de410db28d960dcab694fd3ac8cbc08e9d2ea06627e8cd5f514b2a57
4
- data.tar.gz: a7d6540c305bf8519789aa11073dc38141cdb60226a1296a99c5ea2e2d412838
3
+ metadata.gz: f838562b7bce4ffaab0944a370300bfa1c9d2f43d71777342a34be928857622b
4
+ data.tar.gz: f693bb521585a843abe5afd0fa1637a6235198a0a466cfe116130bd8f4906c81
5
5
  SHA512:
6
- metadata.gz: e64d55ee5b4ab827fb78ebd864ea278bfaaa50506de7e73737cfd88cc9e9f83485b34c7c96d840f3b3a5e26b3a8df730d69f8822d1c513f31b7f4d11bf8dd2e4
7
- data.tar.gz: dacaceb6e96523354e470e70056f574933cd8dd4e9bf30757a5ab9742545d7b460c73b3b32ff9e41a6284a99c25cb62d4eed9f312b7e4c443242f0d18d3dc894
6
+ metadata.gz: a008498534cd8274a24dcb37fe11c090126f128756d388173c908a29458aedc7fe8f8b70a53652c5499aafad5f27896ca61c7648c8bf3dacb8d032e0d21a66a3
7
+ data.tar.gz: 99ac0de4fa2bfb6a1a6bbbc709bb8b84eac47157561e45a16e5df4827f8e8b12ecfd7222ba262a626546b20fee27919655a01b6b25a820cd31bda389d083c519
@@ -82,6 +82,11 @@ module ErpIntegration
82
82
  # @return [Symbol] The configured adapter for the order lines.
83
83
  attr_writer :sales_order_line_adapter
84
84
 
85
+ # Allows configuring an adapter for the `SalesReturnReason` resource. When none is
86
+ # configured, it will default to Fulfil.
87
+ # @return [Symbol] The configured adapter for the order lines.
88
+ attr_writer :sales_return_reason_adapter
89
+
85
90
  # Allows configuring an adapter for the `SupplierShipment` resource. When
86
91
  # none is configured, it will default to Fulfil.
87
92
  # @return [Symbol] The configured adapter for the supplier shipment.
@@ -92,6 +97,11 @@ module ErpIntegration
92
97
  # @return [Symbol] The configured adapter for the stock move.
93
98
  attr_writer :stock_move_adapter
94
99
 
100
+ # Allows configuring an adapter for the `TrackingNumber` resource. When
101
+ # none is configured, it will default to Fulfil.
102
+ # @return [Symbol] The configured adapter for the tracking number.
103
+ attr_writer :tracking_number_adapter
104
+
95
105
  # Logger that will be used for HTTP operations on Client
96
106
  # @return [Logger] The configured logger
97
107
  attr_accessor :logger
@@ -150,6 +160,10 @@ module ErpIntegration
150
160
  @sales_order_adapter || :fulfil
151
161
  end
152
162
 
163
+ def sales_return_reason_adapter
164
+ @sales_return_reason_adapter || :fulfil
165
+ end
166
+
153
167
  def supplier_shipment_adapter
154
168
  @supplier_shipment_adapter || :fulfil
155
169
  end
@@ -157,6 +171,10 @@ module ErpIntegration
157
171
  def stock_move_adapter
158
172
  @stock_move_adapter || :fulfil
159
173
  end
174
+
175
+ def tracking_number_adapter
176
+ @tracking_number_adapter || :fulfil
177
+ end
160
178
  end
161
179
 
162
180
  # Returns ERP Integration's configuration.
@@ -27,6 +27,17 @@ module ErpIntegration
27
27
  [attributes, [extract_error_message(e)]]
28
28
  end
29
29
 
30
+ # Destroys the resource.
31
+ #
32
+ # @param resource_id [Integer] The ID of the resource.
33
+ # @return [Boolean] Returns true if the resource was deleted
34
+ def destroy(resource_id)
35
+ client.delete("model/#{model_name}/#{resource_id}")
36
+ { id: resource_id }
37
+ rescue ErpIntegration::HttpError::BadRequest => e
38
+ [{ id: resource_id }, [extract_error_message(e)]]
39
+ end
40
+
30
41
  private
31
42
 
32
43
  # Fulfil returns a 400 status code (e.g. Bad Request) with the error message
@@ -28,6 +28,55 @@ module ErpIntegration
28
28
  rescue Faraday::ParsingError
29
29
  true
30
30
  end
31
+
32
+ # Allows duplicating the entire sales order in Fulfil.
33
+ # @param id [Integer|String] The ID of the to be duplicated order.
34
+ # @return [Array|boolean] Whether the sales order was duplicated successfully or not.
35
+ def duplicate(id)
36
+ duplicated_order_id = client.put("model/sale.sale/#{id}/copy").first
37
+ ErpIntegration::SalesOrder.new(id: duplicated_order_id)
38
+
39
+ # Fulfil will return an 400 (a.k.a. "Bad Request") status code when a sales order couldn't
40
+ # be duplicated.
41
+ rescue ErpIntegration::HttpError::BadRequest
42
+ false
43
+ end
44
+
45
+ # Confirm the order on Fulfil.
46
+ # @param id [Integer|String] The ID of the to be confirmed order.
47
+ # @return [boolean] Whether the sales order was confirmed successfully or not.
48
+ def confirm(id)
49
+ client.put("model/sale.sale/#{id}/confirm")
50
+ true
51
+
52
+ # Fulfil will return an 400 (a.k.a. "Bad Request") status code when a sales order couldn't
53
+ # be confirmed.
54
+ rescue ErpIntegration::HttpError::BadRequest
55
+ false
56
+ # Workaround: Fulfil api does not return a json when status code is 200 (a.k.a. "Ok")
57
+ # and faraday is having an error when trying to parse it. Let's skip the parse error
58
+ # and move on.
59
+ rescue Faraday::ParsingError
60
+ true
61
+ end
62
+
63
+ # Process the order on Fulfil.
64
+ # @param id [Integer|String] The ID of the to be processed order.
65
+ # @return [boolean] Whether the sales order was processed successfully or not.
66
+ def process(id)
67
+ client.put("model/sale.sale/#{id}/process")
68
+ true
69
+
70
+ # Fulfil will return an 400 (a.k.a. "Bad Request") status code when a sales order couldn't
71
+ # be processed.
72
+ rescue ErpIntegration::HttpError::BadRequest
73
+ false
74
+ # Workaround: Fulfil api does not return a json when status code is 200 (a.k.a. "Ok")
75
+ # and faraday is having an error when trying to parse it. Let's skip the parse error
76
+ # and move on.
77
+ rescue Faraday::ParsingError
78
+ true
79
+ end
31
80
  end
32
81
  end
33
82
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../api_resource'
4
+
5
+ module ErpIntegration
6
+ module Fulfil
7
+ module Resources
8
+ class SalesReturnReason < ApiResource
9
+ self.model_name = 'sale.return.reason'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../api_resource'
4
+
5
+ module ErpIntegration
6
+ module Fulfil
7
+ module Resources
8
+ class TrackingNumber < ApiResource
9
+ self.model_name = 'shipment.tracking'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -35,6 +35,15 @@ module ErpIntegration
35
35
  assign_attributes(attrs)
36
36
  validate_with(error_messages)
37
37
  end
38
+
39
+ # Destroy an resource in the ERP.
40
+ # @return [Boolean] Whether the destroy action was succcesful or not.
41
+ def destroy(id)
42
+ attrs, error_messages = self.class.adapter.destroy(id)
43
+
44
+ assign_attributes(attrs)
45
+ validate_with(error_messages)
46
+ end
38
47
  end
39
48
  end
40
49
  end
@@ -19,5 +19,17 @@ module ErpIntegration
19
19
  def cancel
20
20
  self.class.adapter.cancel(id)
21
21
  end
22
+
23
+ def duplicate
24
+ self.class.adapter.duplicate(id)
25
+ end
26
+
27
+ def confirm
28
+ self.class.adapter.confirm(id)
29
+ end
30
+
31
+ def process
32
+ self.class.adapter.process(id)
33
+ end
22
34
  end
23
35
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErpIntegration
4
+ # The `ErpIntegration::SalesReturnReason` exposes an uniformed API for interaction with
5
+ # third-party ERP vendors.
6
+ class SalesReturnReason < Resource
7
+ attr_accessor :attachments, :create_date, :create_uid, :description,
8
+ :id, :messages, :metadata, :name, :private_notes,
9
+ :public_notes, :rec_blurb, :rec_name, :write_date,
10
+ :write_uid
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErpIntegration
4
+ # The `ErpIntegration::TrackingNumber` exposes an uniformed API for interaction with
5
+ # third-party ERP vendors.
6
+ class TrackingNumber < Resource
7
+ attr_accessor :attachments, :attempts, :carrier, :carrier_identifier,
8
+ :carrier_service, :create_date, :create_uid, :delivered_at,
9
+ :delivered_date, :delivery_date, :delivery_time, :easypost_order_id,
10
+ :estimated_delivery_date, :id, :is_master, :messages, :metadata,
11
+ :next_update_at, :origin, :private_notes, :public_notes, :rec_blurb,
12
+ :rec_name, :reference, :scac, :state, :tracking_number,
13
+ :tracking_url, :transportation_mode, :write_date, :write_uid
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ErpIntegration
4
- VERSION = '0.11.0'
4
+ VERSION = '0.12.0'
5
5
  end
@@ -33,8 +33,10 @@ module ErpIntegration
33
33
  autoload :Resource, 'erp_integration/resource'
34
34
  autoload :SalesOrder, 'erp_integration/sales_order'
35
35
  autoload :SalesOrderLine, 'erp_integration/sales_order_line'
36
+ autoload :SalesReturnReason, 'erp_integration/sales_return_reason'
36
37
  autoload :StockMove, 'erp_integration/stock_move'
37
38
  autoload :SupplierShipment, 'erp_integration/supplier_shipment'
39
+ autoload :TrackingNumber, 'erp_integration/tracking_number'
38
40
 
39
41
  module Resources
40
42
  autoload :Errors, 'erp_integration/resources/errors'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erp_integration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Vermaas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-11 00:00:00.000000000 Z
11
+ date: 2022-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -284,8 +284,10 @@ files:
284
284
  - lib/erp_integration/fulfil/resources/purchase_request.rb
285
285
  - lib/erp_integration/fulfil/resources/sales_order.rb
286
286
  - lib/erp_integration/fulfil/resources/sales_order_line.rb
287
+ - lib/erp_integration/fulfil/resources/sales_return_reason.rb
287
288
  - lib/erp_integration/fulfil/resources/stock_move.rb
288
289
  - lib/erp_integration/fulfil/resources/supplier_shipment.rb
290
+ - lib/erp_integration/fulfil/resources/tracking_number.rb
289
291
  - lib/erp_integration/fulfil/where_clause.rb
290
292
  - lib/erp_integration/middleware/error_handling.rb
291
293
  - lib/erp_integration/product.rb
@@ -299,8 +301,10 @@ files:
299
301
  - lib/erp_integration/resources/validations.rb
300
302
  - lib/erp_integration/sales_order.rb
301
303
  - lib/erp_integration/sales_order_line.rb
304
+ - lib/erp_integration/sales_return_reason.rb
302
305
  - lib/erp_integration/stock_move.rb
303
306
  - lib/erp_integration/supplier_shipment.rb
307
+ - lib/erp_integration/tracking_number.rb
304
308
  - lib/erp_integration/version.rb
305
309
  homepage: https://www.github.com/mejuri-inc/erp-integration
306
310
  licenses:
@@ -325,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
325
329
  - !ruby/object:Gem::Version
326
330
  version: '0'
327
331
  requirements: []
328
- rubygems_version: 3.1.4
332
+ rubygems_version: 3.2.22
329
333
  signing_key:
330
334
  specification_version: 4
331
335
  summary: Connects Mejuri with third-party ERP vendors