Class: Easy::Resources::Redmine::RedmineBase
Direct Known Subclasses
CustomField, EasyAttendance, EasyContact, EasyCrmCase, EasyServer, EasyWebApplication, EasyWebApplicationActivity, EasyWebHook, Issue, Project, TimeEntry, User
Class Method Summary
collapse
Instance Method Summary
collapse
#becomes, configure_bearer, #patch, #update_column, #update_columns
Class Method Details
14
15
16
17
18
19
20
|
# File 'lib/easy/resources/redmine/redmine_base.rb', line 14
def configure(conf = nil)
conf ||= ::Easy.config.sites.redmine
self.api_key = conf[:api_key]
super(conf)
end
|
.get_all(**params, &block) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/easy/resources/redmine/redmine_base.rb', line 34
def get_all(**params, &block)
records = results = all(params: params)
response = results.http_response
total = retrieve_total(response)
current_page = 1
while records.any?
records.each(&block) if block_given?
break if results.size >= total
self.format = :xml
records = all(params: params.merge(page: (current_page += 1)))
results.concat(records)
end
results
end
|
22
23
24
25
26
|
# File 'lib/easy/resources/redmine/redmine_base.rb', line 22
def
h = super
h['X-Redmine-API-Key'] = api_key
h
end
|
.retrieve_total(response) ⇒ Integer
Parse value of TOTAL amount of entities from headers or response
30
31
32
|
# File 'lib/easy/resources/redmine/redmine_base.rb', line 30
def retrieve_total(response)
(response['Total'] || (response.body[/total_count[:="]+(\d+)/] && Regexp.last_match(1))).to_i
end
|
Instance Method Details
#errors ⇒ Object
55
56
57
|
# File 'lib/easy/resources/redmine/redmine_base.rb', line 55
def errors
@errors ||= Errors.new(self)
end
|