Class: Git2Mite::MiteClient
- Inherits:
-
Object
- Object
- Git2Mite::MiteClient
- Defined in:
- lib/git2mite/mite_client.rb
Instance Method Summary collapse
- #add_message_to_entry(entry, message) ⇒ Object
- #get(path) ⇒ Object
-
#initialize(url, api_key) ⇒ MiteClient
constructor
A new instance of MiteClient.
- #projects ⇒ Object
- #time_entries(project_id, user_id, date) ⇒ Object
Constructor Details
#initialize(url, api_key) ⇒ MiteClient
Returns a new instance of MiteClient.
14 15 16 17 |
# File 'lib/git2mite/mite_client.rb', line 14 def initialize(url, api_key) @url = url @api_key = api_key end |
Instance Method Details
#add_message_to_entry(entry, message) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/git2mite/mite_client.rb', line 27 def (entry, ) builder = Builder::XmlMarkup.new builder.tag!('time-entry') do |time_entry| time_entry.note((entry['note'].size == 0 ? '' : entry['note'] + ', ') + ) end put "/time_entries/#{entry['id']}.xml", builder.target! end |
#get(path) ⇒ Object
35 36 37 |
# File 'lib/git2mite/mite_client.rb', line 35 def get(path) JSON.parse(RestClient.get(@url + path, {'User-Agent' => 'git2mite/0.0.1', 'X-MiteApiKey' => @api_key, 'Content-Type' => 'application/json'}).to_s) end |
#projects ⇒ Object
23 24 25 |
# File 'lib/git2mite/mite_client.rb', line 23 def projects get '/projects.json' end |
#time_entries(project_id, user_id, date) ⇒ Object
19 20 21 |
# File 'lib/git2mite/mite_client.rb', line 19 def time_entries(project_id, user_id, date) get("/time_entries.json?project-id=#{project_id}&user-id=#{user_id}&at=#{date.to_s}") end |