plenty_client 0.1.0 → 0.1.1

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: b6ff37ac81ad08b66efcf7d3bf22de8bd7c044f63e9075049cfa12e48e79e67d
4
- data.tar.gz: 32bcc7518200db454ff6723807e4f895669a6a96bbc3855376a90b2af23aa965
3
+ metadata.gz: 468471d1063a081184202e28692e3b8f6f2a8f99011cbcd52ad11dcc57a2dff3
4
+ data.tar.gz: 8b3dfd65b46808a089ec788576d9d1d0db196148d032d6c977e3f53d27f03ffb
5
5
  SHA512:
6
- metadata.gz: a544191236f9de2a8ea7b57e50015e73ade83a0fde9225844a71308439151ffb9121dd1681fbe8fe4616f130c008f3e10057bcd2f3e348cf0c823bb6167a6297
7
- data.tar.gz: 1b02c33c9ca78d69435186cccf3851c4e2cc02d75cd9d66a83c6a6d9685d0b68e85afbcf516e26b9f7a217a061daf24e63fa25840365f16a281414159316a583
6
+ metadata.gz: 40c8107ab4b4e6d46f5fff6bcaa008e7c587f875955e8cd42977d8e8f313d833791a57d48f4dcf0c04d509eabebed3221ce9acdb0cffd52804a7fab31118f6ce
7
+ data.tar.gz: d13f2f3ac98937ade8439d9fac70374869c831f4675cbc1b51cd86b98edfe90c8e20e9c158199be84207a4963dede77cb39efb16abf968ec29b9fe4afb567941
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Quickly extends boilerplate paths that comply with the schema:
4
+ # POST BASE_PATH => create
5
+ # GET BASE_PATH/:id => find
6
+ # PUT BASE_PATH/:id => update
7
+ # DELETE BASE_PATH/:id => destroy
8
+ # You can undefine unnecessary methods by adding a call to
9
+ # #skip_rest_routes in the class body:
10
+ # class Someclass
11
+ # skip_rest_routes :find, :destroy
12
+ # end
13
+
14
+ # Usage:
15
+ # Extend this module in your class/module and define `self.base_path`
16
+ # Do keep in mind that this method should be private or protected.
17
+ #
18
+ # class Someclass
19
+ # extend PlentyClient::Concerns::RestRoutes
20
+ #
21
+ # # method definition returns method name as a Symbol
22
+ # private_class_method def self.base_path
23
+ # '/my_base_path'
24
+ # end
25
+ #
26
+ # # or
27
+ # def self.base_path
28
+ # '/my_base_path'
29
+ # end
30
+ # private_class_method :base_path
31
+ #
32
+ # # or
33
+ # class << self
34
+ # private
35
+ #
36
+ # def base_path
37
+ # '/my_base_path'
38
+ # end
39
+ # end
40
+ # end
41
+
42
+ module PlentyClient
43
+ module Concerns
44
+ module RestRoutes
45
+ # Undefines class methods in modules/classes extending this module.
46
+ # You don't have to do it if you overload the method explicitly.
47
+ def skip_rest_routes(*paths)
48
+ instance_exec(paths) do |p|
49
+ p.each { |mn| undef :"#{mn}" }
50
+ end
51
+ end
52
+
53
+ def create(headers = {}, &block)
54
+ post(base_path, headers, &block)
55
+ end
56
+
57
+ def list(headers = {}, &block)
58
+ get(base_path, headers, &block)
59
+ end
60
+
61
+ def find(id, headers = {}, &block)
62
+ get(single_path(id), headers, &block)
63
+ end
64
+
65
+ def update(id, headers = {}, &block)
66
+ put(single_path(id), headers, &block)
67
+ end
68
+
69
+ def destroy(id, headers = {}, &block)
70
+ delete(single_path(id), headers, &block)
71
+ end
72
+
73
+ private
74
+
75
+ def single_path(id)
76
+ base_path + "/#{id}"
77
+ end
78
+ end
79
+ end
80
+ end
@@ -7,11 +7,12 @@ module PlentyClient
7
7
  include PlentyClient::Endpoint
8
8
  include PlentyClient::Request
9
9
 
