erp_integration 0.9.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: 7aa8a1bdac1da55e10572a0f25ad21f3e608d77e014e6abfb1c8e93667dee23f
4
- data.tar.gz: 7bda7954766e6925764a2477acdf7dbd5974d8fb463a44ba8ee6d9ad4b695a26
3
+ metadata.gz: f838562b7bce4ffaab0944a370300bfa1c9d2f43d71777342a34be928857622b
4
+ data.tar.gz: f693bb521585a843abe5afd0fa1637a6235198a0a466cfe116130bd8f4906c81
5
5
  SHA512:
6
- metadata.gz: 7f72a741e0c219a30b961acea16804e9c47d8941e941518942856c20faef421ed0465b58e202ce0b79c29b6289334e6e3ae09e5a82bcc921aecb0d17fbcd80f2
7
- data.tar.gz: 210749ddda85e42fa4cd8a4503580ca0c7e53de84f4c5339dd4a7c2476de8da14eb67023bdfafa47ae748481c09965acd53aac1fdd667f949d475ef5b704abfe
6
+ metadata.gz: a008498534cd8274a24dcb37fe11c090126f128756d388173c908a29458aedc7fe8f8b70a53652c5499aafad5f27896ca61c7648c8bf3dacb8d032e0d21a66a3
7
+ data.tar.gz: 99ac0de4fa2bfb6a1a6bbbc709bb8b84eac47157561e45a16e5df4827f8e8b12ecfd7222ba262a626546b20fee27919655a01b6b25a820cd31bda389d083c519
data/README.md CHANGED
@@ -104,7 +104,7 @@ It's important to note that you'll need the right privileges to publish the gem.
104
104
 
105
105
  2. Create Pull Request
106
106
 
107
- 3. Merge it to main
107
+ 3. Merge it to develop
108
108
 
109
109
  4. Run Release script
