erp_integration 0.30.0 → 0.32.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.
- checksums.yaml +4 -4
- data/lib/erp_integration/configuration.rb +9 -0
- data/lib/erp_integration/customer_shipment_return.rb +7 -0
- data/lib/erp_integration/fulfil/resources/customer_shipment_return.rb +7 -0
- data/lib/erp_integration/fulfil/resources/gift_card.rb +13 -0
- data/lib/erp_integration/gift_card.rb +18 -0
- data/lib/erp_integration/resource.rb +19 -0
- data/lib/erp_integration/types/decimal.rb +15 -0
- data/lib/erp_integration/version.rb +1 -1
- data/lib/erp_integration.rb +4 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68d6ab5f0b8acef6529a34e21cd851993017341ad68c7c1fb1dfb1ccd2762edd
|
4
|
+
data.tar.gz: b2ee68b1369e4cc4eee5bb479cae9f12eee26f0d892db7a4b1e93e7fa7c3c31c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b1b421b5dd434a0a5607a78ffc5935a65c5f6c867bd964547689cf1a90fcccfb991aad1fcc04d36090bdbc32ac8b9da6ba25efee8264dc7e83f13c5bf5c70ca
|
7
|
+
data.tar.gz: 329629ed3de09845cd3c9eeb1114f3ca96d245bea2970f423e5e74efe501ca2b1d2bfe48044ad97ed652a254bc561e2f66193a7c59193913d64379f10f3e6b85
|
@@ -107,6 +107,11 @@ module ErpIntegration
|
|
107
107
|
# @return [Symbol] The configured adapter for the tracking number.
|
108
108
|
attr_writer :tracking_number_adapter
|
109
109
|
|
110
|
+
# Allows configuring an adapter for the `GiftCard` resource. When
|
111
|
+
# none is configured, it will default to Fulfil.
|
112
|
+
# @return [Symbol] The configured adapter for the tracking number.
|
113
|
+
attr_writer :gift_card_adapter
|
114
|
+
|
110
115
|
# Logger that will be used for HTTP operations on Client
|
111
116
|
# @return [Logger] The configured logger
|
112
117
|
attr_accessor :logger
|
@@ -200,6 +205,10 @@ module ErpIntegration
|
|
200
205
|
def webhook_adapter
|
201
206
|
@webhook_adapter || :fulfil
|
202
207
|
end
|
208
|
+
|
209
|
+
def gift_card_adapter
|
210
|
+
@gift_card_adapter || :fulfil
|
211
|
+
end
|
203
212
|
end
|
204
213
|
|
205
214
|
# Returns ERP Integration's configuration.
|
@@ -40,5 +40,12 @@ module ErpIntegration
|
|
40
40
|
def create_package(id, options)
|
41
41
|
self.class.adapter.create_package(id, options)
|
42
42
|
end
|
43
|
+
|
44
|
+
# Mark a {CustomerShipmentRetun} as received.
|
45
|
+
#
|
46
|
+
# @param id [Integer] The ID of the {CustomerShipmentReturn}.
|
47
|
+
def receive!(id)
|
48
|
+
self.class.adapter.receive!(id)
|
49
|
+
end
|
43
50
|
end
|
44
51
|
end
|
@@ -25,6 +25,13 @@ module ErpIntegration
|
|
25
25
|
def create_package(id, options)
|
26
26
|
client.put("model/#{model_name}/#{id}", options)
|
27
27
|
end
|
28
|
+
|
29
|
+
def receive!(id)
|
30
|
+
client.put("model/#{model_name}/#{id}/receive")
|
31
|
+
true
|
32
|
+
rescue Faraday::ParsingError
|
33
|
+
true
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
30
37
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ErpIntegration
|
4
|
+
# The `ErpIntegration::GiftCard` exposes an uniformed API for interaction with
|
5
|
+
# third-party ERP vendors.
|
6
|
+
class GiftCard < Resource
|
7
|
+
attr_accessor :id, :currency
|
8
|
+
attr_reader :amount, :amount_available
|
9
|
+
|
10
|
+
def amount=(value)
|
11
|
+
@amount = parse_value(value)
|
12
|
+
end
|
13
|
+
|
14
|
+
def amount_available=(value)
|
15
|
+
@amount_available = parse_value(value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -48,6 +48,25 @@ module ErpIntegration
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
private
|
52
|
+
|
53
|
+
# The `parse_value` method is used to convert serialized ERP objects
|
54
|
+
# into a Ruby object that can be assigned to the resource attribute.
|
55
|
+
#
|
56
|
+
# @param value [Object] The raw API response value.
|
57
|
+
# @return [Object] The converted value.
|
58
|
+
def parse_value(value)
|
59
|
+
value_class = value.is_a?(Hash) && value['__class__']
|
60
|
+
return value unless value_class
|
61
|
+
|
62
|
+
ruby_class = Object.const_get("ErpIntegration::Types::#{value_class}")
|
63
|
+
value_key = value.keys.find { |key| key == value_class.downcase }
|
64
|
+
|
65
|
+
ruby_class.new(value[value_key]).object
|
66
|
+
rescue NameError
|
67
|
+
value
|
68
|
+
end
|
69
|
+
|
51
70
|
class << self
|
52
71
|
# Dynamically defines and loads the adapter for the class inheriting from
|
53
72
|
# the `ErpIntegration::Resource`.
|
data/lib/erp_integration.rb
CHANGED
@@ -43,10 +43,13 @@ module ErpIntegration
|
|
43
43
|
autoload :SupplierShipment, 'erp_integration/supplier_shipment'
|
44
44
|
autoload :TrackingNumber, 'erp_integration/tracking_number'
|
45
45
|
autoload :Webhook, 'erp_integration/webhook'
|
46
|
-
|
46
|
+
autoload :GiftCard, 'erp_integration/gift_card'
|
47
47
|
module Resources
|
48
48
|
autoload :Errors, 'erp_integration/resources/errors'
|
49
49
|
autoload :Persistence, 'erp_integration/resources/persistence'
|
50
50
|
autoload :Validations, 'erp_integration/resources/validations'
|
51
51
|
end
|
52
|
+
module Types
|
53
|
+
autoload :Decimal, 'erp_integration/types/decimal'
|
54
|
+
end
|
52
55
|
end
|
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.
|
4
|
+
version: 0.32.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: 2023-
|
11
|
+
date: 2023-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -288,6 +288,7 @@ files:
|
|
288
288
|
- lib/erp_integration/fulfil/resources/channel_listing.rb
|
289
289
|
- lib/erp_integration/fulfil/resources/customer_shipment.rb
|
290
290
|
- lib/erp_integration/fulfil/resources/customer_shipment_return.rb
|
291
|
+
- lib/erp_integration/fulfil/resources/gift_card.rb
|
291
292
|
- lib/erp_integration/fulfil/resources/product.rb
|
292
293
|
- lib/erp_integration/fulfil/resources/production_order.rb
|
293
294
|
- lib/erp_integration/fulfil/resources/purchase_order.rb
|
@@ -301,6 +302,7 @@ files:
|
|
301
302
|
- lib/erp_integration/fulfil/resources/tracking_number.rb
|
302
303
|
- lib/erp_integration/fulfil/resources/webhook.rb
|
303
304
|
- lib/erp_integration/fulfil/where_clause.rb
|
305
|
+
- lib/erp_integration/gift_card.rb
|
304
306
|
- lib/erp_integration/middleware/error_handling.rb
|
305
307
|
- lib/erp_integration/product.rb
|
306
308
|
- lib/erp_integration/production_order.rb
|
@@ -317,6 +319,7 @@ files:
|
|
317
319
|
- lib/erp_integration/stock_move.rb
|
318
320
|
- lib/erp_integration/supplier_shipment.rb
|
319
321
|
- lib/erp_integration/tracking_number.rb
|
322
|
+
- lib/erp_integration/types/decimal.rb
|
320
323
|
- lib/erp_integration/version.rb
|
321
324
|
- lib/erp_integration/webhook.rb
|
322
325
|
homepage: https://www.github.com/mejuri-inc/erp-integration
|
@@ -342,7 +345,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
342
345
|
- !ruby/object:Gem::Version
|
343
346
|
version: '0'
|
344
347
|
requirements: []
|
345
|
-
rubygems_version: 3.
|
348
|
+
rubygems_version: 3.2.22
|
346
349
|
signing_key:
|
347
350
|
specification_version: 4
|
348
351
|
summary: Connects Mejuri with third-party ERP vendors
|