lightspeed_pos 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +57 -29
  3. data/bin/console +15 -7
  4. data/lib/lightspeed/account.rb +44 -43
  5. data/lib/lightspeed/accounts.rb +22 -0
  6. data/lib/lightspeed/categories.rb +5 -5
  7. data/lib/lightspeed/category.rb +16 -7
  8. data/lib/lightspeed/client.rb +37 -26
  9. data/lib/lightspeed/collection.rb +218 -0
  10. data/lib/lightspeed/employee.rb +25 -0
  11. data/lib/lightspeed/employees.rb +8 -0
  12. data/lib/lightspeed/{errors.rb → error.rb} +2 -1
  13. data/lib/lightspeed/image.rb +35 -0
  14. data/lib/lightspeed/images.rb +16 -0
  15. data/lib/lightspeed/inventories.rb +8 -0
  16. data/lib/lightspeed/inventory.rb +12 -0
  17. data/lib/lightspeed/item.rb +54 -18
  18. data/lib/lightspeed/item_attribute_set.rb +13 -0
  19. data/lib/lightspeed/item_attribute_sets.rb +8 -0
  20. data/lib/lightspeed/item_matrices.rb +4 -3
  21. data/lib/lightspeed/item_matrix.rb +48 -10
  22. data/lib/lightspeed/items.rb +4 -7
  23. data/lib/lightspeed/order.rb +34 -0
  24. data/lib/lightspeed/orders.rb +10 -0
  25. data/lib/lightspeed/prices.rb +43 -0
  26. data/lib/lightspeed/request.rb +74 -28
  27. data/lib/lightspeed/request_throttler.rb +31 -0
  28. data/lib/lightspeed/resource.rb +221 -0
  29. data/lib/lightspeed/sale.rb +57 -0
  30. data/lib/lightspeed/sale_line.rb +52 -0
  31. data/lib/lightspeed/sale_lines.rb +9 -0
  32. data/lib/lightspeed/sales.rb +10 -0
  33. data/lib/lightspeed/shop.rb +30 -0
  34. data/lib/lightspeed/shops.rb +8 -0
  35. data/lib/lightspeed/special_order.rb +22 -0
  36. data/lib/lightspeed/special_orders.rb +10 -0
  37. data/lib/lightspeed/vendor.rb +23 -0
  38. data/lib/lightspeed/vendors.rb +9 -0
  39. data/lib/lightspeed/version.rb +1 -1
  40. data/lib/lightspeed_pos.rb +2 -4
  41. data/lightspeed_pos.gemspec +3 -3
  42. data/script/buildkite +11 -0
  43. data/script/docker_tests +29 -0
  44. metadata +63 -24
  45. data/lib/lightspeed/account_resources.rb +0 -103
  46. data/lib/lightspeed/base.rb +0 -17
@@ -0,0 +1,10 @@
1
+ require_relative 'collection'
2
+
3
+ require_relative 'special_order'
4
+
5
+ module Lightspeed
6
+ class SpecialOrders < Lightspeed::Collection
7
+ end
8
+ end
9
+
10
+
@@ -0,0 +1,23 @@
1
+ require_relative 'resource'
2
+
3
+ module Lightspeed
4
+ class Vendor < Lightspeed::Resource
5
+ alias_method :archive, :destroy
6
+
7
+ fields(
8
+ vendorID: :id,
9
+ name: :string,
10
+ archived: :boolean,
11
+ accountNumber: :string,
12
+ priceLevel: :string,
13
+ updatePrice: :boolean,
14
+ updateCost: :boolean,
15
+ updateDescription: :boolean,
16
+ shareSellThrough: :boolean,
17
+ timeStamp: :datetime,
18
+ Contact: :hash,
19
+ Reps: :hash
20
+ )
21
+
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ require_relative 'collection'
2
+
3
+ require_relative 'vendor'
4
+
5
+ module Lightspeed
6
+ class Vendors < Lightspeed::Collection
7
+ alias_method :archive, :destroy
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Lightspeed
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,9 +1,7 @@
1
- require 'typhoeus'
2
1
  require 'json'
3
- require 'pry'
4
2
 
5
3
  module Lightspeed
6
4
  end
7
5
 
8
- require 'lightspeed/client'
9
- require 'lightspeed/errors'
6
+ require_relative 'lightspeed/client'
7
+ require_relative 'lightspeed/error'
@@ -19,14 +19,14 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
  spec.license = "MIT"
