futureshop 0.1.4 → 0.1.7
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 +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +2 -1
- data/exe/futureshop +38 -4
- data/futureshop.gemspec +3 -3
- data/lib/futureshop/inventory.rb +51 -0
- data/lib/futureshop/version.rb +1 -1
- data/lib/futureshop.rb +1 -0
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 149ccbc61f6f2a24a204a3e5388916d0cc88ed83a3e430139343258b35cfdc54
|
4
|
+
data.tar.gz: fe5ccfb36388c2a542fba637ad267ea8b2dfdf00bcce585260b8fcfb87b73c66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c91b48060e10dbde69a59715636b256091d5107a564c184f740f385bc3c766fa7b41daf30efb7988cb7463601e1cb91c3d35af35906471f09be6f283e61e746
|
7
|
+
data.tar.gz: 5a897ec2722dda6fe75b7537f2a602a59cdf53c79d3db1c59d9be90e7a38f7e03cf25f7d38cdcc4c0bff51127737b889e24c9ec35dff653df79adbfd586d53be
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.7] - 2022-06-13
|
4
|
+
|
5
|
+
- Remove couponList.id and couponList.name fields from orders CSV output
|
6
|
+
|
7
|
+
## [0.1.6] - 2021-11-04
|
8
|
+
|
9
|
+
- Change required Ruby version from 3.0.0 to 2.7.0
|
10
|
+
- Complete command options
|
11
|
+
|
12
|
+
## [0.1.5] - 2021-10-21
|
13
|
+
|
14
|
+
- Add `Futureshop::Inventory` class
|
15
|
+
- Add `inventories` subcommand
|
16
|
+
|
3
17
|
## [0.1.4] - 2021-10-11
|
4
18
|
|
5
19
|
- Handle order's couponList field, which was introduced on 2021-09-29
|
data/README.md
CHANGED
@@ -21,6 +21,7 @@ Or install it yourself as:
|
|
21
21
|
## Usage
|
22
22
|
|
23
23
|
futureshop orders -fcsv --order-date-start=2016-07-05 --order-date-end=2021-07-20 > orders.2021-07-20.csv
|
24
|
+
futureshop inventories --type=regular,preorder
|
24
25
|
|
25
26
|
## Development
|
26
27
|
|
@@ -30,4 +31,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
30
31
|
|
31
32
|
## Contributing
|
32
33
|
|
33
|
-
Bug reports and merge requests are welcome on GitHub at https://gitlab.com/KitaitiMakoto/
|
34
|
+
Bug reports and merge requests are welcome on GitHub at https://gitlab.com/KitaitiMakoto/futureshop
|
data/exe/futureshop
CHANGED
@@ -4,7 +4,7 @@ require "optparse"
|
|
4
4
|
require "optparse/time"
|
5
5
|
require "futureshop"
|
6
6
|
|
7
|
-
SUPPORTED_COMMANDS = %w[orders]
|
7
|
+
SUPPORTED_COMMANDS = %w[orders inventories]
|
8
8
|
|
9
9
|
def main(argv)
|
10
10
|
global_options = parse_global_options(argv)
|
@@ -14,6 +14,8 @@ def main(argv)
|
|
14
14
|
case subcommand
|
15
15
|
when "orders"
|
16
16
|
orders global_options, argv
|
17
|
+
when "inventories"
|
18
|
+
inventories global_options, argv
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
@@ -27,6 +29,11 @@ end
|
|
27
29
|
|
28
30
|
def parse_global_options(argv)
|
29
31
|
parse_options(argv) {|opt|
|
32
|
+
opt.banner = "Usage:\n" + SUPPORTED_COMMANDS.collect {|command|
|
33
|
+
" #{opt.program_name} [global options] #{command} [options]"
|
34
|
+
}.join("\n")
|
35
|
+
opt.version = Futureshop::VERSION
|
36
|
+
opt.separator "Global options:"
|
30
37
|
opt.on "--verbose" do
|
31
38
|
$VERBOSE = true
|
32
39
|
end
|
@@ -36,11 +43,38 @@ end
|
|
36
43
|
def orders(global_options, argv)
|
37
44
|
options = {format: "json"}
|
38
45
|
options.update(parse_options(argv) {|opt|
|
39
|
-
|
40
|
-
opt.on "--
|
41
|
-
opt.on "--order-date-
|
46
|
+
formats = %w[json csv]
|
47
|
+
opt.on "-f", "--format=FORMAT", ["json", "csv"], "Output format. Available: #{formats.join(', ')}"
|
48
|
+
opt.on "--order-date-start=YYYY-MM-DD", Time, "Retrieve orders whose date is newer than or equal to argument."
|
49
|
+
opt.on "--order-date-end=YYYY-MM-DD", Time, "Retrieve orders whose date is older than or equal to argument."
|
42
50
|
})
|
43
51
|
Futureshop.orders(order_date_start: options[:"order-date-start"], order_date_end: options[:"order-date-end"], format: options[:format])
|
44
52
|
end
|
45
53
|
|
54
|
+
def inventories(global_options, argv)
|
55
|
+
require "futureshop/inventory"
|
56
|
+
|
57
|
+
options = {
|
58
|
+
type: ["regular"],
|
59
|
+
product_no: [],
|
60
|
+
jan_code: []
|
61
|
+
}
|
62
|
+
options = options.update(parse_options(argv) {|opt|
|
63
|
+
opt.on "--type=TYPE", Array, "Type. Available: regular, preorder, planned, realstore"
|
64
|
+
opt.on "--create-date-start=DATE", Time, "Retrieve products whose registration date is newer than or equal to argument."
|
65
|
+
opt.on "--create-date-end=DATE", Time, "Retrieve products whose registration date is older than or equal to argument."
|
66
|
+
opt.on "--product-no=NUMBER", Array, "Product number."
|
67
|
+
opt.on "--jan-code=CODE", Array, "JAN code."
|
68
|
+
})
|
69
|
+
if options[:type]
|
70
|
+
unknown_types = options[:type].select {|type| ! %w[regular preorder planned realstore].include?(type)}
|
71
|
+
unless unknown_types.empty?
|
72
|
+
raise "Unknown type(s): #{unknown_types.join(', ')}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
Futureshop::Inventory.each types: options[:type].collect(&:to_sym), create_date_start: options[:"create-date-start"], create_date_end: options[:"create-date-end"], product_no: options[:"product-no"], jan_code: options[:"jan-code"] do |inventory|
|
76
|
+
puts inventory.to_json
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
46
80
|
main ARGV
|
data/futureshop.gemspec
CHANGED
@@ -8,13 +8,13 @@ Gem::Specification.new do |spec|
|
|
8
8
|
|
9
9
|
spec.summary = "futureshop APIv2 client and tools"
|
10
10
|
spec.description = "futureshop APIv2 client and tools"
|
11
|
-
spec.homepage = "https://gitlab.com/KitaitiMakoto/
|
12
|
-
spec.required_ruby_version = ">=
|
11
|
+
spec.homepage = "https://gitlab.com/KitaitiMakoto/futureshop"
|
12
|
+
spec.required_ruby_version = ">= 2.7.0"
|
13
13
|
spec.license = "AGPL-3.0-or-later"
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
16
|
spec.metadata["source_code_uri"] = spec.homepage
|
17
|
-
spec.metadata["changelog_uri"] = "https://gitlab.com/KitaitiMakoto/
|
17
|
+
spec.metadata["changelog_uri"] = "https://gitlab.com/KitaitiMakoto/futureshop/-/blob/main/CHANGELOG.md"
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Futureshop
|
2
|
+
class Inventory
|
3
|
+
class << self
|
4
|
+
def each_batch(types: [:regular], create_date_start: nil, create_date_end: nil, product_no: [], jan_code: [])
|
5
|
+
params = {
|
6
|
+
types: types,
|
7
|
+
product_no: product_no,
|
8
|
+
jan_code: jan_code
|
9
|
+
}
|
10
|
+
params[:create_date_start] = create_date_start.strftime("%FT%T") if create_date_start
|
11
|
+
params[:create_date_end] = create_date_end.strftime("%FT%T") if create_date_end
|
12
|
+
res = client.get("/admin-api/v1/inventory", params: params)
|
13
|
+
yield res["productList"]
|
14
|
+
|
15
|
+
next_url = res["nextUrl"]
|
16
|
+
while next_url
|
17
|
+
sleep Client::INTERVAL
|
18
|
+
url = URI.parse(next_url)
|
19
|
+
res = client.request_by_uri(:get, url)
|
20
|
+
yield res["productList"]
|
21
|
+
next_url = res["nextUrl"]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def each(**args)
|
26
|
+
return enum_for(__method__, **args) unless block_given?
|
27
|
+
|
28
|
+
each_batch **args do |inventories|
|
29
|
+
inventories.each do |inventory|
|
30
|
+
yield inventory
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def all(**args)
|
36
|
+
return each.to_a
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def client
|
42
|
+
@client ||= Futureshop::Client.new(
|
43
|
+
shop_key: ENV["FUTURESHOP_SHOP_KEY"],
|
44
|
+
client_id: ENV["FUTURESHOP_CLIENT_ID"],
|
45
|
+
client_secret: ENV["FUTURESHOP_CLIENT_SECRET"],
|
46
|
+
api_domain: ENV["FUTURESHOP_API_DOMAIN"]
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/futureshop/version.rb
CHANGED
data/lib/futureshop.rb
CHANGED
@@ -93,6 +93,7 @@ module Futureshop
|
|
93
93
|
when Hash
|
94
94
|
headers.concat aggregate_headers(value).collect {|header| "#{key}.#{header}"}
|
95
95
|
when Array
|
96
|
+
next if key == "couponList"
|
96
97
|
sample = value[0]
|
97
98
|
if sample
|
98
99
|
headers.concat aggregate_headers(sample).collect {|header| "#{key}.#{header}"}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: futureshop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kitaiti Makoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -73,14 +73,15 @@ files:
|
|
73
73
|
- futureshop.gemspec
|
74
74
|
- lib/futureshop.rb
|
75
75
|
- lib/futureshop/client.rb
|
76
|
+
- lib/futureshop/inventory.rb
|
76
77
|
- lib/futureshop/version.rb
|
77
|
-
homepage: https://gitlab.com/KitaitiMakoto/
|
78
|
+
homepage: https://gitlab.com/KitaitiMakoto/futureshop
|
78
79
|
licenses:
|
79
80
|
- AGPL-3.0-or-later
|
80
81
|
metadata:
|
81
|
-
homepage_uri: https://gitlab.com/KitaitiMakoto/
|
82
|
-
source_code_uri: https://gitlab.com/KitaitiMakoto/
|
83
|
-
changelog_uri: https://gitlab.com/KitaitiMakoto/
|
82
|
+
homepage_uri: https://gitlab.com/KitaitiMakoto/futureshop
|
83
|
+
source_code_uri: https://gitlab.com/KitaitiMakoto/futureshop
|
84
|
+
changelog_uri: https://gitlab.com/KitaitiMakoto/futureshop/-/blob/main/CHANGELOG.md
|
84
85
|
post_install_message:
|
85
86
|
rdoc_options: []
|
86
87
|
require_paths:
|
@@ -89,14 +90,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
90
|
requirements:
|
90
91
|
- - ">="
|
91
92
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
93
|
+
version: 2.7.0
|
93
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
95
|
requirements:
|
95
96
|
- - ">="
|
96
97
|
- !ruby/object:Gem::Version
|
97
98
|
version: '0'
|
98
99
|
requirements: []
|
99
|
-
rubygems_version: 3.
|
100
|
+
rubygems_version: 3.3.7
|
100
101
|
signing_key:
|
101
102
|
specification_version: 4
|
102
103
|
summary: futureshop APIv2 client and tools
|