fastbound-ruby 1.1.5 → 1.1.8

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: e1ddd372f0736a3153b3f7e3004b77edc4f4a472856a4b47bde3dd888e653546
4
- data.tar.gz: 87ee6aba545cae8ddb3748b1190910a9542f313bb3f2e04466690e549716e85c
3
+ metadata.gz: 50830df9f9e5a74017244b8c88ee516a77a9eeae5be383682991979ebee49f80
4
+ data.tar.gz: bb26944605d2a06c0363fa3f4d56b948bc962bd100577a8df26c836ce7ccb3ee
5
5
  SHA512:
6
- metadata.gz: 489f34169de6fb6865505271bc54a5f2ff1beb3c81a9123084da897165f7bed229c77d96298af9d6cc8c0f9b712b43cb8c4edcabe360023237a00ac2c26dc4e9
7
- data.tar.gz: f99ec40017fc51153d88ab9799511a74f432ebdbcda5b38e70845d92d1ee9d11c188aff309b48f709324718feccb287318abf0aa04d59e23f821a62f1c6ceeef
6
+ metadata.gz: a333e982aab96995f73f768953b7e0440afac23aeb597bc1ac72037ac0885d9299f05ff159e25bb755d87defe8fb08ee16a521e485b9256d3da32961ac92e99f
7
+ data.tar.gz: 25196bf4c453658170c420924a241df4f60aed60534595febb004f87ad14cd67bcb13a40fa6460ad19131f83232d5e6ec54eaedc5a15f79f27eb25da44f8a9d4
@@ -13,38 +13,41 @@ module FastBound
13
13
  def get_request(client, endpoint)
14
14
  request = Net::HTTP::Get.new(request_url(client, endpoint))
15
15
 
16
+ set_request_headers(client, request)
16
17
  submit_request(client, request)
17
18
  end
18
19
 
19
20
  def post_request(client, endpoint, data = {})
20
21
  request = Net::HTTP::Post.new(request_url(client, endpoint))
21
22
 
23
+ set_request_headers(client, request, 'application/json')
22
24
  submit_request(client, request, data)
23
25
  end
24
26
 
25
27
  def put_request(client, endpoint, data = {})
26
28
  request = Net::HTTP::Put.new(request_url(client, endpoint))
27
29
 
30
+ set_request_headers(client, request, 'application/json')
28
31
  submit_request(client, request, data)
29
32
  end
30
33
 
31
34
  def delete_request(client, endpoint)
32
35
  request = Net::HTTP::Delete.new(request_url(client, endpoint))
33
36
 
37
+ set_request_headers(client, request)
34
38
  submit_request(client, request)
35
39
  end
36
40
 
37
41
  def post_file_request(client, endpoint, file_data)
38
42
  request = Net::HTTP::Post.new(request_url(client, endpoint))
39
43
 
44
+ set_request_headers(client, request)
40
45
  submit_file_request(client, request, file_data)
41
46
  end
42
47
 
43
48
  private
44
49
 
45
50
  def submit_request(client, request, data = {})
46
- set_request_headers(client, request)
47
-
48
51
  request.body = data.is_a?(Hash) ? data.to_json : data
49
52
 
50
53
  process_request(request)
@@ -56,7 +59,6 @@ module FastBound
56
59
  headers.merge!(content_type_header("multipart/form-data; boundary=#{boundary}"))
57
60
 
58
61
  build_multipart_request_body(request, file_data, boundary)
59
- set_request_headers(client, request)
60
62
  process_request(request)
61
63
  end
62
64
 
@@ -89,10 +91,11 @@ module FastBound
89
91
  request.body = body.join
90
92
  end
91
93
 
92
- def set_request_headers(client, request)
94
+ def set_request_headers(client, request, content_type = nil)
93
95
  request['User-Agent'] = USER_AGENT
94
96
  request['Authorization'] = ['Basic', Base64.strict_encode64(client.api_key + ':')].join(' ')
95
97
  request['X-AuditUser'] = client.account_email
98
+ request['Content-Type'] = content_type if content_type.present?
96
99
  end
97
100
 
98
101
  def request_url(client, endpoint)
@@ -152,7 +152,7 @@ module FastBound
152
152
  post_request(@client, endpoint, commit_data)
153
153
  end
154
154
 
155
- def create_and_commit(disposition_data, items_data, contact_data = {}, commit_data = {})
155
+ def create_and_commit(disposition_data, items_data, contact_data = {}, commit_data = nil)
156
156
  items_data.each { |item| requires!(item, :id) }
157
157
 
158
158
  endpoint = ENDPOINTS[:create_and_commit]
@@ -12,7 +12,7 @@ module FastBound
12
12
  when Net::HTTPNotFound
13
13
  raise FastBound::Error::NotFound.new(@response.body)
14
14
  when Net::HTTPNoContent
15
- raise FastBound::Error::NoContent.new(@response.body)
15
+ self.success = true
16
16
  when Net::HTTPOK, Net::HTTPSuccess
17
17
  self.success = true
18
18
  _data = (JSON.parse(@response.body) if @response.body.present?)
@@ -28,7 +28,7 @@ module FastBound
28
28
  puts "-- DEBUG: #{self}: RequestError: #{@response.inspect}"
29
29
  end
30
30
 
31
- raise FastBound::Error::RequestError.new(@response.body)
31
+ raise FastBound::Error::RequestError.new([@response.body, @response.message].reject(&:blank?).join(" | "))
32
32
  end
33
33
  end
34
34
 
@@ -1,3 +1,3 @@
1
1
  module FastBound
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastbound-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Dill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-17 00:00:00.000000000 Z
11
+ date: 2022-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler