lightspeed_pos 0.1.0 → 0.6.0

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.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/.mailmap +4 -0
  3. data/.rubocop.yml +32 -24
  4. data/.rubocop_todo.yml +284 -0
  5. data/.travis.yml +5 -3
  6. data/Gemfile +2 -0
  7. data/README.markdown +85 -28
  8. data/Rakefile +2 -0
  9. data/bin/console +33 -6
  10. data/lib/lightspeed/account.rb +50 -43
  11. data/lib/lightspeed/accounts.rb +24 -0
  12. data/lib/lightspeed/categories.rb +7 -5
  13. data/lib/lightspeed/category.rb +18 -7
  14. data/lib/lightspeed/client.rb +41 -27
  15. data/lib/lightspeed/collection.rb +214 -0
  16. data/lib/lightspeed/customer.rb +36 -0
  17. data/lib/lightspeed/customers.rb +11 -0
  18. data/lib/lightspeed/employee.rb +27 -0
  19. data/lib/lightspeed/employees.rb +10 -0
  20. data/lib/lightspeed/error.rb +17 -0
  21. data/lib/lightspeed/image.rb +37 -0
  22. data/lib/lightspeed/images.rb +18 -0
  23. data/lib/lightspeed/inventories.rb +10 -0
  24. data/lib/lightspeed/inventory.rb +14 -0
  25. data/lib/lightspeed/item.rb +55 -18
  26. data/lib/lightspeed/item_attribute_set.rb +15 -0
  27. data/lib/lightspeed/item_attribute_sets.rb +10 -0
  28. data/lib/lightspeed/item_matrices.rb +6 -3
  29. data/lib/lightspeed/item_matrix.rb +50 -10
  30. data/lib/lightspeed/items.rb +6 -7
  31. data/lib/lightspeed/order.rb +36 -0
  32. data/lib/lightspeed/orders.rb +12 -0
  33. data/lib/lightspeed/price_level.rb +16 -0
  34. data/lib/lightspeed/price_levels.rb +10 -0
  35. data/lib/lightspeed/prices.rb +45 -0
  36. data/lib/lightspeed/request.rb +98 -29
  37. data/lib/lightspeed/request_throttler.rb +33 -0
  38. data/lib/lightspeed/resource.rb +221 -0
  39. data/lib/lightspeed/sale.rb +59 -0
  40. data/lib/lightspeed/sale_line.rb +54 -0
  41. data/lib/lightspeed/sale_lines.rb +11 -0
  42. data/lib/lightspeed/sales.rb +12 -0
  43. data/lib/lightspeed/shop.rb +32 -0
  44. data/lib/lightspeed/shops.rb +10 -0
  45. data/lib/lightspeed/special_order.rb +24 -0
  46. data/lib/lightspeed/special_orders.rb +12 -0
  47. data/lib/lightspeed/vendor.rb +25 -0
  48. data/lib/lightspeed/vendors.rb +11 -0
  49. data/lib/lightspeed/version.rb +3 -1
  50. data/lib/lightspeed_pos.rb +5 -5
  51. data/lightspeed_pos.gemspec +11 -7
  52. data/script/buildkite +24 -0
  53. data/script/docker_tests +29 -0
  54. metadata +96 -38
  55. data/lib/lightspeed/account_resources.rb +0 -103
  56. data/lib/lightspeed/base.rb +0 -17
  57. data/lib/lightspeed/errors.rb +0 -8
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'resource'
4
+
5
+ module Lightspeed
6
+ class Customer < Lightspeed::Resource
7
+ alias_method :archive, :destroy
8
+
9
+ fields(
10
+ customerID: :id,
11
+ firstName: :string,
12
+ lastName: :string,
13
+ dob: :timestamp,
14
+ archived: :boolean,
15
+ title: :string,
16
+ company: :string,
17
+ companyRegistrationNumber: :string,
18
+ vatNumber: :string,
19
+ createTime: :timestamp,
20
+ timeStamp: :timestamp,
21
+ creditAccountID: :id,
22
+ customerTypeID: :id,
23
+ discountID: :id,
24
+ taxCategoryID: :id,
25
+ Contact: :hash,
26
+ CreditAccount: :hash,
27
+ CustomerType: :hash,
28
+ Discount: :hash,
29
+ Note: :hash,
30
+ TaxCategory: :hash,
31
+ CustomFieldValues: :hash
32
+ )
33
+
34
+ end
35
+ end
36
+
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'collection'
4
+
5
+ require_relative 'customer'
6
+
7
+ module Lightspeed
8
+ class Customers < Lightspeed::Collection
9
+ alias_method :archive, :destroy
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'resource'
4
+
5
+ module Lightspeed
6
+ class Employee < Lightspeed::Resource
7
+ fields(
8
+ employeeID: :id,
9
+ firstName: :string,
10
+ lastName: :string,
11
+ accessPin: :string,
12
+ lockOut: :boolean,
13
+ archived: :boolean,
14
+ contactID: :integer,
15
+ clockInEmployeeHoursID: :integer,
16
+ employeeRoleID: :integer,
17
+ limitToShopID: :integer,
18
+ lastShopID: :integer,
19
+ lastSaleID: :integer,
20
+ lastRegisterID: :integer,
21
+ timeStamp: :datetime,
22
+ Contact: :hash,
23
+ EmployeeRole: :hash,
24
+ EmployeeRights: :hash
25
+ )
26
+ end
27
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'collection'
4
+
5
+ require_relative 'employee'
6
+
7
+ module Lightspeed
8
+ class Employees < Lightspeed::Collection
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lightspeed
4
+ class Error < Exception
5
+ class BadRequest < Lightspeed::Error; end # 400
6
+
7
+ class Unauthorized < Lightspeed::Error; end # 401
8
+
9
+ class NotAuthorized < Lightspeed::Error; end # 403
10
+
11
+ class NotFound < Lightspeed::Error; end # 404
12
+
13
+ class InternalServerError < Lightspeed::Error; end # 500
14
+
15
+ class Throttled < Lightspeed::Error; end # 503
16
+ end
17
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'resource'
4
+
5
+ require_relative 'item'
6
+ require_relative 'item_matrix'
7
+
8
+ module Lightspeed
9
+ class Image < Lightspeed::Resource
10
+ fields(
11
+ imageID: :id,
12
+ description: :string,
13
+ filename: :string,
14
+ baseImageURL: :string,
15
+ publicID: :string, # part of the file path; not a Lightspeed ID
16
+ itemID: :id,
17
+ itemMatrixID: :id,
18
+ Item: :hash,
19
+ ItemMatrix: :hash
20
+ )
21
+
22
+ relationships :Item, :ItemMatrix
23
+
24
+ def url
25
+ "#{baseImageURL}#{publicID}"
26
+ end
27
+
28
+ def base_path
29
+ if context.is_a?(Lightspeed::Item) ||
30
+ context.is_a?(Lightspeed::ItemMatrix)
31
+ "#{context.base_path}/#{resource_name}/#{id}"
32
+ else
33
+ super
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'collection'
4
+
5
+ require_relative 'image'
6
+
7
+ module Lightspeed
8
+ class Images < Lightspeed::Collection
9
+ def base_path
10
+ if context.is_a?(Lightspeed::Item) ||
11
+ context.is_a?(Lightspeed::ItemMatrix)
12
+ "#{context.base_path}/#{resource_name}"
13
+ else
14
+ super
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'collection'
4
+
5
+ require_relative 'inventory'
6
+
7
+ module Lightspeed
8
+ class Inventories < Lightspeed::Collection
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'resource'
4
+
5
+ require_relative 'item'
6
+
7
+ module Lightspeed
8
+ class Inventory < Lightspeed::Resource
9
+ fields(
10
+ inventoryID: :integer
11
+ )
12
+ relationships :Item
13
+ end
14
+ end
@@ -1,26 +1,63 @@
1
- require 'lightspeed/base'
1
+ # frozen_string_literal: true
2
2
 
