Class: Avm::EacGitlabBase0::Api::BaseEntity
- Inherits:
-
EacRest::Entity
- Object
- EacRest::Entity
- Avm::EacGitlabBase0::Api::BaseEntity
show all
- Defined in:
- lib/avm/eac_gitlab_base0/api/base_entity.rb,
lib/avm/eac_gitlab_base0/api/base_entity/validate_response_data.rb
Defined Under Namespace
Classes: ValidateResponseData
Instance Method Summary
collapse
Instance Method Details
#delete(url_suffix) ⇒ Object
13
14
15
|
# File 'lib/avm/eac_gitlab_base0/api/base_entity.rb', line 13
def delete(url_suffix)
api.request(url_suffix).verb(:delete).response.body_data
end
|
#dump_debug(basename, data) ⇒ Object
58
59
60
61
62
|
# File 'lib/avm/eac_gitlab_base0/api/base_entity.rb', line 58
def dump_debug(basename, data)
file = ::Pathname.new('/tmp').join('gitlab_temp', "#{basename}.yaml")
file.parent.mkpath
::EacRubyUtils::Yaml.dump_file(file, data)
end
|
#dump_response(response) ⇒ Object
51
52
53
54
55
56
|
# File 'lib/avm/eac_gitlab_base0/api/base_entity.rb', line 51
def dump_response(response)
basename = response.url.to_s.variableize[0..99]
{ data: response.body_data, headers: response., links: response.links }
.each { |part, value| dump_debug("#{basename}_#{part}", value) }
response
end
|
#encode_id(id) ⇒ Object
17
18
19
20
21
|
# File 'lib/avm/eac_gitlab_base0/api/base_entity.rb', line 17
def encode_id(id)
return id if id.is_a?(::Integer)
::CGI.escape(id.to_s)
end
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/avm/eac_gitlab_base0/api/base_entity.rb', line 35
def fetch_entities(suffix, klass) r = []
request = api.request_json(suffix)
while request
response = request.response
body_data = validate_response_data(response)
break unless body_data
r += body_data.map { |rr| child_entity(klass, rr) }
request = response.link('next').if_present do |v|
api.request_json(v)
end
end
r
end
|
26
27
28
29
30
|
# File 'lib/avm/eac_gitlab_base0/api/base_entity.rb', line 26
def fetch_entity(suffix, klass)
validate_response_data(
dump_response(api.request_json(suffix).response)
).if_present { |v| child_entity(klass, v) }
end
|