lightspeed_ruby 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/lib/lightspeed/api/categories.rb +27 -0
- data/lib/lightspeed/api/customers.rb +17 -0
- data/lib/lightspeed/api/items.rb +21 -0
- data/lib/lightspeed/api/sales.rb +17 -0
- data/lib/lightspeed/api/sales/sale_lines.rb +25 -0
- data/lib/lightspeed/client.rb +20 -2
- data/lib/lightspeed/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99c19349a0b1ae4455685c1725d8d8dffedc43a7
|
4
|
+
data.tar.gz: 33663fccc4c8bb1a93d1497d176764f29545cbbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7480af20b6955a1d385b4559878602e063a0ffdbf76d021d93cc6663fcd157e32aab921118376a6d9c95fec0fda72c73de0a3f84c64e6098277e52a9d0e8b042
|
7
|
+
data.tar.gz: 69a5263c9fbb6a84e91a7c0a91eefd5b7e57d44cc69bd0a2375860a42d8867b049704bfba45cf0469211d0070971f17d51d083fc4824429801563877803c2abc
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Lightspeed
|
2
|
+
module API
|
3
|
+
class Categories
|
4
|
+
def initialize(client)
|
5
|
+
@client = client
|
6
|
+
end
|
7
|
+
|
8
|
+
def all
|
9
|
+
client.get("Account/#{client.account_id}/Category.json").body
|
10
|
+
end
|
11
|
+
|
12
|
+
def find(item_id, with: [])
|
13
|
+
client.get("Account/#{client.account_id}/Category/#{item_id}.json", relations: with).body
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :client
|
19
|
+
|
20
|
+
def chosen_relations(with)
|
21
|
+
with.map do |relation|
|
22
|
+
relation.to_s.camelize
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Lightspeed
|
2
|
+
module API
|
3
|
+
class Customers
|
4
|
+
def initialize(client)
|
5
|
+
@client = client
|
6
|
+
end
|
7
|
+
|
8
|
+
def find(customer_id, with: [])
|
9
|
+
client.get("Account/#{client.account_id}/Customer/#{customer_id}.json", relations: with).body
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
attr_reader :client
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Lightspeed
|
2
|
+
module API
|
3
|
+
class Items
|
4
|
+
def initialize(client)
|
5
|
+
@client = client
|
6
|
+
end
|
7
|
+
|
8
|
+
def find(item_id, with: [])
|
9
|
+
client.get("Account/#{client.account_id}/Item/#{item_id}.json", relations: with).body
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(attributes = {})
|
13
|
+
client.post("Account/#{client.account_id}/Item.json", body: attributes).body
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :client
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "lightspeed/api/sales/sale_lines"
|
2
|
+
|
3
|
+
module Lightspeed
|
4
|
+
module API
|
5
|
+
class Sales
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def sale_lines; API::Sales::SaleLines.new(client); end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
attr_reader :client
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Lightspeed
|
2
|
+
module API
|
3
|
+
class Sales
|
4
|
+
class SaleLines
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def all(sale_id)
|
10
|
+
client.
|
11
|
+
get("Account/#{client.account_id}/Sale/#{sale_id}/SaleLine.json").
|
12
|
+
body
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(attributes = {})
|
16
|
+
client.post("Account/#{client.account_id}/Sale/#{attributes[:saleID]}/SaleLine.json", body: attributes).body
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :client
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/lightspeed/client.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require "lightspeed/api/tokens"
|
2
2
|
require "lightspeed/api/accounts"
|
3
|
+
require "lightspeed/api/sales"
|
4
|
+
require "lightspeed/api/customers"
|
5
|
+
require "lightspeed/api/items"
|
6
|
+
require "lightspeed/api/categories"
|
3
7
|
|
4
8
|
module Lightspeed
|
5
9
|
class Client
|
@@ -16,11 +20,19 @@ module Lightspeed
|
|
16
20
|
@account_id = account_id
|
17
21
|
end
|
18
22
|
|
19
|
-
def get(url, params: {})
|
20
|
-
conn.get(url, params)
|
23
|
+
def get(url, params: {}, relations: [])
|
24
|
+
conn.get(url, params.merge(load_relations: "[#{relation_names(relations)}]"))
|
25
|
+
end
|
26
|
+
|
27
|
+
def post(url, body: {})
|
28
|
+
conn.post(url, body)
|
21
29
|
end
|
22
30
|
|
23
31
|
def accounts; API::Accounts.new(self); end
|
32
|
+
def sales; API::Sales.new(self); end
|
33
|
+
def customers; API::Customers.new(self); end
|
34
|
+
def items; API::Items.new(self); end
|
35
|
+
def categories; API::Categories.new(self); end
|
24
36
|
|
25
37
|
private
|
26
38
|
|
@@ -32,5 +44,11 @@ module Lightspeed
|
|
32
44
|
f.adapter Faraday.default_adapter
|
33
45
|
end
|
34
46
|
end
|
47
|
+
|
48
|
+
def relation_names(relations)
|
49
|
+
relations.map do |relation|
|
50
|
+
"\"#{relation.to_s.camelize}\""
|
51
|
+
end.join(",")
|
52
|
+
end
|
35
53
|
end
|
36
54
|
end
|
data/lib/lightspeed/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lightspeed_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zamith
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,6 +98,11 @@ files:
|
|
98
98
|
- bin/setup
|
99
99
|
- lib/lightspeed.rb
|
100
100
|
- lib/lightspeed/api/accounts.rb
|
101
|
+
- lib/lightspeed/api/categories.rb
|
102
|
+
- lib/lightspeed/api/customers.rb
|
103
|
+
- lib/lightspeed/api/items.rb
|
104
|
+
- lib/lightspeed/api/sales.rb
|
105
|
+
- lib/lightspeed/api/sales/sale_lines.rb
|
101
106
|
- lib/lightspeed/api/tokens.rb
|
102
107
|
- lib/lightspeed/client.rb
|
103
108
|
- lib/lightspeed/errors/missing_refresh_token.rb
|