lightspeed_pos 0.1.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.mailmap +4 -0
- data/.rubocop.yml +32 -24
- data/.rubocop_todo.yml +284 -0
- data/.travis.yml +5 -3
- data/Gemfile +2 -0
- data/README.markdown +85 -28
- data/Rakefile +2 -0
- data/bin/console +33 -6
- data/lib/lightspeed/account.rb +50 -43
- data/lib/lightspeed/accounts.rb +24 -0
- data/lib/lightspeed/categories.rb +7 -5
- data/lib/lightspeed/category.rb +18 -7
- data/lib/lightspeed/client.rb +41 -27
- data/lib/lightspeed/collection.rb +214 -0
- data/lib/lightspeed/customer.rb +36 -0
- data/lib/lightspeed/customers.rb +11 -0
- data/lib/lightspeed/employee.rb +27 -0
- data/lib/lightspeed/employees.rb +10 -0
- data/lib/lightspeed/error.rb +17 -0
- data/lib/lightspeed/image.rb +37 -0
- data/lib/lightspeed/images.rb +18 -0
- data/lib/lightspeed/inventories.rb +10 -0
- data/lib/lightspeed/inventory.rb +14 -0
- data/lib/lightspeed/item.rb +55 -18
- data/lib/lightspeed/item_attribute_set.rb +15 -0
- data/lib/lightspeed/item_attribute_sets.rb +10 -0
- data/lib/lightspeed/item_matrices.rb +6 -3
- data/lib/lightspeed/item_matrix.rb +50 -10
- data/lib/lightspeed/items.rb +6 -7
- data/lib/lightspeed/order.rb +36 -0
- data/lib/lightspeed/orders.rb +12 -0
- data/lib/lightspeed/price_level.rb +16 -0
- data/lib/lightspeed/price_levels.rb +10 -0
- data/lib/lightspeed/prices.rb +45 -0
- data/lib/lightspeed/request.rb +98 -29
- data/lib/lightspeed/request_throttler.rb +33 -0
- data/lib/lightspeed/resource.rb +221 -0
- data/lib/lightspeed/sale.rb +59 -0
- data/lib/lightspeed/sale_line.rb +54 -0
- data/lib/lightspeed/sale_lines.rb +11 -0
- data/lib/lightspeed/sales.rb +12 -0
- data/lib/lightspeed/shop.rb +32 -0
- data/lib/lightspeed/shops.rb +10 -0
- data/lib/lightspeed/special_order.rb +24 -0
- data/lib/lightspeed/special_orders.rb +12 -0
- data/lib/lightspeed/vendor.rb +25 -0
- data/lib/lightspeed/vendors.rb +11 -0
- data/lib/lightspeed/version.rb +3 -1
- data/lib/lightspeed_pos.rb +5 -5
- data/lightspeed_pos.gemspec +11 -7
- data/script/buildkite +24 -0
- data/script/docker_tests +29 -0
- metadata +96 -38
- data/lib/lightspeed/account_resources.rb +0 -103
- data/lib/lightspeed/base.rb +0 -17
- data/lib/lightspeed/errors.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 698710d57a5ef3c30c022c2f050b9df04976227b2482a3075c851b27db3642fe
|
4
|
+
data.tar.gz: 6abdc460a2cd345883c2cb853c9c6c16051273606914d7ba5fcaa72089402dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03f3b9db98a4145a9751b2990beabccf96d79a78fece26a40a3163ffe0d8604ea41ad0316b52ce9a3e27f77fea1e6cb0ce708438bc37c22cacef0a0401ef9245
|
7
|
+
data.tar.gz: 3c8f3710b4f8e76bda81e5e02265115c0252c38b8c177ff707c9dab53026da1d8598504d77ae9d31c3a17a0cfa2796d5cd293355b25b7c8aeca4e44762e26830
|
data/.mailmap
ADDED
data/.rubocop.yml
CHANGED
@@ -1,69 +1,77 @@
|
|
1
|
-
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
NewCops: enable
|
5
|
+
SuggestExtensions:
|
6
|
+
rubocop-rake: false
|
7
|
+
rubocop-rspec: false
|
8
|
+
|
9
|
+
Layout/HashAlignment:
|
2
10
|
EnforcedLastArgumentHashStyle: always_ignore
|
3
11
|
|
4
|
-
|
12
|
+
Layout/ParameterAlignment:
|
5
13
|
Enabled: false
|
6
14
|
|
7
|
-
LineLength:
|
15
|
+
Layout/LineLength:
|
8
16
|
Max: 180
|
9
17
|
|
10
|
-
ClassLength:
|
18
|
+
Metrics/ClassLength:
|
11
19
|
Enabled: true
|
12
20
|
Severity: refactor
|
13
21
|
Max: 300
|
14
22
|
|
15
|
-
MethodLength:
|
23
|
+
Metrics/MethodLength:
|
16
24
|
Enabled: true
|
17
25
|
Max: 30
|
18
26
|
Severity: refactor
|
19
27
|
|
20
|
-
CyclomaticComplexity:
|
28
|
+
Metrics/CyclomaticComplexity:
|
21
29
|
Max: 10
|
22
30
|
Severity: refactor
|
23
31
|
|
24
|
-
EndAlignment:
|
32
|
+
Layout/EndAlignment:
|
25
33
|
Enabled: false
|
26
34
|
|
27
|
-
StringLiterals:
|
35
|
+
Style/StringLiterals:
|
28
36
|
Enabled: false
|
29
37
|
|
30
|
-
Documentation:
|
38
|
+
Style/Documentation:
|
31
39
|
Enabled: false
|
32
40
|
|
33
|
-
PercentLiteralDelimiters:
|
41
|
+
Style/PercentLiteralDelimiters:
|
34
42
|
PreferredDelimiters:
|
35
43
|
'%w': '{}'
|
36
44
|
|
37
|
-
MethodDefParentheses:
|
45
|
+
Style/MethodDefParentheses:
|
38
46
|
Enabled: false
|
39
47
|
|
40
|
-
PredicateName:
|
41
|
-
|
48
|
+
Naming/PredicateName:
|
49
|
+
ForbiddenPrefixes:
|
42
50
|
- is_
|
43
51
|
- have_
|
44
52
|
|
45
|
-
|
53
|
+
Layout/FirstHashElementIndentation:
|
46
54
|
EnforcedStyle: consistent
|
47
55
|
|
48
56
|
# breaks using if blocks with assignments
|
49
|
-
IndentationWidth:
|
57
|
+
Layout/IndentationWidth:
|
50
58
|
Enabled: false
|
51
59
|
|
52
|
-
CaseIndentation:
|
53
|
-
|
54
|
-
|
55
|
-
FormatString:
|
56
|
-
Enabled: false
|
60
|
+
Layout/CaseIndentation:
|
61
|
+
EnforcedStyle: end
|
57
62
|
|
58
|
-
|
63
|
+
Style/FormatString:
|
59
64
|
Enabled: false
|
60
65
|
|
61
66
|
# different methods calls that do exactly the same thing are a smell, regardless of semantics
|
62
|
-
SignalException:
|
67
|
+
Style/SignalException:
|
63
68
|
EnforcedStyle: only_raise
|
64
69
|
|
65
|
-
DoubleNegation:
|
70
|
+
Style/DoubleNegation:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Style/TrailingCommaInArrayLiteral:
|
66
74
|
Enabled: false
|
67
75
|
|
68
|
-
|
76
|
+
Style/TrailingCommaInArguments:
|
69
77
|
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,284 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-05-06 09:20:12 +1000 using RuboCop version 0.68.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 3
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, Include.
|
12
|
+
# Include: **/*.gemspec
|
13
|
+
Gemspec/OrderedDependencies:
|
14
|
+
Exclude:
|
15
|
+
- 'lightspeed_pos.gemspec'
|
16
|
+
|
17
|
+
# Offense count: 5
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
Layout/EmptyLineAfterGuardClause:
|
20
|
+
Exclude:
|
21
|
+
- 'bin/console'
|
22
|
+
- 'lib/lightspeed/collection.rb'
|
23
|
+
- 'lib/lightspeed/request.rb'
|
24
|
+
|
25
|
+
# Offense count: 1
|
26
|
+
# Cop supports --auto-correct.
|
27
|
+
Layout/EmptyLineAfterMagicComment:
|
28
|
+
Exclude:
|
29
|
+
- 'lightspeed_pos.gemspec'
|
30
|
+
|
31
|
+
# Offense count: 1
|
32
|
+
# Cop supports --auto-correct.
|
33
|
+
# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
|
34
|
+
Layout/EmptyLineBetweenDefs:
|
35
|
+
Exclude:
|
36
|
+
- 'lib/lightspeed/resource.rb'
|
37
|
+
|
38
|
+
# Offense count: 1
|
39
|
+
# Cop supports --auto-correct.
|
40
|
+
Layout/EmptyLines:
|
41
|
+
Exclude:
|
42
|
+
- 'lib/lightspeed/resource.rb'
|
43
|
+
|
44
|
+
# Offense count: 7
|
45
|
+
# Cop supports --auto-correct.
|
46
|
+
# Configuration parameters: EnforcedStyle.
|
47
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
48
|
+
Layout/EmptyLinesAroundBlockBody:
|
49
|
+
Exclude:
|
50
|
+
- 'spec/lightspeed/orders_spec.rb'
|
51
|
+
- 'spec/lightspeed/sale_line_spec.rb'
|
52
|
+
- 'spec/lightspeed/sale_spec.rb'
|
53
|
+
- 'spec/lightspeed/sales_spec.rb'
|
54
|
+
- 'spec/lightspeed/special_order_spec.rb'
|
55
|
+
- 'spec/lightspeed/special_orders_spec.rb'
|
56
|
+
- 'spec/lightspeed/vendor_spec.rb'
|
57
|
+
|
58
|
+
# Offense count: 7
|
59
|
+
# Cop supports --auto-correct.
|
60
|
+
# Configuration parameters: EnforcedStyle.
|
61
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
|
62
|
+
Layout/EmptyLinesAroundClassBody:
|
63
|
+
Exclude:
|
64
|
+
- 'lib/lightspeed/customer.rb'
|
65
|
+
- 'lib/lightspeed/order.rb'
|
66
|
+
- 'lib/lightspeed/request_throttler.rb'
|
67
|
+
- 'lib/lightspeed/sale.rb'
|
68
|
+
- 'lib/lightspeed/sale_line.rb'
|
69
|
+
- 'lib/lightspeed/vendor.rb'
|
70
|
+
|
71
|
+
# Offense count: 3
|
72
|
+
# Cop supports --auto-correct.
|
73
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
74
|
+
# SupportedStyles: aligned, indented, indented_relative_to_receiver
|
75
|
+
Layout/MultilineMethodCallIndentation:
|
76
|
+
Exclude:
|
77
|
+
- 'lib/lightspeed/collection.rb'
|
78
|
+
|
79
|
+
# Offense count: 1
|
80
|
+
# Cop supports --auto-correct.
|
81
|
+
Layout/SpaceAfterNot:
|
82
|
+
Exclude:
|
83
|
+
- 'lib/lightspeed/request.rb'
|
84
|
+
|
85
|
+
# Offense count: 1
|
86
|
+
# Cop supports --auto-correct.
|
87
|
+
# Configuration parameters: AllowForAlignment.
|
88
|
+
Layout/SpaceAroundOperators:
|
89
|
+
Exclude:
|
90
|
+
- 'lib/lightspeed/request_throttler.rb'
|
91
|
+
|
92
|
+
# Offense count: 3
|
93
|
+
# Cop supports --auto-correct.
|
94
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
95
|
+
# SupportedStyles: space, no_space, compact
|
96
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
97
|
+
Layout/SpaceInsideHashLiteralBraces:
|
98
|
+
Exclude:
|
99
|
+
- 'spec/lightspeed/sales_spec.rb'
|
100
|
+
|
101
|
+
# Offense count: 14
|
102
|
+
# Cop supports --auto-correct.
|
103
|
+
# Configuration parameters: EnforcedStyle.
|
104
|
+
# SupportedStyles: final_newline, final_blank_line
|
105
|
+
Layout/TrailingEmptyLines:
|
106
|
+
Exclude:
|
107
|
+
- 'lib/lightspeed/customer.rb'
|
108
|
+
- 'lib/lightspeed/customers.rb'
|
109
|
+
- 'lib/lightspeed/order.rb'
|
110
|
+
- 'lib/lightspeed/orders.rb'
|
111
|
+
- 'lib/lightspeed/sale.rb'
|
112
|
+
- 'lib/lightspeed/sale_line.rb'
|
113
|
+
- 'lib/lightspeed/sale_lines.rb'
|
114
|
+
- 'lib/lightspeed/sales.rb'
|
115
|
+
- 'lib/lightspeed/special_order.rb'
|
116
|
+
- 'lib/lightspeed/special_orders.rb'
|
117
|
+
- 'spec/lightspeed/sale_line_spec.rb'
|
118
|
+
- 'spec/lightspeed/sale_spec.rb'
|
119
|
+
- 'spec/lightspeed/sales_spec.rb'
|
120
|
+
- 'spec/lightspeed/special_order_spec.rb'
|
121
|
+
|
122
|
+
# Offense count: 1
|
123
|
+
# Configuration parameters: AllowSafeAssignment.
|
124
|
+
Lint/AssignmentInCondition:
|
125
|
+
Exclude:
|
126
|
+
- 'lib/lightspeed/request.rb'
|
127
|
+
|
128
|
+
# Offense count: 2
|
129
|
+
# Cop supports --auto-correct.
|
130
|
+
Lint/BigDecimalNew:
|
131
|
+
Exclude:
|
132
|
+
- 'lib/lightspeed/prices.rb'
|
133
|
+
- 'lib/lightspeed/resource.rb'
|
134
|
+
|
135
|
+
# Offense count: 3
|
136
|
+
Lint/DuplicateMethods:
|
137
|
+
Exclude:
|
138
|
+
- 'lib/lightspeed/resource.rb'
|
139
|
+
|
140
|
+
# Offense count: 1
|
141
|
+
# Cop supports --auto-correct.
|
142
|
+
# Configuration parameters: EnforcedStyle.
|
143
|
+
# SupportedStyles: runtime_error, standard_error
|
144
|
+
Lint/InheritException:
|
145
|
+
Exclude:
|
146
|
+
- 'lib/lightspeed/error.rb'
|
147
|
+
|
148
|
+
# Offense count: 3
|
149
|
+
# Cop supports --auto-correct.
|
150
|
+
Lint/ToJSON:
|
151
|
+
Exclude:
|
152
|
+
- 'lib/lightspeed/collection.rb'
|
153
|
+
- 'lib/lightspeed/prices.rb'
|
154
|
+
- 'lib/lightspeed/resource.rb'
|
155
|
+
|
156
|
+
# Offense count: 1
|
157
|
+
# Configuration parameters: CheckForMethodsWithNoSideEffects.
|
158
|
+
Lint/Void:
|
159
|
+
Exclude:
|
160
|
+
- 'lib/lightspeed/resource.rb'
|
161
|
+
|
162
|
+
# Offense count: 7
|
163
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
164
|
+
# ExcludedMethods: refine
|
165
|
+
Metrics/BlockLength:
|
166
|
+
Max: 82
|
167
|
+
|
168
|
+
# Offense count: 2
|
169
|
+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
170
|
+
# AllowedNames: io, id, to, by, on, in, at, ip, db
|
171
|
+
Naming/MethodParameterName:
|
172
|
+
Exclude:
|
173
|
+
- 'lib/lightspeed/accounts.rb'
|
174
|
+
- 'lib/lightspeed/collection.rb'
|
175
|
+
|
176
|
+
# Offense count: 14
|
177
|
+
# Cop supports --auto-correct.
|
178
|
+
# Configuration parameters: EnforcedStyle.
|
179
|
+
# SupportedStyles: prefer_alias, prefer_alias_method
|
180
|
+
Style/Alias:
|
181
|
+
Exclude:
|
182
|
+
- 'lib/lightspeed/collection.rb'
|
183
|
+
- 'lib/lightspeed/customer.rb'
|
184
|
+
- 'lib/lightspeed/customers.rb'
|
185
|
+
- 'lib/lightspeed/item.rb'
|
186
|
+
- 'lib/lightspeed/items.rb'
|
187
|
+
- 'lib/lightspeed/order.rb'
|
188
|
+
- 'lib/lightspeed/orders.rb'
|
189
|
+
- 'lib/lightspeed/prices.rb'
|
190
|
+
- 'lib/lightspeed/resource.rb'
|
191
|
+
- 'lib/lightspeed/sale.rb'
|
192
|
+
- 'lib/lightspeed/sales.rb'
|
193
|
+
- 'lib/lightspeed/vendor.rb'
|
194
|
+
- 'lib/lightspeed/vendors.rb'
|
195
|
+
|
196
|
+
# Offense count: 1
|
197
|
+
# Cop supports --auto-correct.
|
198
|
+
# Configuration parameters: Keywords.
|
199
|
+
# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW
|
200
|
+
Style/CommentAnnotation:
|
201
|
+
Exclude:
|
202
|
+
- 'spec/lightspeed/sales_spec.rb'
|
203
|
+
|
204
|
+
# Offense count: 6
|
205
|
+
Style/CommentedKeyword:
|
206
|
+
Exclude:
|
207
|
+
- 'lib/lightspeed/error.rb'
|
208
|
+
|
209
|
+
# Offense count: 1
|
210
|
+
# Cop supports --auto-correct.
|
211
|
+
Style/EmptyCaseCondition:
|
212
|
+
Exclude:
|
213
|
+
- 'lib/lightspeed/resource.rb'
|
214
|
+
|
215
|
+
# Offense count: 1
|
216
|
+
# Cop supports --auto-correct.
|
217
|
+
Style/Encoding:
|
218
|
+
Exclude:
|
219
|
+
- 'lightspeed_pos.gemspec'
|
220
|
+
|
221
|
+
# Offense count: 2
|
222
|
+
# Cop supports --auto-correct.
|
223
|
+
Style/ExpandPathArguments:
|
224
|
+
Exclude:
|
225
|
+
- 'lightspeed_pos.gemspec'
|
226
|
+
- 'spec/spec_helper.rb'
|
227
|
+
|
228
|
+
# Offense count: 2
|
229
|
+
# Configuration parameters: MinBodyLength.
|
230
|
+
Style/GuardClause:
|
231
|
+
Exclude:
|
232
|
+
- 'lib/lightspeed/request.rb'
|
233
|
+
- 'lib/lightspeed/resource.rb'
|
234
|
+
|
235
|
+
# Offense count: 4
|
236
|
+
# Cop supports --auto-correct.
|
237
|
+
Style/IfUnlessModifier:
|
238
|
+
Exclude:
|
239
|
+
- 'lib/lightspeed/resource.rb'
|
240
|
+
- 'spec/spec_helper.rb'
|
241
|
+
|
242
|
+
# Offense count: 1
|
243
|
+
Style/MissingRespondToMissing:
|
244
|
+
Exclude:
|
245
|
+
- 'lib/lightspeed/prices.rb'
|
246
|
+
|
247
|
+
# Offense count: 1
|
248
|
+
# Cop supports --auto-correct.
|
249
|
+
# Configuration parameters: EnforcedStyle.
|
250
|
+
# SupportedStyles: literals, strict
|
251
|
+
Style/MutableConstant:
|
252
|
+
Exclude:
|
253
|
+
- 'lib/lightspeed/version.rb'
|
254
|
+
|
255
|
+
# Offense count: 1
|
256
|
+
# Cop supports --auto-correct.
|
257
|
+
Style/OneLineConditional:
|
258
|
+
Exclude:
|
259
|
+
- 'lib/lightspeed/request_throttler.rb'
|
260
|
+
|
261
|
+
# Offense count: 1
|
262
|
+
# Cop supports --auto-correct.
|
263
|
+
Style/ParallelAssignment:
|
264
|
+
Exclude:
|
265
|
+
- 'lib/lightspeed/request_throttler.rb'
|
266
|
+
|
267
|
+
# Offense count: 1
|
268
|
+
# Cop supports --auto-correct.
|
269
|
+
Style/RedundantSelf:
|
270
|
+
Exclude:
|
271
|
+
- 'lib/lightspeed/resource.rb'
|
272
|
+
|
273
|
+
# Offense count: 1
|
274
|
+
# Cop supports --auto-correct.
|
275
|
+
Style/SelfAssignment:
|
276
|
+
Exclude:
|
277
|
+
- 'spec/lightspeed/client_spec.rb'
|
278
|
+
|
279
|
+
# Offense count: 3
|
280
|
+
# Cop supports --auto-correct.
|
281
|
+
# Configuration parameters: MinSize.
|
282
|
+
# SupportedStyles: percent, brackets
|
283
|
+
Style/SymbolArray:
|
284
|
+
EnforcedStyle: brackets
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -1,46 +1,50 @@
|
|
1
1
|
# Lightspeed POS
|
2
2
|
|
3
|
-
[
|
4
|
-
[![Code Climate](https://codeclimate.com/github/radar/lightspeed-pos/badges/gpa.svg)](https://codeclimate.com/github/radar/lightspeed-pos)
|
3
|
+
An _unofficial_ gem for interacting with [Lightspeed's Point of Sale API](http://www.lightspeedpos.com/retail/help/developers/api/basics/), ([documentation](http://cloud-docs.lightspeedapp.com/API/APIHelp.help)).
|
5
4
|
|
6
|
-
|
7
|
-
An _unofficial_ gem for interacting with [Lightspeed's Point of Sale API](http://www.lightspeedpos.com/retail/help/developers/api/basics/). Works with API keys for the time being.
|
8
|
-
|
9
|
-
Most definitely not production ready yet, but you can help by submitting pull requests!
|
5
|
+
Not all endpoints are implemented yet, but you can help by submitting pull requests!
|
10
6
|
|
11
7
|
## Getting Started
|
12
8
|
|
13
9
|
First, intialize a new client:
|
14
10
|
|
15
11
|
```ruby
|
16
|
-
client = Lightspeed::Client.new(
|
12
|
+
client = Lightspeed::Client.new(oauth_token_holder: yourOAuthAwareObjectHere)
|
17
13
|
```
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
client = Lightspeed::Client.new(oauth_token: "YOUR_ACCESS_TOKEN_HERE")
|
23
|
-
```
|
15
|
+
`yourOAuthAwareObjectHere` must be an object that responds to `oauth_token` and `refresh_oauth_token`. `oauth_token` must return an access token, and `refresh_oauth_token` must handle the refreshing of expired access tokens, so that a subsequent call to `oauth_token` will return a new, unexpired access token.
|
24
16
|
|
25
17
|
Next, make a request for your accounts:
|
26
18
|
|
27
19
|
```ruby
|
28
|
-
accounts = client.accounts
|
20
|
+
accounts = client.accounts.all
|
29
21
|
```
|
30
22
|
|
31
23
|
Pick the account you want to use, and then start using it:
|
32
24
|
|
33
25
|
```ruby
|
34
26
|
account = accounts.first
|
35
|
-
account.items
|
27
|
+
account.items.first
|
36
28
|
```
|
37
29
|
|
38
|
-
##
|
30
|
+
## Resources
|
39
31
|
|
40
|
-
|
32
|
+
resources share a common API. Resources that are currently supported by this library are:
|
41
33
|
|
34
|
+
* Accounts
|
42
35
|
* Categories
|
36
|
+
* Employees
|
43
37
|
* Items
|
38
|
+
* Item Matrices
|
39
|
+
* Item Attribute Sets
|
40
|
+
* Images
|
41
|
+
* Inventories
|
42
|
+
* Orders
|
43
|
+
* Sales
|
44
|
+
* Shops
|
45
|
+
* Special Orders
|
46
|
+
* Vendors
|
47
|
+
* Customers
|
44
48
|
|
45
49
|
To work with account resources, you first need to fetch an account. The examples below are for items, but will also work with other types listed above.
|
46
50
|
|
@@ -52,6 +56,28 @@ You can fetch a list of items with this:
|
|
52
56
|
account.items.all
|
53
57
|
```
|
54
58
|
|
59
|
+
You can pass query parameters to this by using the `params` keyword:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
account.items.all(params: { itemMatrixID: 0 })
|
63
|
+
```
|
64
|
+
|
65
|
+
You can enumerate over a group of 100 resources at a time (the max in a single request) using `each_page`
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
account.items.each_page! do |items|
|
69
|
+
# ItemImporter.import(items)
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
Or enumerate over each resource using #each (this still only does a request for each 100 items)
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
account.items.each do |item|
|
77
|
+
# ItemImporter.import(item)
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
55
81
|
### Show
|
56
82
|
|
57
83
|
You can fetch a particular item by its ID by doing this:
|
@@ -59,15 +85,19 @@ You can fetch a particular item by its ID by doing this:
|
|
59
85
|
```ruby
|
60
86
|
account.items.find(1)
|
61
87
|
```
|
88
|
+
If item with id of `1` is not there, this will raise `Lightspeed::Error::NotFound`
|
89
|
+
|
90
|
+
You can fetch the first item using `first`
|
91
|
+
```ruby
|
92
|
+
account.items.first
|
93
|
+
```
|
62
94
|
|
63
95
|
### Create
|
64
96
|
|
65
97
|
You can create a particular item by calling `create`:
|
66
98
|
|
67
99
|
```ruby
|
68
|
-
account.items.create(
|
69
|
-
description: "Onesie"
|
70
|
-
})
|
100
|
+
account.items.create(description: "Onesie")
|
71
101
|
```
|
72
102
|
|
73
103
|
### Update
|
@@ -75,24 +105,51 @@ account.items.create({
|
|
75
105
|
You can update a particular item by calling `update`, passing that item's ID and providing a list of attributes to update:
|
76
106
|
|
77
107
|
```ruby
|
78
|
-
account.items.update(1,
|
79
|
-
|
80
|
-
|
108
|
+
account.items.update(1, description: "Onesie")
|
109
|
+
# OR
|
110
|
+
account.items.find(1)
|
111
|
+
item.update(description: "Onesie")
|
81
112
|
```
|
82
113
|
|
83
|
-
This method isn't available on items themselves because I couldn't work out how to share the account ID easily there.
|
84
|
-
|
85
114
|
### Destroy
|
86
115
|
|
87
116
|
You can destroy a particular item by calling `destroy` and passing that item's ID:
|
88
117
|
|
89
118
|
```ruby
|
90
|
-
account.
|
119
|
+
account.images.destroy(1)
|
120
|
+
# OR
|
121
|
+
account.images.find(1)
|
122
|
+
item.destroy
|
91
123
|
```
|
92
124
|
|
93
|
-
For the `
|
125
|
+
For the `Item` resource, `destroy` is aliased to `archive`:
|
126
|
+
|
127
|
+
## Rate Limiting
|
128
|
+
|
129
|
+
This gem respects the `X-LS-API-Bucket-Level` header by pausing before a request that would otherwise overrun the API rate limit. It calls `Kernel.sleep` with the minimum number of seconds needed to avoid hitting the limit, which suspends the current thread during that time. If you need to make API calls across multiple Lightspeed accounts using this gem, its recommended to make requests against each account in a separate thread.
|
130
|
+
|
131
|
+
## Contributing
|
132
|
+
|
133
|
+
### Local setup
|
94
134
|
|
95
|
-
```ruby
|
96
|
-
account.items.archive(1)
|
97
135
|
```
|
136
|
+
$ bundle install
|
137
|
+
```
|
138
|
+
|
139
|
+
### How to run Tests
|
140
|
+
|
141
|
+
```
|
142
|
+
$ rspec
|
143
|
+
```
|
144
|
+
|
145
|
+
### How to write Tests
|
146
|
+
|
147
|
+
This repository uses the [`vcr` gem](https://github.com/vcr/vcr) to record HTTP interactions and replay them during next tests runs.
|
148
|
+
|
149
|
+
The following `ENV` variables are required for recording new HTTP interactions.
|
150
|
+
|
151
|
+
* `LIGHTSPEED_OAUTH_TOKEN` : not expired OAuth token
|
152
|
+
* `LIGHTSPEED_OAUTH_REFRESH_TOKEN` : the OAuth refresh token
|
153
|
+
* `LIGHTSPEED_ACCOUNT_ID` : a Ligthspeed account id
|
98
154
|
|
155
|
+
**Be careful with the data you set as real API calls will be performed.**
|