zaikio-warehouse 0.5.0 → 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: b27e4cb1d7c29e1f7066607d0ab7e7a4048c68a1a01a98fac834ce98511869eb
4
- data.tar.gz: 1e9d184f6b06f1bc8f7e79a79223773892b750251209154b8e2738fe1ad31055
3
+ metadata.gz: ac5343b7ea219fe1f866ecb0bdb71a5cc09339443a5838d5c3445efab99585d1
4
+ data.tar.gz: c6f134a7c3b88c08857831f63ad8d1747e57ff38bff857aa5692273d3c6ce1d4
5
5
  SHA512:
6
- metadata.gz: 5b774df07a6af007f3213ccc2593d7b8a7cff6fc7f8c4ed23cf900adc8dcc997ff167bc51058a28c37de2da32a3e6d2d189373af939e5a3d2f12045e20ce667f
7
- data.tar.gz: c6869a82225fb97df7d12736d8699519c2e3f979279e81f902441d8037ee56228dde49dcd01c53abc866b3329f5aabb3d012e45b47c1da2e2e889ef0fab66636
6
+ metadata.gz: be1a0622b2a4bf71f9492d305bb53477538d907113b151281a5022d1210038252b46a7030e87e25641046017420634090de115af726a42318222b4c38948c058
7
+ data.tar.gz: 5b0e00c7e68b7a07e935e3231d5f805141b746e9e65dccccd3abe483503857bfc09a3450f2da7ee3ce245d752c39fa5be5462af388058bb38f65b220838e4a1b
data/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ 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
+
15
+ ## [0.5.1] - 2023-11-09
16
+
17
+ - Improve workstep transitions to return updated workstep
18
+
10
19
  ## [0.5.0] - 2023-11-06
11
20
 
12
21
  - Add support for worksteps and material requirements API
@@ -55,7 +64,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55
64
  - Update and reuse `zaikio-client-helpers` logic to support `Zaikio::Client.with_token`
56
65
  - Initial release
57
66
 
58
- [Unreleased]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.5.0..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
69
+ [0.5.1]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.5.0..v0.5.1
70
+ [0.5.0]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.4.0..v0.5.0
59
71
  [0.4.0]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.4.0..v0.5.0
60
72
  [0.4.0]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.3.0..v0.4.0
61
73
  [0.3.0]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.2.5..v0.3.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.0"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
@@ -17,24 +17,28 @@ module Zaikio
17
17
  has_many :material_requirements, uri: nil, class_name: "Zaikio::Warehouse::MaterialRequirement"
18
18
 
19
19
  def prepare(params = {})
20
- response = self.class.send(:send_request, :post, "worksteps/#{id}/prepare", params)
21
- puts "response prepare: #{response.inspect}"
22
-
23
- raise InvalidTransition, response.body if (200..201).exclude?(response.status)
20
+ transition("prepare", params)
24
21
  end
25
22
 
26
23
  def start(params = {})
27
- response = self.class.send(:send_request, :post, "worksteps/#{id}/start", params)
28
- puts "response start: #{response.inspect}"
29
-
30
- raise InvalidTransition, response.body if (200..201).exclude?(response.status)
24
+ transition("start", params)
31
25
  end
32
26
 
33
27
  def complete(params = {})
34
- response = self.class.send(:send_request, :post, "worksteps/#{id}/complete", params)
35
- puts "response complete: #{response.inspect}"
28
+ transition("complete", params)
29
+ end
30
+
31
+ private
32
+
33
+ def transition(transition, params = {})
34
+ response = self.class.send(:send_request, :post, "worksteps/#{id}/#{transition}", params)
36
35
 
37
36
  raise InvalidTransition, response.body if (200..201).exclude?(response.status)
37
+
38
+ result = Spyke::Result.new_from_response(response)
39
+ self.attributes = result.data["workstep"].merge(
40
+ "material_requirements" => result.data["material_requirements"]
41
+ )
38
42
  end
39
43
  end
40
44
  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.0
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-06 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