110
110
  ```shell
@@ -37,6 +37,11 @@ module ErpIntegration
37
37
  # @return [Symbol] The configured adapter for the bill_of_material.
38
38
  attr_writer :bill_of_material_output_adapter
39
39
 
40
+ # Allows configuring an adapter for the `CustomerShipment` resource. When
41
+ # none is configured, it will default to Fulfil.
42
+ # @return [Symbol] The configured adapter for the customer shipment.
43
+ attr_writer :customer_shipment_adapter
44
+
40
45
  # Allows configuring an adapter for the `CustomerShipmentReturn` resource. When
41
46
  # none is configured, it will default to Fulfil.
42
47
  # @return [Symbol] The configured adapter for the customer shipment.
@@ -77,6 +82,11 @@ module ErpIntegration
77
82
  # @return [Symbol] The configured adapter for the order lines.
78
83
  attr_writer :sales_order_line_adapter
79
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
+
80
90
  # Allows configuring an adapter for the `SupplierShipment` resource. When
81
91
  # none is configured, it will default to Fulfil.
82
92
  # @return [Symbol] The configured adapter for the supplier shipment.
@@ -87,6 +97,15 @@ module ErpIntegration
87
97
  # @return [Symbol] The configured adapter for the stock move.
88
98
  attr_writer :stock_move_adapter
89
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
+
105
+ # Logger that will be used for HTTP operations on Client
106
+ # @return [Logger] The configured logger
107
+ attr_accessor :logger
108
+
90
109
  def initialize(**options)
91
110
  options.each_pair do |key, value|
92
111
  public_send("#{key}=", value) if respond_to?("#{key}=")
@@ -105,6 +124,10 @@ module ErpIntegration
105
124
  @bill_of_material_output_adapter || :fulfil
106
125
  end
107
126
 
127
+ def customer_shipment_adapter
128
+ @customer_shipment_adapter || :fulfil
129
+ end
130
+
108
131
  def customer_shipment_return_adapter
109
132
  @customer_shipment_return_adapter || :fulfil
110
133
  end
@@ -137,6 +160,10 @@ module ErpIntegration
137
160
  @sales_order_adapter || :fulfil
138
161
  end
139
162
 
163
+ def sales_return_reason_adapter
164
+ @sales_return_reason_adapter || :fulfil
165
+ end
166
+
140
167
  def supplier_shipment_adapter
141
168
  @supplier_shipment_adapter || :fulfil
142
169
  end
@@ -144,6 +171,10 @@ module ErpIntegration
144
171
  def stock_move_adapter
145
172
  @stock_move_adapter || :fulfil
146
173
  end
174
+
175
+ def tracking_number_adapter
176
+ @tracking_number_adapter || :fulfil
177
+ end
147
178
  end
148
179
 
149
180
  # Returns ERP Integration's configuration.
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErpIntegration
4
+ # The `ErpIntegration::CustomerShipment` exposes an uniformed API for interaction with
5
+ # third-party ERP vendors.
6
+ class CustomerShipment < Resource
7
+ attr_accessor :acknowledged_by_3pl_at, :aes_itn, :assigned_by, :assigned_time, :attachments,
8
+ :available_carrier_services, :avg_cycle_time, :avg_cycle_time_cache, :carrier,
9
+ :carrier_billing_account, :carrier_cost_method, :carrier_duties_account,
10
+ :carrier_service, :channel_carrier_service_code, :channel_logo_url, :channels,
11
+ :checklists, :company, :consumable_moves, :consumables_cost, :consumables_cost_cache,
12
+ :contact_categories, :contents_explanation, :contents_type, :cost, :cost_currency,
13
+ :cost_currency_digits, :cost_invoice_line, :create_date, :create_return_label, :create_uid,
14
+ :customer, :customer_location, :customs_items, :default_box_type, :delivery_address,
15
+ :delivery_address_datetime, :delivery_mode, :done_by, :duties_tax_id, :duties_tax_id_type,
16
+ :eel_pfc, :effective_date, :eori_number, :fedex_saturday_delivery, :full_delivery_address,
17
+ :gift_message, :has_gift_message, :hold_reason, :id, :incoterm, :insurance_amount, :inventory_moves,
18
+ :invoices, :is_international_shipping, :is_shippo, :last_modification, :license_plates, :messages,
19
+ :metadata, :moves, :non_delivery_option, :number, :on_hold, :on_hold_until, :order_confirmation_time,
20
+ :order_numbers, :origins, :outgoing_moves, :packages, :packed_at, :packed_by, :packed_date, :packer,
21
+ :payment_status, :payment_transactions, :picked_at, :picked_date, :picker, :picking_started_at,
22
+ :picking_status, :planned_date, :planned_datetime, :planned_time, :priority, :private_notes,
23
+ :productions, :public_notes, :rec_blurb, :rec_name, :reference, :request_confirmation,
24
+ :requested_delivery_date, :requested_shipping_service, :require_customs, :root_packages, :sale_date,
25
+ :sales, :sent_to_3pl_at, :shipped_at, :shipper, :shipping_batch, :shipping_instructions,
26
+ :shipping_label_date, :shipping_label_printed, :shipping_manifest, :sscc_code, :state, :tax_id,
27
+ :total_amount_ccy, :total_cost, :total_customs_value, :total_item_cost_ccy, :total_quantity, :tpl,
28
+ :tpl_status, :tracking_export_status, :tracking_number, :tracking_number_blurb, :tsv,
29
+ :ups_saturday_delivery, :warehouse, :warehouse_output, :warehouse_storage, :weight, :weight_digits,
30
+ :weight_uom, :weight_uom_symbol, :write_date, :write_uid
31
+ end
32
+ end
@@ -12,8 +12,8 @@ module ErpIntegration
12
12
  :done_by, :duties_tax_id, :duties_tax_id_type, :eel_pfc, :effective_date,
13
13
  :eori_number, :id, :incoming_moves, :inventory_moves, :is_international_shipping,
14
14
  :is_shippo, :last_modification, :license_plates, :messages, :metadata, :moves,
15
- :packages, :planned_date, :private_notes, :public_notes, :putaway_by, :rec_blurb,
16
- :rec_name, :received_by, :reference, :require_customs, :root_packages, :sales,
15
+ :origins, :number, :packages, :planned_date, :private_notes, :public_notes, :putaway_by,
16
+ :rec_blurb, :rec_name, :received_by, :reference, :require_customs, :root_packages, :sales,
17
17
  :sent_to_3pl_at, :shipping_instructions, :shipping_manifest, :sscc_code, :state,
18
18
  :total_customs_value, :tpl_status, :tracking_number, :tsv, :warehouse, :warehouse_input,
19
19
  :warehouse_storage, :warehouse_type, :weight, :weight_digits, :weight_uom,
@@ -44,7 +44,8 @@ module ErpIntegration
44
44
  def self.client
45
45
  Client.new(
46
46
  api_key: config.fulfil_api_key,
47
- merchant_id: config.fulfil_merchant_id
47
+ merchant_id: config.fulfil_merchant_id,
48
+ logger: config.logger
48
49
  )
49
50
  end
50
51
 
@@ -6,9 +6,10 @@ module ErpIntegration
6
6
  attr_reader :api_key, :merchant_id
7
7
  attr_writer :connection, :faraday_adapter
8
8
 
9
- def initialize(api_key:, merchant_id:)
9
+ def initialize(api_key:, merchant_id:, logger: nil)
10
10
  @api_key = api_key
11
11
  @merchant_id = merchant_id
12
+ @logger = logger
12
13
  end
13
14
 
14
15
  # Generates the url prefix for the Faraday connection client.
@@ -35,6 +36,11 @@ module ErpIntegration
35
36
  faraday.response :follow_redirects
36
37
  faraday.response :json # Decode response bodies as JSON
37
38
 
39
+ # Notice that logging headers will expose sensitive information
40
+ # like api-key. To avoid use filters:
41
+ # https://lostisland.github.io/faraday/middleware/logger
42
+ faraday.response :logger, @logger, { headers: false, bodies: true }
43
+
38
44
  # Custom error handling for the error response
39
45
  faraday.use ErpIntegration::Middleware::ErrorHandling
40
46
 
@@ -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
@@ -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 CustomerShipment < ApiResource
9
+ self.model_name = 'stock.shipment.out'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -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.9.0'
4
+ VERSION = '0.12.0'
5
5
  end
@@ -23,6 +23,7 @@ module ErpIntegration
23
23
  autoload :BillOfMaterial, 'erp_integration/bill_of_material'
24
24
  autoload :BillOfMaterialInput, 'erp_integration/bill_of_material_input'
25
25
  autoload :BillOfMaterialOutput, 'erp_integration/bill_of_material_output'
26
+ autoload :CustomerShipment, 'erp_integration/customer_shipment'
26
27
  autoload :CustomerShipmentReturn, 'erp_integration/customer_shipment_return'
27
28
  autoload :Product, 'erp_integration/product'
28
29
  autoload :ProductionOrder, 'erp_integration/production_order'
@@ -32,8 +33,10 @@ module ErpIntegration
32
33
  autoload :Resource, 'erp_integration/resource'
33
34
  autoload :SalesOrder, 'erp_integration/sales_order'
34
35
  autoload :SalesOrderLine, 'erp_integration/sales_order_line'
36
+ autoload :SalesReturnReason, 'erp_integration/sales_return_reason'
35
37
  autoload :StockMove, 'erp_integration/stock_move'
36
38
  autoload :SupplierShipment, 'erp_integration/supplier_shipment'
39
+ autoload :TrackingNumber, 'erp_integration/tracking_number'
37
40
 
38
41
  module Resources
39
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.9.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-01-21 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
@@ -263,6 +263,7 @@ files:
263
263
  - lib/erp_integration/bill_of_material_input.rb
264
264
  - lib/erp_integration/bill_of_material_output.rb
265
265
  - lib/erp_integration/configuration.rb
266
+ - lib/erp_integration/customer_shipment.rb
266
267
  - lib/erp_integration/customer_shipment_return.rb
267
268
  - lib/erp_integration/errors.rb
268
269
  - lib/erp_integration/fulfil/api_resource.rb
@@ -274,6 +275,7 @@ files:
274
275
  - lib/erp_integration/fulfil/resources/bill_of_material.rb
275
276
  - lib/erp_integration/fulfil/resources/bill_of_material_input.rb
276
277
  - lib/erp_integration/fulfil/resources/bill_of_material_output.rb
278
+ - lib/erp_integration/fulfil/resources/customer_shipment.rb
277
279
  - lib/erp_integration/fulfil/resources/customer_shipment_return.rb
278
280
  - lib/erp_integration/fulfil/resources/product.rb
279
281
  - lib/erp_integration/fulfil/resources/production_order.rb
@@ -282,8 +284,10 @@ files:
282
284
  - lib/erp_integration/fulfil/resources/purchase_request.rb
283
285
  - lib/erp_integration/fulfil/resources/sales_order.rb
284
286
  - lib/erp_integration/fulfil/resources/sales_order_line.rb
287
+ - lib/erp_integration/fulfil/resources/sales_return_reason.rb
285
288
  - lib/erp_integration/fulfil/resources/stock_move.rb
286
289
  - lib/erp_integration/fulfil/resources/supplier_shipment.rb
290
+ - lib/erp_integration/fulfil/resources/tracking_number.rb
287
291
  - lib/erp_integration/fulfil/where_clause.rb
288
292
  - lib/erp_integration/middleware/error_handling.rb
289
293
  - lib/erp_integration/product.rb
@@ -297,8 +301,10 @@ files:
297
301
  - lib/erp_integration/resources/validations.rb
298
302
  - lib/erp_integration/sales_order.rb
299
303
  - lib/erp_integration/sales_order_line.rb
304
+ - lib/erp_integration/sales_return_reason.rb
300
305
  - lib/erp_integration/stock_move.rb
301
306
  - lib/erp_integration/supplier_shipment.rb
307
+ - lib/erp_integration/tracking_number.rb
302
308
  - lib/erp_integration/version.rb
303
309
  homepage: https://www.github.com/mejuri-inc/erp-integration
304
310
  licenses:
@@ -323,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
323
329
  - !ruby/object:Gem::Version
324
330
  version: '0'
325
331
  requirements: []
326
- rubygems_version: 3.0.3
332
+ rubygems_version: 3.2.22
327
333
  signing_key:
328
334
  specification_version: 4
329
335
  summary: Connects Mejuri with third-party ERP vendors