lightspeed_restaurant 3.1.0 → 3.3.3

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
  SHA256:
3
- metadata.gz: 83e2c9e1ba5994e82fea005d149d07846a9e7f41c7f2b74b3e45cd42d33f588a
4
- data.tar.gz: f6b362e9068216fff247bcb6365bafa8dcd68ead0615cdaf1a8949ef81101c4b
3
+ metadata.gz: 340ce0c747aaa516dc5c4bbed52c1842c138ecc4d6777e953a41ae649b1a60b1
4
+ data.tar.gz: 975aedc38edeba28cde45a90d07833e6c34a58578444e948bb424b20dc0a68ca
5
5
  SHA512:
6
- metadata.gz: aaf589b90f0612e6488a42baeedcb37a83dbbb740b626ec3bf81c03978158747fe96b42ad44af3b26c4e455364bd082a3780c3482963440dd2df10ab5879fcc5
7
- data.tar.gz: e0945deffe64bca611cb82b2299b199cf6e4185c085a8a38911530f8975123c4730ff40279a4f512b21cbf3386555df911ee0ec645f42d9831922d621d1e7cc9
6
+ metadata.gz: d057e14d22367a2ee8882b8e1dc3d2b3baff505e68867e6747e3e53b37844742c490e1844c8094636681d039992de64f0f9bd7e82c447ee43be459c8a6b0478e
7
+ data.tar.gz: c7a1262ea1ef6fd00cc99be0815bcd9c84b45c4e2a62aef103f38c20c1d1b5153fb8cb8b721b8da6ce42d36add021fc38b8c15733f6e1bc5e3da44a6cfe45565
@@ -0,0 +1,66 @@
1
+ name: CI
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ tests:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby: [2.6]
11
+
12
+ steps:
13
+ - uses: actions/checkout@master
14
+
15
+ - name: Set up the Ruby version
16
+ uses: actions/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+
20
+ - name: Ruby gem cache
21
+ uses: actions/cache@v1
22
+ with:
23
+ path: vendor/bundle
24
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
25
+ restore-keys: |
26
+ ${{ runner.os }}-gems-
27
+
28
+ - name: Set up the environment
29
+ run: |
30
+ gem install bundler
31
+ bundle config path vendor/bundle
32
+ bundle install --jobs 4 --retry 3
33
+
34
+ - name: Runs tests
35
+ run: bundle exec rspec
36
+
37
+ rubocop:
38
+ runs-on: ubuntu-latest
39
+ strategy:
40
+ matrix:
41
+ ruby: [2.6]
42
+
43
+ steps:
44
+ - uses: actions/checkout@master
45
+
46
+ - name: Set up the Ruby version
47
+ uses: actions/setup-ruby@v1
48
+ with:
49
+ ruby-version: ${{ matrix.ruby }}
50
+
51
+ - name: Ruby gem cache
52
+ uses: actions/cache@v1
53
+ with:
54
+ path: vendor/bundle
55
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
56
+ restore-keys: |
57
+ ${{ runner.os }}-gems-
58
+
59
+ - name: Set up the environment
60
+ run: |
61
+ gem install bundler
62
+ bundle config path vendor/bundle
63
+ bundle install --jobs 4 --retry 3
64
+
65
+ - name: Runs Rubocop
66
+ run: bundle exec rubocop
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  /vendor/
11
11
  /.idea/
12
+ .DS_Store
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  require: rubocop-rspec
2
2
 
3
- Metrics/LineLength:
4
- Max: 120
3
+ Layout/LineLength:
4
+ Max: 100
5
5
 
6
6
  Metrics/ParameterLists:
7
7
  Max: 6
@@ -21,7 +21,7 @@ Metrics/BlockLength:
21
21
  Exclude:
22
22
  - spec/**/*
23
23
 
24
- Lint/HandleExceptions:
24
+ Lint/SuppressedException:
25
25
  Enabled: false
26
26
 
27
27
  RSpec/MultipleExpectations:
@@ -51,6 +51,3 @@ Style/PercentLiteralDelimiters:
51
51
  Metrics/ClassLength:
52
52
  Max: 200
53
53
  Severity: warning
