zaikio-warehouse 0.5.1 → 0.6.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: 2c62c0970c1b081c6700f3314338a4ae3ee4f568924b8c7dc73617e05cad3507
4
- data.tar.gz: bac0a0541969b5ecf8f57d25092c5a58937652e339ce8721734f2bb3caf4a160
3
+ metadata.gz: ac5343b7ea219fe1f866ecb0bdb71a5cc09339443a5838d5c3445efab99585d1
4
+ data.tar.gz: c6f134a7c3b88c08857831f63ad8d1747e57ff38bff857aa5692273d3c6ce1d4
5
5
  SHA512:
6
- metadata.gz: 350f090f78a86b594365c69b1913cc9011aea013cb8ea89956caa76be6211a7e78001f19a70288b14b4dd6ed2f1a1b3d7466264db354d5fdb8b3bced37b6445d
7
- data.tar.gz: 3a297ec8bfb7fd0e9f9168f63d5794697c822c00c2fde3c0ea06421ff4b2dfbd6ca83e2ea5e50855c7f04b8d62cd8753ae92f83f1b9a47ffbc1fa999eabaf68a
6
+ metadata.gz: be1a0622b2a4bf71f9492d305bb53477538d907113b151281a5022d1210038252b46a7030e87e25641046017420634090de115af726a42318222b4c38948c058
7
+ data.tar.gz: 5b0e00c7e68b7a07e935e3231d5f805141b746e9e65dccccd3abe483503857bfc09a3450f2da7ee3ce245d752c39fa5be5462af388058bb38f65b220838e4a1b
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.6.0] - 2023-11-15
11
+
12
+ - Support creation of nested material requirement operations
13
+ - Add `cancel` method to `ConsumptionRequest`
14
+
10
15
  ## [0.5.1] - 2023-11-09
11
16
 
12
17
  - Improve workstep transitions to return updated workstep
@@ -59,7 +64,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
59
64
  - Update and reuse `zaikio-client-helpers` logic to support `Zaikio::Client.with_token`
60
65
  - Initial release
61
66
 
62
- [Unreleased]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.5.1..HEAD
67
+ [Unreleased]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.6.0..HEAD
68
+ [0.6.0]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.5.1..v0.6.0
63
69
  [0.5.1]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.5.0..v0.5.1
64
70
  [0.5.0]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.4.0..v0.5.0
65
71
  [0.4.0]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.4.0..v0.5.0
@@ -3,6 +3,8 @@
3
3
  module Zaikio
4
4
  module Warehouse
5
5
  class ConsumptionRequest < Base
6
+ class CanNotBeCanceled < StandardError; end
7
+
6
8
  disable_http_methods :patch, :put, :delete
7
9
  include_root_in_json :consumption_request
8
10
 
@@ -19,6 +21,22 @@ module Zaikio
19
21
  has_one :consumption, uri: nil, class_name: "Zaikio::Warehouse::Consumption"
20
22
  has_one :operator, uri: nil, class_name: "Zaikio::Warehouse::Organization"
21
23
  has_one :material_requirement, uri: nil, class_name: "Zaikio::Warehouse::MaterialRequirement"
24
+
25
+ def cancel(params = {})
26
+ response = if material_requirement.id
27
+ # cancelation_reference, cancelation_reference_link, person_id
28
+ self.class.send(:send_request, :post,
29
+ "material_requirements/#{material_requirement.id}/consumption_requests/#{id}/cancel", # rubocop:disable Layout/LineLength
30
+ consumption_request_cancel: params)
31
+ else
32
+ self.class.send(:send_request, :post, "consumption_request_cancelations/#{id}",
33
+ consumption_request_cancelation: params)
34
+ end
35
+
36
+ raise CanNotBeCanceled, response.body if (200..201).exclude?(response.status)
37
+
38
+ Spyke::Result.new_from_response(response)
39
+ end
22
40
  end
23
41
  end
24
42
  end
@@ -16,10 +16,14 @@ module Zaikio
16
16
  has_one :warehouse, uri: nil, class_name: "Zaikio::Warehouse::Warehouse"
17
17
  has_one :workstep, uri: nil, class_name: "Zaikio::Warehouse::Workstep"
18
18
  has_one :material, uri: nil, class_name: "Zaikio::Warehouse::Material"
19
- has_many :open_consumption_requests, uri: nil, class_name: "Zaikio::Warehouse::ConsumptionRequest"
20
- has_many :open_transfer_requests, uri: nil, class_name: "Zaikio::Warehouse::TransferRequest"
21
- has_many :consumptions, uri: nil, class_name: "Zaikio::Warehouse::Consumption"
22
- has_many :transfers, uri: nil, class_name: "Zaikio::Warehouse::Transfer"
19
+ has_many :open_consumption_requests, uri: "material_requirements/:material_requirement_id/consumption_requests",
20
+ class_name: "Zaikio::Warehouse::ConsumptionRequest"
21
+ has_many :open_transfer_requests, uri: "material_requirements/:material_requirement_id/transfer_requests",
22
+ class_name: "Zaikio::Warehouse::TransferRequest"
23
+ has_many :consumptions, uri: "material_requirements/:material_requirement_id/consumptions",
24
+ class_name: "Zaikio::Warehouse::Consumption"
25
+ has_many :transfers, uri: "material_requirements/:material_requirement_id/transfers",
26
+ class_name: "Zaikio::Warehouse::Transfer"
23
27
  has_many :deposits, uri: "material_requirements/:material_requirement_id/deposits",
24
28
  class_name: "Zaikio::Warehouse::Deposit"
25
29
 
@@ -3,6 +3,8 @@
3
3
  module Zaikio
4
4
  module Warehouse
5
5
  class TransferRequest < Base
6
+ class CanNotBeCanceled < StandardError; end
7
+
6
8
  disable_http_methods :patch, :put
7
9
  include_root_in_json :transfer_request
8
10
 
@@ -20,6 +22,22 @@ module Zaikio
20
22
  has_one :transfer_request_cancelation, uri: nil, class_name: "Zaikio::Warehouse::TransferRequestCancelation"
21
23
  has_one :operator, uri: nil, class_name: "Zaikio::Warehouse::Organization"
22
24
  has_one :material_requirement, uri: nil, class_name: "Zaikio::Warehouse::MaterialRequirement"
25
+
26
+ def cancel(params = {})
27
+ response = if material_requirement.id
28
+ # cancelation_reference, cancelation_reference_link
29
+ self.class.send(:send_request, :post,
30
+ "material_requirements/#{material_requirement.id}/transfer_requests/#{id}/cancel",
31
+ params)
32
+ else
33
+ self.class.send(:send_request, :post, "transfer_request_cancelations/#{id}",
34
+ transfer_request_cancelation: params)
35
+ end
36
+
37
+ raise CanNotBeCanceled, response.body if (200..201).exclude?(response.status)
38
+
39
+ Spyke::Result.new_from_response(response)
40
+ end
23
41
  end
24
42
  end
25
43
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Zaikio
4
4
  module Warehouse
5
- VERSION = "0.5.1"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zaikio-warehouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaikio GmbH
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-11-09 00:00:00.000000000 Z
12
+ date: 2023-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport