qbo_api 1.0.3 → 1.1.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.
- checksums.yaml +4 -4
- data/lib/qbo_api.rb +4 -6
- data/lib/qbo_api/entity.rb +15 -1
- data/lib/qbo_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9705a6a9fde66e76546b9203e846d505dd5d3f15
|
4
|
+
data.tar.gz: 171efdaf99db8369c5a7abe900ee2be306600a10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4ce0818cb0ef23707b903d765d092b6e2a784d1e3cfe2ac570cbe4be31d25a9bf91dc5dfde76281b62279543f31b650c67dd25591f0a1c8c991cf5ea2910da6
|
7
|
+
data.tar.gz: 8a9007b00ec9464125a5851c97a5f1754cc74472ff2292a0fbc7a505140b89693958632e2757f618988aa25900a7608df6d29d35a2f42f5cc251e38d98217bdc
|
data/lib/qbo_api.rb
CHANGED
@@ -59,24 +59,22 @@ class QboApi
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def get(entity, id)
|
62
|
-
path = "#{
|
62
|
+
path = "#{entity_path(entity)}/#{id}"
|
63
63
|
request(:get, entity: entity, path: path)
|
64
64
|
end
|
65
65
|
|
66
66
|
def create(entity, payload:)
|
67
|
-
path
|
68
|
-
request(:post, entity: entity, path: path, payload: payload)
|
67
|
+
request(:post, entity: entity, path: entity_path(entity), payload: payload)
|
69
68
|
end
|
70
69
|
|
71
70
|
def update(entity, id:, payload:)
|
72
|
-
path = "#{realm_id}/#{entity}"
|
73
71
|
payload.merge!(set_update(entity, id))
|
74
|
-
request(:post, entity: entity, path:
|
72
|
+
request(:post, entity: entity, path: entity_path(entity), payload: payload)
|
75
73
|
end
|
76
74
|
|
77
75
|
def delete(entity, id:)
|
78
76
|
raise QboApi::NotImplementedError unless is_transaction_entity?(entity)
|
79
|
-
path = "#{
|
77
|
+
path = "#{entity_path(entity)}?operation=delete"
|
80
78
|
payload = set_update(entity, id)
|
81
79
|
request(:post, entity: entity, path: path, payload: payload)
|
82
80
|
end
|
data/lib/qbo_api/entity.rb
CHANGED
@@ -13,6 +13,10 @@ class QboApi
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
def entity_path(entity)
|
17
|
+
"#{realm_id}/#{singular(entity).downcase}"
|
18
|
+
end
|
19
|
+
|
16
20
|
def snake_to_camel(sym)
|
17
21
|
sym.to_s.split('_').collect(&:capitalize).join
|
18
22
|
end
|
@@ -78,9 +82,19 @@ class QboApi
|
|
78
82
|
|
79
83
|
def extract_entity_from_query(query, to_sym: false)
|
80
84
|
if m = query.match(/from\s+(\w+)\s/i)
|
81
|
-
(to_sym ? m[1].
|
85
|
+
(to_sym ? underscore(m[1]).to_sym : m[1]) if m[1]
|
82
86
|
end
|
83
87
|
end
|
84
88
|
|
89
|
+
private
|
90
|
+
|
91
|
+
def underscore(entity)
|
92
|
+
entity.gsub(/::/, '/')
|
93
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
94
|
+
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
|
95
|
+
.tr("-", "_")
|
96
|
+
.downcase
|
97
|
+
end
|
98
|
+
|
85
99
|
end
|
86
100
|
end
|
data/lib/qbo_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qbo_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Pelczarski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|