lightspeed_restaurant 1.1.2 → 2.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
- SHA1:
3
- metadata.gz: aa8b609368b750f359883afec36d740604a012fa
4
- data.tar.gz: eb514c7033c4e7770f2ce1f62be7dc645cf296c6
2
+ SHA256:
3
+ metadata.gz: be21149b7c665bad2dfa1c2895724be5788114e80a49731a24565ea2462cb595
4
+ data.tar.gz: 545ab4f1484b34940b49c3243ba250b41c9be9c07382332611339e01d7f08e53
5
5
  SHA512:
6
- metadata.gz: ee0076a606539411582588121df6ef017d863eccecc5336428448e485dace47700ca08005d7850a90975cfed2de1405fc75b2b8d984f0a78d3dc225dd2dd8d94
7
- data.tar.gz: 68355cf483fc08fe3648cf473fbb56b9c152533b7d90116ff71e073237526e32314c2366d1ee3d1cdee1704f80b852a00f5c5c4dc51467c590c182529b9d4e0a
6
+ metadata.gz: eeec7eee4a78fc0405f80dace6126e05bdde90fb1c7b5a011d2c79cb34d6217c04246dbbc18e571384984a05de19f22628af467614b45db4da5a8a9aac49c6c0
7
+ data.tar.gz: e79a49317522eb218c5d2be6b1a519c66962e0f7a1aaccbe0ae06bb0bf70427b777c52bfc15eb2b58d242db9ac2c675b9cd1d51fb2e32b9909381950c6a9089c
data/.rubocop.yml CHANGED
@@ -1,15 +1,56 @@
1
+ require: rubocop-rspec
2
+
1
3
  Metrics/LineLength:
2
4
  Max: 120
3
5
 
6
+ Metrics/ParameterLists:
7
+ Max: 6
8
+
4
9
  Metrics/MethodLength:
5
- Max: 20
10
+ Max: 15
11
+
12
+ Style/StringLiterals:
13
+ EnforcedStyle: single_quotes
14
+ SupportedStyles:
15
+ - single_quotes
16
+ - double_quotes
17
+ ConsistentQuotesInMultiline: false
6
18
 
7
19
  Metrics/BlockLength:
20
+ Severity: warning
8
21
  Exclude:
9
- - 'spec/**/*'
22
+ - spec/**/*
23
+
24
+ Lint/HandleExceptions:
25
+ Enabled: false
26
+
27
+ RSpec/MultipleExpectations:
28
+ Max: 3
29
+
30
+ Security/YAMLLoad:
31
+ Enabled: false
10
32
 
11
33
  Style/Documentation:
12
- Exclude:
13
- - 'spec/**/*'
14
- - 'test/**/*'
15
- - 'lib/**/*'
34
+ Enabled: false
35
+
36
+ Layout/MultilineMethodCallIndentation:
37
+ Enabled: false
38
+
39
+ Style/ClassAndModuleChildren:
40
+ Enabled: false
41
+
42
+ Style/PercentLiteralDelimiters:
43
+ PreferredDelimiters:
44
+ default: ()
45
+ '%i': '[]'
46
+ '%I': '[]'
47
+ '%r': '{}'
48
+ '%w': '[]'
49
+ '%W': '[]'
50
+
51
+ Metrics/ClassLength:
52
+ Max: 200
53
+ Severity: warning
54
+
55
+ HttpPositionalArguments:
56
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.8
1
+ ruby-2.5.1
data/Gemfile CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  gemspec
data/README.md CHANGED
@@ -74,6 +74,14 @@ customer = LightspeedRestaurantClient::Customer.find(123)
74
74
  customer.destroy
75
75
  ```
76
76
 
77
+ ### Logs
78
+
79
+ By default the logs are done on STDOUT.
80
+ You can specify your own logger (it has to respond to info and error methods, like the Rails logger) :
81
+ ```ruby
82
+ LightspeedRestaurantClient.logger = "YOUR_LOGGER"
83
+ ```
84
+
77
85
  ## Contributing
78
86
 
79
87
  Pull requests are welcome on GitHub at https://github.com/chronogolf/lightspeed_restaurant.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'lightspeed_restaurant'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Lightspeed Restaurant Ruby Bindings
2
4
  # API spec at http://stating-integration.posios.com/PosServer/swagger-ui.html
3
5
 
@@ -15,7 +17,7 @@ require 'lightspeed_restaurant/company'
15
17
 
16
18
  module LightspeedRestaurantClient
17
19
  class << self
18
- attr_accessor :api_token, :base_uri
20
+ attr_accessor :api_token, :base_uri, :logger
19
21
 
20
22
  def get(path, body = {}, query = {})
21
23
  request(path, body, query).perform(method: :get)
@@ -36,7 +38,7 @@ module LightspeedRestaurantClient
36
38
  private
37
39
 
38
40
  def request(path, body, query)
39
- Request.new(@base_uri, path, @api_token, body, query)
41
+ Request.new(@base_uri, path, @api_token, body, query, @logger)
40
42
  end
41
43
  end
42
44
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  class Base
3
5
  def initialize(data = {})
@@ -16,8 +18,8 @@ module LightspeedRestaurantClient
16
18
 
17
19
  private
18
20
 
19
- def convert_to_obj(h)
20
- h.each do |key, value|
21
+ def convert_to_obj(hash)
22
+ hash.each do |key, value|
21
23
  self.class.send(:attr_accessor, key)
22
24
  instance_variable_set("@#{key}", value)
23
25
  convert_to_obj(value) if value.is_a? Hash
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lightspeed_restaurant/base'
2
4
  require 'lightspeed_restaurant/operations/list'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lightspeed_restaurant/base'
2
4
  require 'lightspeed_restaurant/operations/list'
3
5
  require 'lightspeed_restaurant/operations/find'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lightspeed_restaurant/base'
2
4
  require 'lightspeed_restaurant/operations/list'
3
5
  require 'lightspeed_restaurant/operations/create'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lightspeed_restaurant/base'
2
4
  require 'lightspeed_restaurant/operations/create'
3
5
  require 'lightspeed_restaurant/operations/list'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  class APIError < LightspeedRestaurantClientError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  class AuthenticationError < LightspeedRestaurantClientError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  class InvalidRequestError < LightspeedRestaurantClientError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  class LightspeedRestaurantClientError < StandardError
3
5
  attr_reader :message
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  class NotFoundError < LightspeedRestaurantClientError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  class UnauthorizedError < LightspeedRestaurantClientError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  module Operations
3
5
  module Create
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  module Operations
3
5
  module Destroy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  module Operations
3
5
  module Find
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  module Operations
3
5
  module List
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  module Operations
3
5
  module Save
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
4
  module Operations
3
5
  module Update
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lightspeed_restaurant/base'
2
4
  require 'lightspeed_restaurant/operations/list'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lightspeed_restaurant/errors/lightspeed_restaurant_error'
2
4
  require 'lightspeed_restaurant/errors/api_error'
3
5
  require 'lightspeed_restaurant/errors/authentication_error'
@@ -7,16 +9,21 @@ require 'uri'
7
9
 
8
10
  module LightspeedRestaurantClient
9
11
  class Request
10
- def initialize(base_uri, path, token, body = {}, query = {})
11
- @base_uri = base_uri || 'http://stating-integration.posios.com'
12
+ def initialize(base_uri, path, token, body = {}, query = {}, logger = nil)
13
+ @base_uri = base_uri || 'http://staging-integration.posios.com'
12
14
  @headers = { 'Content-Type' => 'application/json', 'X-Auth-Token' => token }
13
15
  @body = body.to_json
14
16
  @query = query
15
17
  @path = '/PosServer' + path
16
18
  @connection = Excon.new(@base_uri)
19
+ @logger = logger || begin
20
+ require 'logger'
21
+ ::Logger.new($stdout)
22
+ end
17
23
  end
18
24
 
19
25
  def perform(**args)
26
+ log_request(args[:method])
20
27
  response = @connection.request(args.merge(path: @path, headers: @headers, body: @body, query: @query))
21
28
  if [200, 201].include?(response.status)
22
29
  response.body
@@ -27,7 +34,14 @@ module LightspeedRestaurantClient
27
34
 
28
35
  private
29
36
 
37
+ def log_request(http_method)
38
+ @logger.info('request') do
39
+ "#{http_method} #{@base_uri}#{@path} : #{@query} - #{@body}"
40
+ end
41
+ end
42
+
30
43
  def handle_error(response)
44
+ @logger.error('response') { "Error : #{response.status} #{response.body}" }
31
45
  case response.status
32
46
  when 400
33
47
  raise invalid_request_error(response)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LightspeedRestaurantClient
2
- VERSION = '1.1.2'.freeze
4
+ VERSION = '2.0.0'
3
5
  end
@@ -1,11 +1,13 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'lightspeed_restaurant/version'
4
6
 
5
7
  Gem::Specification.new do |spec|
6
8
  spec.name = 'lightspeed_restaurant'
7
9
  spec.version = LightspeedRestaurantClient::VERSION
8
- spec.authors = ['Olivier Buffon']
10
+ spec.authors = ['Olivier Buffon, Laurent Cobos, Sybil Deboin']
9
11
  spec.email = ['olivier@chronogolf.ca']
10
12
 
11
13
  spec.summary = 'Ruby bindings for the Lightspeed Restaurant API'
@@ -20,7 +22,7 @@ Gem::Specification.new do |spec|
20
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
23
  spec.require_paths = ['lib']
22
24
 
23
- spec.add_dependency('excon', '~> 0.45.4')
25
+ spec.add_dependency('excon', '~> 0.62.0')
24
26
  spec.add_dependency('json', '~> 1.8.3')
25
27
 
26
28
  spec.add_development_dependency('bundler-audit')
@@ -29,6 +31,7 @@ Gem::Specification.new do |spec|
29
31
  spec.add_development_dependency('rspec')
30
32
  spec.add_development_dependency('rspec_junit_formatter')
31
33
  spec.add_development_dependency('rubocop')
34
+ spec.add_development_dependency('rubocop-rspec')
32
35
  spec.add_development_dependency('vcr')
33
36
  spec.add_development_dependency('webmock')
34
37
  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: 1.1.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Olivier Buffon
7
+ - Olivier Buffon, Laurent Cobos, Sybil Deboin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-24 00:00:00.000000000 Z
11
+ date: 2018-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.45.4
19
+ version: 0.62.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.45.4
26
+ version: 0.62.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: vcr
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -214,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
228
  version: '0'
215
229
  requirements: []
216
230
  rubyforge_project:
217
- rubygems_version: 2.4.5.3
231
+ rubygems_version: 2.7.6
218
232
  signing_key:
219
233
  specification_version: 4
220
234
  summary: Ruby bindings for the Lightspeed Restaurant API