lightspeed_pos 0.4.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +24 -21
  3. data/.rubocop_todo.yml +2 -16
  4. data/.travis.yml +3 -2
  5. data/Gemfile +2 -0
  6. data/Rakefile +2 -0
  7. data/bin/console +1 -0
  8. data/lib/lightspeed/account.rb +2 -0
  9. data/lib/lightspeed/accounts.rb +3 -1
  10. data/lib/lightspeed/categories.rb +2 -0
  11. data/lib/lightspeed/category.rb +2 -0
  12. data/lib/lightspeed/client.rb +6 -4
  13. data/lib/lightspeed/collection.rb +3 -1
  14. data/lib/lightspeed/customer.rb +2 -0
  15. data/lib/lightspeed/customers.rb +2 -0
  16. data/lib/lightspeed/employee.rb +2 -0
  17. data/lib/lightspeed/employees.rb +2 -0
  18. data/lib/lightspeed/error.rb +7 -0
  19. data/lib/lightspeed/image.rb +2 -0
  20. data/lib/lightspeed/images.rb +2 -0
  21. data/lib/lightspeed/inventories.rb +2 -0
  22. data/lib/lightspeed/inventory.rb +2 -0
  23. data/lib/lightspeed/item.rb +1 -0
  24. data/lib/lightspeed/item_attribute_set.rb +2 -0
  25. data/lib/lightspeed/item_attribute_sets.rb +2 -0
  26. data/lib/lightspeed/item_matrices.rb +2 -0
  27. data/lib/lightspeed/item_matrix.rb +2 -0
  28. data/lib/lightspeed/items.rb +2 -0
  29. data/lib/lightspeed/order.rb +2 -0
  30. data/lib/lightspeed/orders.rb +2 -0
  31. data/lib/lightspeed/price_level.rb +2 -0
  32. data/lib/lightspeed/price_levels.rb +2 -0
  33. data/lib/lightspeed/prices.rb +3 -1
  34. data/lib/lightspeed/request.rb +3 -1
  35. data/lib/lightspeed/request_throttler.rb +2 -0
  36. data/lib/lightspeed/resource.rb +6 -4
  37. data/lib/lightspeed/sale.rb +2 -0
  38. data/lib/lightspeed/sale_line.rb +2 -0
  39. data/lib/lightspeed/sale_lines.rb +2 -0
  40. data/lib/lightspeed/sales.rb +2 -0
  41. data/lib/lightspeed/shop.rb +2 -0
  42. data/lib/lightspeed/shops.rb +2 -0
  43. data/lib/lightspeed/special_order.rb +2 -0
  44. data/lib/lightspeed/special_orders.rb +2 -0
  45. data/lib/lightspeed/vendor.rb +2 -0
  46. data/lib/lightspeed/vendors.rb +2 -0
  47. data/lib/lightspeed/version.rb +3 -1
  48. data/lib/lightspeed_pos.rb +2 -0
  49. data/lightspeed_pos.gemspec +3 -0
  50. metadata +4 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b42db3649e13304941c1fb7770b350bccb22d5751c1f8277c290df0134ea468
4
- data.tar.gz: b2f9b9005019a428f673e7d6999fbc3f4900f2923b13342c9050d0deb88dbc51
3
+ metadata.gz: 698710d57a5ef3c30c022c2f050b9df04976227b2482a3075c851b27db3642fe
4
+ data.tar.gz: 6abdc460a2cd345883c2cb853c9c6c16051273606914d7ba5fcaa72089402dae
5
5
  SHA512:
6
- metadata.gz: 34f6532de1edfe8417970b7b255557b7882d2bc4df373bdf69631f29bed3b941f7db5eb4a38a1a074bebc539b5e3c6e192d47d3d6db8a5294b6aa4d156fc1c10
7
- data.tar.gz: 78455dc05e80e7246e13dd858bcb30d40956a75967ed9e8bb516e24b122be63287b8678d508d29c25483615be7ad7488395cb7a2f1a3c93631c6f819dddef06f
6
+ metadata.gz: 03f3b9db98a4145a9751b2990beabccf96d79a78fece26a40a3163ffe0d8604ea41ad0316b52ce9a3e27f77fea1e6cb0ce708438bc37c22cacef0a0401ef9245
7
+ data.tar.gz: 3c8f3710b4f8e76bda81e5e02265115c0252c38b8c177ff707c9dab53026da1d8598504d77ae9d31c3a17a0cfa2796d5cd293355b25b7c8aeca4e44762e26830
data/.rubocop.yml CHANGED
@@ -1,70 +1,73 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
- AlignHash:
3
+ AllCops:
4
+ NewCops: enable
5
+ SuggestExtensions:
6
+ rubocop-rake: false
7
+ rubocop-rspec: false
8
+
9
+ Layout/HashAlignment:
4
10
  EnforcedLastArgumentHashStyle: always_ignore
