lightspeed_restaurant 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +14 -6
- data/lib/lightspeed_restaurant.rb +16 -10
- data/lib/lightspeed_restaurant/configuration.rb +23 -0
- data/lib/lightspeed_restaurant/operations/create.rb +2 -2
- data/lib/lightspeed_restaurant/operations/destroy.rb +2 -2
- data/lib/lightspeed_restaurant/operations/find.rb +2 -2
- data/lib/lightspeed_restaurant/operations/list.rb +2 -2
- data/lib/lightspeed_restaurant/operations/save.rb +2 -2
- data/lib/lightspeed_restaurant/operations/update.rb +2 -2
- data/lib/lightspeed_restaurant/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 596bcc60f9081547e5af8933d0141a1fd1f680ccb02b01b0c4791898dab1d443
|
4
|
+
data.tar.gz: 62d3ea59ef8648f990354d1df4e4eb798a4d8c34458e3c1792819be6dcc7c859
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86d88c2ec9e4d77e0679935ac03d2225d87d1d19407abc3e949f6548aac9e6655081af53f1d7feeec92d995cf574ce83ee05e04a76ca08828e57052b9d535950
|
7
|
+
data.tar.gz: 9cd317017c26171f661b0748298ae45f72937edf48d27e534793844574347ff1b18db9756bb459c530042e7444b07d59bf01dea14f6137f0b8aa9771f41d0f11
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
[![Circle CI](https://circleci.com/gh/chronogolf/lightspeed_restaurant.svg?style=shield&circle-token=94ebc6c7495f5c0bbf9f6a89526395306f223b7e)](https://circleci.com/gh/chronogolf/lightspeed_restaurant) [![Dependency Status](https://gemnasium.com/chronogolf/lightspeed_restaurant.svg)](https://gemnasium.com/chronogolf/lightspeed_restaurant) [![Code Climate](https://codeclimate.com/github/chronogolf/lightspeed_restaurant/badges/gpa.svg)](https://codeclimate.com/github/chronogolf/lightspeed_restaurant) [![Gem Version](https://badge.fury.io/rb/lightspeed_restaurant.svg)](https://badge.fury.io/rb/lightspeed_restaurant)
|
2
|
-
|
3
1
|
# Lightspeed Restaurant API Client
|
4
2
|
|
3
|
+
[![Circle CI](https://circleci.com/gh/chronogolf/lightspeed_restaurant.svg?style=shield&circle-token=94ebc6c7495f5c0bbf9f6a89526395306f223b7e)](https://circleci.com/gh/chronogolf/lightspeed_restaurant)
|
4
|
+
[![Dependency Status](https://gemnasium.com/chronogolf/lightspeed_restaurant.svg)](https://gemnasium.com/chronogolf/lightspeed_restaurant) [![Code Climate](https://codeclimate.com/github/chronogolf/lightspeed_restaurant/badges/gpa.svg)](https://codeclimate.com/github/chronogolf/lightspeed_restaurant) [![Gem Version](https://badge.fury.io/rb/lightspeed_restaurant.svg)](https://badge.fury.io/rb/lightspeed_restaurant)
|
5
|
+
|
5
6
|
[Lightspeed Restaurant API Client](https://github.com/chronogolf/lightspeed_restaurant) is a gem for interacting with [Lightspeed Restaurant](https://www.lightspeedhq.com/products/restaurant/) API.
|
6
7
|
Lightspeed Restaurant is point of sale that helps bars, restaurants, and cafés deliver a better customer experience and run a more profitable business.
|
7
8
|
|
@@ -38,6 +39,13 @@ customer.save
|
|
38
39
|
```
|
39
40
|
That's it!
|
40
41
|
|
42
|
+
### Using a custom API configuration per action
|
43
|
+
Each action support a configuration object as the last param, allows you to setup `api_token`, `base_uri`
|
44
|
+
Sample usage:
|
45
|
+
```ruby
|
46
|
+
LightspeedRestaurantClient::Customer.all(LightspeedRestaurantClient.default_configuration.with(api_token: 'MY_OTHER_TOKEN', base_uri: 'other_ls_resto_uri'))
|
47
|
+
```
|
48
|
+
|
41
49
|
### Available operations
|
42
50
|
|
43
51
|
#### List
|
@@ -87,11 +95,11 @@ LightspeedRestaurantClient.logger = "YOUR_LOGGER"
|
|
87
95
|
Pull requests are welcome on GitHub at https://github.com/chronogolf/lightspeed_restaurant.
|
88
96
|
|
89
97
|
## About Us
|
90
|
-
[![Chronogolf][crest]](
|
98
|
+
[![Chronogolf][crest]](https://www.chronogolf.com)
|
91
99
|
|
92
|
-
[Chronogolf](
|
100
|
+
[Chronogolf](https://www.chronogolf.com)'s mission is to facilitate the interactions between golf managers and golf players. We are building software that allows golf directors to better manage their course, together with a marketplace to find & book games in real-time. We are constantly innovating and trying to challenge the status quo.
|
93
101
|
|
94
|
-
Find more informations at
|
102
|
+
Find more informations at https://pro.chronogolf.com
|
95
103
|
|
96
104
|
## Future Improvements
|
97
105
|
- Improve destroy operation to handle destroy by passing an ID (or an array of IDs)
|
@@ -102,4 +110,4 @@ Find more informations at http://www.chronogolf.com/solutions
|
|
102
110
|
|
103
111
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
104
112
|
|
105
|
-
[crest]: https://
|
113
|
+
[crest]: https://cdn2.chronogolf.com/assets/logos/Github%20-%20Header.png
|
@@ -8,6 +8,7 @@ require 'json'
|
|
8
8
|
|
9
9
|
require 'lightspeed_restaurant/version'
|
10
10
|
require 'lightspeed_restaurant/request'
|
11
|
+
require 'lightspeed_restaurant/configuration'
|
11
12
|
|
12
13
|
require 'lightspeed_restaurant/customer'
|
13
14
|
require 'lightspeed_restaurant/customer_credit_change'
|
@@ -19,26 +20,31 @@ module LightspeedRestaurantClient
|
|
19
20
|
class << self
|
20
21
|
attr_accessor :api_token, :base_uri, :logger
|
21
22
|
|
22
|
-
def
|
23
|
-
|
23
|
+
def default_configuration
|
24
|
+
Configuration.new(@api_token, @base_uri)
|
24
25
|
end
|
25
26
|
|
26
|
-
def
|
27
|
-
request(path,
|
27
|
+
def get(path, query = {}, configuration = nil)
|
28
|
+
request(path, {}, query, configuration).perform(method: :get)
|
28
29
|
end
|
29
30
|
|
30
|
-
def
|
31
|
-
request(path, body, query).perform(method: :
|
31
|
+
def post(path, body = {}, query = {}, configuration = nil)
|
32
|
+
request(path, body, query, configuration).perform(method: :post)
|
32
33
|
end
|
33
34
|
|
34
|
-
def
|
35
|
-
request(path, body, query).perform(method: :
|
35
|
+
def put(path, body = {}, query = {}, configuration = nil)
|
36
|
+
request(path, body, query, configuration).perform(method: :put)
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete(path, query = {}, configuration = nil)
|
40
|
+
request(path, {}, query, configuration).perform(method: :delete)
|
36
41
|
end
|
37
42
|
|
38
43
|
private
|
39
44
|
|
40
|
-
def request(path, body, query)
|
41
|
-
|
45
|
+
def request(path, body, query, configuration = nil)
|
46
|
+
configuration ||= default_configuration
|
47
|
+
Request.new(configuration.base_uri, path, configuration.api_token, body, query, @logger)
|
42
48
|
end
|
43
49
|
end
|
44
50
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LightspeedRestaurantClient
|
4
|
+
class Configuration
|
5
|
+
attr_reader :api_token, :base_uri
|
6
|
+
|
7
|
+
def initialize(api_token, base_uri)
|
8
|
+
@api_token = api_token
|
9
|
+
@base_uri = base_uri
|
10
|
+
end
|
11
|
+
|
12
|
+
def with(attributes)
|
13
|
+
attributes_with_string_keys = {}
|
14
|
+
attributes.dup.each_pair do |name, value|
|
15
|
+
attributes_with_string_keys[name.to_s] = value
|
16
|
+
end
|
17
|
+
self.class.new(
|
18
|
+
attributes_with_string_keys.fetch('api_token', api_token),
|
19
|
+
attributes_with_string_keys.fetch('base_uri', base_uri)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module LightspeedRestaurantClient
|
4
4
|
module Operations
|
5
5
|
module Create
|
6
|
-
def create(attributes)
|
7
|
-
response = LightspeedRestaurantClient.post(resource_path, attributes)
|
6
|
+
def create(attributes, configuration = nil)
|
7
|
+
response = LightspeedRestaurantClient.post(resource_path, attributes, {}, configuration)
|
8
8
|
payload = build_payload(attributes, response)
|
9
9
|
return new(payload) if is_a?(Class)
|
10
10
|
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module LightspeedRestaurantClient
|
4
4
|
module Operations
|
5
5
|
module Destroy
|
6
|
-
def destroy
|
7
|
-
JSON.parse(LightspeedRestaurantClient.delete(self.class.resource_path + "/#{id}"))
|
6
|
+
def destroy(configuration = nil)
|
7
|
+
JSON.parse(LightspeedRestaurantClient.delete(self.class.resource_path + "/#{id}", {}, configuration))
|
8
8
|
self
|
9
9
|
end
|
10
10
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module LightspeedRestaurantClient
|
4
4
|
module Operations
|
5
5
|
module Find
|
6
|
-
def find(id)
|
7
|
-
response = JSON.parse(LightspeedRestaurantClient.get(resource_path + "/#{id}"))
|
6
|
+
def find(id, configuration = nil)
|
7
|
+
response = JSON.parse(LightspeedRestaurantClient.get(resource_path + "/#{id}", {}, configuration))
|
8
8
|
new(response)
|
9
9
|
end
|
10
10
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module LightspeedRestaurantClient
|
4
4
|
module Operations
|
5
5
|
module List
|
6
|
-
def list(params = {})
|
7
|
-
response = JSON.parse(LightspeedRestaurantClient.get(resource_path,
|
6
|
+
def list(params = {}, configuration = nil)
|
7
|
+
response = JSON.parse(LightspeedRestaurantClient.get(resource_path, params, configuration))
|
8
8
|
results = response.is_a?(Array) ? response : response['results']
|
9
9
|
instantiate(results)
|
10
10
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module LightspeedRestaurantClient
|
4
4
|
module Operations
|
5
5
|
module Save
|
6
|
-
def save
|
7
|
-
LightspeedRestaurantClient.put(self.class.resource_path + "/#{id}", self)
|
6
|
+
def save(configuration = nil)
|
7
|
+
LightspeedRestaurantClient.put(self.class.resource_path + "/#{id}", self, {}, configuration)
|
8
8
|
self
|
9
9
|
end
|
10
10
|
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
module LightspeedRestaurantClient
|
4
4
|
module Operations
|
5
5
|
module Update
|
6
|
-
def update(id, attributes)
|
6
|
+
def update(id, attributes, configuration = nil)
|
7
7
|
updated_object = new(attributes)
|
8
|
-
LightspeedRestaurantClient.put(resource_path + "/#{id}", updated_object)
|
8
|
+
LightspeedRestaurantClient.put(resource_path + "/#{id}", updated_object, {}, configuration)
|
9
9
|
updated_object
|
10
10
|
end
|
11
11
|
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:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier Buffon, Laurent Cobos, Sybil Deboin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- lib/lightspeed_restaurant.rb
|
190
190
|
- lib/lightspeed_restaurant/base.rb
|
191
191
|
- lib/lightspeed_restaurant/company.rb
|
192
|
+
- lib/lightspeed_restaurant/configuration.rb
|
192
193
|
- lib/lightspeed_restaurant/customer.rb
|
193
194
|
- lib/lightspeed_restaurant/customer_credit_change.rb
|
194
195
|
- lib/lightspeed_restaurant/customer_loyalty_card.rb
|