54
-
55
- HttpPositionalArguments:
56
- Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.6.2
1
+ ruby-2.6.5
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## 3.3.3 / 2021-04-08
4
+
5
+ - Add `find` endpoint for the company
6
+
7
+ ## 3.3.2 / 2020-03-20
8
+
9
+ - Fix CVE-2020-10663 (Update JSON dependency to 2.3)
10
+
11
+ ## 3.3.1 / 2020-02-24
12
+
13
+ - Introducing `RateLimitError` when status code is `429`
14
+
15
+ ## 3.2.0 / 2019-12-17
16
+
17
+ - Fix CVE-2019-16779
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Lightspeed Restaurant API Client
2
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)
3
+ [![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
4
 
6
5
  [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.
7
6
  Lightspeed Restaurant is point of sale that helps bars, restaurants, and cafés deliver a better customer experience and run a more profitable business.
@@ -5,6 +5,7 @@ require 'lightspeed_restaurant/operations/list'
5
5
 
6
6
  module LightspeedRestaurantClient
7
7
  class Company < LightspeedRestaurantClient::Base
8
+ extend Operations::Find
8
9
  extend Operations::List
9
10
 
10
11
  def self.resource_name
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LightspeedRestaurantClient
4
+ class RateLimitError < LightspeedRestaurantClientError
5
+ end
6
+ end
@@ -4,21 +4,22 @@ module LightspeedRestaurantClient
4
4
  module Operations
5
5
  module Create
6
6
  def create(attributes, configuration = nil)
7
- response = LightspeedRestaurantClient.post(default_resource_path, attributes, {}, configuration)
8
- payload = build_payload(attributes, response)
9
- return new(payload) if is_a?(Class)
7
+ response = JSON.parse(LightspeedRestaurantClient.post(default_resource_path, attributes, {}, configuration))
8
+ response = handle_create_response(response, attributes)
9
+ return new(response) if is_a?(Class)
10
10
 
11
- self.class.new(payload)
11
+ self.class.new(response)
12
12
  end
13
13
 
14
14
  private
15
15
 
16
- def build_payload(attributes, response)
17
- JSON.parse(response)
18
- rescue JSON::ParserError => error
19
- raise error if response.to_i.zero?
20
-
21
- attributes.merge!(id: response.to_i)
16
+ def handle_create_response(response, attributes)
17
+ case response
18
+ when Numeric
19
+ attributes.merge(id: response)
20
+ else
21
+ response
22
+ end
22
23
  end
23
24
  end
24
25
  end
@@ -5,8 +5,8 @@ module LightspeedRestaurantClient
5
5
  module List
6
6
  def list(params = {}, configuration = nil)
7
7
  response = JSON.parse(LightspeedRestaurantClient.get(resource_path, params, configuration))
8
- results = response.is_a?(Array) ? response : response['results']
9
- instantiate(results)
8
+ response = handle_list_response(response)
9
+ instantiate(response)
10
10
  end
11
11
  alias all list
12
12
 
@@ -16,6 +16,15 @@ module LightspeedRestaurantClient
16
16
  respond_to?(:list_resource_path) ? list_resource_path : default_resource_path
17
17
  end
18
18
 
19
+ def handle_list_response(response)
20
+ case response
21
+ when Hash
22
+ response['results']
23
+ else
24
+ response
25
+ end
26
+ end
27
+
19
28
  def instantiate(records)
20
29
  records.map do |record|
21
30
  is_a?(Class) ? new(record) : self.class.new(record)
@@ -5,12 +5,17 @@ require 'lightspeed_restaurant/errors/api_error'
5
5
  require 'lightspeed_restaurant/errors/authentication_error'
6
6
  require 'lightspeed_restaurant/errors/invalid_request_error'
7
7
  require 'lightspeed_restaurant/errors/not_found_error'
8
+ require 'lightspeed_restaurant/errors/rate_limit_error'
8
9
  require 'uri'
9
10
 
10
11
  module LightspeedRestaurantClient
11
12
  class Request
13
+ STAGING_URL = 'http://staging-integration.posios.com'
14
+
15
+ attr_reader :base_uri, :path, :token, :body, :headers, :query, :logger, :connection
16
+
12
17
  def initialize(base_uri, path, token, body = {}, query = {}, logger = nil)
13
- @base_uri = base_uri || 'http://staging-integration.posios.com'
18
+ @base_uri = base_uri || STAGING_URL
14
19
  @headers = { 'Content-Type' => 'application/json', 'X-Auth-Token' => token }
15
20
  @body = body.to_json
16
21
  @query = query
@@ -24,7 +29,7 @@ module LightspeedRestaurantClient
24
29
 
25
30
  def perform(**args)
26
31
  log_request(args[:method])
27
- response = @connection.request(args.merge(path: @path, headers: @headers, body: @body, query: @query))
32
+ response = connection.request(args.merge(path: path, headers: headers, body: body, query: query))
28
33
  if [200, 201].include?(response.status)
29
34
  response.body
30
35
  else
@@ -35,13 +40,13 @@ module LightspeedRestaurantClient
35
40
  private
36
41
 
37
42
  def log_request(http_method)
38
- @logger.info('request') do
39
- "#{http_method} #{@base_uri}#{@path} : #{@query} - #{@body}"
43
+ logger.info('request') do
44
+ "#{http_method} #{base_uri}#{path} : #{query} - #{body}"
40
45
  end
41
46
  end
42
47
 
43
48
  def handle_error(response)
44
- @logger.error('response') { "Error : #{response.status} #{response.body}" }
49
+ logger.error('response') { "Error : #{response.status} #{response.body}" }
45
50
  case response.status
46
51
  when 400
47
52
  raise invalid_request_error(response)
@@ -51,6 +56,8 @@ module LightspeedRestaurantClient
51
56
  raise unauthorized_error(response)
52
57
  when 404
53
58
  raise not_found_error(response)
59
+ when 429
60
+ raise rate_limit_error(response)
54
61
  else
55
62
  raise response_object_error(response)
56
63
  end
@@ -66,17 +73,22 @@ module LightspeedRestaurantClient
66
73
 
67
74
  def response_object_error(response)
68
75
  APIError.new("Invalid response object from API: #{JSON.parse(response.body)['description']}",
69
- response.status, response.body, response.headers)
76
+ response.status, response.body, response.headers)
70
77
  end
71
78
 
72
79
  def invalid_request_error(response)
73
80
  InvalidRequestError.new(JSON.parse(response.body)['description'],
74
- response.status, response.body, response.headers)
81
+ response.status, response.body, response.headers)
75
82
  end
76
83
 
77
84
  def authentication_error(response)
78
85
  AuthenticationError.new(JSON.parse(response.body)['description'],
79
- response.status, response.body, response.headers)
86
+ response.status, response.body, response.headers)
87
+ end
88
+
89
+ def rate_limit_error(response)
90
+ RateLimitError.new(JSON.parse(response.body)['description'],
91
+ response.status, response.body, response.headers)
80
92
  end