5
11
 
6
- AlignParameters:
12
+ Layout/ParameterAlignment:
7
13
  Enabled: false
8
14
 
9
- LineLength:
15
+ Layout/LineLength:
10
16
  Max: 180
11
17
 
12
- ClassLength:
18
+ Metrics/ClassLength:
13
19
  Enabled: true
14
20
  Severity: refactor
15
21
  Max: 300
16
22
 
17
- MethodLength:
23
+ Metrics/MethodLength:
18
24
  Enabled: true
19
25
  Max: 30
20
26
  Severity: refactor
21
27
 
22
- CyclomaticComplexity:
28
+ Metrics/CyclomaticComplexity:
23
29
  Max: 10
24
30
  Severity: refactor
25
31
 
26
- EndAlignment:
32
+ Layout/EndAlignment:
27
33
  Enabled: false
28
34
 
29
- StringLiterals:
35
+ Style/StringLiterals:
30
36
  Enabled: false
31
37
 
32
- Documentation:
38
+ Style/Documentation:
33
39
  Enabled: false
34
40
 
35
- PercentLiteralDelimiters:
41
+ Style/PercentLiteralDelimiters:
36
42
  PreferredDelimiters:
37
43
  '%w': '{}'
38
44
 
39
- MethodDefParentheses:
45
+ Style/MethodDefParentheses:
40
46
  Enabled: false
41
47
 
42
- PredicateName:
43
- NamePrefixBlacklist:
48
+ Naming/PredicateName:
49
+ ForbiddenPrefixes:
44
50
  - is_
45
51
  - have_
46
52
 
47
- IndentFirstHashElement:
53
+ Layout/FirstHashElementIndentation:
48
54
  EnforcedStyle: consistent
49
55
 
50
56
  # breaks using if blocks with assignments
51
- IndentationWidth:
57
+ Layout/IndentationWidth:
52
58
  Enabled: false
53
59
 
54
60
  Layout/CaseIndentation:
55
61
  EnforcedStyle: end
56
62
 
57
- FormatString:
58
- Enabled: false
59
-
60
- ActionFilter:
63
+ Style/FormatString:
61
64
  Enabled: false
62
65
 
63
66
  # different methods calls that do exactly the same thing are a smell, regardless of semantics
64
- SignalException:
67
+ Style/SignalException:
65
68
  EnforcedStyle: only_raise
66
69
 
67
- DoubleNegation:
70
+ Style/DoubleNegation:
68
71
  Enabled: false
69
72
 
70
73
  Style/TrailingCommaInArrayLiteral:
data/.rubocop_todo.yml CHANGED
@@ -68,12 +68,6 @@ Layout/EmptyLinesAroundClassBody:
68
68
  - 'lib/lightspeed/sale_line.rb'
69
69
  - 'lib/lightspeed/vendor.rb'
70
70
 
71
- # Offense count: 1
72
- # Cop supports --auto-correct.
73
- Layout/LeadingBlankLines:
74
- Exclude:
75
- - 'lib/lightspeed/item.rb'
76
-
77
71
  # Offense count: 3
78
72
  # Cop supports --auto-correct.
79
73
  # Configuration parameters: EnforcedStyle, IndentationWidth.
@@ -108,7 +102,7 @@ Layout/SpaceInsideHashLiteralBraces:
108
102
  # Cop supports --auto-correct.
109
103
  # Configuration parameters: EnforcedStyle.
110
104
  # SupportedStyles: final_newline, final_blank_line
111
- Layout/TrailingBlankLines:
105
+ Layout/TrailingEmptyLines:
112
106
  Exclude:
113
107
  - 'lib/lightspeed/customer.rb'
