zaikio-warehouse 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 62bf49ab4d0b2be86c5c8d9638a542a153674911d6718030354f08f7494ea47e
4
+ data.tar.gz: e82ad62f51dafd402cd3fedf0374ccbe7c36af0138289bd3eada8a931d3281a3
5
+ SHA512:
6
+ metadata.gz: b0a6296b272dd744b53f2fe2e16facdf76ba8c895fad36f7ea9bea7248f88d160c4f925bee816ef5aeea2fce704f6832579a4b118e158775bdce6b593a2ec6d3
7
+ data.tar.gz: 9f4642e4a913bd9b1357d6dce4ad5555970d9405c67d77bb1518676d340a5dc76623903bef0240e59c8e39e84d32a96ef2bc5afb62ac33960302aaf14011fb42
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2022-10-10
11
+
12
+ - Add `Consumption`, `ConsumptionRequest`, `ConsumptionAnnouncement` and `ConsumptionRequestCancelation`
13
+ - Update and reuse `zaikio-client-helpers` logic to support `Zaikio::Client.with_token`
14
+ - Initial release
15
+
16
+ [Unreleased]: https://github.com/zaikio/zaikio-warehouse-ruby/compare/v0.1.0..HEAD
17
+ [0.1.0]: https://github.com/zaikio/zaikio-hub-models/compare/c96ae1302a6ec5b90cfc445116fc83af16579e01..v0.1.0
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Zaikio GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # Zaikio::Warehouse
2
+
3
+ This is a Ruby client gem for the [Zaikio Warehouse](https://docs.zaikio.com/api/warehouse/warehouse.html).
4
+
5
+ ## Installation
6
+
7
+ Add to the Gemfile and install by running
8
+
9
+ $ bundle add zaikio-warehouse
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ $ gem install zaikio-warehouse
14
+
15
+ ## Configuration and Usage
16
+
17
+ After installation, add an initializer to configure the client:
18
+
19
+ ```ruby
20
+ # maybe config/initializers/zaikio-warehouse.rb
21
+
22
+ Zaikio::Warehouse.configure do |config|
23
+ config.environment = :sandbox # or :production
24
+ end
25
+ ```
26
+
27
+ You will need a valid access token for any calls, [zaikio-oauth_client](https://github.com/zaikio/zaikio-oauth_client)
28
+ can help you with that. Once you have a token available, you can use `Zaikio::Warehouse.with_token`:
29
+
30
+ ```ruby
31
+ Zaikio::Warehouse.with_token(access_token) do
32
+ # any API requests will now use the given access token
33
+ warehouse = Warehouse.find(params[:warehouse_id])
34
+ warehouse.name = "#{warehouse.name} with automation"
35
+ warehouse.save
36
+ end
37
+ ```
38
+
39
+ The gem uses [spyke](https://github.com/balvig/spyke) and mimics some of ActiveRecord's interface, as you can see in the
40
+ example above.
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive
45
+ prompt that will allow you to experiment.
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
50
+
51
+ ## Code of Conduct
52
+
53
+ Everyone interacting in the zaikio-warehouse-ruby project's codebases, issue trackers, chat rooms and mailing lists is
54
+ expected to follow the
55
+ [code of conduct](https://github.com/zaikio/zaikio-warehouse-ruby/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # Base class for Zaikio Warehouse models
6
+ class Base < Zaikio::Client::Model
7
+ self.callback_methods = { create: :post, update: :patch }.freeze
8
+
9
+ class_attribute :allowed_methods
10
+
11
+ self.allowed_methods = %i[get post patch put delete]
12
+
13
+ class << self
14
+ def readonly!
15
+ self.allowed_methods = %i[get]
16
+ end
17
+
18
+ def disable_http_methods(*disabled_methods)
19
+ self.allowed_methods -= disabled_methods
20
+ end
21
+
22
+ def request(method, *args, **opts)
23
+ raise Zaikio::Error, "HTTP method #{method} is not allowed on #{self}" unless allowed_methods.include?(method)
24
+
25
+ super
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # See https://docs.zaikio.com/api/warehouse/warehouse.html#/SKUs/get_skus__sku_id__call_off_agreement
6
+ class CallOffAgreement < Base
7
+ uri "skus/:sku_id/call_off_agreement"
8
+ include_root_in_json :call_off_agreement
9
+
10
+ attributes :contract_number, :expires_on, :expired_on, :expires_after_amount_called_off,
11
+ :sales_price_per_unit, :sales_price_per_unit_currency, :deletable, :created_at, :updated_at
12
+
13
+ has_one :sku, uri: nil, class_name: "Zaikio::Warehouse::SKU"
14
+
15
+ def reload
16
+ self.attributes = self.class.where(sku_id: sku.id).find(id).attributes
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # Configuration for the Zaikio Warehouse client
6
+ class Configuration < Zaikio::Client::Helpers::Configuration
7
+ def self.hosts
8
+ {
9
+ development: "http://warehouse.zaikio.test/api/v1/",
10
+ test: "http://warehouse.zaikio.test/api/v1/",
11
+ staging: "https://warehouse.staging.zaikio.com/api/v1/",
12
+ sandbox: "https://warehouse.sandbox.zaikio.com/api/v1/",
13
+ production: "https://warehouse.zaikio.com/api/v1/"
14
+ }.freeze
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ class Consumption < Base
6
+ disable_http_methods :patch, :put, :delete
7
+ include_root_in_json :consumption
8
+
9
+ uri "consumptions(/:id)"
10
+
11
+ attributes :consuming_reference, :consuming_reference_link, :consuming_client, :consuming_subject, :amount,
12
+ :amount_in_base_unit, :created_at, :updated_at
13
+
14
+ has_one :material, uri: nil, class_name: "Zaikio::Warehouse::Material"
15
+ has_one :sku, uri: nil, class_name: "Zaikio::Warehouse::SKU"
16
+ has_one :storage_area, uri: nil, class_name: "Zaikio::Warehouse::StorageArea"
17
+ has_one :person, uri: nil, class_name: "Zaikio::Warehouse::Person"
18
+ has_one :manifest_entry, uri: nil, class_name: "Zaikio::Warehouse::ManifestEntry"
19
+ has_one :consumption_request, uri: nil, class_name: "Zaikio::Warehouse::ConsumptionRequest"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ class ConsumptionAnnouncement < Base
6
+ disable_http_methods :patch, :put, :delete
7
+ include_root_in_json :consumption_announcement
8
+
9
+ uri "consumption_announcements"
10
+
11
+ attributes :consuming_reference, :consuming_reference_link, :amount_in_base_unit,
12
+ :warehouse_id, :material_id
13
+
14
+ has_many :consumption_requests, uri: nil, class_name: "Zaikio::Warehouse::ConsumptionRequest"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ class ConsumptionRequest < Base
6
+ disable_http_methods :patch, :put, :delete
7
+ include_root_in_json :consumption_request
8
+
9
+ uri "consumption_requests(/:id)"
10
+
11
+ attributes :consuming_reference, :consuming_reference_link, :consuming_client, :consuming_subject, :amount,
12
+ :amount_in_base_unit, :created_at, :updated_at
13
+
14
+ has_one :material, uri: nil, class_name: "Zaikio::Warehouse::Material"
15
+ has_one :sku, uri: nil, class_name: "Zaikio::Warehouse::SKU"
16
+ has_one :storage_area, uri: nil, class_name: "Zaikio::Warehouse::StorageArea"
17
+ has_one :person, uri: nil, class_name: "Zaikio::Warehouse::Person"
18
+ has_one :consumption_request_cancelation, uri: nil, class_name: "Zaikio::Warehouse::ConsumptionRequestCancelation"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ class ConsumptionRequestCancelation < Base
6
+ disable_http_methods :patch, :put, :delete
7
+ include_root_in_json :consumption_request_cancelation
8
+
9
+ uri "consumption_request_cancelations(/:id)"
10
+
11
+ attributes :consumption_request_id, :cancelation_reference, :cancelation_reference_link,
12
+ :cancelation_client, :cancelation_subject, :amount,
13
+ :amount_in_base_unit, :created_at, :updated_at
14
+
15
+ has_one :material, uri: nil, class_name: "Zaikio::Warehouse::Material"
16
+ has_one :sku, uri: nil, class_name: "Zaikio::Warehouse::SKU"
17
+ has_one :storage_area, uri: nil, class_name: "Zaikio::Warehouse::StorageArea"
18
+ has_one :person, uri: nil, class_name: "Zaikio::Warehouse::Person"
19
+ has_one :consumption_request, uri: nil, class_name: "Zaikio::Warehouse::ConsumptionRequest"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # Contact model
6
+ class Contact < Base
7
+ readonly!
8
+
9
+ uri "contacts(/:id)"
10
+
11
+ attributes :name, :source_uri, :created_at, :updated_at
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ class Correction < Operation
6
+ disable_http_methods :delete, :patch, :put
7
+
8
+ uri "corrections(/:id)"
9
+ include_root_in_json :correction
10
+
11
+ attributes :amount, :amount_in_base_unit, :created_at, :updated_at
12
+
13
+ has_one :material, uri: nil, class_name: "Zaikio::Warehouse::Material"
14
+ has_one :sku, uri: nil, class_name: "Zaikio::Warehouse::SKU"
15
+ has_one :storage_area, uri: nil, class_name: "Zaikio::Warehouse::StorageArea"
16
+ has_one :person, uri: nil, class_name: "Zaikio::Warehouse::Person"
17
+ has_one :manifest_entry, uri: nil, class_name: "Zaikio::Warehouse::ManifestEntry"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ class Deposit < Operation
6
+ disable_http_methods :patch, :put, :delete
7
+
8
+ uri "deposits(/:id)"
9
+ include_root_in_json :deposit
10
+
11
+ attributes :amount, :amount_in_base_unit, :created_at, :updated_at
12
+
13
+ has_one :material, uri: nil, class_name: "Zaikio::Warehouse::Material"
14
+ has_one :sku, uri: nil, class_name: "Zaikio::Warehouse::SKU"
15
+ has_one :storage_area, uri: nil, class_name: "Zaikio::Warehouse::StorageArea"
16
+ has_one :person, uri: nil, class_name: "Zaikio::Warehouse::Person"
17
+ has_one :manifest_entry, uri: nil, class_name: "Zaikio::Warehouse::ManifestEntry"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ module FinishedGoods
6
+ # See https://docs.zaikio.com/api/warehouse/warehouse.html#/GoodsCallOffs
7
+ class CallOff < ::Zaikio::Warehouse::Base
8
+ # Nested address model for call offs
9
+ class Address < ::Zaikio::Warehouse::Base
10
+ readonly!
11
+
12
+ uri nil
13
+
14
+ attributes :addressee, :street, :addition, :number, :zip_code, :town, :state, :country_code, :location
15
+ end
16
+
17
+ # Nested line item model for call offs
18
+ class LineItem < ::Zaikio::Warehouse::Base
19
+ readonly!
20
+
21
+ uri nil
22
+
23
+ attributes :quantity, :created_at, :updated_at, :picked_at
24
+
25
+ has_one :sku, uri: nil, class_name: "Zaikio::Warehouse::SKU"
26
+ has_one :picked_by, uri: nil, class_name: "Zaikio::Warehouse::Person"
27
+ end
28
+
29
+ # Nested pick model for call offs
30
+ class Pick < ::Zaikio::Warehouse::Base
31
+ disable_http_methods :post, :put, :patch
32
+
33
+ uri "finished_goods/call_offs/:call_off_id/picks(/:id)"
34
+
35
+ attributes :call_off_line_item_id, :quantity, :created_at
36
+
37
+ has_one :sku, uri: nil, class_name: "Zaikio::Warehouse::SKU"
38
+ has_one :storage_area, uri: nil, class_name: "Zaikio::Warehouse::StorageArea"
39
+ has_one :call_off, uri: nil, class_name: "Zaikio::Warehouse::FinishedGoods::CallOff"
40
+ has_one :picker, uri: nil, class_name: "Zaikio::Warehouse::Person"
41
+ end
42
+
43
+ uri "finished_goods/call_offs(/:id)"
44
+
45
+ attributes :state, :references, :delivery_date, :deletable, :created_at, :updated_at
46
+
47
+ has_one :delivery_address, uri: nil, class_name: "Address"
48
+ has_one :customer, uri: nil, class_name: "Zaikio::Warehouse::Contact"
49
+ has_one :operator, uri: nil, class_name: "Zaikio::Warehouse::Organization"
50
+ has_many :line_items, uri: nil, class_name: "LineItem"
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ module FinishedGoods
6
+ # See https://docs.zaikio.com/api/warehouse/warehouse.html#/GoodsCallOff%20Materials
7
+ class Material < ::Zaikio::Warehouse::Base
8
+ readonly!
9
+
10
+ uri "finished_goods/materials(/:id)"
11
+
12
+ attributes :name, :references, :kind, :category, :base_unit, :width, :length, :height, :weight,
13
+ :dimensions_unit, :created_at, :updated_at, :deletable
14
+
15
+ has_one :operator, uri: nil, class_name: "Zaikio::Warehouse::Organization"
16
+ has_many :skus, uri: nil, class_name: "Zaikio::Warehouse::SKU"
17
+ has_many :manifest, uri: nil, class_name: "Zaikio::Warehouse::ManifestEntry"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # See https://docs.zaikio.com/api/warehouse/warehouse.html#/Manifests/get_manifest_entries__id_
6
+ class ManifestEntry < Base
7
+ readonly!
8
+
9
+ uri "manifest_entries(/:id)"
10
+
11
+ attributes :amount, :amount_in_base_unit, :amount_available, :amount_available_in_base_unit, :amount_delta,
12
+ :amount_delta_in_base_unit, :amount_available_delta, :amount_available_delta_in_base_unit,
13
+ :created_at, :updated_at
14
+
15
+ has_one :operator, uri: nil, class_name: "Zaikio::Warehouse::Organization"
16
+ has_one :storage_area, uri: nil, class_name: "Zaikio::Warehouse::StorageArea"
17
+ has_one :material, uri: nil, class_name: "Zaikio::Warehouse::Material"
18
+ has_one :sku, uri: nil, class_name: "Zaikio::Warehouse::SKU"
19
+ has_one :operation, uri: nil, class_name: "Zaikio::Warehouse::Operation"
20
+ has_one :person, uri: nil, class_name: "Zaikio::Warehouse::Person"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # See https://docs.zaikio.com/api/warehouse/warehouse.html#/Materials
6
+ class Material < Base
7
+ uri "materials(/:id)"
8
+ include_root_in_json :material
9
+
10
+ attributes :name, :article_number, :references, :kind, :category, :base_unit, :width, :length, :height, :weight,
11
+ :dimensions_unit, :weight_unit, :created_at, :updated_at, :deletable
12
+
13
+ has_many :skus, class_name: "Zaikio::Warehouse::SKU", uri: "materials/:material_id/skus"
14
+
15
+ has_one :operator, uri: nil
16
+ has_many :manifest,
17
+ uri: "materials/:material_id/manifest",
18
+ class_name: "Zaikio::Warehouse::ManifestEntry"
19
+ has_many :manifest_entries,
20
+ uri: "materials/:material_id/manifest_entries(/:id)",
21
+ class_name: "Zaikio::Warehouse::ManifestEntry"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # Base class for all operations
6
+ class Operation < Base
7
+ uri nil
8
+
9
+ attributes :type
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # Organization model. Kept here to not have a dependency on zaikio-hub-models
6
+ class Organization < Base
7
+ readonly!
8
+
9
+ uri nil # cannot use Warehouse API to retrieve the operator
10
+
11
+ attributes :name
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # Person model. Kept here to not have a dependency on zaikio-hub-models
6
+ class Person < Base
7
+ readonly!
8
+
9
+ uri nil
10
+
11
+ attributes :display_name
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # Site model. Kept here to not have a dependency on zaikio-hub-models
6
+ class Site < Base
7
+ readonly!
8
+
9
+ uri nil
10
+
11
+ attributes :display_name
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # See https://docs.zaikio.com/api/warehouse/warehouse.html#/SKUs
6
+ class SKU < Base
7
+ uri "skus(/:id)"
8
+ include_root_in_json :sku
9
+
10
+ attributes :identifier, :amount_in_base_unit, :unit, :order_number, :references, :width, :length, :height,
11
+ :weight, :dimensions_unit, :weight_unit, :packed, :costs_per_unit, :costs_per_unit_currency,
12
+ :minimum_stock_level, :locked, :deletable, :created_at, :updated_at
13
+
14
+ has_one :operator, uri: nil, class_name: "Zaikio::Warehouse::Organization"
15
+ has_one :owner, uri: nil, class_name: "Zaikio::Warehouse::Contact"
16
+ has_one :material, uri: nil, class_name: "Zaikio::Warehouse::Material"
17
+ has_many :manifest,
18
+ uri: "skus/:sku_id/manifest",
19
+ class_name: "Zaikio::Warehouse::ManifestEntry"
20
+ has_many :manifest_entries,
21
+ uri: "skus/:sku_id/manifest_entries(/:id)",
22
+ class_name: "Zaikio::Warehouse::ManifestEntry"
23
+ has_one :call_off_agreement, uri: "skus/:sku_id/call_off_agreement"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # See https://docs.zaikio.com/api/warehouse/warehouse.html#/StorageAreas
6
+ class StorageArea < Base
7
+ uri "storage_areas(/:id)"
8
+ include_root_in_json :storage_area
9
+
10
+ attributes :name, :usage, :level, :coordinates, :width, :length, :height, :weight_limit, :deletable,
11
+ :created_at, :updated_at
12
+
13
+ has_one :warehouse, uri: nil, class_name: "Zaikio::Warehouse::Warehouse"
14
+ has_many :manifest,
15
+ uri: "storage_areas/:storage_area_id/manifest",
16
+ class_name: "Zaikio::Warehouse::ManifestEntry"
17
+ has_many :manifest_entries,
18
+ uri: "storage_areas/:storage_area_id/manifest_entries(/:id)",
19
+ class_name: "Zaikio::Warehouse::ManifestEntry"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ class Transfer < Operation
6
+ disable_http_methods :put, :patch, :delete
7
+
8
+ uri "transfers(/:id)"
9
+ include_root_in_json :transfer
10
+
11
+ attributes :amount, :amount_in_base_unit
12
+
13
+ has_one :material, uri: nil, class_name: "Zaikio::Warehouse::Material"
14
+ has_one :sku, uri: nil, class_name: "Zaikio::Warehouse::SKU"
15
+ has_one :source_storage_area, uri: nil, class_name: "Zaikio::Warehouse::StorageArea"
16
+ has_one :target_storage_area, uri: nil, class_name: "Zaikio::Warehouse::StorageArea"
17
+ has_one :person, uri: nil, class_name: "Zaikio::Warehouse::Person"
18
+ has_one :withdrawal, uri: nil, class_name: "Zaikio::Warehouse::Withdrawal"
19
+ has_one :deposit, uri: nil, class_name: "Zaikio::Warehouse::Deposit"
20
+ has_one :manifest_entry, uri: nil, class_name: "Zaikio::Warehouse::ManifestEntry"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # See https://docs.zaikio.com/api/warehouse/warehouse.html#/Warehouses
6
+ class Warehouse < Base
7
+ uri "warehouses(/:id)"
8
+ include_root_in_json :warehouse
9
+
10
+ attributes :name, :deletable, :created_at, :updated_at
11
+
12
+ has_one :operator, uri: nil, class_name: "Zaikio::Warehouse::Organization"
13
+ has_one :site, uri: nil, class_name: "Zaikio::Warehouse::Site"
14
+
15
+ has_many :storage_areas,
16
+ class_name: "Zaikio::Warehouse::StorageArea",
17
+ uri: "storage_areas?warehouse_id=:warehouse_id"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ class Withdrawal < Operation
6
+ disable_http_methods :patch, :put, :delete
7
+ include_root_in_json :withdrawal
8
+
9
+ uri "withdrawals(/:id)"
10
+
11
+ attributes :amount, :amount_in_base_unit, :created_at, :updated_at
12
+
13
+ has_one :material, uri: nil, class_name: "Zaikio::Warehouse::Material"
14
+ has_one :sku, uri: nil, class_name: "Zaikio::Warehouse::SKU"
15
+ has_one :storage_area, uri: nil, class_name: "Zaikio::Warehouse::StorageArea"
16
+ has_one :person, uri: nil, class_name: "Zaikio::Warehouse::Person"
17
+ has_one :manifest_entry, uri: nil, class_name: "Zaikio::Warehouse::ManifestEntry"
18
+
19
+ has_one :goods_call_off_line_item,
20
+ uri: nil,
21
+ class_name: "Zaikio::Warehouse::FinishedGoods::CallOff::LineItem"
22
+ has_one :withdrawal_request, uri: nil, class_name: "Zaikio::Warehouse::WithdrawalRequest"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zaikio
4
+ module Warehouse
5
+ # Client model for nested withdrawal request representations
6
+ class WithdrawalRequest < Base
7
+ disable_http_methods :get, :put, :post, :patch, :delete # there is no endpoint available at the moment
8
+
9
+ # no attributes, there's only an ID
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/class/attribute"
4
+ require "zaikio-client-helpers"
5
+
6
+ # Base und utility classes
7
+ require "zaikio/warehouse/configuration"
8
+ require "zaikio/warehouse/base"
9
+ require "zaikio/warehouse/operation"
10
+
11
+ # Models
12
+ require "zaikio/warehouse/call_off_agreement"
13
+ require "zaikio/warehouse/consumption"
14
+ require "zaikio/warehouse/consumption_request"
15
+ require "zaikio/warehouse/consumption_request_cancelation"
16
+ require "zaikio/warehouse/consumption_announcement"
17
+ require "zaikio/warehouse/contact"
18
+ require "zaikio/warehouse/correction"
19
+ require "zaikio/warehouse/deposit"
20
+ require "zaikio/warehouse/finished_goods/call_off"
21
+ require "zaikio/warehouse/finished_goods/material"
22
+ require "zaikio/warehouse/manifest_entry"
23
+ require "zaikio/warehouse/material"
24
+ require "zaikio/warehouse/organization"
25
+ require "zaikio/warehouse/person"
26
+ require "zaikio/warehouse/site"
27
+ require "zaikio/warehouse/sku"
28
+ require "zaikio/warehouse/storage_area"
29
+ require "zaikio/warehouse/transfer"
30
+ require "zaikio/warehouse/warehouse"
31
+ require "zaikio/warehouse/withdrawal"
32
+ require "zaikio/warehouse/withdrawal_request"
33
+
34
+ require "zaikio/warehouse/version"
35
+
36
+ module Zaikio
37
+ # Namespace for the Zaikio Warehouse Client
38
+ module Warehouse
39
+ class << self
40
+ attr_reader :configuration
41
+
42
+ class_attribute :connection
43
+
44
+ def configure
45
+ self.connection = nil
46
+ @configuration ||= Configuration.new
47
+ yield(@configuration)
48
+
49
+ Base.connection = create_connection
50
+ end
51
+
52
+ def with_token(token, &block)
53
+ Zaikio::Client.with_token(token, &block)
54
+ end
55
+
56
+ def create_connection
57
+ self.connection = Zaikio::Client.create_connection(configuration).tap do |c|
58
+ c.headers = { user_agent: "zaikio-warehouse-ruby #{Zaikio::Warehouse::VERSION}" }
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
metadata ADDED
@@ -0,0 +1,272 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zaikio-warehouse
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Zaikio GmbH
8
+ - Torsten Schönebaum
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2022-10-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: concurrent-ruby
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: zaikio-client-helpers
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 0.3.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.3.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: minitest
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: mocha
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: oauth2
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: pry
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rake
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rubocop
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: rubocop-minitest
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: rubocop-rake
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: thor
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ type: :development
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ - !ruby/object:Gem::Dependency
183
+ name: vcr
184
+ requirement: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ type: :development
190
+ prerelease: false
191
+ version_requirements: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ - !ruby/object:Gem::Dependency
197
+ name: webmock
198
+ requirement: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ type: :development
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ description: Ruby API Client for Zaikio's Warehouse Platform
211
+ email:
212
+ - ts@zaikio.com
213
+ executables: []
214
+ extensions: []
215
+ extra_rdoc_files: []
216
+ files:
217
+ - CHANGELOG.md
218
+ - LICENSE.txt
219
+ - README.md
220
+ - lib/zaikio/warehouse.rb
221
+ - lib/zaikio/warehouse/base.rb
222
+ - lib/zaikio/warehouse/call_off_agreement.rb
223
+ - lib/zaikio/warehouse/configuration.rb
224
+ - lib/zaikio/warehouse/consumption.rb
225
+ - lib/zaikio/warehouse/consumption_announcement.rb
226
+ - lib/zaikio/warehouse/consumption_request.rb
227
+ - lib/zaikio/warehouse/consumption_request_cancelation.rb
228
+ - lib/zaikio/warehouse/contact.rb
229
+ - lib/zaikio/warehouse/correction.rb
230
+ - lib/zaikio/warehouse/deposit.rb
231
+ - lib/zaikio/warehouse/finished_goods/call_off.rb
232
+ - lib/zaikio/warehouse/finished_goods/material.rb
233
+ - lib/zaikio/warehouse/manifest_entry.rb
234
+ - lib/zaikio/warehouse/material.rb
235
+ - lib/zaikio/warehouse/operation.rb
236
+ - lib/zaikio/warehouse/organization.rb
237
+ - lib/zaikio/warehouse/person.rb
238
+ - lib/zaikio/warehouse/site.rb
239
+ - lib/zaikio/warehouse/sku.rb
240
+ - lib/zaikio/warehouse/storage_area.rb
241
+ - lib/zaikio/warehouse/transfer.rb
242
+ - lib/zaikio/warehouse/version.rb
243
+ - lib/zaikio/warehouse/warehouse.rb
244
+ - lib/zaikio/warehouse/withdrawal.rb
245
+ - lib/zaikio/warehouse/withdrawal_request.rb
246
+ homepage: https://docs.zaikio.com/api/warehouse/warehouse.html
247
+ licenses:
248
+ - MIT
249
+ metadata:
250
+ homepage_uri: https://docs.zaikio.com/api/warehouse/warehouse.html
251
+ source_code_uri: https://github.com/zaikio/zaikio-warehouse-ruby
252
+ changelog_uri: https://github.com/zaikio/zaikio-warehouse-ruby/blob/main/CHANGELOG.md
253
+ post_install_message:
254
+ rdoc_options: []
255
+ require_paths:
256
+ - lib
257
+ required_ruby_version: !ruby/object:Gem::Requirement
258
+ requirements:
259
+ - - ">="
260
+ - !ruby/object:Gem::Version
261
+ version: 2.7.1
262
+ required_rubygems_version: !ruby/object:Gem::Requirement
263
+ requirements:
264
+ - - ">="
265
+ - !ruby/object:Gem::Version
266
+ version: '0'
267
+ requirements: []
268
+ rubygems_version: 3.3.11
269
+ signing_key:
270
+ specification_version: 4
271
+ summary: Ruby API Client for Zaikio's Warehouse Platform
272
+ test_files: []