xdelivery 0.1.4 → 0.1.5

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: 6a868928d20ca0b40ee042017d5d7d51d2aa2781
4
- data.tar.gz: e34ad96b04e83766f3f842e5a7cc39ddd46bb406
3
+ metadata.gz: 33bf42ea5206fa01969a3f4516e9142b49276a22
4
+ data.tar.gz: d4144d88efcc751abe6e8a05bd68b348626e405c
5
5
  SHA512:
6
- metadata.gz: 850d970ed8267ba6145ebf2d3b1c481e7da6962b0cb4c22001ebcd0065683c2776d14a34ee9bd6ec2ed523a62c5f1054eea88d4e520c07087a4a18f230811814
7
- data.tar.gz: 35fb31e5051ffad4c04e5d060342bd17f7f537a42912e82182813b8b70b9d9ef756a28f321bc6ab367778bd9ab129db08569f55dcd6cce679a902ea56359f964
6
+ metadata.gz: b5a7cbf5397e0e596188566ad705a35d0d09bd71c41371e24f97b8c5a492aeed6acfd1d9c09550c3c58191d41fce57ddf3c6d8a1637394958ead69430ed676b8
7
+ data.tar.gz: 900f0f75ee0dc18b1a515af5ec870d38d27cd6e3a979e4f0f5ba9a17bdc5b70d1b70356b008427abd729c6e82d26ffbc79fbf092d0097c6a2e426472e2febc23
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xdelivery (0.1.3)
4
+ xdelivery (0.1.4)
5
5
  rest-client
6
6
 
7
7
  GEM
@@ -0,0 +1,53 @@
1
+ module Xdelivery
2
+ module API
3
+ class Sales < Base
4
+ include Enumerable
5
+
6
+ attr_accessor :sales
7
+
8
+ COLUMNS = [
9
+ :order_id, :recipient, :mobile, :email, :address,
10
+ :items, :warehouse_items, :total_order_amount, :cash_on_delivery, :order_created_at,
11
+ :note, :callback_url, :ref_id, :tag
12
+ ]
13
+
14
+ INVOICE_COLUMNS = [
15
+ :create_type, :email, :company_code, :donate_code, :device_id, :device, :items
16
+ ]
17
+
18
+ def add(params, invoice_params={})
19
+ self.sales ||= []
20
+ (params || {}).delete_if do |k, v|
21
+ COLUMNS.include?(k) == false
22
+ end
23
+ invoice_params.delete_if do |k, v|
24
+ INVOICE_COLUMNS.include?(k) == false
25
+ end
26
+
27
+ params.merge!(invoice: invoice_params) unless invoice_params.empty?
28
+
29
+ sales.push(params)
30
+ params
31
+ end
32
+
33
+ def [](index)
34
+ sales[index]
35
+ end
36
+
37
+ def count
38
+ sales.count
39
+ end
40
+
41
+ def create!
42
+ response = post('/sales/batch.json')
43
+ Response::Orders.new(response)
44
+ end
45
+
46
+ protected
47
+
48
+ def post_data
49
+ { import: { orders: sales } }
50
+ end
51
+ end
52
+ end
53
+ end
@@ -14,6 +14,12 @@ module Xdelivery
14
14
  api.create!
15
15
  end
16
16
 
17
+ def create_sales!
18
+ api = API::Sales.new(merchant_no, access_key)
19
+ yield(api)
20
+ api.create!
21
+ end
22
+
17
23
  def update_products!
18
24
  api = API::Products.new(merchant_no, access_key)
19
25
  yield(api)
@@ -1,3 +1,3 @@
1
1
  module Xdelivery
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/xdelivery.rb CHANGED
@@ -4,6 +4,7 @@ require "xdelivery/version"
4
4
  require "xdelivery/client"
5
5
  require "xdelivery/api/base"
6
6
  require "xdelivery/api/orders"
7
+ require "xdelivery/api/sales"
7
8
  require "xdelivery/api/products"
8
9
  require "xdelivery/api/ping"
9
10
  require "xdelivery/api/response/base"
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.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - eddie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-13 00:00:00.000000000 Z
11
+ date: 2019-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -105,6 +105,7 @@ files:
105
105
  - lib/xdelivery/api/response/orders.rb
106
106
  - lib/xdelivery/api/response/ping.rb
107
107
  - lib/xdelivery/api/response/products.rb
108
+ - lib/xdelivery/api/sales.rb
108
109
  - lib/xdelivery/client.rb
109
110
  - lib/xdelivery/version.rb
110
111
  - xdelivery-ruby.gemspec