114
108
  - 'lib/lightspeed/customers.rb'
@@ -174,7 +168,7 @@ Metrics/BlockLength:
174
168
  # Offense count: 2
175
169
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
176
170
  # AllowedNames: io, id, to, by, on, in, at, ip, db
177
- Naming/UncommunicativeMethodParamName:
171
+ Naming/MethodParameterName:
178
172
  Exclude:
179
173
  - 'lib/lightspeed/accounts.rb'
180
174
  - 'lib/lightspeed/collection.rb'
@@ -199,14 +193,6 @@ Style/Alias:
199
193
  - 'lib/lightspeed/vendor.rb'
200
194
  - 'lib/lightspeed/vendors.rb'
201
195
 
202
- # Offense count: 1
203
- # Cop supports --auto-correct.
204
- # Configuration parameters: EnforcedStyle.
205
- # SupportedStyles: braces, no_braces, context_dependent
206
- Style/BracesAroundHashParameters:
207
- Exclude:
208
- - 'spec/lightspeed/sales_spec.rb'
209
-
210
196
  # Offense count: 1
211
197
  # Cop supports --auto-correct.
212
198
  # Configuration parameters: Keywords.
data/.travis.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3
4
- - 2.4
5
3
  - 2.5
4
+ - 2.6
5
+ - 2.7
6
+ - 3.0
6
7
  script:
7
8
  - 'bundle exec rubocop'
8
9
  - 'bundle exec rspec spec'
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in lightspeed-pos.gemspec
data/Rakefile CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
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 'dotenv'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
2
4
  require_relative 'categories'
3
5
  require_relative 'employees'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
  require_relative 'account'
3
5
 
@@ -11,7 +13,7 @@ module Lightspeed
11
13
  first_loaded || first
12
14
  end
13
15
 
14
- def page(n, *args)
16
+ def page(n, **args)
15
17
  # turns out lightspeed doesn't respect pagination for accounts.
16
18
  # so page(1) is identical to page(0).
17
19
  # they should be different, thus.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'category'
2
4
  require_relative 'collection'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  module Lightspeed
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/core_ext/array/wrap'
2
4
 
3
5
  require_relative 'accounts'
@@ -21,19 +23,19 @@ module Lightspeed
21
23
  end
22
24
 
23
25
  def get(**args)
24
- perform_request(args.merge(method: :get))
26
+ perform_request(**args, method: :get)
25
27
  end
26
28
 
27
29
  def post(**args)
28
- perform_request(args.merge(method: :post))
30
+ perform_request(**args, method: :post)
29
31
  end
30
32
 
31
33
  def put(**args)
32
- perform_request(args.merge(method: :put))
34
+ perform_request(**args, method: :put)
33
35
  end
34
36
 
35
37
  def delete(**args)
36
- perform_request(args.merge(method: :delete))
38
+ perform_request(**args, method: :delete)
37
39
  end
38
40
 
39
41
  def oauth_token
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/core_ext/string'
2
4
  require 'active_support/core_ext/array/wrap'
3
5
 
@@ -174,7 +176,7 @@ module Lightspeed
174
176
  params = { load_relations: load_relations_default }
175
177
  .merge(context_params)
176
178
  .merge(params)
