shop_express 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f4f893058662a1ecae75107bb0e5aeadb98a6bf0e42f438c530654e0b5380e8
4
- data.tar.gz: a3ceabf6340410701d8c83a32d03852951ebd91fa571d2e3e3c6b2c573f545bd
3
+ metadata.gz: 130730098a5790e13912632ad714ab719fc8063fbb3f70daa1eda8553ea88c31
4
+ data.tar.gz: 5bfd59df810e1256ef25ca0a2425c549212259903f10ffc5aaeceb74cbec5850
5
5
  SHA512:
6
- metadata.gz: 05f5bac4f5e2c110aff3ec6a3096f4606783b15117a201adf5ef6f9ddf016d369766cfa5a59c0a9446da374db54dcb7b614f5cd461935b54f5eefdaaba3e3fb1
7
- data.tar.gz: f5e9de20dbd3ae3cb2e219d324fb8fc365d7cfe80814ee2835723e7691f703d33489457ed9f5fb7a69e9276bed32fbd2e36fb822a65b8e9644a31c51e3b04b4a
6
+ metadata.gz: 37c3bde3127497796fdb8f8a050049085eebd6fdbecb9a08ed684e6ef055209fd84bac0668cb8cd3b1b9abca7c67efebd1785702bd5d00ff57df2c746a51ecc7
7
+ data.tar.gz: cb2367f193e284bb7867c260d4141e49166684d2d3fb5117eb4c16c3f21f733b5c928ae9482b7175ffe4e885c3e448e071109a2642462d5182cf0b660326e96e
data/README.md CHANGED
@@ -1,11 +1,24 @@
1
- This is gem used for exchange data with shop-express.ua internet shop constructor
1
+ This is gem used for exchange data with https://shop-express.ua - internet shop constructor
2
2
 
3
- Authorization usage, at first you must create instance of class ShopExpress with valid params to connect
3
+ ### Authorization
4
+ At first, you must create instance of class ShopExpress with valid params to connect
4
5
  After that you just use instance shop_express for all next requests.
5
6
 
6
7
  shop_express = ShopExpress::Client.new(url: URI.parse('http://somesite.org'), username: 'jhon', password: 'piterson')
7
-
8
8
  ShopExpress::Authotization.new(shop_express).authorize
9
- ShopExpress::ImportResidues.new(shop_express).import(hash)
9
+
10
+
11
+ ### ImportResidues
12
+ Send returns all log data without OK status.
13
+ ```ruby
14
+ ShopExpress::ImportResidues.new(shop_express).call(hash)
15
+ ```
10
16
 
11
- *ImportResidues* returns all log data without OK status.
17
+ ### CatalogExport
18
+ Returns all products in the catalog. Possible arguments:
19
+ - limit (default 5000)
20
+ - offset (default: 0)
21
+ - display_in_show_case ("true" - only goods with quantity > 0, "false" all goods)
22
+ ```ruby
23
+ ShopExpress::CatalogExport.new(shop_express).call(limit: 100, offset: 5)
24
+ ```
@@ -8,6 +8,8 @@ module ShopExpress
8
8
  include Connection
9
9
  attr_reader :shop_express
10
10
 
11
+ STATUS_OK = 'OK'
12
+
11
13
  # @param shop_express [ShopExpress::Client]
12
14
  def initialize(shop_express)
13
15
  @shop_express = shop_express
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShopExpress
4
+ # get list of the products from the shop_express
5
+ class CatalogExport < ::ShopExpress::Base
6
+ URL = 'api/catalog/export'
7
+
8
+ # @param limit [Integer]
9
+ # @param offset [Integer]
10
+ # @param display_in_show_case [String] possible values (false, true)
11
+ def call(limit: 5000, offset: 0, display_in_show_case: 'false')
12
+ request_body = {
13
+ limit: limit,
14
+ offset: offset,
15
+ display_in_showcase: display_in_show_case
16
+ }
17
+
18
+ response_body = post(shop_express: shop_express, url: URL, body: request_body, add_token: true)
19
+ parse_response(response_body)
20
+ end
21
+
22
+ private
23
+
24
+ def parse_response(body)
25
+ return [] if body['status'] != STATUS_OK
26
+
27
+ body.dig('response', 'products')
28
+ end
29
+ end
30
+ end
@@ -4,7 +4,6 @@ module ShopExpress
4
4
  # import_residues to the shop_express
5
5
  class ImportResiduences < ::ShopExpress::Base
6
6
  URL = 'api/catalog/importResidues/'
7
- STATUS_OK = 'OK'
8
7
 
9
8
  # @param body [Hash]
10
9
  def call(body)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shop_express
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denys Krupenov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-26 00:00:00.000000000 Z
11
+ date: 2025-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -35,6 +35,7 @@ files:
35
35
  - lib/shop_express.rb
36
36
  - lib/shop_express/authorization.rb
37
37
  - lib/shop_express/base.rb
38
+ - lib/shop_express/catalog_export.rb
38
39
  - lib/shop_express/connection.rb
39
40
  - lib/shop_express/import_residues.rb
40
41
  homepage: https://github.com/dkru/shop_express