ecoportal-api 0.1.12 → 0.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/ecoportal/api/common/base_model.rb +6 -0
- data/lib/ecoportal/api/common/batch_operation.rb +1 -1
- data/lib/ecoportal/api/common/doc_helpers.rb +3 -0
- data/lib/ecoportal/api/common/hash_diff.rb +1 -1
- data/lib/ecoportal/api/v1/people.rb +4 -23
- data/lib/ecoportal/api/v1/person_details.rb +2 -0
- data/lib/ecoportal/api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b5603297e3d8f896195915049712b370adfe3dd903fa980bb89d57b4c41c8cb
|
4
|
+
data.tar.gz: 46ea17c5f957ac03f8db92241477b8c823e2f0685fc0ef6bbf2dbf3e0722461e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8ebd19ddf1ccce8b78bd703043f9e2f02fa9296c4872bea6f4143aa097b4dba200e65dbb030bb2c06694615e2e9e4de29b8fa4b0f6d10d5aff8a649a005826c
|
7
|
+
data.tar.gz: a2437d527e4043160bd2cd8c74bf011ee419b4348f37679ed02db890a95de436ae4d325f3a9f84b44f270c8cefa518bb8a4f11c481958379513080a82d116ff7
|
@@ -8,6 +8,12 @@ module Ecoportal
|
|
8
8
|
@original_doc = JSON.parse(doc.to_json)
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.build(doc = {})
|
12
|
+
new(doc).tap do |instance|
|
13
|
+
instance.instance_variable_set("@original_doc", {})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
11
17
|
def print
|
12
18
|
puts JSON.pretty_generate(as_json)
|
13
19
|
self
|
@@ -30,7 +30,7 @@ module Ecoportal
|
|
30
30
|
|
31
31
|
batch_response = BatchResponse.new(status, body)
|
32
32
|
if batch_response.success? && method == "GET"
|
33
|
-
callback.call
|
33
|
+
callback.call batch_response, @wrapper.new(body)
|
34
34
|
else
|
35
35
|
callback.call batch_response
|
36
36
|
end
|
@@ -13,7 +13,7 @@ module Ecoportal
|
|
13
13
|
b_value = b[key]
|
14
14
|
next if a_value == b_value && !ID_KEYS.include?(key)
|
15
15
|
diffed[key] = diff(a_value, b_value)
|
16
|
-
diffed.delete
|
16
|
+
diffed.delete(key) if diffed[key] == {}
|
17
17
|
end
|
18
18
|
# All keys are IDs, so it's actually blank
|
19
19
|
if (diffed.keys - ID_KEYS).empty?
|
@@ -47,9 +47,10 @@ module Ecoportal
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def upsert(doc)
|
50
|
-
body
|
51
|
-
id
|
52
|
-
|
50
|
+
body = get_body(doc)
|
51
|
+
id = get_id(doc)
|
52
|
+
external_id = get_external_id(doc)
|
53
|
+
@client.post("/people/"+CGI::escape(external_id || id), data: body)
|
53
54
|
end
|
54
55
|
|
55
56
|
def batch
|
@@ -74,26 +75,6 @@ module Ecoportal
|
|
74
75
|
def person_class
|
75
76
|
V1::Person
|
76
77
|
end
|
77
|
-
|
78
|
-
def get_body(doc)
|
79
|
-
if doc.respond_to?(:as_update)
|
80
|
-
doc.as_update
|
81
|
-
elsif doc.respond_to?(:as_json)
|
82
|
-
doc.as_json
|
83
|
-
else
|
84
|
-
doc
|
85
|
-
end
|
86
|
-
end
|
87
|
-
def get_id(doc)
|
88
|
-
id = nil
|
89
|
-
id ||= doc.id if doc.respond_to?(:id)
|
90
|
-
id ||= doc.external_id if doc.respond_to?(:external_id)
|
91
|
-
id ||= doc["id"] if doc.is_a?(Hash)
|
92
|
-
id ||= doc["external_id"] if doc.is_a?(Hash)
|
93
|
-
id ||= doc if doc.is_a?(String)
|
94
|
-
id or raise "No ID has been given!"
|
95
|
-
id
|
96
|
-
end
|
97
78
|
end
|
98
79
|
end
|
99
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecoportal-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tapio Saarinen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|