qbo_api 2.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.test +0 -4
- data/.travis.yml +3 -3
- data/README.md +41 -27
- data/lib/qbo_api/connection.rb +6 -3
- data/lib/qbo_api/supporting.rb +15 -0
- data/lib/qbo_api/version.rb +1 -1
- data/qbo_api.gemspec +0 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 162fa8b773e3b73b82ea03e73d06ded342f6ac3bc7daafc9c02cc6a965a34aa7
|
4
|
+
data.tar.gz: a074c58fe2826531c2fe7a04cee0fecaf4021aac7e2c9a64fc30062fd3602fd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29a5b45354f2dbd9978fee3498dbfa96b660c6c747b93432b00836079f64e35d1448463ba13f055fc866e85804981f0a8110b6a429f23fc118da8a9f732d003b
|
7
|
+
data.tar.gz: f733937e458917500539ad443c8bfe61d29584b00caa2d8b7824d525170d2058806a7ad5e6a6a485ac05a6adf45be18feed8afff53372a7b7f643dd1fa1d40c2
|
data/.env.test
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Ruby client for the QuickBooks Online API version 3.
|
|
13
13
|
</a>
|
14
14
|
|
15
15
|
|
16
|
-
## Ruby >= 2.
|
16
|
+
## Ruby >= 2.6 required
|
17
17
|
|
18
18
|
## Installation
|
19
19
|
|
@@ -91,7 +91,6 @@ QboApi.minor_version = 8
|
|
91
91
|
# Works with .get, .create, .update, .query methods
|
92
92
|
```
|
93
93
|
|
94
|
-
|
95
94
|
### Create
|
96
95
|
```ruby
|
97
96
|
invoice = {
|
@@ -163,6 +162,40 @@ QboApi.minor_version = 8
|
|
163
162
|
p response.size # => 28
|
164
163
|
```
|
165
164
|
|
165
|
+
### Import/retrieve all
|
166
|
+
*Note: There is some overlap with the `all` and the `get` methods. The `get` method is limited to 1000 results where the `all` method will return all the results no matter the number.*
|
167
|
+
```ruby
|
168
|
+
# retrieves all active customers
|
169
|
+
qbo_api.all(:customers).each do |c|
|
170
|
+
p "#{c['Id']} #{c['DisplayName']}"
|
171
|
+
end
|
172
|
+
|
173
|
+
# retrieves all active or inactive employees
|
174
|
+
qbo_api.all(:employees, inactive: true).each do |e|
|
175
|
+
p "#{e['Id']} #{e['DisplayName']}"
|
176
|
+
end
|
177
|
+
|
178
|
+
# retrieves all vendors by groups of 5
|
179
|
+
qbo_api.all(:vendor, max: 5).each do |v|
|
180
|
+
p v['DisplayName']
|
181
|
+
end
|
182
|
+
|
183
|
+
# retrieves all customers by groups of 2 using a custom select query
|
184
|
+
where = "WHERE Id IN ('5', '6', '7', '8', '9', '10')"
|
185
|
+
qbo_api.all(:customer, max: 2, select: "SELECT * FROM Customer #{where}").each do |c|
|
186
|
+
p c['DisplayName']
|
187
|
+
end
|
188
|
+
```
|
189
|
+
|
190
|
+
#### Note: .all() returns a Ruby Enumerator
|
191
|
+
|
192
|
+
```
|
193
|
+
api.all(:clients).take(50).each { |c| p c["Id"] }
|
194
|
+
api.all(:clients).count
|
195
|
+
api.all(:clients).first
|
196
|
+
api.all(:clients).to_a
|
197
|
+
```
|
198
|
+
|
166
199
|
### Search with irregular characters
|
167
200
|
```ruby
|
168
201
|
# Use the .esc() method
|
@@ -173,6 +206,12 @@ QboApi.minor_version = 8
|
|
173
206
|
p response['Id'] # => 1
|
174
207
|
```
|
175
208
|
|
209
|
+
|
210
|
+
### Email a transaction entity
|
211
|
+
```ruby
|
212
|
+
api.send_invoice(invoice_id: 1, email_address: 'billy@joe.com')
|
213
|
+
```
|
214
|
+
|
176
215
|
### Uploading an attachment
|
177
216
|
```ruby
|
178
217
|
payload = {"AttachableRef":
|
@@ -282,31 +321,6 @@ See [docs](https://developer.intuit.com/docs/0100_quickbooks_online/0100_essenti
|
|
282
321
|
end
|
283
322
|
```
|
284
323
|
|
285
|
-
### Import/retrieve all
|
286
|
-
*Note: There is some overlap with the `all` and the `get` methods. The `get` method is limited to 1000 results where the `all` method will return all the results no matter the number.*
|
287
|
-
```ruby
|
288
|
-
# retrieves all active customers
|
289
|
-
qbo_api.all(:customers).each do |c|
|
290
|
-
p "#{c['Id']} #{c['DisplayName']}"
|
291
|
-
end
|
292
|
-
|
293
|
-
# retrieves all active or inactive employees
|
294
|
-
qbo_api.all(:employees, inactive: true).each do |e|
|
295
|
-
p "#{e['Id']} #{e['DisplayName']}"
|
296
|
-
end
|
297
|
-
|
298
|
-
# retrieves all vendors by groups of 5
|
299
|
-
qbo_api.all(:vendor, max: 5).each do |v|
|
300
|
-
p v['DisplayName']
|
301
|
-
end
|
302
|
-
|
303
|
-
# retrieves all customers by groups of 2 using a custom select query
|
304
|
-
where = "WHERE Id IN ('5', '6', '7', '8', '9', '10')"
|
305
|
-
qbo_api.all(:customer, max: 2, select: "SELECT * FROM Customer #{where}").each do |c|
|
306
|
-
p c['DisplayName']
|
307
|
-
end
|
308
|
-
```
|
309
|
-
|
310
324
|
### What kind of QuickBooks entity?
|
311
325
|
```ruby
|
312
326
|
p qbo_api.is_transaction_entity?(:invoice) # => true
|
data/lib/qbo_api/connection.rb
CHANGED
@@ -37,14 +37,17 @@ class QboApi
|
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
40
|
-
def request(method, path:, entity: nil, payload: nil, params: nil)
|
41
|
-
raw_response = raw_request(method, conn: connection, path: path, params: params, payload: payload)
|
40
|
+
def request(method, path:, entity: nil, payload: nil, params: nil, headers: nil)
|
41
|
+
raw_response = raw_request(method, conn: connection, path: path, params: params, payload: payload, headers: headers)
|
42
42
|
response(raw_response, entity: entity)
|
43
43
|
end
|
44
44
|
|
45
|
-
def raw_request(method, conn:, path:, payload: nil, params: nil)
|
45
|
+
def raw_request(method, conn:, path:, payload: nil, params: nil, headers: nil)
|
46
46
|
path = finalize_path(path, method: method, params: params)
|
47
|
+
|
47
48
|
conn.public_send(method) do |req|
|
49
|
+
req.headers = headers if headers
|
50
|
+
|
48
51
|
case method
|
49
52
|
when :get, :delete
|
50
53
|
req.url path
|
data/lib/qbo_api/supporting.rb
CHANGED
@@ -16,5 +16,20 @@ class QboApi
|
|
16
16
|
path = add_params_to_path(path: path, params: params) if params
|
17
17
|
request(:get, path: path)
|
18
18
|
end
|
19
|
+
|
20
|
+
def deliver(entity, entity_id:, email_address: nil)
|
21
|
+
valid_entities = %i(invoice estimate purchaseorder creditmemo salesreceipt refundreceipt)
|
22
|
+
unless valid_entities.include?(entity.to_sym)
|
23
|
+
raise ArgumentError, "Invalid entity type '#{entity}'. Must be one of: #{valid_entities.join(', ')}"
|
24
|
+
end
|
25
|
+
|
26
|
+
path = "#{realm_id}/#{entity}/#{entity_id}/send"
|
27
|
+
unless email_address.nil?
|
28
|
+
params = { minorversion: 63, sendTo: email_address }
|
29
|
+
path = add_params_to_path(path: path, params: params)
|
30
|
+
end
|
31
|
+
headers = { 'Content-Type' => 'application/octet-stream' }
|
32
|
+
request(:post, path: path, headers: headers)
|
33
|
+
end
|
19
34
|
end
|
20
35
|
end
|
data/lib/qbo_api/version.rb
CHANGED
data/qbo_api.gemspec
CHANGED
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
24
|
spec.add_development_dependency 'webmock'
|
25
|
-
spec.add_development_dependency 'simple_oauth'
|
26
25
|
spec.add_development_dependency 'dotenv'
|
27
26
|
spec.add_development_dependency 'vcr'
|
28
27
|
spec.add_development_dependency 'amazing_print'
|
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: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Pelczarski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: simple_oauth
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: dotenv
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -233,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
219
|
- !ruby/object:Gem::Version
|
234
220
|
version: '0'
|
235
221
|
requirements: []
|
236
|
-
rubygems_version: 3.
|
222
|
+
rubygems_version: 3.2.22
|
237
223
|
signing_key:
|
238
224
|
specification_version: 4
|
239
225
|
summary: Ruby JSON-only client for QuickBooks Online API v3. Built on top of the Faraday
|