qbo_api 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qbo_api.rb +2 -24
- data/lib/qbo_api/attachment.rb +32 -0
- data/lib/qbo_api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7adea0a0229386937227a9f861700e95e57ac8ff
|
4
|
+
data.tar.gz: cf5a41e4d1880c4f853d0340a75148747b3df867
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 801572c7debb2df943d6ff61d41ba1bd48debc2f749b7e24ba81fd0c1674875aec371705d8687ede67a244a574d7561c2efe0fb4d58afd068cf9b5e0c8b22892
|
7
|
+
data.tar.gz: 47072fe0957f1e7f20bf8d85bfcaf88ed46c7b9e1aafcc2c65155b591834d7f731e18368d4d432c5403eeb416cb0ad2764dbaa463b5d5aa9774e611243e05b96
|
data/lib/qbo_api.rb
CHANGED
@@ -12,12 +12,14 @@ require_relative 'qbo_api/error'
|
|
12
12
|
require_relative 'qbo_api/raise_http_exception'
|
13
13
|
require_relative 'qbo_api/entity'
|
14
14
|
require_relative 'qbo_api/util'
|
15
|
+
require_relative 'qbo_api/attachment'
|
15
16
|
|
16
17
|
class QboApi
|
17
18
|
extend Configuration
|
18
19
|
include Supporting
|
19
20
|
include Entity
|
20
21
|
include Util
|
22
|
+
include Attachment
|
21
23
|
attr_reader :realm_id
|
22
24
|
|
23
25
|
REQUEST_TOKEN_URL = 'https://oauth.intuit.com/oauth/v1/get_request_token'
|
@@ -140,32 +142,8 @@ class QboApi
|
|
140
142
|
data
|
141
143
|
end
|
142
144
|
|
143
|
-
def upload_attachment(payload:, attachment:)
|
144
|
-
content_type = payload['ContentType'] || payload[:ContentType]
|
145
|
-
file_name = payload['FileName'] || payload[:FileName]
|
146
|
-
raw_response = attachment_connection.post do |request|
|
147
|
-
request.url "#{realm_id}/upload"
|
148
|
-
request.body = {
|
149
|
-
'file_metadata_01':
|
150
|
-
Faraday::UploadIO.new(StringIO.new(JSON.generate(payload)), 'application/json', 'attachment.json'),
|
151
|
-
'file_content_01':
|
152
|
-
Faraday::UploadIO.new(attachment, content_type, file_name)
|
153
|
-
}
|
154
|
-
end
|
155
|
-
response(raw_response, entity: :attachable)
|
156
|
-
end
|
157
|
-
|
158
145
|
private
|
159
146
|
|
160
|
-
def attachment_connection
|
161
|
-
return @attachment_connection if @attachment_connection
|
162
|
-
multipart_connection = connection.dup
|
163
|
-
multipart_connection.headers['Content-Type'] = 'multipart/form-data'
|
164
|
-
multipart_middleware_index = multipart_connection.builder.handlers.index(Faraday::Request::UrlEncoded) || 1
|
165
|
-
multipart_connection.builder.insert(multipart_middleware_index, Faraday::Request::Multipart)
|
166
|
-
@attachment_connection = multipart_connection
|
167
|
-
end
|
168
|
-
|
169
147
|
def create_all_enumerator(entity, max: 1000, select: nil, inactive: false)
|
170
148
|
Enumerator.new do |enum_yielder|
|
171
149
|
select = build_all_query(entity, select: select, inactive: inactive)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class QboApi
|
2
|
+
module Attachment
|
3
|
+
|
4
|
+
def upload_attachment(payload:, attachment:)
|
5
|
+
content_type = payload['ContentType'] || payload[:ContentType]
|
6
|
+
file_name = payload['FileName'] || payload[:FileName]
|
7
|
+
raw_response = attachment_connection.post do |request|
|
8
|
+
request.url "#{realm_id}/upload"
|
9
|
+
request.body = {
|
10
|
+
'file_metadata_01':
|
11
|
+
Faraday::UploadIO.new(StringIO.new(JSON.generate(payload)), 'application/json', 'attachment.json'),
|
12
|
+
'file_content_01':
|
13
|
+
Faraday::UploadIO.new(attachment, content_type, file_name)
|
14
|
+
}
|
15
|
+
end
|
16
|
+
response(raw_response, entity: :attachable)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def attachment_connection
|
22
|
+
return @attachment_connection if @attachment_connection
|
23
|
+
multipart_connection = connection.dup
|
24
|
+
multipart_connection.headers['Content-Type'] = 'multipart/form-data'
|
25
|
+
multipart_middleware_index = multipart_connection.builder.handlers.index(Faraday::Request::UrlEncoded) || 1
|
26
|
+
multipart_connection.builder.insert(multipart_middleware_index, Faraday::Request::Multipart)
|
27
|
+
@attachment_connection = multipart_connection
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
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.6.
|
4
|
+
version: 1.6.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: 2018-01-
|
11
|
+
date: 2018-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -269,6 +269,7 @@ files:
|
|
269
269
|
- example/views/oauth2.erb
|
270
270
|
- example/views/oauth2_redirect.erb
|
271
271
|
- lib/qbo_api.rb
|
272
|
+
- lib/qbo_api/attachment.rb
|
272
273
|
- lib/qbo_api/configuration.rb
|
273
274
|
- lib/qbo_api/entity.rb
|
274
275
|
- lib/qbo_api/error.rb
|