qbo_api 2.0.0 → 2.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/.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 +1 -2
- metadata +7 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdae2e1e7049a7b71c286a5e3b36056a100c89c8fad4a85690b174457f9b1072
|
4
|
+
data.tar.gz: 36baaf4f27090e11b630a620c0b08fe2f531ccd25436a7ea4d5f4156f2d53c12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7402792bd0691b386469c65543c729799a5aedd150a4a06e726c50d382cd7342a4215676cbb13b20898f93f1501525c03ea8481627003fd311d6332d828c03a
|
7
|
+
data.tar.gz: f3d4d4ba01db6d69dfccb22c5f4225d0b68e91c5e591384516971154b837aa06b370f822a8dc20f5c859ace71fe4c033bec002b44224505773c208459f44a1f4
|
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,11 +22,10 @@ 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'
|
29
|
-
spec.add_runtime_dependency 'faraday'
|
28
|
+
spec.add_runtime_dependency 'faraday', '~> 1.10.0'
|
30
29
|
spec.add_runtime_dependency 'faraday_middleware'
|
31
30
|
spec.add_runtime_dependency 'faraday-detailed_logger'
|
32
31
|
spec.add_runtime_dependency 'nokogiri'
|
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.
|
4
|
+
version: 2.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:
|
11
|
+
date: 2022-07-12 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
|
@@ -126,16 +112,16 @@ dependencies:
|
|
126
112
|
name: faraday
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
|
-
- - "
|
115
|
+
- - "~>"
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
117
|
+
version: 1.10.0
|
132
118
|
type: :runtime
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
|
-
- - "
|
122
|
+
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
124
|
+
version: 1.10.0
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: faraday_middleware
|
141
127
|
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
|