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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f8f44d9da2d869cddbfbd1deef375987615efc1
4
- data.tar.gz: 9ac1f9d22f019b8e78e81b2daf821b1e9fce662a
3
+ metadata.gz: d11d75386598e9ae8b966771fa61304da3eab1b1
4
+ data.tar.gz: dbc172dee6b93df31d5315446b9ec99dd7e7556e
5
5
  SHA512:
6
- metadata.gz: fbfb63682e57d1f59db199d2b72e3e447a3be258f92330c4c2b65110873ebe7a8e5f3cee269b8a7875968894cc76bd3d63b5d5879d536245d779047db78d3414
7
- data.tar.gz: 82e6f4f0d509240e56ae0ddc752d31c98ec4cefa903aa0d1944f459918342087c4ed3e7ae48384b80d0a4f4d31273a546233df1ac50828e0de54d58bf25196f9
6
+ metadata.gz: 2adc4f957559b691bb47b6d123809900ca0adce4096f36c4fcd0657c71adf715865ef447606c5d92627f56fcb0c288275a17dcba068a0cfca11e90a73540b718
7
+ data.tar.gz: affd114bc6bdfa183f9e25abaab6066dc061799819ea1dcbf8a8c406c2606ec030a007575d364c4e06f897cf5f61ebf05c786e1e2f33451473e730af14b422c1
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  .env
11
+ README.md.html
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
- 3. Put your production and development/sandbox credentials in an .env file. For example `vim ~/qbo-sandbox.env`
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
- 5. Important: Only tested with QuickBooks Online Name List Resources Customer and Vendor.
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/[USERNAME]/qbo-sandbox.
67
+ Bug reports and pull requests are welcome on GitHub at https://github.com/minimul/qbo-sandbox.
40
68
 
41
69
 
42
70
  ## License
@@ -22,7 +22,7 @@ end
22
22
 
23
23
  begin
24
24
  entity = ARGV.at(0)
25
- preview = Qbo::Sandbox.new.send(entity)
25
+ preview = Qbo::Sandbox.new.copy(entity)
26
26
  $stdout.puts "Done"
27
27
  rescue => e
28
28
  $stderr.puts e
@@ -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
- payload = { "BatchItemRequest" => [] }
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
- payload["BatchItemRequest"] << build_single_batch(e, entity)
28
+ batch << build_single_batch(e, entity)
30
29
  end
31
- QboApi.production = false
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,
@@ -1,5 +1,5 @@
1
1
  module Qbo
2
2
  class Sandbox
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
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.1.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-19 00:00:00.000000000 Z
11
+ date: 2016-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler