Class: Easy::Resources::Redmine::RedmineBase
Direct Known Subclasses
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
15
16
17
18
19
20
21
|
# File 'lib/easy/resources/redmine/redmine_base.rb', line 15
def configure(conf = nil)
conf ||= ::Easy.config.sites.redmine
self.api_key = conf[:api_key]
super(conf)
end
|
.get_all(**params, &block) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/easy/resources/redmine/redmine_base.rb', line 35
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
|
23
24
25
26
27
|
# File 'lib/easy/resources/redmine/redmine_base.rb', line 23
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
31
32
33
|
# File 'lib/easy/resources/redmine/redmine_base.rb', line 31
def retrieve_total(response)
(response['Total'] || response.body[/total_count[:="]+(\d+)/] && $1).to_i
end
|
Instance Method Details
#errors ⇒ Object
56
57
58
|
# File 'lib/easy/resources/redmine/redmine_base.rb', line 56
def errors
@errors ||= Errors.new(self)
end
|