3
- module Lightspeed
4
- class Item < Lightspeed::Base
5
- attr_accessor :systemSku, :defaultCost, :avgCost, :discountable, :tax,
6
- :archived, :itemType, :description, :modelYear, :upc, :ean, :customSku,
7
- :manufacturerSku, :createTime, :timeStamp,
3
+ require_relative 'resource'
4
+
5
+ require_relative 'item_matrix'
6
+ require_relative 'category'
7
+ require_relative 'images'
8
+ require_relative 'prices'
8
9
 
9
- # Association keys
10
- :categoryID, :taxClassID, :departmentID, :itemMatrixID, :manufacturerID, :seasonID,
11
- :defaultVendorID, :itemECommerceID,
10
+ module Lightspeed
11
+ class Item < Lightspeed::Resource
12
+ alias_method :archive, :destroy
12
13
 
13
- # Embedded
14
- :ItemMatrix, :ItemAttributes, :ItemShops, :Prices, :Note
14
+ fields(
15
+ itemID: :id,
16
+ systemSku: :string,
17
+ defaultCost: :decimal,
18
+ avgCost: :decimal,
19
+ discountable: :boolean,
20
+ tax: :boolean,
21
+ archived: :boolean,
22
+ itemType: :string,
23
+ description: :string,
24
+ modelYear: :integer,
25
+ upc: :string,
26
+ ean: :string,
27
+ customSku: :string,
28
+ manufacturerSku: :string,
29
+ createTime: :datetime,
30
+ timeStamp: :datetime,
31
+ categoryID: :id,
32
+ taxClassID: :id,
33
+ departmentID: :id,
34
+ itemMatrixID: :id,
35
+ manufacturerID: :id,
36
+ seasonID: :id,
37
+ defaultVendorID: :id,
38
+ itemECommerceID: :id,
39
+ # Category: :hash,
40
+ TaxClass: :hash,
41
+ Department: :hash,
42
+ ItemAttributes: :hash,
43
+ # ItemMatrix: :hash,
44
+ # Images: :hash,
45
+ Manufacturer: :hash,
46
+ Note: :hash,
47
+ ItemECommerce: :hash,
48
+ ItemShops: :hash,
49
+ ItemComponents: :hash,
50
+ ItemShelfLocations: :hash,
51
+ ItemVendorNums: :hash,
52
+ CustomFieldValues: :hash,
53
+ Prices: :hash,
54
+ Tags: :hash
55
+ )
15
56
 