21
21
 
22
- spec.add_dependency "typhoeus", "0.7.2"
23
- spec.add_dependency "activesupport", "4.2.3"
22
+ spec.add_dependency "activesupport", "~> 4.2.0"
24
23
 
25
24
  spec.add_development_dependency "bundler", "~> 1.9"
26
25
  spec.add_development_dependency "rake", "~> 10.0"
27
26
  spec.add_development_dependency "rspec", "3.2.0"
28
27
  spec.add_development_dependency "webmock", "1.21.0"
29
28
  spec.add_development_dependency "vcr", "2.9.3"
30
-
29
+ spec.add_development_dependency "rubocop"
30
+ spec.add_development_dependency "dotenv"
31
31
  spec.add_development_dependency "pry"
32
32
  end
data/script/buildkite ADDED
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+ set -x
5
+
6
+ set
7
+ echo $PWD
8
+
9
+ REAL_CORES=`cat /proc/cpuinfo | grep "core id" | sort | uniq | wc -l`
10
+
11
+ docker run --rm=true -e "PARALLEL_TEST_PROCESSORS=$REAL_CORES" -v $PWD:/source -v ~/.buildbox/be-bundle-cache:/cache -v /tmp/ramdisk:/tmp/ramdisk -t marketplacer/ci /source/script/docker_tests
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ # This script is ran within the Docker teg-ci image
4
+
5
+ set -e
6
+ set -x
7
+
8
+ echo "--- docker environment"
9
+
10
+ export RAILS_ENV=test
11
+ export CI=yup
12
+ export TZ=Australia/Melbourne
13
+ export LC_ALL=en_AU.UTF-8
14
+ export LANG=en_AU.UTF-8
15
+ export LANGUAGE=en_AU.UTF-8
16
+ rsync -a /source/ /build/ --exclude .git --exclude log --exclude tmp --exclude .zeus.sock
17
+
18
+ cd /build
19
+ rm -rf .bundle #if not on ci machine the wrong bundler paths get cached
20
+
21
+ /etc/init.d/postgresql start
22
+ sudo -u postgres createuser --superuser root
23
+ createdb lightspeed-bridge_test -e utf8
24
+
25
+ echo "--- bundle install"
26
+ bundle check --path /cache/bundler || bundle install -j 8
27
+
28
+ echo "--- rspec"
29
+ time bundle exec rspec spec
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightspeed_pos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.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: 2015-07-31 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: typhoeus
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 0.7.2
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 0.7.2
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: activesupport
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - '='
17
+ - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: 4.2.3
19
+ version: 4.2.0
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - '='
24
+ - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: 4.2.3
26
+ version: 4.2.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +94,34 @@ dependencies:
108
94
  - - '='
109
95
  - !ruby/object:Gem::Version
110
96
  version: 2.9.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
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
+ - !ruby/object:Gem::Dependency
112
+ name: dotenv
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: pry
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -140,20 +154,45 @@ files:
140
154
  - bin/console
141
155
  - bin/setup
142
156
  - lib/lightspeed/account.rb
143
- - lib/lightspeed/account_resources.rb
144
- - lib/lightspeed/base.rb
157
+ - lib/lightspeed/accounts.rb
145
158
  - lib/lightspeed/categories.rb
146
159
  - lib/lightspeed/category.rb
147
160
  - lib/lightspeed/client.rb
148
- - lib/lightspeed/errors.rb
161
+ - lib/lightspeed/collection.rb
162
+ - lib/lightspeed/employee.rb
163
+ - lib/lightspeed/employees.rb
164
+ - lib/lightspeed/error.rb
165
+ - lib/lightspeed/image.rb
166
+ - lib/lightspeed/images.rb
167
+ - lib/lightspeed/inventories.rb
168
+ - lib/lightspeed/inventory.rb
149
169
  - lib/lightspeed/item.rb
170
+ - lib/lightspeed/item_attribute_set.rb
171
+ - lib/lightspeed/item_attribute_sets.rb
150
172
  - lib/lightspeed/item_matrices.rb
151
173
  - lib/lightspeed/item_matrix.rb
152
174
  - lib/lightspeed/items.rb
