cloverrb 0.1.4 → 0.1.6

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
  SHA1:
3
- metadata.gz: f95037dcc59859796be6c92e82ae5f77e922b77c
4
- data.tar.gz: 18fa345148011de92a67b4b623e032c8aa372d25
3
+ metadata.gz: 5c8371361183eff941edeb79916e93c56a20097f
4
+ data.tar.gz: 308530484196083a6fc5b8bd37631fa860e71f7c
5
5
  SHA512:
6
- metadata.gz: 73fca4319d5eb4fc1fd8796035abce831d392f423d89524bce892af13768daf1cdbf95d310a49280305dbfc7f618358689775c84462523189461580196e0724f
7
- data.tar.gz: c43129e86b25d27b532cc7e243afb78494aefc0b867dadb97896e723c579e8a4af9a8c1043cfc60e2cd3b27f2384b959dc5618a630db59095bf23e24dac0bf8c
6
+ metadata.gz: bb6929b420e93fbc76c132731c47e4f221eb304c2785f0acd14c9b3068bfc0c15b64a564eb7a0135917fa12643445cdee65387b5b4bb5bb08a4c2e9ec79ded76
7
+ data.tar.gz: dedadad0213c0e3575e6a4dff7e5f218eb54010815e353dc55d8c1fddb1b4a4c0d94bfda11ada60d1bf2a8775680269546d3ce738c3dfa7bcba536667497e7a1
data/README.md CHANGED
@@ -38,6 +38,38 @@ Or install it yourself as:
38
38
  employees_client.all(merchant_id)
39
39
  ```
40
40
 
41
+ ### Order
42
+ > Get a list of orders of a specific merchant
43
+ ```ruby
44
+ order_client = Cloverrb::Order(token)
45
+ orders = order_client.all(merchant_id
46
+ ```
47
+
48
+ > Get the total order amount for a line items
49
+ ```ruby
50
+ line_items_client = Cloverrb::LineItem.new(token, order_id, merchant_id)
51
+ line_items = line_items_client.all
52
+ total = described_class.total(line_items)
53
+ ```
54
+
55
+ > Get a list of orders from a specific timeframe
56
+ ```ruby
57
+ order_client = Cloverrb::Order(token)
58
+ orders = order_client.all(merchant_id, start_date, end_date)
59
+ ```
60
+ Note: `start_date` and `end_date` must be in milliseconds.
61
+ Example:
62
+ ```
63
+ "June 15, 2017 8:00am".to_time.to_i * 1000
64
+ ```
65
+
66
+ ### Line Item
67
+ > Get a list of line items for a specific order
68
+ ```ruby
69
+ line_item_client = Cloverrb::LineItem(token, order_id, merchant_id)
70
+ line_items = line_item_client.all
71
+ ```
72
+
41
73
  ## Contributing
42
74
 
43
75
  Bug reports and pull requests are welcome on GitHub at https://github.com/iamarmanjon/cloverrb.
@@ -0,0 +1,14 @@
1
+ module Cloverrb
2
+ class LineItem < Client
3
+ def initialize(token, order, merchant)
4
+ @token = token
5
+ @order = order
6
+ @merchant = merchant
7
+ end
8
+
9
+ def all
10
+ url = "/merchants/#{@merchant}/orders/#{@order}/line_items"
11
+ response = get(@token, url)
12
+ end
13
+ end
14
+ end
@@ -14,5 +14,10 @@ module Cloverrb
14
14
 
15
15
  response = get(@token, url)
16
16
  end
17
+
18
+ def self.total(line_items)
19
+ items = line_items["elements"]
20
+ items.inject(0) { |sum, item| sum + item["price"] }
21
+ end
17
22
  end
18
23
  end
@@ -1,3 +1,3 @@
1
1
  module Cloverrb
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.6"
3
3
  end
data/lib/cloverrb.rb CHANGED
@@ -7,6 +7,7 @@ require_relative "cloverrb/client"
7
7
  require_relative "cloverrb/merchant"
8
8
  require_relative "cloverrb/employee"
9
9
  require_relative "cloverrb/order"
10
+ require_relative "cloverrb/line_item"
10
11
 
11
12
  module Cloverrb
12
13
  # Your code goes here...
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloverrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arman Jon Villalobos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-10 00:00:00.000000000 Z
11
+ date: 2017-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -155,6 +155,7 @@ files:
155
155
  - lib/cloverrb.rb
156
156
  - lib/cloverrb/client.rb
157
157
  - lib/cloverrb/employee.rb
158
+ - lib/cloverrb/line_item.rb
158
159
  - lib/cloverrb/merchant.rb
159
160
  - lib/cloverrb/order.rb
160
161
  - lib/cloverrb/version.rb