qbo_api 2.0.1 → 2.1.1

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
  SHA256:
3
- metadata.gz: 922f5a2dd0bb1020d9366c1a993686aa5febdb50e54a5b4c2a6160e572612def
4
- data.tar.gz: '032848b350e352d8edaf376cd49b41fbaae20bccf902473d775e90c513fc0ff5'
3
+ metadata.gz: a9e249e7e48339a74b585f7afd97711407c8b814c0670e417b4792b465e59515
4
+ data.tar.gz: ef17013bf8fd40513f0f4ddb7ffa9653baa2b686f7091a1ba82a8f0cfb79e9ed
5
5
  SHA512:
6
- metadata.gz: c4f17dcf8f2fe0680c34dbb8cf9c864d7d42887f291a968023e1538902a8460cc13d968f669777b53efbc21000d1db44b6e78d21ad8619514dd62c7c0375ba10
7
- data.tar.gz: f2d7a86d02a465e6cc9ce8de0110c250c0e500a5d02b7e0cbc402e3cae37ae11832592ecef08d6c58de8735fd0081fbc8adae277efff3698416fc40da4d02274
6
+ metadata.gz: c31a1c1e627e8f1677323d74e959bb377338984c8cd73c49ebdb95253a97986e7634e20ced251a67e18321bda1827d67e759add75dece2bcb052b2411132bcba
7
+ data.tar.gz: b8c46643f89b9be3e285dd4d8e9bf030af7b75b3872e21937afc6d0c5bfbe59c23038e9bc4431f1efa762888f408d240dd0149c4035f9e19a35ee63c1dbf2847
data/.env.test CHANGED
@@ -1,6 +1,2 @@
1
- export QBO_API_CONSUMER_KEY=
2
- export QBO_API_CONSUMER_SECRET=
3
1
  export QBO_API_ACCESS_TOKEN=
4
- export QBO_API_ACCESS_TOKEN_SECRET=
5
- export QBO_API_OAUTH2_ACCESS_TOKEN=
6
2
  export QBO_API_COMPANY_ID=12345
data/README.md CHANGED
@@ -206,6 +206,12 @@ api.all(:clients).to_a
206
206
  p response['Id'] # => 1
207
207
  ```
208
208
 
209
+
210
+ ### Email a transaction entity
211
+ ```ruby
212
+ api.send_invoice(invoice_id: 1, email_address: 'billy@joe.com')
213
+ ```
214
+
209
215
  ### Uploading an attachment
210
216
  ```ruby
211
217
  payload = {"AttachableRef":
@@ -366,8 +372,8 @@ for how to install ngrok and what it is.
366
372
  Add the token to your .env as QBO_API_VERIFIER_TOKEN
367
373
 
368
374
  - In another tab, create a customer via the API:
369
- `bundle exec ruby -rqbo_api -rdotenv -e 'Dotenv.load; p QboApi.new(access_token: ENV.fetch("QBO_API_OAUTH2_ACCESS_TOKEN"), realm_id: ENV.fetch("QBO_API_COMPANY_ID")).create(:customer, payload: { DisplayName: "TestCustomer" })'`
370
- (You'll also need to have added the QBO_API_COMPANY_ID and QBO_API_OAUTH2_ACCESS_TOKEN to your .env)
375
+ `bundle exec ruby -rqbo_api -rdotenv -e 'Dotenv.load; p QboApi.new(access_token: ENV.fetch("QBO_API_ACCESS_TOKEN"), realm_id: ENV.fetch("QBO_API_COMPANY_ID")).create(:customer, payload: { DisplayName: "TestCustomer" })'`
376
+ (You'll also need to have added the QBO_API_COMPANY_ID and QBO_API_ACCESS_TOKEN to your .env)
371
377
 
372
378
  There could be a delay of up to a minute before the webhook fires.
373
379
 
data/example/base.rb CHANGED
@@ -3,6 +3,7 @@ BASE_GEMS = proc do
3
3
  # This app
4
4
  gem 'sinatra'
5
5
  gem 'sinatra-contrib'
6
+ gem 'puma'
6
7
 
7
8
  # Creds from ../.env
8
9
  gem 'dotenv'
@@ -58,6 +58,14 @@ class QboApi
58
58
  request(:post, entity: entity, path: entity_path(entity), payload: payload)
59
59
  end
60
60
 
61
+ def void(entity, id:)
62
+ err_msg = "Void is only for voidable transaction entities. Use .delete or .deactivate instead"
63
+ raise QboApi::NotImplementedError.new, err_msg unless is_voidable_transaction_entity?(entity)
64
+ path = add_params_to_path(path: entity_path(entity), params: { operation: :void })
65
+ payload = set_update(entity, id)
66
+ request(:post, entity: entity, path: path, payload: payload)
67
+ end
68
+
61
69
  private
62
70
 
63
71
  def get_query_str(entity, query_filter_args)
@@ -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
@@ -20,6 +20,19 @@ class QboApi
20
20
  sym.to_s.split('_').collect(&:capitalize).join
21
21
  end
22
22
 
23
+ def is_voidable_transaction_entity?(entity)
24
+ voidable_transaction_entities.include?(singular(entity))
25
+ end
26
+
27
+ def voidable_transaction_entities
28
+ %w{
29
+ BillPayment
30
+ Invoice
31
+ Payment
32
+ SalesReceipt
33
+ }
34
+ end
35
+
23
36
  def is_transaction_entity?(entity)
24
37
  transaction_entities.include?(singular(entity))
25
38
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  class QboApi
2
- VERSION = "2.0.1"
2
+ VERSION = "2.1.1"
3
3
  end
data/qbo_api.gemspec CHANGED
@@ -22,12 +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 'rexml'
26
- spec.add_development_dependency 'simple_oauth'
27
25
  spec.add_development_dependency 'dotenv'
28
26
  spec.add_development_dependency 'vcr'
29
27
  spec.add_development_dependency 'amazing_print'
30
- spec.add_runtime_dependency 'faraday'
28
+ spec.add_runtime_dependency 'faraday', '~> 1.10.0'
31
29
  spec.add_runtime_dependency 'faraday_middleware'
32
30
  spec.add_runtime_dependency 'faraday-detailed_logger'
33
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.0.1
4
+ version: 2.1.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: 2021-10-02 00:00:00.000000000 Z
11
+ date: 2022-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,34 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rexml
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
- - !ruby/object:Gem::Dependency
84
- name: simple_oauth
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: dotenv
99
71
  requirement: !ruby/object:Gem::Requirement
@@ -140,16 +112,16 @@ dependencies:
140
112
  name: faraday
141
113
  requirement: !ruby/object:Gem::Requirement
142
114
  requirements:
143
- - - ">="
115
+ - - "~>"
144
116
  - !ruby/object:Gem::Version
145
- version: '0'
117
+ version: 1.10.0
146
118
  type: :runtime
147
119
  prerelease: false
148
120
  version_requirements: !ruby/object:Gem::Requirement
149
121
  requirements:
150
- - - ">="
122
+ - - "~>"
151
123
  - !ruby/object:Gem::Version
152
- version: '0'
124
+ version: 1.10.0
153
125
  - !ruby/object:Gem::Dependency
154
126
  name: faraday_middleware
155
127
  requirement: !ruby/object:Gem::Requirement
@@ -247,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
219
  - !ruby/object:Gem::Version
248
220
  version: '0'
249
221
  requirements: []
250
- rubygems_version: 3.0.3
222
+ rubygems_version: 3.2.22
251
223
  signing_key:
252
224
  specification_version: 4
253
225
  summary: Ruby JSON-only client for QuickBooks Online API v3. Built on top of the Faraday