fastbound-ruby 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastbound-ruby/api.rb +7 -4
- data/lib/fastbound-ruby/response.rb +1 -1
- data/lib/fastbound-ruby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d852c62270f374ee9e8114027108e39f67d74dbef1ca33c8f5ef2be371b04af3
|
4
|
+
data.tar.gz: da98709eff4b8b3e4efefc218abaea16914fc0c7698ff5a044b8ce6fe4b38903
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18a3f83fc9a13b909fa3cb0014f3b44d3c1e085b33abf3cb3095a54d847e085ccc0ba1977f5ff064e497dc010c551b3fdd21f7a9b1d274e3ba6e4c185f348382
|
7
|
+
data.tar.gz: 28f1071c6db244a90509b22bcd4c398797cea10018f806771abc9d59ad087bc22e03715aca63c8c4005e510b6d5e0cd35dc2bbb8f88355ba7beb11d5bfb8179d
|
data/lib/fastbound-ruby/api.rb
CHANGED
@@ -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)
|
@@ -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
|
|