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.
- checksums.yaml +4 -4
- data/README.markdown +57 -29
- data/bin/console +15 -7
- data/lib/lightspeed/account.rb +44 -43
- data/lib/lightspeed/accounts.rb +22 -0
- data/lib/lightspeed/categories.rb +5 -5
- data/lib/lightspeed/category.rb +16 -7
- data/lib/lightspeed/client.rb +37 -26
- data/lib/lightspeed/collection.rb +218 -0
- data/lib/lightspeed/employee.rb +25 -0
- data/lib/lightspeed/employees.rb +8 -0
- data/lib/lightspeed/{errors.rb → error.rb} +2 -1
- data/lib/lightspeed/image.rb +35 -0
- data/lib/lightspeed/images.rb +16 -0
- data/lib/lightspeed/inventories.rb +8 -0
- data/lib/lightspeed/inventory.rb +12 -0
- data/lib/lightspeed/item.rb +54 -18
- data/lib/lightspeed/item_attribute_set.rb +13 -0
- data/lib/lightspeed/item_attribute_sets.rb +8 -0
- data/lib/lightspeed/item_matrices.rb +4 -3
- data/lib/lightspeed/item_matrix.rb +48 -10
- data/lib/lightspeed/items.rb +4 -7
- data/lib/lightspeed/order.rb +34 -0
- data/lib/lightspeed/orders.rb +10 -0
- data/lib/lightspeed/prices.rb +43 -0
- data/lib/lightspeed/request.rb +74 -28
- data/lib/lightspeed/request_throttler.rb +31 -0
- data/lib/lightspeed/resource.rb +221 -0
- data/lib/lightspeed/sale.rb +57 -0
- data/lib/lightspeed/sale_line.rb +52 -0
- data/lib/lightspeed/sale_lines.rb +9 -0
- data/lib/lightspeed/sales.rb +10 -0
- data/lib/lightspeed/shop.rb +30 -0
- data/lib/lightspeed/shops.rb +8 -0
- data/lib/lightspeed/special_order.rb +22 -0
- data/lib/lightspeed/special_orders.rb +10 -0
- data/lib/lightspeed/vendor.rb +23 -0
- data/lib/lightspeed/vendors.rb +9 -0
- data/lib/lightspeed/version.rb +1 -1
- data/lib/lightspeed_pos.rb +2 -4
- data/lightspeed_pos.gemspec +3 -3
- data/script/buildkite +11 -0
- data/script/docker_tests +29 -0
- metadata +63 -24
- data/lib/lightspeed/account_resources.rb +0 -103
- data/lib/lightspeed/base.rb +0 -17
@@ -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
|
data/lib/lightspeed/version.rb
CHANGED
data/lib/lightspeed_pos.rb
CHANGED
data/lightspeed_pos.gemspec
CHANGED
@@ -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 "
|
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
|
data/script/docker_tests
ADDED
@@ -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.
|
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:
|
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.
|
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.
|
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/
|
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/
|
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.
|
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
|
data/lib/lightspeed/base.rb
DELETED
@@ -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
|