bimbly 1.1.0 → 1.2.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/bimbly.rb +30 -14
- data/lib/{data_types.yml → data_types_v3.yml} +0 -0
- data/lib/data_types_v4.yml +860 -0
- data/lib/{error_codes.yml → error_codes_v3.yml} +0 -0
- data/lib/error_codes_v4.yml +1546 -0
- data/lib/{object_sets_v2.yml → object_sets_v3.yml} +0 -0
- data/lib/object_sets_v4.yml +10917 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7c36f37dd2d247f733bbeb4d380ee12c42b4d37
|
4
|
+
data.tar.gz: 7987d33554de4e38667705ceef45e407a1689518
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed68f34c77cdfeccb9dc7fd2d6ed89c5f320a40972a8977ae712739852b7af8cf773aa54daaccff099c05c1d346b4b607b86e19abb4cf2bfd0f0908351595fa5
|
7
|
+
data.tar.gz: 94d7be01a4f9868eb6b69f7dc3121812aa4c71de076bcbb151890328c3480ace31ee7e52078ea24806202360af0dacbdd39219b61b86e2e48f05d8b0844e09c9
|
data/lib/bimbly.rb
CHANGED
@@ -11,13 +11,17 @@ class Bimbly
|
|
11
11
|
|
12
12
|
def initialize(opts = {})
|
13
13
|
# Read in setup files
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
if opts[:version] == "3"
|
15
|
+
opts.delete(:version)
|
16
|
+
@error_codes = YAML.load(File.read("#{File.dirname(__FILE__)}/error_codes_v3.yml"))
|
17
|
+
@obj_sets = YAML.load(File.read("#{File.dirname(__FILE__)}/object_sets_v3.yml"))
|
18
|
+
@data_type = YAML.load(File.read("#{File.dirname(__FILE__)}/data_types_v3.yml"))
|
19
|
+
else
|
20
|
+
@error_codes = YAML.load(File.read("#{File.dirname(__FILE__)}/error_codes_v4.yml"))
|
21
|
+
@obj_sets = YAML.load(File.read("#{File.dirname(__FILE__)}/object_sets_v4.yml"))
|
22
|
+
@data_type = YAML.load(File.read("#{File.dirname(__FILE__)}/data_types_v4.yml"))
|
23
|
+
end
|
24
|
+
|
21
25
|
@meth_name = nil
|
22
26
|
|
23
27
|
@base_url = "NotConnected"
|
@@ -43,6 +47,13 @@ class Bimbly
|
|
43
47
|
# Check if url is valid
|
44
48
|
raise ArgumentError, "Invalid URL: #{uri}" unless uri =~ /\A#{URI::regexp}\z/
|
45
49
|
|
50
|
+
# Do some payload stuff to wrap with 'data' and make sure it's usable
|
51
|
+
if not payload.nil?
|
52
|
+
# payload = payload["data"] if payload.keys.size == 1 and payload.keys.include?("data")
|
53
|
+
|
54
|
+
payload = { data: payload }
|
55
|
+
end
|
56
|
+
|
46
57
|
payload = payload.to_json if payload.class == Hash
|
47
58
|
|
48
59
|
begin
|
@@ -93,8 +104,6 @@ class Bimbly
|
|
93
104
|
|
94
105
|
if @file
|
95
106
|
conn_data = YAML.load(File.read(File.expand_path(@file)))
|
96
|
-
puts File.expand_path(@file)
|
97
|
-
puts conn_data
|
98
107
|
conn_data = conn_data[@file_select] if @file_select
|
99
108
|
@array = conn_data["array"]
|
100
109
|
@cert = conn_data["cert"]
|
@@ -259,9 +268,16 @@ class Bimbly
|
|
259
268
|
uri = gen_uri(url_suffix: url_suffix,
|
260
269
|
params: opts[:params])
|
261
270
|
|
271
|
+
payload = opts[:payload]
|
272
|
+
# Unwrap the payload data if it is json or wrapped in 'data' so we can inspect the attrs
|
273
|
+
if not payload.nil?
|
274
|
+
payload = JSON.parse(payload) if payload.class == String
|
275
|
+
payload = payload["data"] if payload.keys.include?("data")
|
276
|
+
end
|
277
|
+
|
262
278
|
@uri = uri
|
263
279
|
@verb = hash[:verb]
|
264
|
-
@payload =
|
280
|
+
@payload = payload
|
265
281
|
|
266
282
|
if not opts[:params].nil?
|
267
283
|
opts[:params].each { |key, value|
|
@@ -281,16 +297,16 @@ class Bimbly
|
|
281
297
|
|
282
298
|
raise ArgumentError,
|
283
299
|
"Must supply :payload with attributes #{mando_array} on #{method_name}" if
|
284
|
-
not mando_array.empty? and
|
300
|
+
not mando_array.empty? and payload.nil?
|
285
301
|
|
286
302
|
mando_array.each { |ele|
|
287
303
|
raise ArgumentError,
|
288
304
|
"\'#{ele}\' is a mandatory attribute in the payload for #{method_name}: Please supply these attributes #{mando_array}" unless
|
289
|
-
|
305
|
+
payload.keys.to_s.include?(ele)
|
290
306
|
}
|
291
307
|
|
292
|
-
if not
|
293
|
-
|
308
|
+
if not payload.nil?
|
309
|
+
payload.keys.each { |key|
|
294
310
|
raise ArgumentError,
|
295
311
|
"The attribute \'#{key}\' is not an available attribute for #{method_name}" unless
|
296
312
|
hash[:request].keys.include?(key.to_s)
|
File without changes
|