Class: Redmine::Client
- Inherits:
-
Object
- Object
- Redmine::Client
- Defined in:
- lib/redmine-ruby.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#token ⇒ Object
Returns the value of attribute token.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url, token) ⇒ Client
constructor
A new instance of Client.
- #issues ⇒ Object
- #projects ⇒ Object
- #resource(name, options = {}) ⇒ Object
- #time_entries ⇒ Object
- #uploads ⇒ Object
Constructor Details
#initialize(url, token) ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/redmine-ruby.rb', line 16 def initialize(url, token) self.url = url self.token = token self.api = Her::API.new self.api.setup url: url, ssl: { verify: false } do |c| c.use Faraday::Request::BasicAuthentication, token, '' c.use Faraday::Request::UrlEncoded c.use Redmine::Middleware::XmlParser c.use Faraday::Adapter::NetHttp end end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
14 15 16 |
# File 'lib/redmine-ruby.rb', line 14 def api @api end |
#token ⇒ Object
Returns the value of attribute token.
14 15 16 |
# File 'lib/redmine-ruby.rb', line 14 def token @token end |
#url ⇒ Object
Returns the value of attribute url.
14 15 16 |
# File 'lib/redmine-ruby.rb', line 14 def url @url end |
Instance Method Details
#issues ⇒ Object
45 46 47 |
# File 'lib/redmine-ruby.rb', line 45 def issues resource(:issue) end |
#projects ⇒ Object
41 42 43 |
# File 'lib/redmine-ruby.rb', line 41 def projects resource(:project) end |
#resource(name, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/redmine-ruby.rb', line 28 def resource(name, ={}) klass = "Redmine::#{name.to_s.classify}".constantize the_api = api the_token = token Class.new(klass) do |c| c.uses_api the_api c.api_token the_token c.element_name name.to_s.underscore.to_sym c.collection_path klass.collection_path c.resource_path klass.resource_path end end |
#time_entries ⇒ Object
53 54 55 |
# File 'lib/redmine-ruby.rb', line 53 def time_entries resource(:time_entry) end |
#uploads ⇒ Object
49 50 51 |
# File 'lib/redmine-ruby.rb', line 49 def uploads resource(:upload) end |