ecoportal-api 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30256db72d10e576aa2a5cfaf7746757ec6e0e9422d850a31f0e96644b480488
4
- data.tar.gz: '08e901d8c555553846f13a6a9cd3270408be694385c210760e8ad92fd6c5740b'
3
+ metadata.gz: 7556b0b8b049d1f3b7aaceff7f44b426be650a25f7973af7203254a8073350d0
4
+ data.tar.gz: 7a37f67cbdb3bc8c8237a79b3c4a3de915eb464c015975acb596ed9ceabebcb0
5
5
  SHA512:
6
- metadata.gz: e7df20d551e1052811af4230567d47f09a7c292fc2cab07a674b87819faaad4a603300656be5199d3036335ec2236c343215a16a312964e59e82c21bf62fc467
7
- data.tar.gz: 31c29458dc17da53d725e208f4bc88ebdf01633fda22027c5c9990999b9134bf1054c6792f33ef9c67f0a4508ab6a7fbbdde86437976a829896324228f4ab24e
6
+ metadata.gz: db45b0f254848749ef3802a3229fc04b278332bb4cde34880fb3698bacdc5baf8c77f9a871847c14736c5fb1eaa3ab4cdc05f6b35f3e18f6ebe15040b187a8b0
7
+ data.tar.gz: 0ffd2ef4c5d058e98323c13203af5121242021fb0dbddf6cbc7f99395ba8c2b6a48f9b8a3891769db58a581ab69b84a253aeafe9dd8e3f8e11c4f482a0a3c29f
@@ -17,6 +17,10 @@ module Ecoportal
17
17
  doc
18
18
  end
19
19
 
20
+ def to_json(*args)
21
+ doc.to_json(*args)
22
+ end
23
+
20
24
  def as_update
21
25
  new_doc = as_json
22
26
  Common::HashDiff.diff(new_doc, @original_doc)
@@ -2,6 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  module Common
4
4
  class WrappedResponse
5
+ include Enumerable
5
6
  attr_reader :response, :result
6
7
  def initialize(response, klass)
7
8
  @response = response
@@ -2,6 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class Internal
4
4
  class LoginProviders
5
+ include Enumerable
5
6
  attr_reader :client
6
7
  def initialize(client)
7
8
  @client = client
@@ -25,7 +25,7 @@ module Ecoportal
25
25
  # TODO
26
26
  raise "Invalid set on account: Need nil, Account or Hash; got #{value.class}"
27
27
  end
28
- remove_instance_variable("@account")
28
+ remove_instance_variable("@account") if defined?(@account)
29
29
  return account
30
30
  end
31
31
 
@@ -2,6 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class Internal
4
4
  class PolicyGroups
5
+ include Enumerable
5
6
  attr_reader :client
6
7
  def initialize(client)
7
8
  @client = client
@@ -3,6 +3,7 @@ module Ecoportal
3
3
  module API
4
4
  class V1
5
5
  class People
6
+ include Enumerable
6
7
  include Common::DocHelpers
7
8
  attr_reader :client
8
9
 
@@ -24,8 +25,8 @@ module Ecoportal
24
25
  self
25
26
  end
26
27
 
27
- def get(id)
28
- response = @client.get("/people/"+CGI::escape(id))
28
+ def get(doc)
29
+ response = @client.get("/people/"+CGI::escape(get_id(doc)))
29
30
  Common::WrappedResponse.new(response, person_class)
30
31
  end
31
32
 
@@ -63,6 +64,10 @@ module Ecoportal
63
64
  @client.delete("/people/"+CGI::escape(id))
64
65
  end
65
66
 
67
+ def new
68
+ person_class.new
69
+ end
70
+
66
71
  private
67
72
 
68
73
  def person_class
@@ -28,17 +28,22 @@ module Ecoportal
28
28
  case value
29
29
  when NilClass
30
30
  doc["details"] = nil
31
- when V1::PersonDetails
32
- doc["details"] = JSON.parse(value.to_json)
31
+ when person_details_class
32
+ doc["details"] = value.as_json
33
33
  when Hash
34
34
  doc["details"] = value.slice("schema_id", "fields")
35
35
  else
36
36
  raise "Invalid set on details: Need nil, PersonDetails or Hash; got #{value.class}"
37
37
  end
38
- remove_instance_variable("@details")
38
+ remove_instance_variable("@details") if defined?(@details)
39
39
  return details
40
40
  end
41
41
 
42
+ def add_details(schema_id)
43
+ self.details = person_details_class.new
44
+ self.details.schema_id = schema_id
45
+ end
46
+
42
47
  private
43
48
 
44
49
  def person_details_class
@@ -9,8 +9,8 @@ module Ecoportal
9
9
  end
10
10
 
11
11
  def schema_id=(value)
12
- @fields = [] if value.nil?
13
- super
12
+ @fields = [] if value.nil?
13
+ doc["schema_id"] = value
14
14
  end
15
15
 
16
16
  def fields
@@ -2,6 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V1
4
4
  class PersonSchemas
5
+ include Enumerable
5
6
  attr_reader :client
6
7
  def initialize(client)
7
8
  @client = client
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tapio Saarinen