81
93
  end
82
94
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LightspeedRestaurantClient
4
- VERSION = '3.1.0'
4
+ VERSION = '3.3.3'
5
5
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ['developers@chronogolf.com']
12
12
 
13
13
  spec.summary = 'Ruby bindings for the Lightspeed Restaurant API'
14
- spec.description = 'Lightspeed Restaurant is point of sale that helps bars, restaurants, '\
14
+ spec.description = 'Lightspeed Restaurant is a Point Of Sale that helps bars, restaurants, '\
15
15
  'and cafés deliver a better customer experience and run a more profitable business. '\
16
16
  'See https://www.lightspeedhq.com/products/restaurant/ for details'
17
17
  spec.homepage = 'https://github.com/chronogolf/lightspeed_restaurant'
@@ -22,14 +22,12 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_dependency('excon', '~> 0.62.0')
26
- spec.add_dependency('json', '~> 1.8.3')
25
+ spec.add_dependency('excon', '~> 0.71.0')
26
+ spec.add_dependency('json', '~> 2.3')
27
27
 
28
- spec.add_development_dependency('bundler-audit')
29
28
  spec.add_development_dependency('pry')
30
29
  spec.add_development_dependency('rake')
31
30
  spec.add_development_dependency('rspec')
32
- spec.add_development_dependency('rspec_junit_formatter')
33
31
  spec.add_development_dependency('rubocop')