10
- FIND_LISTING_MARKET_HISTORY = '/listings/markets/histories/{marketListingHistoryId}'
11
- LIST_LISTING_MARKET_HISTORIES = '/listings/markets/histories'
12
- END_LISTING_MARKET_HISTORY = '/listings/markets/histories/end/{marketListingHistoryId}'
13
- RELIST_LISTING_MARKET_HISTORY = '/listings/markets/histories/relist/{marketListingHistoryId}'
14
- UPDATE_LISTING_MARKET_HISTORY = '/listings/markets/histories/update/{marketListingHistoryId}'
10
+ FIND_LISTING_MARKET_HISTORY = '/listings/markets/histories/{marketListingHistoryId}'
11
+ LIST_LISTING_MARKET_HISTORIES = '/listings/markets/histories'
12
+ END_LISTING_MARKET_HISTORY = '/listings/markets/histories/end/{marketListingHistoryId}'
13
+ RELIST_LISTING_MARKET_HISTORY = '/listings/markets/histories/relist/{marketListingHistoryId}'
14
+ UPDATE_LISTING_MARKET_HISTORY = '/listings/markets/histories/update/{marketListingHistoryId}'
15
+ UPDATE_LISTING_MARKET_HISTORIES = '/listings/markets/histories/update'
15
16
 
16
17
  class << self
17
18
  def find(market_listing_history_id, headers = {}, &block)
@@ -34,6 +35,10 @@ module PlentyClient
34
35
  def update(market_listing_history_id, body = {})
35
36
  put(build_endpoint(UPDATE_LISTING_MARKET_HISTORY, market_listing_history: market_listing_history_id), body)
36
37
  end
38
+
39
+ def update_many(body = {})
40
+ put(build_endpoint(UPDATE_LISTING_MARKET_HISTORIES), body)
41
+ end
37
42
  end
38
43
  end
39
44
  end
@@ -14,8 +14,11 @@ module PlentyClient
14
14
 
15
15
  attempts = PlentyClient::Config.attempt_count
16
16
  attempts.times do
17
- response = perform(http_method, path, params)
18
- return response if response
17
+ begin
18
+ response = perform(http_method, path, params)
19
+ return response if response
20
+ rescue Faraday::ConnectionFailed => e
21
+ end
19
22
  end
20
23
  raise PlentyClient::AttemptsExceeded, "unable to get valid response after #{attempts} attempts"
21
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlentyClient
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # PlentyClient::Warehouse::Location::Dimension
4
+ module PlentyClient
5
+ module Warehouse
6
+ module Location
7
+ module Dimension
8
+ include PlentyClient::Request
9
+ extend PlentyClient::Concerns::RestRoutes
10
+
11
+ LIST_URL = '/warehouses/%<warehouse_id>d/locations/dimensions'
12
+
13
+ class << self
14
+ def list(warehouse_id, body = {}, &block)
15
+ get(format(LIST_URL, warehouse_id: warehouse_id), body, &block)
16
+ end
17
+
18
+ private
19
+
20
+ def base_path
21
+ '/warehouses/locations/dimensions'
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # PlentyClient::Warehouse::Location::Level
4
+ module PlentyClient
5
+ module Warehouse
6
+ module Location
7
+ module Level
8
+ include PlentyClient::Request
9
+ extend PlentyClient::Concerns::RestRoutes
10
+
11
+ LIST_URL = '/warehouses/%<warehouse_id>d/locations/levels'
12
+
13
+ class << self
14
+ def list(warehouse_id, body = {}, &block)
15
+ get(format(LIST_URL, warehouse_id: warehouse_id), body, &block)
16
+ end
17
+
18
+ private
19
+
20
+ def base_path
21
+ '/warehouses/locations/levels'
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # PlentyClient::Warehouse::Location
4
+ module PlentyClient
5
+ module Warehouse
6
+ module Location
7
+ include PlentyClient::Request
8
+ extend PlentyClient::Concerns::RestRoutes
9
+
10
+ LIST_URL = '/warehouses/%<warehouse_id>d/locations'
11
+
12
+ class << self
13
+ def list(warehouse_id, body = {}, &block)
14
+ get(format(LIST_URL, warehouse_id: warehouse_id), body, &block)
15
+ end
16
+
17
+ private
18
+
19
+ def base_path
20
+ '/warehouses/locations'
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -2,25 +2,13 @@
2
2
 
3
3
  module PlentyClient
4
4
  module Warehouse
5
- include PlentyClient::Endpoint
6
5
  include PlentyClient::Request
