lightspeed_restaurant 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/lib/lightspeed_restaurant/operations/create.rb +13 -5
- data/lib/lightspeed_restaurant/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56e75042c46fc74a5583e60722906e07bc755f82
|
4
|
+
data.tar.gz: 67491992739dc6b5004472eea7073a2e3e09b159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 998ec24bb48dcade87256889928a07ab3752f19cf843f2372fe8c869891615a1784215c815787947da3e0ccd1f6e8ec6f9b5fa44705906fcfd36021b326c1c98
|
7
|
+
data.tar.gz: 4225df362838635e0583e129f9a080dd54415531352e48dea5de0be46d171fc5f909af87527d332238a571ab5f251ead8268acbfd0a3b2dd36da009874f153fc
|
data/.rubocop.yml
CHANGED
@@ -3,11 +3,19 @@ module LightspeedRestaurant
|
|
3
3
|
module Create
|
4
4
|
def create(attributes)
|
5
5
|
response = LightspeedRestaurant.post(resource_path, attributes)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
payload = build_payload(attributes, response)
|
7
|
+
return new(payload) if is_a?(Class)
|
8
|
+
|
9
|
+
self.class.new(payload)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def build_payload(attributes, response)
|
15
|
+
JSON.parse(response)
|
16
|
+
rescue JSON::ParserError => error
|
17
|
+
raise error if response.to_i.zero?
|
18
|
+
attributes.merge!(id: response.to_i)
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lightspeed_restaurant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier Buffon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|