eac_rest 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da7660dd050c1920b397917c2c95bd18f30a1b913e843c09dd7c83bc42228dd2
4
- data.tar.gz: 9208b5fda36acf2f02852e077828fcaed49a4d69cc101c44ac46711475e87320
3
+ metadata.gz: 643d41f4e29430fdc1b49bae8b5f161241cdf6a022af0df70634e9df8dd04999
4
+ data.tar.gz: 643c87c4f14cca345437f5cf07fe855e5d804008927a7ef24d945d297af9e9d1
5
5
  SHA512:
6
- metadata.gz: 2ab9b0cf48244fcee4954f36029ae5977b31f505889cd9b9b70057445efc438d60cff96163de9a03034a23ad630df6faabc89ec55dfabafc165e4bb2b39b9537
7
- data.tar.gz: bef01266af1814bbf101bd2eebc31a24a87d3e8eed86cd13d4d840263465670208e156313c6a140708f6a4977102b80446932fcb00703eafa9b2c1d5228e1586
6
+ metadata.gz: 67af3d87c3a01ce868c85c4ff489212e267b6136afa902002340b61ea5f36418a9d0c917fba905d92c84fe6713764988efab1924284cc1788356f6f62e719117
7
+ data.tar.gz: 0ed08cabe9f5295ae4c522f6d896e4f31f30522e82dc4a7d9f52a41bd2bf14c8c359611f085c6d4117e893dbb26ac35b1278a2336173755c6c52af260146e0ab
data/lib/eac_rest/api.rb CHANGED
@@ -13,6 +13,13 @@ module EacRest
13
13
  self.ssl_verify = true
14
14
  end
15
15
 
16
+ # @param entity_class [Class]
17
+ # @param url_suffix [String]
18
+ # @return [EacRest::Entity]
19
+ def entity(entity_class, url_suffix)
20
+ entity_class.new(self, request_json(url_suffix))
21
+ end
22
+
16
23
  def request(service_url_suffix, headers = {}, &body_data_proc)
17
24
  r = ::EacRest::Request.new(build_service_url(service_url_suffix),
18
25
  body_data_proc).ssl_verify(ssl_verify)
@@ -4,13 +4,30 @@ require 'eac_ruby_utils/core_ext'
4
4
 
5
5
  module EacRest
6
6
  class Entity
7
+ enable_abstract_methods
7
8
  enable_simple_cache
8
- common_constructor :api, :data
9
+ common_constructor :api, :data_or_id
9
10
 
10
11
  class << self
11
12
  def from_array_data(api, array_data, *args)
12
13
  array_data.map { |item_data| new(api, item_data, *args) }
13
14
  end
14
15
  end
16
+
17
+ # @return [Hash]
18
+ def data
19
+ self.data_or_id = data_from_id unless data_or_id_data?
20
+ data_or_id
21
+ end
22
+
23
+ # @return [Boolean]
24
+ def data_or_id_data?
25
+ data_or_id.is?(::Hash)
26
+ end
27
+
28
+ # @return [Hash]
29
+ def data_from_id
30
+ raise_abstract_method __method__
31
+ end
15
32
  end
16
33
  end
@@ -15,11 +15,13 @@ module EacRest
15
15
  @internal_request = url
16
16
  else
17
17
  @internal_request = ::EacEnvs::Http::Request.new.url(url)
18
- response_body_data_proc.if_present { |v| @internal_request.response_body_data_proc = v }
18
+ response_body_data_proc.if_present do |v|
19
+ @internal_request = @internal_request.response_body_data_proc(v)
20
+ end
19
21
  end
20
22
  end
21
23
 
22
- delegate :sanitized_verb, to: :internal_request
24
+ delegate :sanitized_verb, :url, to: :internal_request
23
25
 
24
26
  {
25
27
  auth: 0, body_data: 0, header: 1, headers: 0, ssl_verify: 0, verb: 0
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRest
4
- VERSION = '0.7.3'
4
+ VERSION = '0.8.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-28 00:00:00.000000000 Z
11
+ date: 2023-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_envs-http
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.2'
19
+ version: '0.3'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.3.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '0.2'
29
+ version: '0.3'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.3.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: eac_fs
29
35
  requirement: !ruby/object:Gem::Requirement