qbo_api 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +13 -4
- data/bin/console +5 -0
- data/lib/qbo_api.rb +11 -3
- data/lib/qbo_api/util.rb +16 -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: 03b3f06c76e70aa87331ccf79916407536a54bed
|
4
|
+
data.tar.gz: 79b5441fe6ec65d06153ab200a5fe27a88735d6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 800b0c6ccb9a1f1cf70867038cd035b364426b6f83656a6bbc8c3f864cf0b1a6a851f2602a83ccd5ab457ca42223edf432e5dc51d7f33f3b1d12c4acc202cb6c
|
7
|
+
data.tar.gz: 4657a2c0bb876fdd994ff5ebd0abb3bdb616f2be5bec033b51210fe488122148a87b6c6d27e9f08b7431e10e85c1fd2565b8c934b917c4e769917e63d0c7c692
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -117,6 +117,12 @@ QboApi.request_id = true
|
|
117
117
|
p response['status'] # => "Deleted"
|
118
118
|
```
|
119
119
|
|
120
|
+
### Deactivate (only works for name list entities)
|
121
|
+
```ruby
|
122
|
+
response = qbo_api.deactivate(:employee, id: 55)
|
123
|
+
p response['Active'] # => false
|
124
|
+
```
|
125
|
+
|
120
126
|
### Search with irregular characters
|
121
127
|
```ruby
|
122
128
|
name = qbo_api.esc "Amy's Bird Sanctuary"
|
@@ -206,11 +212,16 @@ See [docs](https://developer.intuit.com/docs/0100_quickbooks_online/0100_essenti
|
|
206
212
|
|
207
213
|
### Import/retrieve all
|
208
214
|
```ruby
|
209
|
-
# retrieves all customers
|
215
|
+
# retrieves all active customers
|
210
216
|
qbo_api.all(:customers) do |c|
|
211
217
|
p "#{c['Id']} #{c['DisplayName']}"
|
212
218
|
end
|
213
219
|
|
220
|
+
# retrieves all active or inactive employees
|
221
|
+
qbo_api.all(:employees, inactive: true) do |e|
|
222
|
+
p "#{e['Id']} #{e['DisplayName']}"
|
223
|
+
end
|
224
|
+
|
214
225
|
# retrieves all vendors by groups of 5
|
215
226
|
qbo_api.all(:vendor, max: 5) do |v|
|
216
227
|
p v['DisplayName']
|
@@ -283,9 +294,7 @@ export QBO_API_COMPANY_ID=12345
|
|
283
294
|
|
284
295
|
#### Protip: Once your .env file is completely filled out you can use the console to play around in your sandbox
|
285
296
|
```
|
286
|
-
bin/console
|
287
|
-
>> require_relative 'spec/spec_helper'
|
288
|
-
>> VCR.configure { |c| c.allow_http_connections_when_no_cassette = true }
|
297
|
+
bin/console test
|
289
298
|
>> q = QboApi.new(creds.to_h)
|
290
299
|
>> q.get :customer, 1
|
291
300
|
```
|
data/bin/console
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
require "bundler/setup"
|
4
4
|
require "qbo_api"
|
5
5
|
|
6
|
+
if ARGV[0] == "test"
|
7
|
+
require_relative '../spec/support/credentials'
|
8
|
+
ARGV[0] = nil # needed to avoid irb error
|
9
|
+
end
|
10
|
+
|
6
11
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
12
|
# with your gem easier. You can also use a different console, if you like.
|
8
13
|
|
data/lib/qbo_api.rb
CHANGED
@@ -71,12 +71,20 @@ class QboApi
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def delete(entity, id:)
|
74
|
-
|
74
|
+
err_msg = "Delete is only for transaction entities. Use .deactivate instead"
|
75
|
+
raise QboApi::NotImplementedError.new, err_msg unless is_transaction_entity?(entity)
|
75
76
|
path = add_params_to_path(path: entity_path(entity), params: { operation: :delete })
|
76
77
|
payload = set_update(entity, id)
|
77
78
|
request(:post, entity: entity, path: path, payload: payload)
|
78
79
|
end
|
79
80
|
|
81
|
+
def deactivate(entity, id:)
|
82
|
+
err_msg = "Deactivate is only for name list entities. Use .delete instead"
|
83
|
+
raise QboApi::NotImplementedError.new, err_msg unless is_name_list_entity?(entity)
|
84
|
+
payload = set_update(entity, id).merge('sparse': true, 'Active': false)
|
85
|
+
request(:post, entity: entity, path: entity_path(entity), payload: payload)
|
86
|
+
end
|
87
|
+
|
80
88
|
# TODO: Need specs for disconnect and reconnect
|
81
89
|
# https://developer.intuit.com/docs/0100_quickbooks_online/0100_essentials/0085_develop_quickbooks_apps/0004_authentication_and_authorization/oauth_management_api#/Reconnect
|
82
90
|
def disconnect
|
@@ -89,8 +97,8 @@ class QboApi
|
|
89
97
|
request(:get, path: path)
|
90
98
|
end
|
91
99
|
|
92
|
-
def all(entity, max: 1000, select: nil, &block)
|
93
|
-
select
|
100
|
+
def all(entity, max: 1000, select: nil, inactive: false, &block)
|
101
|
+
select = build_all_query(entity, select: select, inactive: inactive)
|
94
102
|
pos = 0
|
95
103
|
begin
|
96
104
|
pos = pos == 0 ? pos + 1 : pos + max
|
data/lib/qbo_api/util.rb
CHANGED
@@ -4,7 +4,7 @@ class QboApi
|
|
4
4
|
if time.is_a?(String)
|
5
5
|
time
|
6
6
|
else
|
7
|
-
time.
|
7
|
+
time.iso8601
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -29,6 +29,21 @@ class QboApi
|
|
29
29
|
uri.to_s
|
30
30
|
end
|
31
31
|
|
32
|
+
def join_or_start_where_clause!(select:)
|
33
|
+
if select.match(/where/i)
|
34
|
+
str = ' AND '
|
35
|
+
else
|
36
|
+
str = ' WHERE '
|
37
|
+
end
|
38
|
+
str
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_all_query(entity, select: nil, inactive: false)
|
42
|
+
select ||= "SELECT * FROM #{singular(entity)}"
|
43
|
+
select += join_or_start_where_clause!(select: select) + 'Active IN ( true, false )' if inactive
|
44
|
+
select
|
45
|
+
end
|
46
|
+
|
32
47
|
end
|
33
48
|
end
|
34
49
|
|
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.2.
|
4
|
+
version: 1.2.1
|
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-
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|