cloverrb 0.1.6 → 0.2.0

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: 5c8371361183eff941edeb79916e93c56a20097f
4
- data.tar.gz: 308530484196083a6fc5b8bd37631fa860e71f7c
3
+ metadata.gz: 8c441fba873cc8b12cf89b6868ac4ffd38d2d0db
4
+ data.tar.gz: 4495a8d769954603eba7e4fadf273b28ebcb4d9d
5
5
  SHA512:
6
- metadata.gz: bb6929b420e93fbc76c132731c47e4f221eb304c2785f0acd14c9b3068bfc0c15b64a564eb7a0135917fa12643445cdee65387b5b4bb5bb08a4c2e9ec79ded76
7
- data.tar.gz: dedadad0213c0e3575e6a4dff7e5f218eb54010815e353dc55d8c1fddb1b4a4c0d94bfda11ada60d1bf2a8775680269546d3ce738c3dfa7bcba536667497e7a1
6
+ metadata.gz: f9a677d60bb38c4b9e7ebf222faea2c9ebe1c415bacc77c99ae921ad710d7f8d1ef80f4f950b85de15ea0881e6b4fc7ab6f40307c64c6c3540ad8d5320ea8813
7
+ data.tar.gz: 5ec4ccf005d45650af5136932d602b13dd25fd4930e8163fb1419ba515b4fd2489418f072855f37f02ab199b51053dd949fafce4d02861a1309cb3860690f09c
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Code Climate](https://codeclimate.com/github/iamarmanjon/cloverrb/badges/gpa.svg)](https://codeclimate.com/github/codeclimate/codeclimate)
2
+
1
3
  # Cloverrb
2
4
 
3
5
  This is a ruby wrapper for the [Clover API - US](https://www.clover.com/api_docs/).
@@ -8,7 +8,7 @@ module Cloverrb
8
8
  def all(role=nil)
9
9
  url = "/merchants/#{@merchant_code}/employees"
10
10
  url += "?filter=role=#{role}" if role
11
- response = get(@token, url)
11
+ get(@token, url)
12
12
  end
13
13
  end
14
14
  end
@@ -8,7 +8,7 @@ module Cloverrb
8
8
 
9
9
  def all
10
10
  url = "/merchants/#{@merchant}/orders/#{@order}/line_items"
11
- response = get(@token, url)
11
+ get(@token, url)
12
12
  end
13
13
  end
14
14
  end
@@ -6,7 +6,7 @@ module Cloverrb
6
6
 
7
7
  def find(merchant_id)
8
8
  url = "/merchants/#{merchant_id}"
9
- response = get(@token, url)
9
+ get(@token, url)
10
10
  end
11
11
  end
12
12
  end
@@ -4,20 +4,33 @@ module Cloverrb
4
4
  @token = token
5
5
  end
6
6
 
7
- def all(merchant_id, start_datetime=nil, end_datetime=nil)
8
- url = "/merchants/#{merchant_id}/orders"
7
+ def all(merchant_id, options = {})
8
+ url = "/merchants/#{merchant_id}/orders?"
9
9
 
10
- if start_datetime && end_datetime
11
- url += "?filter=createdTime>=#{start_datetime}"
12
- url += "&filter=createdTime<=#{end_datetime}"
13
- end
10
+ filters = []
11
+ filters << "filter=createdTime>=#{options[:start_date]}" if has_start_date?(options)
12
+ filters << "filter=createdTime<=#{options[:end_date]}" if has_end_date?(options)
13
+ filters << "filter=state=#{options[:state]}" if has_state?(options)
14
+ url += filters.join("&")
14
15
 
15
- response = get(@token, url)
16
+ get(@token, url)
16
17
  end
17
18
 
18
19
  def self.total(line_items)
19
20
  items = line_items["elements"]
20
21
  items.inject(0) { |sum, item| sum + item["price"] }
21
22
  end
23
+
24
+ def has_start_date?(options)
25
+ options[:start_date]
26
+ end
27
+
28
+ def has_end_date?(options)
29
+ options[:end_date]
30
+ end
31
+
32
+ def has_state?(options)
33
+ options[:state]
34
+ end
22
35
  end
23
36
  end
@@ -1,3 +1,3 @@
1
1
  module Cloverrb
2
- VERSION = "0.1.6"
2
+ VERSION = "0.2.0"
3
3
  end
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.6
4
+ version: 0.2.0
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-11 00:00:00.000000000 Z
11
+ date: 2017-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler