rest-api-client 0.1.9 → 0.1.10
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/.gitignore +0 -0
- data/.rspec +0 -0
- data/.travis.yml +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/lib/rest/api/client.rb +0 -0
- data/lib/rest/api/client/config.rb +0 -0
- data/lib/rest/api/client/json_parser.rb +31 -2
- data/lib/rest/api/client/logger.rb +0 -0
- data/lib/rest/api/client/request_handler.rb +0 -0
- data/lib/rest/api/client/version.rb +1 -1
- data/lib/rest/api/exceptions/model_errors_exception.rb +0 -0
- data/lib/rest/api/exceptions/service_url_exception.rb +0 -0
- data/lib/rest/api/exceptions/unauthorized_exception.rb +0 -0
- data/rest-api-client.gemspec +0 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59133c4029009610c9c5723b460742ad133c8f5d
|
4
|
+
data.tar.gz: 1c2fdf79a75dffbfb13aeb05adc7864878ce01a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 273f0902c798dd6beda3f49fa8674df4f2d96d2ecd7383e8e706ce26543f7bf5b939f1121a692588c932e9d7cb9a5950a1f99035cc7b0b200729d3c9211e2af2
|
7
|
+
data.tar.gz: f3fdd1c5fb7288efee765521c96e7a8c0a3a6efd7ab0e284eee7b304eabb5997043981d937168dbf158882e5b0215d168a39016e096955b2932421f7c3f90377
|
data/.gitignore
CHANGED
File without changes
|
data/.rspec
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
data/lib/rest/api/client.rb
CHANGED
File without changes
|
File without changes
|
@@ -14,11 +14,11 @@ module RestApiClient
|
|
14
14
|
end
|
15
15
|
|
16
16
|
if json_data.kind_of?(Array)
|
17
|
-
return json_data.map { |data|
|
17
|
+
return json_data.map { |data| self.build_instance data_type, data } if data_type
|
18
18
|
return json_data unless json_data.empty?
|
19
19
|
|
20
20
|
elsif json_data.kind_of?(Hash)
|
21
|
-
return
|
21
|
+
return self.build_instance data_type, json_data if data_type
|
22
22
|
return json_data unless json_data.empty?
|
23
23
|
|
24
24
|
else
|
@@ -31,4 +31,33 @@ module RestApiClient
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
private
|
35
|
+
|
36
|
+
# Set the instance attributes values.
|
37
|
+
# If the instance have associations, the value of these associations will be an empty object, or an object with his id
|
38
|
+
# when the instance data contains a "object_id" key
|
39
|
+
def self.build_instance(data_type, instance_data)
|
40
|
+
instance = data_type.new
|
41
|
+
instance_data.each do |key, value|
|
42
|
+
|
43
|
+
begin
|
44
|
+
if key.end_with? '_id'
|
45
|
+
key_without_id = key.gsub('_id', '')
|
46
|
+
if instance.respond_to?(key_without_id)
|
47
|
+
key = key_without_id
|
48
|
+
value = Object::const_get("#{data_type.parent}::" + key_without_id.camelize).new(:id => value)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
if value.is_a?(Hash)
|
53
|
+
value = Object::const_get("#{data_type.parent}::" + key.camelize).new(value)
|
54
|
+
end
|
55
|
+
rescue Exception => e
|
56
|
+
# ignored
|
57
|
+
end
|
58
|
+
|
59
|
+
instance.instance_variable_set("@#{key}", value)
|
60
|
+
end
|
61
|
+
instance
|
62
|
+
end
|
34
63
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/rest-api-client.gemspec
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -210,8 +210,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
version: '0'
|
211
211
|
requirements: []
|
212
212
|
rubyforge_project:
|
213
|
-
rubygems_version: 2.
|
213
|
+
rubygems_version: 2.4.8
|
214
214
|
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: rest-api-client
|
217
217
|
test_files: []
|
218
|
+
has_rdoc:
|