34
32
  spec.add_development_dependency('rubocop-rspec')
35
33
  spec.add_development_dependency('vcr')
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: 3.1.0
4
+ version: 3.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Buffon, Laurent Cobos, Sybil Deboin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-15 00:00:00.000000000 Z
11
+ date: 2021-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -16,42 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.62.0
19
+ version: 0.71.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.62.0
26
+ version: 0.71.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.8.3
33
+ version: '2.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.8.3
41
- - !ruby/object:Gem::Dependency
42
- name: bundler-audit
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: '2.3'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: pry
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,20 +80,6 @@ dependencies:
94
80
  - - ">="
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rspec_junit_formatter
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
83
  - !ruby/object:Gem::Dependency
112
84
  name: rubocop
113
85
  requirement: !ruby/object:Gem::Requirement
@@ -164,7 +136,7 @@ dependencies:
164
136
  - - ">="
165
137
  - !ruby/object:Gem::Version
166
138
  version: '0'
167
- description: Lightspeed Restaurant is point of sale that helps bars, restaurants,
139
+ description: Lightspeed Restaurant is a Point Of Sale that helps bars, restaurants,
168
140
  and cafés deliver a better customer experience and run a more profitable business.
169
141
  See https://www.lightspeedhq.com/products/restaurant/ for details
170
142
  email:
@@ -173,19 +145,19 @@ executables: []
173
145
  extensions: []
174
146
  extra_rdoc_files: []
175
147
  files:
148
+ - ".github/workflows/ci.yml"
176
149
  - ".gitignore"
177
150
  - ".rspec"
178
151
  - ".rubocop.yml"
179
152
  - ".ruby-gemset"
180
153
  - ".ruby-version"
181
- - ".travis.yml"
154
+ - CHANGELOG.md
182
155
  - Gemfile
183
156
  - LICENSE.txt
184
157
  - README.md
185
158
  - Rakefile
186
159
  - bin/console
187
160
  - bin/setup
188
- - circle.yml
189
161
  - lib/lightspeed_restaurant.rb
190
162
  - lib/lightspeed_restaurant/base.rb
191
163
  - lib/lightspeed_restaurant/company.rb
@@ -199,6 +171,7 @@ files:
199
171
  - lib/lightspeed_restaurant/errors/invalid_request_error.rb
200
172
  - lib/lightspeed_restaurant/errors/lightspeed_restaurant_error.rb
201
173
  - lib/lightspeed_restaurant/errors/not_found_error.rb
174
+ - lib/lightspeed_restaurant/errors/rate_limit_error.rb
202
175
  - lib/lightspeed_restaurant/errors/unauthorized_error.rb
203
176
  - lib/lightspeed_restaurant/operations/create.rb
204
177
  - lib/lightspeed_restaurant/operations/destroy.rb
@@ -217,7 +190,7 @@ homepage: https://github.com/chronogolf/lightspeed_restaurant
217
190
  licenses:
218
191
  - MIT
219
192
  metadata: {}
220
- post_install_message:
193
+ post_install_message:
221
194
  rdoc_options: []
222
195
  require_paths:
223
196
  - lib
@@ -233,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
206
  version: '0'
234
207
  requirements: []
235
208
  rubygems_version: 3.0.3
236
- signing_key:
209
+ signing_key:
237
210
  specification_version: 4
238
211
  summary: Ruby bindings for the Lightspeed Restaurant API
239
212
  test_files: []
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.6.2
4
- before_install: gem install bundler -v 2.0.1
data/circle.yml DELETED
@@ -1,10 +0,0 @@
1
- machine:
2
- timezone:
3
- America/New_York
4
- environment:
5
- RACK_ENV: test
6
- test:
7
- override:
8
- - bundle exec bundle-audit check --update
9
- - bundle exec rubocop
10
- - bundle exec rspec --format RspecJunitFormatter --out $CIRCLE_TEST_REPORTS/junit/rspec.xml --format progress