big_machines 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/big_machines/attachment.rb +2 -2
- data/lib/big_machines/client.rb +9 -7
- data/lib/big_machines/transaction.rb +5 -5
- data/lib/big_machines/version.rb +1 -1
- data/spec/lib/client_spec.rb +12 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd8d3cb173966ddd3034d6d1389d98acd42f759c
|
4
|
+
data.tar.gz: bb076b8ae805e104fa336977a5114fa55106c62b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 726db915351a63c7cd89679f937bd8f5593ac6ccfe21b55df3d5aa9530509cfaffe18048846e1b9a0f81a07391d788dc3ea22001f03a269eeb2793b55db9e6c7
|
7
|
+
data.tar.gz: 0359c30687366b458184ac9447cad671a23dac49fce02a9e7ab564db0522ab3f961e5c8e5d4a862a0f65c2e8202093b56bd7bcebe1f8ec4154dd65c03aba313a
|
@@ -7,14 +7,14 @@ module BigMachines
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def write(file_path)
|
10
|
-
data = Base64.strict_decode64(@raw_attachment[
|
10
|
+
data = Base64.strict_decode64(@raw_attachment["file_content"])
|
11
11
|
File.open(file_path, 'wb') do |f|
|
12
12
|
f.write(data)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
def method_missing(method, *args)
|
17
|
-
@raw_attachment[method]
|
17
|
+
@raw_attachment[method.to_s]
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
data/lib/big_machines/client.rb
CHANGED
@@ -68,13 +68,13 @@ module BigMachines
|
|
68
68
|
message = {userInfo: {username: username, password: password}}
|
69
69
|
response = self.security_call(:login, message)
|
70
70
|
|
71
|
-
userInfo = response[
|
71
|
+
userInfo = response["userInfo"]
|
72
72
|
|
73
|
-
@session_id = userInfo[
|
73
|
+
@session_id = userInfo["sessionId"]
|
74
74
|
|
75
75
|
@security_client = Savon.client(configuration)
|
76
76
|
|
77
|
-
response[
|
77
|
+
response["status"]["success"]
|
78
78
|
end
|
79
79
|
alias_method :authenticate, :login
|
80
80
|
|
@@ -177,7 +177,7 @@ module BigMachines
|
|
177
177
|
result = commerce_call(:export_file_attachments, export)
|
178
178
|
|
179
179
|
attachments = []
|
180
|
-
result[
|
180
|
+
result["attachments"].each do |key, data|
|
181
181
|
attachments << BigMachines::Attachment.new(data)
|
182
182
|
end
|
183
183
|
|
@@ -243,6 +243,7 @@ module BigMachines
|
|
243
243
|
soap_header: headers(:security),
|
244
244
|
filters: [:password],
|
245
245
|
convert_request_keys_to: :none,
|
246
|
+
convert_response_tags_to: lambda { |tag| tag },
|
246
247
|
pretty_print_xml: true,
|
247
248
|
logger: @logger,
|
248
249
|
log: @logger != false
|
@@ -276,11 +277,12 @@ module BigMachines
|
|
276
277
|
response = response.to_hash
|
277
278
|
|
278
279
|
# Get Response Body
|
279
|
-
|
280
|
+
key = method.to_s.gsub(/_(\w)/) {|x| x[1].upcase }
|
281
|
+
response = response["#{key}Response"]
|
280
282
|
|
281
283
|
# Raise error when response contains errors
|
282
|
-
if response.is_a?(Hash) && response[
|
283
|
-
raise Savon::Error.new(response[
|
284
|
+
if response.is_a?(Hash) && response["status"] && response["status"]["success"] == false
|
285
|
+
raise Savon::Error.new(response["status"]["message"])
|
284
286
|
end
|
285
287
|
|
286
288
|
return response
|
@@ -5,19 +5,19 @@ module BigMachines
|
|
5
5
|
def initialize(response)
|
6
6
|
@raw_transaction = response
|
7
7
|
# Metadata
|
8
|
-
@transaction = response[
|
8
|
+
@transaction = response["transaction"]
|
9
9
|
# Quote
|
10
|
-
@quote_process = @transaction[
|
10
|
+
@quote_process = @transaction["data_xml"]["quote_process"]
|
11
11
|
# Line Items
|
12
|
-
@line_process = if @quote_process[
|
13
|
-
@quote_process[
|
12
|
+
@line_process = if @quote_process["sub_documents"].is_a?(Hash)
|
13
|
+
@quote_process["sub_documents"]["line_process"]
|
14
14
|
else
|
15
15
|
[]
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def method_missing(method, *args)
|
20
|
-
@transaction[method]
|
20
|
+
@transaction[method.to_s]
|
21
21
|
end
|
22
22
|
|
23
23
|
def quote
|
data/lib/big_machines/version.rb
CHANGED
data/spec/lib/client_spec.rb
CHANGED
@@ -34,7 +34,7 @@ describe BigMachines::Client do
|
|
34
34
|
stub = stub_api_request({with_body: body, fixture: 'logout_response'})
|
35
35
|
|
36
36
|
response = subject.logout
|
37
|
-
expect(response[
|
37
|
+
expect(response["status"]["success"]).to eq(true)
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
@@ -45,10 +45,10 @@ describe BigMachines::Client do
|
|
45
45
|
stub = stub_api_request({with_body: body, fixture: 'get_user_info_response'})
|
46
46
|
|
47
47
|
response = subject.get_user_info
|
48
|
-
user_info = response[
|
49
|
-
expect(user_info[
|
50
|
-
expect(user_info[
|
51
|
-
expect(user_info[
|
48
|
+
user_info = response["userInfo"]
|
49
|
+
expect(user_info["company_name"]).to eq('newtempge')
|
50
|
+
expect(user_info["first_name"]).to eq('Joe')
|
51
|
+
expect(user_info["last_name"]).to eq('Heth')
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -58,7 +58,7 @@ describe BigMachines::Client do
|
|
58
58
|
stub = stub_api_request({with_body: body, fixture: 'set_session_currency_response'})
|
59
59
|
|
60
60
|
response = subject.set_session_currency('USD')
|
61
|
-
expect(response[
|
61
|
+
expect(response["status"]["success"]).to eq(true)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -93,12 +93,13 @@ describe BigMachines::Client do
|
|
93
93
|
|
94
94
|
quote_process = transaction.quote
|
95
95
|
expect(quote_process).to be_a(Hash)
|
96
|
+
expect(quote_process["_document_number"]).to eq("1")
|
96
97
|
|
97
98
|
quote_line_items = transaction.quote_line_items
|
98
99
|
expect(quote_line_items).to be_a(Array)
|
99
100
|
|
100
101
|
expect(quote_line_items.length).to eq(109)
|
101
|
-
expect(quote_line_items.first[
|
102
|
+
expect(quote_line_items.first["_model_id"]).to eq("17400975")
|
102
103
|
end
|
103
104
|
|
104
105
|
it "returns not found error" do
|
@@ -158,7 +159,7 @@ describe BigMachines::Client do
|
|
158
159
|
}
|
159
160
|
response = subject.update_transaction(26539349, data)
|
160
161
|
|
161
|
-
expect(response[
|
162
|
+
expect(response["status"]["success"]).to eq(true)
|
162
163
|
end
|
163
164
|
end
|
164
165
|
|
@@ -255,7 +256,7 @@ describe BigMachines::Client do
|
|
255
256
|
|
256
257
|
file = attachments.first
|
257
258
|
expect(file.filename).to eq('1020636-38959 Rev 0.docx')
|
258
|
-
expect(file.file_content[
|
259
|
+
expect(file.file_content["@bm:href"]).to eq("cid:1020636-38959_Rev_0.docx@newtempge.bigmachines.com")
|
259
260
|
end
|
260
261
|
|
261
262
|
end
|
@@ -292,7 +293,7 @@ describe BigMachines::Client do
|
|
292
293
|
|
293
294
|
File.unlink('NewProposal.txt')
|
294
295
|
|
295
|
-
expect(response[
|
296
|
+
expect(response["status"]["success"]).to eq(true)
|
296
297
|
end
|
297
298
|
|
298
299
|
it "deletes file attachment" do
|
@@ -317,7 +318,7 @@ describe BigMachines::Client do
|
|
317
318
|
|
318
319
|
response = subject.delete_attachment(34706909, "uploadEngineeringTemplate_File")
|
319
320
|
|
320
|
-
expect(response[
|
321
|
+
expect(response["status"]["success"]).to eq(true)
|
321
322
|
end
|
322
323
|
|
323
324
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: big_machines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Heth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|