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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be21149b7c665bad2dfa1c2895724be5788114e80a49731a24565ea2462cb595
4
- data.tar.gz: 545ab4f1484b34940b49c3243ba250b41c9be9c07382332611339e01d7f08e53
3
+ metadata.gz: 596bcc60f9081547e5af8933d0141a1fd1f680ccb02b01b0c4791898dab1d443
4
+ data.tar.gz: 62d3ea59ef8648f990354d1df4e4eb798a4d8c34458e3c1792819be6dcc7c859
5
5
  SHA512:
6
- metadata.gz: eeec7eee4a78fc0405f80dace6126e05bdde90fb1c7b5a011d2c79cb34d6217c04246dbbc18e571384984a05de19f22628af467614b45db4da5a8a9aac49c6c0
7
- data.tar.gz: e79a49317522eb218c5d2be6b1a519c66962e0f7a1aaccbe0ae06bb0bf70427b777c52bfc15eb2b58d242db9ac2c675b9cd1d51fb2e32b9909381950c6a9089c
6
+ metadata.gz: 86d88c2ec9e4d77e0679935ac03d2225d87d1d19407abc3e949f6548aac9e6655081af53f1d7feeec92d995cf574ce83ee05e04a76ca08828e57052b9d535950
7
+ data.tar.gz: 9cd317017c26171f661b0748298ae45f72937edf48d27e534793844574347ff1b18db9756bb459c530042e7444b07d59bf01dea14f6137f0b8aa9771f41d0f11
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.1
3
+ - 2.5.1
4
4
  before_install: gem install bundler -v 1.10.6
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]](http://www.chronogolf.com)
98
+ [![Chronogolf][crest]](https://www.chronogolf.com)
91
99
 
92
- [Chronogolf](http://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.
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 http://www.chronogolf.com/solutions
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://d2gn4xht817m0g.cloudfront.net/p/product_screenshots/images/original/000/614/797/614797-f3db0c404af118f18f765c51e9be9a44dda57875.png?1447183798
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 get(path, body = {}, query = {})
23
- request(path, body, query).perform(method: :get)
23
+ def default_configuration
24
+ Configuration.new(@api_token, @base_uri)
24
25
  end
25
26
 
26
- def post(path, body = {}, query = {})
27
- request(path, body, query).perform(method: :post)
27
+ def get(path, query = {}, configuration = nil)
28
+ request(path, {}, query, configuration).perform(method: :get)
28
29
  end
29
30
 
30
- def put(path, body = {}, query = {})
31
- request(path, body, query).perform(method: :put)
31
+ def post(path, body = {}, query = {}, configuration = nil)
32
+ request(path, body, query, configuration).perform(method: :post)
32
33
  end
33
34
 
34
- def delete(path, body = {}, query = {})
35
- request(path, body, query).perform(method: :delete)
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
- Request.new(@base_uri, path, @api_token, body, query, @logger)
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, {}, params))
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LightspeedRestaurantClient
4
- VERSION = '2.0.0'
4
+ VERSION = '3.0.0'
5
5
  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: 2.0.0
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: 2018-07-09 00:00:00.000000000 Z
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