xdelivery 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
  SHA1:
3
- metadata.gz: 66f01b9efe9c8a673995a602bbf6d56fdd69e878
4
- data.tar.gz: 0bb3faef10eef81dc89a5e66623728688fe48acd
3
+ metadata.gz: 23d9870f314e3bfd98217068f56f0222a5fa5e8c
4
+ data.tar.gz: 4879a5bee3a7c03417236c72d75092cf49e11aaf
5
5
  SHA512:
6
- metadata.gz: d7b68cef150265c95b7e1709a8d6cc791a797e6a310be3753cacf02006a75df300e4af3bbe0a703aab79f078c0a3aa087c07e21ed0c39cca2bfbfd07dae4a99a
7
- data.tar.gz: 54ac80927b4fbf936213eb9e1c42116e50fb3414822f7b358a05df0c210b135509df35c3470acf8c3f638f580274ffefb67b2a9e57296ae28e14c891d25e2fea
6
+ metadata.gz: a2d0fd27bc875cbf074c5514c727dc1677fdf9a3cf7beff996bfe54b556ee721fe0b06503c8b8021084a7cef0e0bf69ee05bc082b247026e840d9cb05cb3ddfb
7
+ data.tar.gz: 9312ddbc3db918dfa11df10c8bafe9de1af78b915be1100ed8f9f670c4809375be66a1d6eb79c73e27ee5a452780ae785bca38653dc4c09bb22a54ada90fd631
data/Gemfile.lock CHANGED
@@ -20,6 +20,7 @@ GEM
20
20
  mime-types-data (~> 3.2015)
21
21
  mime-types-data (3.2018.0812)
22
22
  minitest (5.11.3)
23
+ minitest-stub-const (0.6)
23
24
  netrc (0.11.0)
24
25
  public_suffix (3.0.3)
25
26
  rake (10.5.0)
@@ -42,10 +43,11 @@ PLATFORMS
42
43
  DEPENDENCIES
43
44
  bundler (~> 1.16)
44
45
  minitest (~> 5.0)
46
+ minitest-stub-const
45
47
  rake (~> 10.0)
46
48
  rest-client
47
49
  webmock
48
50
  xdelivery!
49
51
 
50
52
  BUNDLED WITH
51
- 1.16.4
53
+ 1.16.6
data/lib/xdelivery.rb CHANGED
@@ -4,9 +4,11 @@ require "xdelivery/version"
4
4
  require "xdelivery/client"
5
5
  require "xdelivery/api/base"
6
6
  require "xdelivery/api/orders"
7
+ require "xdelivery/api/products"
7
8
  require "xdelivery/api/ping"
8
9
  require "xdelivery/api/response/base"
9
10
  require "xdelivery/api/response/orders"
11
+ require "xdelivery/api/response/products"
10
12
  require "xdelivery/api/response/ping"
11
13
 
12
14
 
@@ -15,6 +15,12 @@ module Xdelivery
15
15
 
16
16
  protected
17
17
 
18
+ def patch(path)
19
+ RestClient.patch(uri(path).to_s, patch_data)
20
+ rescue RestClient::ExceptionWithResponse => e
21
+ e.response
22
+ end
23
+
18
24
  def post(path)
19
25
  RestClient.post(uri(path).to_s, post_data)
20
26
  rescue RestClient::ExceptionWithResponse => e
@@ -32,11 +38,16 @@ module Xdelivery
32
38
  {}
33
39
  end
34
40
 
35
- # [POST]
41
+ # [POST]
36
42
  def post_data
37
43
  {}
38
44
  end
39
45
 
46
+ # [PATCH]
47
+ def patch_data
48
+ {}
49
+ end
50
+
40
51
  private
41
52
 
42
53
  def uri(path)
@@ -27,7 +27,7 @@ module Xdelivery
27
27
  end
28
28
 
29
29
  def create!
30
- response = post('/orders/batch')
30
+ response = post('/orders/batch.json')
31
31
  Response::Orders.new(response)
32
32
  end
33
33
 
@@ -0,0 +1,30 @@
1
+ module Xdelivery
2
+ module API
3
+ class Products < Base
4
+ include Enumerable
5
+
6
+ attr_accessor :products
7
+
8
+ COLUMNS = [
9
+ :days_produce, :qty_day_average, :qty_week_average, :qty_month_average, :qty_owe
10
+ ]
11
+
12
+ def set(code, params)
13
+ self.products ||= []
14
+ params.delete_if { |k, v| COLUMNS.include?(k) == false }
15
+ products.push(params.merge(code: code))
16
+ end
17
+
18
+ def update!
19
+ response = patch('/products/update_all.json')
20
+ Response::Products.new(response)
21
+ end
22
+
23
+ protected
24
+
25
+ def patch_data
26
+ { qtys: { products: products } }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+ module Xdelivery
2
+ module API
3
+ module Response
4
+ class Products < Base
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -14,6 +14,12 @@ module Xdelivery
14
14
  api.create!
15
15
  end
16
16
 
17
+ def update_products!
18
+ api = API::Products.new(merchant_no, access_key)
19
+ yield(api)
20
+ api.update!
21
+ end
22
+
17
23
  def ping!
18
24
  api = API::Ping.new(merchant_no, access_key)
19
25
  api.ping!
@@ -1,3 +1,3 @@
1
1
  module Xdelivery
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -26,5 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "bundler", "~> 1.16"
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
28
  spec.add_development_dependency "minitest", "~> 5.0"
29
+ spec.add_development_dependency "minitest-stub-const"
30
+
29
31
  spec.add_dependency "rest-client"
30
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xdelivery
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
  - eddie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-16 00:00:00.000000000 Z
11
+ date: 2018-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-stub-const
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rest-client
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,9 +100,11 @@ files:
86
100
  - lib/xdelivery/api/base.rb
87
101
  - lib/xdelivery/api/orders.rb
88
102
  - lib/xdelivery/api/ping.rb
103
+ - lib/xdelivery/api/products.rb
89
104
  - lib/xdelivery/api/response/base.rb
90
105
  - lib/xdelivery/api/response/orders.rb
91
106
  - lib/xdelivery/api/response/ping.rb
107
+ - lib/xdelivery/api/response/products.rb
92
108
  - lib/xdelivery/client.rb
93
109
  - lib/xdelivery/version.rb
94
110
  - xdelivery-ruby.gemspec