futureshop 0.1.2 → 0.1.3

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: 4f2fd23ed1fbea603b0fb85215daf907df8452b0e33af3224ff368101f3a69dd
4
- data.tar.gz: 3552f0d56f12cbfc5338b62f673e6c99b4ddda9d81216a9a1afcf9523b8a266e
3
+ metadata.gz: a772346e853a3e3270613fdfdb1b80d7c1b8d6f56036a3894fb896755a2c9221
4
+ data.tar.gz: e269cdf0e96e9ff4223def8c5629c1db17c3c28316a676aee7a6f8d1773eee9d
5
5
  SHA512:
6
- metadata.gz: 88c85c2e8a2be55b4f937a4b6052241b740c0c16b3e57b1597cc42afa63e503013aff67111527297c3cb22fe5760cc399d06e6bf2a9b620dccd8e016ec789b2d
7
- data.tar.gz: f0b1c12f981157dafb3ee4fd5e086675ae9de82dc0083cced20742aa881fe67285071e8248fa68fb69067b7f1cdb401d8dabf72dfc2233d973e83f253d73b046
6
+ metadata.gz: be1565f81d78c145a809516074f699e8a3e101c16a273bd43027cefb44ba8dba661341019e3f2847b27e4d10f252c39b6e4c4f60e695ba232286fa0276448eaf
7
+ data.tar.gz: 7f0ba7fed584633bc70e8ed473d3521e2b377d8bda331274b6356960e71227c7861aa034cf504d7148b5d5dc1bf3900d32cc55287e290f642bc46e54b4fd0f24
data/.gitlab-ci.yml CHANGED
@@ -4,6 +4,6 @@ before_script:
4
4
  - gem install bundler -v 2.2.21
5
5
  - bundle install
6
6
 
7
- example_job:
7
+ test:
8
8
  script:
9
9
  - bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.3] - 2021-08-25
4
+
5
+ - Fix option passing
6
+ - Fix handling of nextUrl
7
+
3
8
  ## [0.1.2] - 2021-08-06
4
9
 
5
10
  - Fix command-line option name
data/exe/futureshop CHANGED
@@ -40,34 +40,7 @@ def orders(global_options, argv)
40
40
  opt.on "--order-date-start=DATE", Time
41
41
  opt.on "--order-date-end=DATE", Time
42
42
  })
43
- Futureshop.orders(order_date_start: options["order-date-start"], order_date_end: options["order-date-end"], format: options["format"])
44
- end
45
-
46
- def client
47
- Futureshop::Client.new(
48
- shop_key: ENV["FUTURESHOP_SHOP_KEY"],
49
- client_id: ENV["FUTURESHOP_CLIENT_ID"],
50
- client_secret: ENV["FUTURESHOP_CLIENT_SECRET"],
51
- api_domain: ENV["FUTURESHOP_API_DOMAIN"]
52
- )
53
- end
54
-
55
- def aggregate_headers(obj, headers = [])
56
- obj.each_pair do |key, value|
57
- unless %w[buyerInfo addressInfo shippingInfo shipmentList productList].include? key
58
- headers << key
59
- end
60
- case value
61
- when Hash
62
- headers.concat aggregate_headers(value).collect {|header| "#{key}.#{header}"}
63
- when Array
64
- sample = value[0]
65
- if sample
66
- headers.concat aggregate_headers(sample).collect {|header| "#{key}.#{header}"}
67
- end
68
- end
69
- end
70
- headers
43
+ Futureshop.orders(order_date_start: options[:"order-date-start"], order_date_end: options[:"order-date-end"], format: options[:format])
71
44
  end
72
45
 
73
46
  main ARGV
@@ -42,10 +42,7 @@ module Futureshop
42
42
  }
43
43
  end
44
44
 
45
- def request(method, path = "/", params: {}, data: {})
46
- raise "Unsupported method: #{method}" unless [:get, :post].include?(method)
47
- query = params.empty? ? nil : build_query(params)
48
- uri = URI::HTTPS.build(host: @api_domain, port: @port, path: path, query: query)
45
+ def request_by_uri(method, uri, data: {})
49
46
  request = Net::HTTP.const_get(method.capitalize).new(uri)
50
47
  headers.each_pair do |field, value|
51
48
  request[field] = value
@@ -56,6 +53,13 @@ module Futureshop
56
53
  JSON.parse(response.body)
57
54
  end
58
55
 
56
+ def request(method, path = "/", params: {}, data: {})
57
+ raise "Unsupported method: #{method}" unless [:get, :post].include?(method)
58
+ query = params.empty? ? nil : build_query(params)
59
+ uri = URI::HTTPS.build(host: @api_domain, port: @port, path: path, query: query)
60
+ request_by_uri(method, uri, data: data)
61
+ end
62
+
59
63
  def get(path = "/", params: {})
60
64
  request(:get, path, params: params)
61
65
  end
@@ -78,12 +82,13 @@ module Futureshop
78
82
  res = get("/admin-api/v1/shipping", params: params)
79
83
  yield res["orderList"]
80
84
 
81
- nextUrl = res["nextUrl"]
82
- while nextUrl
85
+ next_url = res["nextUrl"]
86
+ while next_url
83
87
  sleep INTERVAL
84
- res = get(nextUrl, params: params) # TODO: check spec to see whether it's okay to pass params in this form
88
+ url = URI.parse(next_url)
89
+ res = request_by_uri(:get, url)
85
90
  yield res["orderList"]
86
- nextUrl = res["nextUrl"]
91
+ next_url = res["nextUrl"]
87
92
  end
88
93
  end
89
94
 
@@ -1,3 +1,3 @@
1
1
  module Futureshop
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/futureshop.rb CHANGED
@@ -60,6 +60,8 @@ module Futureshop
60
60
  end
61
61
  end
62
62
  end
63
+ else
64
+ raise RuntimeError("unsupported format: #{format}")
63
65
  end
64
66
  end
65
67
  end
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kitaiti Makoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-06 00:00:00.000000000 Z
11
+ date: 2021-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake