quick_book_gateway 0.0.4 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 40de0d4b980aae3a0595197f6428558780babf934ee6099ff6329402889a674c
4
+ data.tar.gz: 4a3500f27e7926a2228f7f9cea979e7fa9b39499285fa158196378faa9e1cce8
5
+ SHA512:
6
+ metadata.gz: d5541aff318047474721bd540daa4b35961a93970344bc9fd08939d2bc92cf1ad523e02480a5817aa8e4fb19da4091fd4af7573d10529c16c0f218dd8b320d80
7
+ data.tar.gz: fa9c338cbc688398cbc7ca9d66c9f8b14fae2e09bfd20666bb925958bacef78b365892acd749d0b9ea641ec3ae86c464e5f88dcc2a21e3e6a39208d0a51696d7
data/README CHANGED
@@ -1,8 +1,8 @@
1
1
  ## Requirements
2
2
 
3
3
  * Ruby >= 0
4
- * OAuth
5
- * Quickbook tokens
4
+ * OAuth2
5
+ * Quickbook refresh token, can generate via Quickbook playground https://developer.intuit.com/app/developer/playground
6
6
 
7
7
 
8
8
  ## Installation
@@ -19,13 +19,12 @@
19
19
 
20
20
  2. Configure Quickbook by adding below line to your ruby program
21
21
 
