qbo-sandbox 0.1.0 → 0.2.0
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 +32 -4
- data/bin/qbo-sandbox +1 -1
- data/lib/qbo/sandbox.rb +14 -6
- data/lib/qbo/sandbox/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: d11d75386598e9ae8b966771fa61304da3eab1b1
|
4
|
+
data.tar.gz: dbc172dee6b93df31d5315446b9ec99dd7e7556e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2adc4f957559b691bb47b6d123809900ca0adce4096f36c4fcd0657c71adf715865ef447606c5d92627f56fcb0c288275a17dcba068a0cfca11e90a73540b718
|
7
|
+
data.tar.gz: affd114bc6bdfa183f9e25abaab6066dc061799819ea1dcbf8a8c406c2606ec030a007575d364c4e06f897cf5f61ebf05c786e1e2f33451473e730af14b422c1
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -9,8 +9,13 @@ Ruby 2.2.2 or greater
|
|
9
9
|
## Usage
|
10
10
|
|
11
11
|
1. [Clean out](https://developer.intuit.com/hub/blog/2015/12/14/deleting-data-from-your-developer-sandbox-environment) your sandbox.
|
12
|
+
|
12
13
|
2. `gem install qbo-sandbox`
|
13
|
-
|
14
|
+
|
15
|
+
3. Enter in your production and sandbox credentials into a .env file of your choosing.
|
16
|
+
|
17
|
+
For example, here is a .env file at `~/qbo-sandbox.env`
|
18
|
+
|
14
19
|
```
|
15
20
|
# ~/.qbo-sandbox.env
|
16
21
|
QBO_SANDBOX_PROD_TOKEN=prod_token_xxxxx
|
@@ -24,9 +29,26 @@ Ruby 2.2.2 or greater
|
|
24
29
|
QBO_SANDBOX_CONSUMER_SECRET=consumer_secret_sssssss
|
25
30
|
QBO_SANDBOX_REALM_ID=2000000000000
|
26
31
|
```
|
27
|
-
4. `QBO_SANDBOX_ENV_FILE=~/qbo-sandbox.env qbo_sandbox customers`
|
28
32
|
|
29
|
-
|
33
|
+
All variables need to filled in. The `PROD` variables are your QuickBooks Online production credentials
|
34
|
+
|
35
|
+
4. **`QBO_SANDBOX_ENV_FILE=~/qbo-sandbox.env qbo-sandbox customers`**
|
36
|
+
|
37
|
+
5. That's it!
|
38
|
+
|
39
|
+
## FAQ
|
40
|
+
|
41
|
+
- What if I set they wrong credentials and copy entities from the sandbox to the production QuickBooks Online account?
|
42
|
+
|
43
|
+
There is a bit of protection against [this] (https://github.com/minimul/qbo-sandbox/blob/master/lib/qbo/sandbox.rb#L31) but use of this library is at your own risk so be careful to set your credentials correctly.
|
44
|
+
|
45
|
+
- Will this library generate a ton of requests and hit API throttle requirements?
|
46
|
+
|
47
|
+
No, to create the sandbox entities this library uses [batch requests](https://developer.intuit.com/docs/api/accounting/batch).
|
48
|
+
|
49
|
+
- My QBO Sub-customers, certain Items, etc. are not copying over to the sandbox?
|
50
|
+
|
51
|
+
Name list and transaction entities that have references are going to fail because the reference id is not going to be available on the sandbox. This library is not going to support references anytime soon but pull requests are very welcome. This library is only tested with QuickBooks Online Customer, Vendor, and Items. Sub-customers and inventory items that have required references to accounts will not be copied to your sandbox.
|
30
52
|
|
31
53
|
## Development
|
32
54
|
|
@@ -34,9 +56,15 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
34
56
|
|
35
57
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
36
58
|
|
59
|
+
To run the command locally:
|
60
|
+
|
61
|
+
```
|
62
|
+
bundle exec ./bin/qbo-sandbox vendors
|
63
|
+
```
|
64
|
+
|
37
65
|
## Contributing
|
38
66
|
|
39
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
67
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/minimul/qbo-sandbox.
|
40
68
|
|
41
69
|
|
42
70
|
## License
|
data/bin/qbo-sandbox
CHANGED
data/lib/qbo/sandbox.rb
CHANGED
@@ -21,19 +21,27 @@ module Qbo
|
|
21
21
|
ENV.fetch(env_var) { |k| raise "Missing value for either ENV['#{k}'] or keyword argument #{key}" }
|
22
22
|
end
|
23
23
|
|
24
|
-
def copy(entity, max: 1000, select: nil, inactive: false)
|
25
|
-
|
24
|
+
def copy(entity, max: 1000, select: nil, inactive: false, batch_size: 30)
|
25
|
+
batch = []
|
26
26
|
QboApi.production = true
|
27
|
-
#@prod.query(select)
|
28
27
|
@prod.all(entity, max: max, select: select, inactive: inactive) do |e|
|
29
|
-
|
28
|
+
batch << build_single_batch(e, entity)
|
30
29
|
end
|
31
|
-
|
32
|
-
@sandbox.batch payload
|
30
|
+
submit_batch(batch, batch_size)
|
33
31
|
end
|
34
32
|
|
35
33
|
private
|
36
34
|
|
35
|
+
def submit_batch(batch, batch_size)
|
36
|
+
QboApi.production = false
|
37
|
+
collect_responses = []
|
38
|
+
batch.each_slice(batch_size) do |b|
|
39
|
+
payload = { "BatchItemRequest" => b }
|
40
|
+
collect_responses << @sandbox.batch(payload)
|
41
|
+
end
|
42
|
+
collect_responses
|
43
|
+
end
|
44
|
+
|
37
45
|
def keyword_args
|
38
46
|
{
|
39
47
|
token: nil,
|
data/lib/qbo/sandbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qbo-sandbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Pelczarski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|