erp_integration 0.30.0 → 0.31.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: ee536deb4a7a1ac0f90973a12a58fce819c118a61ccd5b99d6b9002babbb96d0
4
- data.tar.gz: 36784a503e0fe9a042641b4e7c3ea046a2c888f6c2f395cc4a006753cf9224ed
3
+ metadata.gz: 1d0074006354a9ad9fcccfdb36d1c9a0b39fe8df0ab30a70a4b448f7e6a0df48
4
+ data.tar.gz: 9e9fc4556694e3a5d9b778f86790ef3402d794d53174636a598c7a2010854665
5
5
  SHA512:
6
- metadata.gz: 4be3be5809f375fb56b0321d0aa40493d60f77f1a0c54cb8c2a63c52bd39638595cdd9d32ec81f2506a6c3834781bf4a979d890e6006a5f01ccb5e52677a2f23
7
- data.tar.gz: 0dceb468b99e51a82acc7282cd51d4f4ec37034ee1140ad353e7df7c4993c6a84c7245662f3d513667d6344d2821d9743a4ba74f5e8e929804b4d63ee4e68297
6
+ metadata.gz: 7ab43b58b98d98bf43ec75a7a89e4dffc75b309799f83a2f5b803d15ab0e690df8084adae8b1702804e32d3575c74a93da2bf00d63e4572c3024fcb7ed24d58b
7
+ data.tar.gz: 9f4aa6467c0207ddb5ca5647a1f70452d4e297f94ccf5207c382d92d71d4e4c23b92e553abffd1692a45d7dcccb5ec8b04f4a04015ba69eae4da814220dbb0ff
@@ -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.
@@ -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 GiftCard < ApiResource
9
+ self.model_name = 'gift_card.gift_card'
10
+ end
11
+ end
12
+ end
13
+ 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`.
@@ -34,9 +34,5 @@ module ErpIntegration
34
34
  def process
35
35
  self.class.adapter.process(id)
36
36
  end
37
-
38
- def shipped?
39
- state == 'done'
40
- end
41
37
  end
42
38
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bigdecimal'
4
+
5
+ module ErpIntegration
6
+ module Types
7
+ class Decimal
8
+ attr_reader :object
9
+
10
+ def initialize(decimal_str)
11
+ @object = BigDecimal(decimal_str)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ErpIntegration
4
- VERSION = '0.30.0'
4
+ VERSION = '0.31.0'
5
5
  end
@@ -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.30.0
4
+ version: 0.31.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-04-26 00:00:00.000000000 Z
11
+ date: 2023-04-28 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.3.7
348
+ rubygems_version: 3.3.3
346
349
  signing_key:
347
350
  specification_version: 4
348
351
  summary: Connects Mejuri with third-party ERP vendors