6
+ extend PlentyClient::Concerns::RestRoutes
7
7
 
8
- LIST_WAREHOUSES = '/stockmanagement/warehouses'
9
- FIND_WAREHOUSE = '/stockmanagement/warehouses/{warehouseId}'
10
- CREATE_WAREHOUSE = '/stockmanagement/warehouses'
8
+ skip_rest_routes :update, :destroy
11
9
 
12
- class << self
13
- def list(headers = {}, &block)
14
- get(build_endpoint(LIST_WAREHOUSES), headers, &block)
15
- end
16
-
17
- def find(warehouse_id, headers = {}, &block)
18
- get(build_endpoint(FIND_WAREHOUSE, warehouse: warehouse_id), headers, &block)
19
- end
20
-
21
- def create(body = {})
22
- post(build_endpoint(CREATE_WAREHOUSE), body)
23
- end
10
+ private_class_method def self.base_path
11
+ '/stockmanagement/warehouses'
24
12
  end
25
13
  end
26
14
  end
data/lib/plenty_client.rb CHANGED
@@ -29,6 +29,10 @@ module PlentyClient
29
29
  autoload :Warehouse, 'plenty_client/warehouse'
30
30
  autoload :Webstore, 'plenty_client/webstore'
31
31
 
32
+ module Concerns
33
+ autoload :RestRoutes, 'plenty_client/concerns/rest_routes'
34
+ end
35
+
32
36
  module Account
33
37
  autoload :Contact, 'plenty_client/account/contact'
34
38
  autoload :Address, 'plenty_client/account/address'
@@ -200,11 +204,11 @@ module PlentyClient
200
204
  module Warehouse
201
205
  autoload :Stock, 'plenty_client/warehouse/stock'
202
206
  autoload :Management, 'plenty_client/warehouse/management'
207
+ autoload :Location, 'plenty_client/warehouse/location'
203
208
 
204
- module Management
205
- autoload :Rack, 'plenty_client/warehouse/management/rack'
206
- autoload :Shelf, 'plenty_client/warehouse/management/shelf'
207
- autoload :StorageLocation, 'plenty_client/warehouse/management/storage_location'
209
+ module Location
210
+ autoload :Dimension, 'plenty_client/warehouse/location/dimension'
211
+ autoload :Level, 'plenty_client/warehouse/location/level'
208
212
  end
209
213
  end
210
214
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plenty_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dariusch Ochlast
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-27 00:00:00.000000000 Z
11
+ date: 2018-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -183,6 +183,7 @@ files:
183
183
  - lib/plenty_client/category/branch.rb
184
184
  - lib/plenty_client/category/template.rb
185
185
  - lib/plenty_client/comment.rb
186
+ - lib/plenty_client/concerns/rest_routes.rb
186
187
  - lib/plenty_client/config.rb
187
188
  - lib/plenty_client/constants.rb
188
189
  - lib/plenty_client/document.rb
@@ -289,10 +290,10 @@ files:
289
290
  - lib/plenty_client/ticket.rb
290
291
  - lib/plenty_client/version.rb
291
292
  - lib/plenty_client/warehouse.rb
293
+ - lib/plenty_client/warehouse/location.rb
294
+ - lib/plenty_client/warehouse/location/dimension.rb
295
+ - lib/plenty_client/warehouse/location/level.rb
292
296
  - lib/plenty_client/warehouse/management.rb
293
- - lib/plenty_client/warehouse/management/rack.rb
294
- - lib/plenty_client/warehouse/management/shelf.rb
295
- - lib/plenty_client/warehouse/management/storage_location.rb
296
297
  - lib/plenty_client/warehouse/stock.rb
297
298
  - lib/plenty_client/webstore.rb