175
+ - lib/lightspeed/order.rb
176
+ - lib/lightspeed/orders.rb
177
+ - lib/lightspeed/prices.rb
153
178
  - lib/lightspeed/request.rb
179
+ - lib/lightspeed/request_throttler.rb
180
+ - lib/lightspeed/resource.rb
181
+ - lib/lightspeed/sale.rb
182
+ - lib/lightspeed/sale_line.rb
183
+ - lib/lightspeed/sale_lines.rb
184
+ - lib/lightspeed/sales.rb
185
+ - lib/lightspeed/shop.rb
186
+ - lib/lightspeed/shops.rb
187
+ - lib/lightspeed/special_order.rb
188
+ - lib/lightspeed/special_orders.rb
189
+ - lib/lightspeed/vendor.rb
190
+ - lib/lightspeed/vendors.rb
154
191
  - lib/lightspeed/version.rb
155
192
  - lib/lightspeed_pos.rb
156
193
  - lightspeed_pos.gemspec
194
+ - script/buildkite
195
+ - script/docker_tests
157
196
  homepage: https://github.com/radar/lightspeed_pos
158
197
  licenses:
159
198
  - MIT
@@ -174,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
213
  version: '0'
175
214
  requirements: []
176
215
  rubyforge_project:
177
- rubygems_version: 2.4.8
216
+ rubygems_version: 2.4.5
178
217
  signing_key:
179
218
  specification_version: 4
180
219
  summary: A gem for interacting with Lightspeed's Point of Sale system
@@ -1,103 +0,0 @@
1
- require 'active_support/core_ext/string'
2
-
3
- module Lightspeed
4
- class AccountResources
5
- attr_accessor :account
6
-
7
- def initialize(account)
8
- @account = account
9
- end
10
-
11
- def all
12
- response = get
13
- account.instantiate(response[resource_name], Lightspeed.const_get(resource_name))
14
- end
15
-
16
- def find(id)
17
- params = { "#{resource_name.camelize(:lower)}ID" => id }
18
- response = get(params: params)
19
- if response[resource_name]
20
- resource_class.new(account, response[resource_name])
21
- else
22
- raise Lightspeed::Errors::NotFound, "Could not find a #{resource_name} by #{params.inspect}"
23
- end
24
- end
25
-
26
- def create(attributes = {})
27
- craft_instance(post(body: attributes.to_json))
28
- end
29
-
30
- def update(id, attributes = {})
31
- craft_instance(put(id, body: attributes.to_json))
32
- end
33
-
34
- def destroy(id)
35
- craft_instance(delete(id))
36
- end
37
-
38
- private
39
-
40
- def craft_instance(response)
41
- resource_class.new(client, response[resource_name])
42
- end
43
-
44
- def client
45
- account.client
46
- end
47
-
48
- def resource_class
49
- Lightspeed.const_get(resource_name)
50
- end
51
-
52
- def resource_name
53
- self.class.resource_name
54
- end
55
-
56
- def get(params: nil)
57
- request = client.request(
58
- method: :get,
59
- path: collection_path,
60
- params: params
61
- )
62
- request.perform
63
- end
64
-
65
- def post(body:)
66
- request = client.request(
67
- method: :post,
68
- path: collection_path,
69
- body: body
70
- )
71
- request.perform
72
- end
73
-
74
- def put(id, body:)
75
- request = client.request(
76
- method: :put,
77
- path: item_path(id),
78
- body: body,
79
- )
80
- request.perform
81
- end
82
-
83
- def delete(id)
84
- request = client.request(
85
- method: :delete,
86
- path: item_path(id)
87
- )
88
- request.perform
89
- end
90
-
91
- def base_path
92
- "/Account/#{account.id}/#{self.class.resource_name}"
93
- end
94
-
95
- def collection_path
96
- base_path + ".json"
97
- end
98
-
99
- def item_path(id)
100
- base_path + "/#{id}.json"
101
- end
102
- end
103
- end
@@ -1,17 +0,0 @@
1
- module Lightspeed
2
- class Base
3
- attr_accessor :id, :owner
4
-
5
- def initialize(owner, data = {})
6
- @owner = owner
7
- self.id = data.delete(self.class.id_field)
8
- data.each do |k, v|
9
- send("#{k}=", v)
10
- end
11
- end
12
-
13
- def inspect
14
- "#<#{self.class.name} id=#{id}>"
15
- end
16
- end
17
- end