Class: Noko::Client
- Inherits:
-
Object
- Object
- Noko::Client
- Defined in:
- lib/noko/client.rb,
lib/noko/client/tags.rb,
lib/noko/client/users.rb,
lib/noko/client/timers.rb,
lib/noko/client/account.rb,
lib/noko/client/entries.rb,
lib/noko/client/expenses.rb,
lib/noko/client/invoices.rb,
lib/noko/client/projects.rb,
lib/noko/client/current_user.rb,
lib/noko/client/project_groups.rb
Instance Method Summary collapse
- #archive_project(id) ⇒ Object
- #archive_projects(project_ids) ⇒ Object
- #create_entry(attributes) ⇒ Object
- #create_expense(attributes) ⇒ Object
- #create_invoice(attributes) ⇒ Object
- #create_project(attributes) ⇒ Object
- #create_project_group(attributes) ⇒ Object
- #create_tags(names) ⇒ Object
- #create_user(attributes) ⇒ Object
- #deactivate_user(id) ⇒ Object
- #delete_entry(id) ⇒ Object
- #delete_expense(id) ⇒ Object
- #delete_invoice(id) ⇒ Object
- #delete_project(id) ⇒ Object
- #delete_project_group(id) ⇒ Object
- #delete_projects(project_ids) ⇒ Object
- #delete_tag(id) ⇒ Object
- #delete_tags(tag_ids) ⇒ Object
- #delete_user(id) ⇒ Object
- #discard_timer(project_id) ⇒ Object
- #get(path, params = nil) ⇒ Object
- #get_account ⇒ Object
- #get_current_user ⇒ Object
- #get_current_user_entries(params = nil) ⇒ Object
- #get_current_user_expenses(params = nil) ⇒ Object
- #get_entries(params = nil) ⇒ Object
- #get_entry(id) ⇒ Object
- #get_expense(id) ⇒ Object
- #get_expenses(params = nil) ⇒ Object
- #get_invoice(id) ⇒ Object
- #get_invoice_entries(id, params = nil) ⇒ Object
- #get_invoice_expenses(id, params = nil) ⇒ Object
- #get_invoices(params = nil) ⇒ Object
- #get_project(id) ⇒ Object
- #get_project_entries(id, params = nil) ⇒ Object
- #get_project_expenses(id, params = nil) ⇒ Object
- #get_project_group(id) ⇒ Object
- #get_project_group_entries(id, params = nil) ⇒ Object
- #get_project_group_projects(id, params = nil) ⇒ Object
- #get_project_groups(params = nil) ⇒ Object
- #get_projects(params = nil) ⇒ Object
- #get_tag(id) ⇒ Object
- #get_tag_entries(id, params = nil) ⇒ Object
- #get_tags(params = nil) ⇒ Object
- #get_timer(project_id) ⇒ Object
- #get_timers(params = nil) ⇒ Object
- #get_user(id) ⇒ Object
- #get_user_entries(id, params = nil) ⇒ Object
- #get_user_expenses(id, params = nil) ⇒ Object
- #get_users(params = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #log_timer(project_id, attributes = {}) ⇒ Object
- #mark_invoice_paid(id) ⇒ Object
- #mark_invoice_unpaid(id) ⇒ Object
- #merge_projects(id, project_id) ⇒ Object
- #merge_tags(id, tag_id) ⇒ Object
- #pause_timer(project_id) ⇒ Object
- #reactivate_user(id) ⇒ Object
- #start_timer(project_id) ⇒ Object
- #unarchive_project(id) ⇒ Object
- #unarchive_projects(project_ids) ⇒ Object
- #update_current_user(attributes) ⇒ Object
- #update_entry(id, attributes) ⇒ Object
- #update_expense(id, attributes) ⇒ Object
- #update_invoice(id, attributes) ⇒ Object
- #update_project(id, attributes) ⇒ Object
- #update_project_group(id, attributes) ⇒ Object
- #update_tag(id, attributes) ⇒ Object
- #update_timer(project_id, attributes) ⇒ Object
- #update_user(id, attributes) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/noko/client.rb', line 11 def initialize( = {}) if .key?(:access_token) @auth_header, @auth_value = 'Authorization', "token #{[:access_token]}" else @auth_header, @auth_value = 'X-NokoToken', .fetch(:token) end @user_agent = .fetch(:user_agent) { "noko/#{VERSION} ruby/#{RUBY_VERSION}" } @host = 'api.nokotime.com' @http = Net::HTTP.new(@host, Net::HTTP.https_default_port) @http.use_ssl = true end |
Instance Method Details
#archive_project(id) ⇒ Object
35 36 37 |
# File 'lib/noko/client/projects.rb', line 35 def archive_project(id) put("/v2/projects/#{id}/archive") end |
#archive_projects(project_ids) ⇒ Object
43 44 45 |
# File 'lib/noko/client/projects.rb', line 43 def archive_projects(project_ids) put('/v2/projects/archive', project_ids: project_ids) end |
#create_entry(attributes) ⇒ Object
11 12 13 |
# File 'lib/noko/client/entries.rb', line 11 def create_entry(attributes) post('/v2/entries', attributes) end |
#create_expense(attributes) ⇒ Object
11 12 13 |
# File 'lib/noko/client/expenses.rb', line 11 def create_expense(attributes) post('/v2/expenses', attributes) end |
#create_invoice(attributes) ⇒ Object
11 12 13 |
# File 'lib/noko/client/invoices.rb', line 11 def create_invoice(attributes) post('/v2/invoices', attributes) end |
#create_project(attributes) ⇒ Object
11 12 13 |
# File 'lib/noko/client/projects.rb', line 11 def create_project(attributes) post('/v2/projects', attributes) end |
#create_project_group(attributes) ⇒ Object
11 12 13 |
# File 'lib/noko/client/project_groups.rb', line 11 def create_project_group(attributes) post('/v2/project_groups', attributes) end |
#create_tags(names) ⇒ Object
7 8 9 |
# File 'lib/noko/client/tags.rb', line 7 def (names) post('/v2/tags', names: names) end |
#create_user(attributes) ⇒ Object
19 20 21 |
# File 'lib/noko/client/users.rb', line 19 def create_user(attributes) post('/v2/users', attributes) end |
#deactivate_user(id) ⇒ Object
35 36 37 |
# File 'lib/noko/client/users.rb', line 35 def deactivate_user(id) put("/v2/users/#{id}/deactivate") end |
#delete_entry(id) ⇒ Object
19 20 21 |
# File 'lib/noko/client/entries.rb', line 19 def delete_entry(id) delete("/v2/entries/#{id}") end |
#delete_expense(id) ⇒ Object
19 20 21 |
# File 'lib/noko/client/expenses.rb', line 19 def delete_expense(id) delete("/v2/expenses/#{id}") end |
#delete_invoice(id) ⇒ Object
35 36 37 |
# File 'lib/noko/client/invoices.rb', line 35 def delete_invoice(id) delete("/v2/invoices/#{id}") end |
#delete_project(id) ⇒ Object
31 32 33 |
# File 'lib/noko/client/projects.rb', line 31 def delete_project(id) delete("/v2/projects/#{id}") end |
#delete_project_group(id) ⇒ Object
27 28 29 |
# File 'lib/noko/client/project_groups.rb', line 27 def delete_project_group(id) delete("/v2/project_groups/#{id}") end |
#delete_projects(project_ids) ⇒ Object
51 52 53 |
# File 'lib/noko/client/projects.rb', line 51 def delete_projects(project_ids) put('/v2/projects/delete', project_ids: project_ids) end |
#delete_tag(id) ⇒ Object
27 28 29 |
# File 'lib/noko/client/tags.rb', line 27 def delete_tag(id) delete("/v2/tags/#{id}") end |
#delete_tags(tag_ids) ⇒ Object
31 32 33 |
# File 'lib/noko/client/tags.rb', line 31 def (tag_ids) put('/v2/tags/delete', tag_ids: tag_ids) end |
#delete_user(id) ⇒ Object
27 28 29 |
# File 'lib/noko/client/users.rb', line 27 def delete_user(id) delete("/v2/users/#{id}") end |
#discard_timer(project_id) ⇒ Object
27 28 29 |
# File 'lib/noko/client/timers.rb', line 27 def discard_timer(project_id) delete("/v2/projects/#{project_id}/timer") end |
#get(path, params = nil) ⇒ Object
27 28 29 |
# File 'lib/noko/client.rb', line 27 def get(path, params = nil) request(Net::HTTP::Get.new(Params.join(path, params))) end |
#get_account ⇒ Object
3 4 5 |
# File 'lib/noko/client/account.rb', line 3 def get_account get('/v2/account') end |
#get_current_user ⇒ Object
3 4 5 |
# File 'lib/noko/client/current_user.rb', line 3 def get_current_user get('/v2/current_user') end |
#get_current_user_entries(params = nil) ⇒ Object
7 8 9 |
# File 'lib/noko/client/current_user.rb', line 7 def get_current_user_entries(params = nil) get('/v2/current_user/entries', params) end |
#get_current_user_expenses(params = nil) ⇒ Object
11 12 13 |
# File 'lib/noko/client/current_user.rb', line 11 def get_current_user_expenses(params = nil) get('/v2/current_user/expenses', params) end |
#get_entries(params = nil) ⇒ Object
3 4 5 |
# File 'lib/noko/client/entries.rb', line 3 def get_entries(params = nil) get('/v2/entries', params) end |
#get_entry(id) ⇒ Object
7 8 9 |
# File 'lib/noko/client/entries.rb', line 7 def get_entry(id) get("/v2/entries/#{id}") end |
#get_expense(id) ⇒ Object
7 8 9 |
# File 'lib/noko/client/expenses.rb', line 7 def get_expense(id) get("/v2/expenses/#{id}") end |
#get_expenses(params = nil) ⇒ Object
3 4 5 |
# File 'lib/noko/client/expenses.rb', line 3 def get_expenses(params = nil) get('/v2/expenses', params) end |
#get_invoice(id) ⇒ Object
7 8 9 |
# File 'lib/noko/client/invoices.rb', line 7 def get_invoice(id) get("/v2/invoices/#{id}") end |
#get_invoice_entries(id, params = nil) ⇒ Object
27 28 29 |
# File 'lib/noko/client/invoices.rb', line 27 def get_invoice_entries(id, params = nil) get("/v2/invoices/#{id}/entries", params) end |
#get_invoice_expenses(id, params = nil) ⇒ Object
31 32 33 |
# File 'lib/noko/client/invoices.rb', line 31 def get_invoice_expenses(id, params = nil) get("/v2/invoices/#{id}/expenses", params) end |
#get_invoices(params = nil) ⇒ Object
3 4 5 |
# File 'lib/noko/client/invoices.rb', line 3 def get_invoices(params = nil) get('/v2/invoices', params) end |
#get_project(id) ⇒ Object
7 8 9 |
# File 'lib/noko/client/projects.rb', line 7 def get_project(id) get("/v2/projects/#{id}") end |
#get_project_entries(id, params = nil) ⇒ Object
15 16 17 |
# File 'lib/noko/client/projects.rb', line 15 def get_project_entries(id, params = nil) get("/v2/projects/#{id}/entries", params) end |
#get_project_expenses(id, params = nil) ⇒ Object
19 20 21 |
# File 'lib/noko/client/projects.rb', line 19 def get_project_expenses(id, params = nil) get("/v2/projects/#{id}/expenses", params) end |
#get_project_group(id) ⇒ Object
7 8 9 |
# File 'lib/noko/client/project_groups.rb', line 7 def get_project_group(id) get("/v2/project_groups/#{id}") end |
#get_project_group_entries(id, params = nil) ⇒ Object
15 16 17 |
# File 'lib/noko/client/project_groups.rb', line 15 def get_project_group_entries(id, params = nil) get("/v2/project_groups/#{id}/entries", params) end |
#get_project_group_projects(id, params = nil) ⇒ Object
19 20 21 |
# File 'lib/noko/client/project_groups.rb', line 19 def get_project_group_projects(id, params = nil) get("/v2/project_groups/#{id}/projects", params) end |
#get_project_groups(params = nil) ⇒ Object
3 4 5 |
# File 'lib/noko/client/project_groups.rb', line 3 def get_project_groups(params = nil) get('/v2/project_groups', params) end |
#get_projects(params = nil) ⇒ Object
3 4 5 |
# File 'lib/noko/client/projects.rb', line 3 def get_projects(params = nil) get('/v2/projects', params) end |
#get_tag(id) ⇒ Object
11 12 13 |
# File 'lib/noko/client/tags.rb', line 11 def get_tag(id) get("/v2/tags/#{id}") end |
#get_tag_entries(id, params = nil) ⇒ Object
15 16 17 |
# File 'lib/noko/client/tags.rb', line 15 def get_tag_entries(id, params = nil) get("/v2/tags/#{id}/entries", params) end |
#get_tags(params = nil) ⇒ Object
3 4 5 |
# File 'lib/noko/client/tags.rb', line 3 def (params = nil) get('/v2/tags', params) end |
#get_timer(project_id) ⇒ Object
7 8 9 |
# File 'lib/noko/client/timers.rb', line 7 def get_timer(project_id) get("/v2/projects/#{project_id}/timer") end |
#get_timers(params = nil) ⇒ Object
3 4 5 |
# File 'lib/noko/client/timers.rb', line 3 def get_timers(params = nil) get('/v2/timers', params) end |
#get_user(id) ⇒ Object
7 8 9 |
# File 'lib/noko/client/users.rb', line 7 def get_user(id) get("/v2/users/#{id}") end |
#get_user_entries(id, params = nil) ⇒ Object
11 12 13 |
# File 'lib/noko/client/users.rb', line 11 def get_user_entries(id, params = nil) get("/v2/users/#{id}/entries", params) end |
#get_user_expenses(id, params = nil) ⇒ Object
15 16 17 |
# File 'lib/noko/client/users.rb', line 15 def get_user_expenses(id, params = nil) get("/v2/users/#{id}/expenses", params) end |
#get_users(params = nil) ⇒ Object
3 4 5 |
# File 'lib/noko/client/users.rb', line 3 def get_users(params = nil) get('/v2/users', params) end |
#log_timer(project_id, attributes = {}) ⇒ Object
23 24 25 |
# File 'lib/noko/client/timers.rb', line 23 def log_timer(project_id, attributes = {}) put("/v2/projects/#{project_id}/timer/log", attributes) end |
#mark_invoice_paid(id) ⇒ Object
19 20 21 |
# File 'lib/noko/client/invoices.rb', line 19 def mark_invoice_paid(id) put("/v2/invoices/#{id}/paid") end |
#mark_invoice_unpaid(id) ⇒ Object
23 24 25 |
# File 'lib/noko/client/invoices.rb', line 23 def mark_invoice_unpaid(id) put("/v2/invoices/#{id}/unpaid") end |
#merge_projects(id, project_id) ⇒ Object
27 28 29 |
# File 'lib/noko/client/projects.rb', line 27 def merge_projects(id, project_id) put("/v2/projects/#{id}/merge", project_id: project_id) end |
#merge_tags(id, tag_id) ⇒ Object
23 24 25 |
# File 'lib/noko/client/tags.rb', line 23 def (id, tag_id) put("/v2/tags/#{id}/merge", tag_id: tag_id) end |
#pause_timer(project_id) ⇒ Object
19 20 21 |
# File 'lib/noko/client/timers.rb', line 19 def pause_timer(project_id) put("/v2/projects/#{project_id}/timer/pause") end |
#reactivate_user(id) ⇒ Object
31 32 33 |
# File 'lib/noko/client/users.rb', line 31 def reactivate_user(id) put("/v2/users/#{id}/activate") end |
#start_timer(project_id) ⇒ Object
15 16 17 |
# File 'lib/noko/client/timers.rb', line 15 def start_timer(project_id) put("/v2/projects/#{project_id}/timer/start") end |
#unarchive_project(id) ⇒ Object
39 40 41 |
# File 'lib/noko/client/projects.rb', line 39 def unarchive_project(id) put("/v2/projects/#{id}/unarchive") end |
#unarchive_projects(project_ids) ⇒ Object
47 48 49 |
# File 'lib/noko/client/projects.rb', line 47 def unarchive_projects(project_ids) put('/v2/projects/unarchive', project_ids: project_ids) end |
#update_current_user(attributes) ⇒ Object
15 16 17 |
# File 'lib/noko/client/current_user.rb', line 15 def update_current_user(attributes) put('/v2/current_user', attributes) end |
#update_entry(id, attributes) ⇒ Object
15 16 17 |
# File 'lib/noko/client/entries.rb', line 15 def update_entry(id, attributes) put("/v2/entries/#{id}", attributes) end |
#update_expense(id, attributes) ⇒ Object
15 16 17 |
# File 'lib/noko/client/expenses.rb', line 15 def update_expense(id, attributes) put("/v2/expenses/#{id}", attributes) end |
#update_invoice(id, attributes) ⇒ Object
15 16 17 |
# File 'lib/noko/client/invoices.rb', line 15 def update_invoice(id, attributes) put("/v2/invoices/#{id}", attributes) end |
#update_project(id, attributes) ⇒ Object
23 24 25 |
# File 'lib/noko/client/projects.rb', line 23 def update_project(id, attributes) put("/v2/projects/#{id}", attributes) end |
#update_project_group(id, attributes) ⇒ Object
23 24 25 |
# File 'lib/noko/client/project_groups.rb', line 23 def update_project_group(id, attributes) put("/v2/project_groups/#{id}", attributes) end |
#update_tag(id, attributes) ⇒ Object
19 20 21 |
# File 'lib/noko/client/tags.rb', line 19 def update_tag(id, attributes) put("/v2/tags/#{id}", attributes) end |
#update_timer(project_id, attributes) ⇒ Object
11 12 13 |
# File 'lib/noko/client/timers.rb', line 11 def update_timer(project_id, attributes) put("/v2/projects/#{project_id}/timer", attributes) end |
#update_user(id, attributes) ⇒ Object
23 24 25 |
# File 'lib/noko/client/users.rb', line 23 def update_user(id, attributes) put("/v2/users/#{id}", attributes) end |