298
299
  - plenty_client.gemspec
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PlentyClient
4
- module Warehouse
5
- module Management
6
- class Rack
7
- include PlentyClient::Endpoint
8
- include PlentyClient::Request
9
-
10
- WM_WAREHOUSE_MGMT_BASE_PATH = '/stockmanagement/warehouses/{warehouseId}/management'
11
-
12
- WM_LIST_RACKS = '/racks'
13
- WM_FIND_RACKS = '/racks/{rackId}'
14
- WM_CREATE_RACK = '/racks'
15
-
16
- class << self
17
- def list(warehouse_id, headers = {}, &block)
18
- get(build_endpoint("#{WM_WAREHOUSE_MGMT_BASE_PATH}#{WM_LIST_RACKS}",
19
- warehouse: warehouse_id),
20
- headers, &block)
21
- end
22
-
23
- def find(warehouse_id, rack_id, headers = {}, &block)
24
- get(build_endpoint("#{WM_WAREHOUSE_MGMT_BASE_PATH}#{WM_FIND_RACKS}",
25
- warehouse: warehouse_id,
26
- rack: rack_id),
27
- headers, &block)
28
- end
29
-
30
- def create(warehouse_id, body = {})
31
- post(build_endpoint("#{WM_WAREHOUSE_MGMT_BASE_PATH}#{WM_CREATE_RACK}", warehouse: warehouse_id), body)
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PlentyClient
4
- module Warehouse
5
- module Management
6
- class Shelf
7
- include PlentyClient::Endpoint
8
- include PlentyClient::Request
9
-
10
- WM_WAREHOUSE_MGMT_BASE_PATH = '/stockmanagement/warehouses/{warehouseId}/management'
11
-
12
- WM_LIST_SHELF = '/racks/{rackId}/shelves'
13
- WM_FIND_SHELF = '/racks/{rackId}/shelves/{shelfId}'
14
- WM_CREATE_SHELF = '/racks/{rackId}/shelves'
15
-
16
- class << self
17
- def list(warehouse_id, rack_id, headers = {}, &block)
18
- get(build_endpoint("#{WM_WAREHOUSE_MGMT_BASE_PATH}#{WM_LIST_SHELF}",
19
- warehouse: warehouse_id, rack: rack_id),
20
- headers, &block)
21
- end
22
-
23
- def find(warehouse_id, rack_id, shelf_id, headers = {}, &block)
24
- get(build_endpoint("#{WM_WAREHOUSE_MGMT_BASE_PATH}#{WM_FIND_SHELF}",
25
- warehouse: warehouse_id,
26
- rack: rack_id,
27
- shelf: shelf_id),
28
- headers, &block)
29
- end
30
-
31
- def create(warehouse_id, rack_id, body = {})
32
- post(build_endpoint("#{WM_WAREHOUSE_MGMT_BASE_PATH}#{WM_CREATE_SHELF}",
33
- warehouse: warehouse_id, rack: rack_id),
34
- body)
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PlentyClient
4
- module Warehouse
5
- module Management
6
- class StorageLocation
7
- include PlentyClient::Endpoint
8
- include PlentyClient::Request
9
-
10
- WM_STORAGE_LOCATION_BASE_PATH = '/stockmanagement/warehouses/{warehouseId}/management'
11
- WM_SL_LIST_STORAGE_LOCATIONS = '/racks/{rackId}/shelves/{shelfId}/storageLocations'
12
- WM_SL_FIND_STORAGE_LOCATIONS = '/racks/{rackId}/shelves/{shelfId}/storageLocations/{storageLocationId}'
13
- WM_SL_CREATE_STORAGE_LOCATION = '/racks/{rackId}/shelves/{shelfId}/storageLocations'
14
-
15
- class << self
16
- def list(warehouse_id, rack_id, shelf_id, headers = {}, &block)
17
- get(build_endpoint("#{WM_STORAGE_LOCATION_BASE_PATH}#{WM_SL_LIST_STORAGE_LOCATIONS}",
18
- warehouse: warehouse_id,
19
- rack: rack_id,
20
- shelf: shelf_id),
21
- headers, &block)
22
- end
23
-
24
- def find(warehouse_id, rack_id, shelf_id, storage_location_id, headers = {}, &block)
25
- get(build_endpoint("#{WM_STORAGE_LOCATION_BASE_PATH}#{WM_SL_FIND_STORAGE_LOCATIONS}",
26
- warehouse: warehouse_id,
27
- rack: rack_id,
28
- shelf: shelf_id,
29
- storage_location: storage_location_id),
30
- headers, &block)
31
- end
32
-
33
- def create(warehouse_id, rack_id, shelf_id, body = {})
34
- post(build_endpoint("#{WM_STORAGE_LOCATION_BASE_PATH}#{WM_SL_CREATE_STORAGE_LOCATION}",
35
- warehouse: warehouse_id,
36
- rack: rack_id,
37
- shelf: shelf_id),
38
- body)
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end