16
- def self.id_field
17
- "itemID"
18
- end
57
+ relationships :ItemMatrix, :Category, :Images, DefaultVendor: :Vendor
19
58
 
20
- # FUNFACT: ItemMatrix data is returned during an `update` request,
21
- # but not during a `find` request.
22
- def item_matrix
23
- @ItemMatrix ||= owner.item_matrices.find(itemMatrixID) # rubocop:disable VariableName
59
+ def prices
60
+ @prices ||= Lightspeed::Prices.new(self.Prices)
24
61
  end
25
62
  end
26
63
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'resource'
4
+
5
+ module Lightspeed
6
+ class ItemAttributeSet < Lightspeed::Resource
7
+ fields(
8
+ itemAttributeSetID: :id,
9
+ name: :string,
10
+ attributeName1: :string,
11
+ attributeName2: :string,
12
+ attributeName3: :string
13
+ )
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'collection'
4
+
5
+ require_relative 'item_attribute_set'
6
+
7
+ module Lightspeed
8
+ class ItemAttributeSets < Lightspeed::Collection
9
+ end
10
+ end
@@ -1,8 +1,11 @@
1
- require 'lightspeed/item_matrix'
2
- require 'lightspeed/account_resources'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'collection'
4
+
5
+ require_relative 'item_matrix'
3
6
 
4
7
  module Lightspeed