177
- .reject { |_, v| v.nil? }
179
+ .compact
178
180
  client.get(
179
181
  path: collection_path,
180
182
  params: params
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  module Lightspeed
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'customer'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  module Lightspeed
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'employee'
@@ -1,10 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Lightspeed
2
4
  class Error < Exception
3
5
  class BadRequest < Lightspeed::Error; end # 400
6
+
4
7
  class Unauthorized < Lightspeed::Error; end # 401
8
+
5
9
  class NotAuthorized < Lightspeed::Error; end # 403
10
+
6
11
  class NotFound < Lightspeed::Error; end # 404
12
+
7
13
  class InternalServerError < Lightspeed::Error; end # 500
14
+
8
15
  class Throttled < Lightspeed::Error; end # 503
9
16
  end
10
17
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  require_relative 'item'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'image'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'inventory'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  require_relative 'item'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require_relative 'resource'
3
4
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  module Lightspeed
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'item_attribute_set'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'item_matrix'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  require_relative 'item_attribute_set'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'item'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  module Lightspeed
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'order'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  module Lightspeed
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'price_level'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/core_ext/string'
2
4
  require 'bigdecimal'
3
5
 
@@ -8,7 +10,7 @@ module Lightspeed
8
10
  end
9
11
 
10
12
  def prices
11
- @prices ||= @attributes["ItemPrice"].map { |v| [v["useType"].parameterize.underscore.to_sym, BigDecimal.new(v["amount"])] }.to_h
13
+ @prices ||= @attributes["ItemPrice"].map { |v| [v["useType"].parameterize.underscore.to_sym, BigDecimal(v["amount"])] }.to_h
12
14
  end
13
15
 
14
16
  def as_json
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pp'
2
4
  require 'net/http'
3
5
 
@@ -106,7 +108,7 @@ module Lightspeed
106
108
 
107
109
  def uri
108
110
  uri = self.class.base_path + @path
109
- uri += "?" + URI.encode_www_form(@params) if @params && @method == :get
111
+ uri += "?#{URI.encode_www_form(@params)}" if @params && @method == :get
110
112
  uri
111
113
  end
112
114
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Lightspeed
2
4
  class RequestThrottler
3
5
  attr_accessor :bucket_level, :bucket_max, :units_per_second
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bigdecimal'
2
4
  require 'active_support/core_ext/string'
3
5
  require 'active_support/core_ext/hash/slice'
@@ -6,7 +8,7 @@ require_relative 'collection'
6
8
 
7
9
  module Lightspeed
8
10
  class ID < Integer; end
9
- class Link; end
11
+ class Link; end # rubocop:disable Lint/EmptyClass
10
12
  class Resource
11
13
  attr_accessor :id, :attributes, :client, :context, :account
12
14
 
@@ -32,6 +34,7 @@ module Lightspeed
32
34
  def self.fields(fields = {})
33
35
  @fields ||= []
34
36
  attr_writer(*fields.keys)
37
+
35
38
  fields.each do |name, klass|
36
39
  @fields << define_method(name) do
37
40
  get_transformed_value(name, klass)
@@ -45,11 +48,10 @@ module Lightspeed
45
48
  if value.is_a?(String)
46
49
  case kind
47
50
  when :string then value
48
- when :integer then value.to_i
49
- when :id then value.to_i
51
+ when :id, :integer then value.to_i
50
52
  when :datetime then DateTime.parse(value)
51
53
  when :boolean then value == 'true'
52
- when :decimal then BigDecimal.new(value)
54
+ when :decimal then BigDecimal(value)
53
55
  when :hash then Hash.new(value)
54
56
  else
55
57
  raise ArgumentError, "Could not transform value #{value} to a #{kind}"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  require_relative 'sale_lines'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
  require_relative 'item'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
  require_relative 'sale_line'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'sale'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  module Lightspeed
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'shop'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  module Lightspeed
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'special_order'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource'
2
4
 
3
5
  module Lightspeed
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'collection'
2
4
 
3
5
  require_relative 'vendor'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Lightspeed
2
- VERSION = "0.4.0"
4
+ VERSION = "0.6.0"
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yajl'
2
4
 
3
5
  module Lightspeed
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'lightspeed/version'
@@ -19,6 +20,8 @@ Gem::Specification.new do |spec|
19
20
  spec.require_paths = ["lib"]
20
21
  spec.license = "MIT"
21
22
 
23
+ spec.required_ruby_version = '>= 2.5'
24
+
22
25
  spec.add_dependency "activesupport"
23
26
  spec.add_dependency "yajl-ruby"
24
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightspeed_pos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-05 00:00:00.000000000 Z
11
+ date: 2021-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -225,15 +225,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
225
225
  requirements:
226
226
  - - ">="
227
227
  - !ruby/object:Gem::Version
228
- version: '0'
228
+ version: '2.5'
229
229
  required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  requirements:
231
231
  - - ">="
232
232
  - !ruby/object:Gem::Version
233
233
  version: '0'
234
234
  requirements: []
235
- rubyforge_project:
236
- rubygems_version: 2.7.6
235
+ rubygems_version: 3.2.3
237
236
  signing_key:
238
237
  specification_version: 4
239
238
  summary: A gem for interacting with Lightspeed's Point of Sale system