22
- Gateway::Quickbook.connect(
23
- :qb_key => Quickbook Key,
24
- :qb_secret => Quickbook Secret,
25
- :token => Access Token,
26
- :secret => Access Sceret,
27
- :company_id => Quickbook Company ID,
28
- :environment => ENVIRONMENT::SANDBOX or ENVIRONMENT::PRODUCTION
22
+ Gateway::Quickbook.connect(
23
+ :client_id => QuickBook App Client ID,
24
+ :client_secret => QuickBook App Client Secret,
25
+ :refresh_token => Can generate from playground https://developer.intuit.com/app/developer/playground, validate for 100 days
26
+ :company_id => QuickBook Company ID,
27
+ :environment => ENVIRONMENT::SANDBOX or ENVIRONMENT::PRODUCTION
29
28
  )
30
29
 
31
30
  3. Create classes with names provided on Quickbook website
@@ -37,22 +36,22 @@
37
36
 
38
37
  4. Inherit all classes with Service::Record Class, class should look like below
39
38
 
40
- class Customer < Service::Record
41
- end
39
+ class Customer < Service::Record
40
+ end
42
41
 
43
- class Vendor < Service::Record
44
- end
42
+ class Vendor < Service::Record
43
+ end
45
44
 
46
- class Item < Service::Record
47
- end
45
+ class Item < Service::Record
46
+ end
48
47
 
49
48
  5. You are ready to create, fetch or modify any data on Quickbook.
50
49
 
51
50
  For ex.
52
51
 
53
- customer = Customer.find(DisplayName: "Kunal")
54
- customer.CompanyName = "Kunal Lalge"
55
- customer.save!
52
+ customer = Customer.find(DisplayName: "Kunal")
53
+ customer.CompanyName = "Kunal Lalge"
54
+ customer.save!
56
55
 
57
56
  6. For attributes reference read Documentation reference for each class on Quickbook link provided above.
58
57
 
@@ -60,24 +59,17 @@
60
59
 
61
60
  7. One can also use callbacks, below are list of callbacks:
62
61
 
63
-
64
- before_save - Executes every time before object save
65
-
66
- after_save - Executes every time after object save
62
+ before_save - Executes every time before object save
63
+ after_save - Executes every time after object save
64
+ before_create - Executes only before new object save
65
+ after_create - Executes only after new object save
66
+ before_update - Executes only before existing object save
67
+ after_update - Executes only after existing object save
68
+ before_destroy - Executes every time before destroy an object
69
+ after_destroy - Executes every time after destroy an object
67
70
 
68
- before_create - Executes only before new object save
71
+ Example
69
72
 
70
- after_create - Executes only after new object save
71
-
72
- before_update - Executes only before existing object save
73
-
74
- after_update - Executes only after existing object save
75
-
76
- before_destroy - Executes every time before destroy an object
77
-
78
- after_destroy - Executes every time after destroy an object
79
-
80
- Ex.
81
73
  class Customer < Service::Record
82
74
  def after_create
83
75
  puts "New customer is created on QB"
@@ -89,6 +81,8 @@
89
81
 
90
82
  0.0.4 - find_all will fetch all records using pagination
91
83
 
84
+ 0.0.5 - Quickbook OAuth 2.0 security upgradation implemented
85
+
92
86
 
93
87
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
94
88
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@@ -1,4 +1,4 @@
1
- require 'oauth'
1
+ require 'oauth2'
2
2
 
3
3
  module Gateway
4
4
  class Quickbook < Result
@@ -32,34 +32,27 @@ module Gateway
32
32
  #Options are as follow
33
33
  # String: Environment ENVIRONMENT::SANDBOX or ENVIRONMENT::PRODUCTION. AutoLoad QuickBook key, secret, access token, access secret, company ID from config/quickbook.yml corresponding to environment given.
34
34
  # Hash:
35
- # :qb_key => QuickBook Key,
36
- # :qb_secret => QuickBook Secret,
37
- # :token => Access Token,
38
- # :secret => Access Sceret,
39
- # :company_id => QuickBook Company ID,
40
- # :environment => ENVIRONMENT::SANDBOX or ENVIRONMENT::PRODUCTION
35
+ # :client_id => QuickBook App Client ID,
36
+ # :client_secret => QuickBook App Client Secret,
37
+ # :refresh_token => Can generate from playground https://developer.intuit.com/app/developer/playground, validate for 100 days
38
+ # :company_id => QuickBook Company ID,
39
+ # :environment => ENVIRONMENT::SANDBOX or ENVIRONMENT::PRODUCTION
41
40
  def self.connect(options)
42
41
  if(options.class == String)
43
42
  configuration = YAML.load_file("config/quickbook.yml")
44
43
  environment = options
45
44
  options = Hash.new
46
- options[:qb_key] = configuration[environment]["key"]
47
- options[:qb_secret] = configuration[environment]["secret"]
48
- options[:token] = configuration[environment]["access_token"]
49
- options[:secret] = configuration[environment]["access_secret"]
45
+ options[:client_id] = configuration[environment]["client_id"]
46
+ options[:client_secret] = configuration[environment]["client_secret"]
47
+ options[:refresh_token] = configuration[environment]["refresh_token"]
50
48
  options[:company_id] = configuration[environment]["company_id"]
51
49
  options[:environment] = environment
52
50
  end
53
51
 
54
52
  gateway = new
55
- gateway.consumer = OAuth::Consumer.new(options[:qb_key], options[:qb_secret], {
56
- :site => "https://oauth.intuit.com",
57
- :request_token_path => "/oauth/v1/get_request_token",
58
- :authorize_url => "https://appcenter.intuit.com/Connect/Begin",
59
- :access_token_path => "/oauth/v1/get_access_token"
60
- })
61
-
62
- gateway.access_token = OAuth::AccessToken.new(gateway.consumer, options[:token], options[:secret])
53
+ gateway.consumer = OAuth2::Client.new(options[:client_id], options[:client_secret], {:token_url => 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer', auth_scheme: :basic_auth})
54
+ gateway.access_token = OAuth2::AccessToken.new(gateway.consumer, nil, {refresh_token: options[:refresh_token]})
55
+ gateway.access_token = gateway.access_token.refresh!
63
56
 
64
57
  gateway.company_id = options[:company_id]
65
58
 
@@ -81,7 +74,7 @@ module Gateway
81
74
 
82
75
  public
83
76
  def get(path, parameters = {})
84
- return handle_query_result(self.access_token.get(url(path, parameters), {"Accept" => HTTP::JSON}))
77
+ return handle_query_result(self.access_token.get(url(path, parameters), {headers: {"Accept" => HTTP::JSON}}))
85
78
  end
86
79
 
87
80
  def query_data(query)
@@ -89,7 +82,7 @@ module Gateway
89
82
  end
90
83
 
91
84
  def post(path, parameters, body)
92
- return handle_query_result(self.access_token.post(url(path, parameters), body, {"Content-Type" => HTTP::JSON, "Accept" => HTTP::JSON}))
85
+ return handle_query_result(self.access_token.post(url(path, parameters), {body: body, headers: {"Content-Type" => HTTP::JSON, "Accept" => HTTP::JSON}}))
93
86
  end
94
87
  end
95
88
  end
@@ -6,7 +6,7 @@ module Gateway
6
6
  include Errors
7
7
 
8
8
  def handle_query_result(response)
9
- if(response.code == "200")
9
+ if(response.status.to_i == 200)
10
10
  result = JSON.parse(response.body)
11
11
 
12
12
  if result["Fault"]
@@ -90,6 +90,7 @@ module Service
90
90
 
91
91
  qb_record = find(options.dup)
92
92
 
93
+ options.delete(:conditions)
93
94
  qb_record = new(options) unless qb_record
94
95
 
95
96
  return qb_record
metadata CHANGED
@@ -1,74 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick_book_gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kunal Lalge
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2017-07-25 00:00:00.000000000 Z
11
+ date: 2020-02-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: oauth
14
+ name: oauth2
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '1'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
30
- description: ! 'Connect to QuickBook Online and easily synchronize data. Please read
31
- README file to know how to use located at gems-directory/quick_book_gateway-0.0.2/README '
26
+ version: '1'
27
+ description: 'Connect to QuickBook Online and easily synchronize data. Please read
28
+ README file to know how to use located at gems-directory/quick_book_gateway-0.0.7/README '
32
29
  email: kunallalge@gmail.com
33
30
  executables: []
34
31
  extensions: []
35
32
  extra_rdoc_files: []
36
33
  files:
37
- - lib/quick_book_gateway.rb
38
- - lib/errors.rb
39
- - lib/core_ext/string.rb
34
+ - README
40
35
  - lib/core_ext/hash.rb
41
36
  - lib/core_ext/nil.rb
37
+ - lib/core_ext/string.rb
38
+ - lib/errors.rb
42
39
  - lib/gateway/quickbook.rb
43
40
  - lib/gateway/result.rb
44
- - lib/service/query.rb
45
- - lib/service/finder.rb
41
+ - lib/quick_book_gateway.rb
46
42
  - lib/service/callback.rb
43
+ - lib/service/finder.rb
47
44
  - lib/service/persistence.rb
45
+ - lib/service/query.rb
48
46
  - lib/service/record.rb
49
- - README
50
- homepage: https://rubygems.org/gems/quick_book_gateway
47
+ homepage: https://github.com/KunalLalge/quick_book_gateway
51
48
  licenses: []
49
+ metadata: {}
52
50
  post_install_message:
53
51
  rdoc_options: []
54
52
  require_paths:
55
53
  - lib
56
54
  required_ruby_version: !ruby/object:Gem::Requirement
57
- none: false
58
55
  requirements:
59
- - - ! '>='
56
+ - - ">="
60
57
  - !ruby/object:Gem::Version
61
58
  version: '0'
62
59
  required_rubygems_version: !ruby/object:Gem::Requirement
63
- none: false
64
60
  requirements:
65
- - - ! '>='
61
+ - - ">="
66
62
  - !ruby/object:Gem::Version
67
63
  version: '0'
68
64
  requirements: []
69
- rubyforge_project:
70
- rubygems_version: 1.8.24
65
+ rubygems_version: 3.1.2
71
66
  signing_key:
72
- specification_version: 3
67
+ specification_version: 4
73
68
  summary: QuickBook Online Gateway
74
69
  test_files: []