5
- class ItemMatrices < AccountResources
8
+ class ItemMatrices < Lightspeed::Collection
6
9
  def self.resource_name
7
10
  "ItemMatrix"
8
11
  end
@@ -1,17 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'resource'
4
+
5
+ require_relative 'item_attribute_set'
6
+ require_relative 'category'
7
+ require_relative 'items'
8
+
1
9
  module Lightspeed
2
- class ItemMatrix < Lightspeed::Base
3
- attr_accessor :description, :tax, :defaultCost, :itemType, :modelYear, :archived,
4
- :timeStamp
10
+ class ItemMatrix < Lightspeed::Resource
11
+ fields(
12
+ itemMatrixID: :id,
13
+ description: :string,
14
+ tax: :boolean,
15
+ defaultCost: :decimal,
16
+ itemType: :string,
17
+ modelYear: :integer,
18
+ archived: :boolean,
19
+ timeStamp: :datetime,
20
+ itemAttributeSetID: :id,
21
+ manufacturerID: :id,
22
+ categoryID: :id,
23
+ defaultVendorID: :id,
24
+ taxClassID: :id,
25
+ seasonID: :id,
26
+ departmentID: :id,
27
+ itemECommerceID: :id,
28
+ itemAttributeSet: :hash,
29
+ Manufacturer: :hash,
30
+ Category: :hash,
31
+ TaxClass: :hash,
32
+ Season: :hash,
33
+ Department: :hash,
34
+ ItemECommerce: :hash,
35
+ Images: :hash,
36
+ Items: :hash,
37
+ CustomFieldValues: :hash,
38
+ Prices: :hash
39
+ )
40
+
41
+ relationships :ItemAttributeSet, :Category, :Items
5
42
 
6
- # Association keys
7
- attr_accessor :itemAttributeSetID, :manufacturerID, :categoryID, :defaultVendorID,
8
- :taxClassID, :seasonID, :departmentID, :itemECommerceID
43
+ # overrides
9
44
 
10
- # Embedded
11
- attr_accessor :Prices
45
+ def self.collection_name
46
+ 'ItemMatrices'
47
+ end
48
+
49
+ def singular_path_parent
50
+ account
51
+ end
12
52
 
13
- def self.id_field
14
- "itemMatrixID"
53
+ def prices
54
+ @prices ||= Lightspeed::Prices.new(self.Prices)
15
55
  end
16
56
  end
17
57
  end
@@ -1,12 +1,11 @@
1
- require 'lightspeed/item'
2
- require 'lightspeed/account_resources'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'collection'
4
+
5
+ require_relative 'item'
3
6
 
4
7
  module Lightspeed
5
- class Items < Lightspeed::AccountResources
8
+ class Items < Lightspeed::Collection
6
9
  alias_method :archive, :destroy
7
-
8
- def self.resource_name
9
- "Item"
10
- end
11
10
  end
12
11
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'resource'
4
+
5
+ module Lightspeed
6
+ class Order < Lightspeed::Resource
7
+ alias_method :archive, :destroy
8
+
9
+ fields(
10
+ orderID: :id,
11
+ orderedDate: :timestamp,
12
+ receivedDate: :timestamp,
13
+ arrivalDate: :timestamp,
14
+ shipInstructions: :integer,
15
+ stockInstructions: :integer,
16
+ shipCost: :decimal,
17
+ otherCost: :decimal,
18
+ complete: :boolean,
19
+ archived: :boolean,
20
+ discount: :boolean,
21
+ totalDiscount: :decimal,
22
+ totalQuantity: :decimal,
23
+ vendorID: :id,
24
+ noteID: :id,
25
+ shopID: :id,
26
+ Vendor: :hash,
27
+ Note: :hash,
28
+ Shop: :hash,
29
+ OrderLines: :hash,
30
+ CustomFieldValues: :hash,
31
+ timeStamp: :timestamp
32
+ )
33
+
34
+ end
35
+ end
36
+