Class: TimelyApp::Client
- Inherits:
-
Object
- Object
- TimelyApp::Client
- Defined in:
- lib/timely-app/client.rb,
lib/timely-app/client/auth.rb,
lib/timely-app/client/roles.rb,
lib/timely-app/client/teams.rb,
lib/timely-app/client/users.rb,
lib/timely-app/client/events.rb,
lib/timely-app/client/labels.rb,
lib/timely-app/client/clients.rb,
lib/timely-app/client/reports.rb,
lib/timely-app/client/accounts.rb,
lib/timely-app/client/projects.rb,
lib/timely-app/client/webhooks.rb,
lib/timely-app/client/forecasts.rb,
lib/timely-app/client/permissions.rb,
lib/timely-app/client/user_capacities.rb
Instance Attribute Summary collapse
-
#account_id ⇒ Object
Returns the value of attribute account_id.
Instance Method Summary collapse
- #create_bulk_events(create) ⇒ Object
- #create_client(name:, **params) ⇒ Object
- #create_event(day:, hours:, minutes:, **params) ⇒ Object
- #create_forecast(project_id:, **params) ⇒ Object
- #create_label(name:, **params) ⇒ Object
- #create_project(name:, color:, client_id:, users:, **params) ⇒ Object
- #create_project_event(project_id:, day:, hours:, minutes:, **params) ⇒ Object
- #create_team(name:, users:, **params) ⇒ Object
- #create_user(name:, email:, role_id:, **params) ⇒ Object
- #create_user_event(user_id:, day:, hours:, minutes:, **params) ⇒ Object
- #create_webhook(url:, **params) ⇒ Object
- #delete_bulk_events(delete) ⇒ Object
- #delete_event(id) ⇒ Object
- #delete_forecast(id) ⇒ Object
- #delete_label(id) ⇒ Object
- #delete_project(id) ⇒ Object
- #delete_team(id) ⇒ Object
- #delete_user(id) ⇒ Object
- #delete_webhook(id) ⇒ Object
- #get(path, params = nil) ⇒ Object
- #get_account(id) ⇒ Object
- #get_account_activities(account_id, **params) ⇒ Object
- #get_accounts ⇒ Object
- #get_child_labels(parent_id) ⇒ Object
- #get_client(id) ⇒ Object
- #get_clients(**params) ⇒ Object
- #get_current_user ⇒ Object
- #get_current_user_permissions ⇒ Object
- #get_event(id) ⇒ Object
- #get_events(**params) ⇒ Object
- #get_filter_reports(**params) ⇒ Object
- #get_forecasts(**params) ⇒ Object
- #get_label(id) ⇒ Object
- #get_labels(**params) ⇒ Object
- #get_oauth_authorize_url(client_id:, redirect_uri:) ⇒ Object
- #get_project(id) ⇒ Object
- #get_project_events(project_id:, **params) ⇒ Object
- #get_projects(**params) ⇒ Object
- #get_reports(**params) ⇒ Object
- #get_roles ⇒ Object
- #get_team(id) ⇒ Object
- #get_teams(**params) ⇒ Object
- #get_user(id) ⇒ Object
- #get_user_capacities(user_id:) ⇒ Object
- #get_user_events(user_id:, **params) ⇒ Object
- #get_user_permissions(user_id:) ⇒ Object
- #get_users(**params) ⇒ Object
- #get_users_capacities(**params) ⇒ Object
- #get_webhook(id) ⇒ Object
- #get_webhooks(**params) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #post_oauth_token(client_id:, client_secret:, code:, redirect_uri:, grant_type: "authorization_code") ⇒ Object
- #start_event_timer(id) ⇒ Object
- #stop_event_timer(id) ⇒ Object
- #update_bulk_events(update) ⇒ Object
- #update_client(id, name:, **params) ⇒ Object
- #update_event(id, day:, hours:, minutes:, **params) ⇒ Object
- #update_forecast(id, project_id:, estimated_minutes:, **params) ⇒ Object
- #update_label(id, name:, **params) ⇒ Object
- #update_project(id, name:, color:, client_id:, users:, **params) ⇒ Object
- #update_project_event(id, project_id:, day:, hours:, minutes:, **params) ⇒ Object
- #update_team(id, name:, users:, **params) ⇒ Object
- #update_user(id, name:, email:, role_id:, **params) ⇒ Object
- #update_user_event(id, user_id:, day:, hours:, minutes:, **params) ⇒ Object
- #update_webhook(id, url:, **params) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/timely-app/client.rb', line 15 def initialize( = {}) @auth_header = 'Authorization' @auth_value = "Bearer #{[:access_token]}" @user_agent = .fetch(:user_agent) { "timely-app/#{VERSION} ruby/#{RUBY_VERSION}" } @host = 'api.timelyapp.com' @http = Net::HTTP.new(@host, Net::HTTP.https_default_port) @http.use_ssl = true @account_id = [:account_id] @verbose = [:verbose] || !ENV['VERBOSE'].nil? || false end |
Instance Attribute Details
#account_id ⇒ Object
Returns the value of attribute account_id.
13 14 15 |
# File 'lib/timely-app/client.rb', line 13 def account_id @account_id end |
Instance Method Details
#create_bulk_events(create) ⇒ Object
18 19 20 |
# File 'lib/timely-app/client/events.rb', line 18 def create_bulk_events(create) post("/1.1/#{account_id}/bulk/events", create: create) end |
#create_client(name:, **params) ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/clients.rb', line 6 def create_client(name:, **params) post("/1.1/#{account_id}/clients", client: params.merge(name: name)) end |
#create_event(day:, hours:, minutes:, **params) ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/events.rb', line 6 def create_event(day:, hours:, minutes:, **params) post("/1.1/#{account_id}/events", event: params.merge(day: day, hours: hours, minutes: minutes)) end |
#create_forecast(project_id:, **params) ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/forecasts.rb', line 6 def create_forecast(project_id:, **params) post("/1.1/#{account_id}/forecasts", forecast: params.merge(project_id: project_id)) end |
#create_label(name:, **params) ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/labels.rb', line 6 def create_label(name:, **params) post("/1.1/#{account_id}/labels", label: params.merge(name: name)) end |
#create_project(name:, color:, client_id:, users:, **params) ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/projects.rb', line 6 def create_project(name:, color:, client_id:, users:, **params) post("/1.1/#{account_id}/projects", project: params.merge(name: name, color: color, client_id: client_id, users: users)) end |
#create_project_event(project_id:, day:, hours:, minutes:, **params) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/events.rb', line 10 def create_project_event(project_id:, day:, hours:, minutes:, **params) post("/1.1/#{account_id}/projects/#{project_id}/events", event: params.merge(day: day, hours: hours, minutes: minutes)) end |
#create_team(name:, users:, **params) ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/teams.rb', line 6 def create_team(name:, users:, **params) post("/1.1/#{account_id}/teams", team: params.merge(name: name, users: users)) end |
#create_user(name:, email:, role_id:, **params) ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/users.rb', line 6 def create_user(name:, email:, role_id:, **params) post("/1.1/#{account_id}/users", user: params.merge(name: name, email: email, role_id: role_id)) end |
#create_user_event(user_id:, day:, hours:, minutes:, **params) ⇒ Object
14 15 16 |
# File 'lib/timely-app/client/events.rb', line 14 def create_user_event(user_id:, day:, hours:, minutes:, **params) post("/1.1/#{account_id}/users/#{user_id}/events", event: params.merge(day: day, hours: hours, minutes: minutes)) end |
#create_webhook(url:, **params) ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/webhooks.rb', line 6 def create_webhook(url:, **params) post("/1.1/#{account_id}/webhooks", webhook: params.merge(url: url)) end |
#delete_bulk_events(delete) ⇒ Object
26 27 28 |
# File 'lib/timely-app/client/events.rb', line 26 def delete_bulk_events(delete) post("/1.1/#{account_id}/bulk/events", delete: delete) end |
#delete_event(id) ⇒ Object
22 23 24 |
# File 'lib/timely-app/client/events.rb', line 22 def delete_event(id) delete("/1.1/#{account_id}/events/#{id}") end |
#delete_forecast(id) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/forecasts.rb', line 10 def delete_forecast(id) delete("/1.1/#{account_id}/forecasts/#{id}") end |
#delete_label(id) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/labels.rb', line 10 def delete_label(id) delete("/1.1/#{account_id}/labels/#{id}") end |
#delete_project(id) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/projects.rb', line 10 def delete_project(id) delete("/1.1/#{account_id}/projects/#{id}") end |
#delete_team(id) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/teams.rb', line 10 def delete_team(id) delete("/1.1/#{account_id}/teams/#{id}") end |
#delete_user(id) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/users.rb', line 10 def delete_user(id) delete("/1.1/#{account_id}/users/#{id}") end |
#delete_webhook(id) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/webhooks.rb', line 10 def delete_webhook(id) delete("/1.1/#{account_id}/webhooks/#{id}") end |
#get(path, params = nil) ⇒ Object
29 30 31 |
# File 'lib/timely-app/client.rb', line 29 def get(path, params = nil) request(Net::HTTP::Get.new(Params.join(path, params))) end |
#get_account(id) ⇒ Object
14 15 16 |
# File 'lib/timely-app/client/accounts.rb', line 14 def get_account(id) get("/1.1/accounts/#{id}") end |
#get_account_activities(account_id, **params) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/accounts.rb', line 10 def get_account_activities(account_id, **params) get("/1.1/#{account_id}/activities", params) end |
#get_accounts ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/accounts.rb', line 6 def get_accounts get('/1.1/accounts') end |
#get_child_labels(parent_id) ⇒ Object
14 15 16 |
# File 'lib/timely-app/client/labels.rb', line 14 def get_child_labels(parent_id) get("/1.1/#{account_id}/labels", parent_id: parent_id) end |
#get_client(id) ⇒ Object
14 15 16 |
# File 'lib/timely-app/client/clients.rb', line 14 def get_client(id) get("/1.1/#{account_id}/clients/#{id}") end |
#get_clients(**params) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/clients.rb', line 10 def get_clients(**params) get('/1.1/accounts', params) end |
#get_current_user ⇒ Object
22 23 24 |
# File 'lib/timely-app/client/users.rb', line 22 def get_current_user get("/1.1/#{account_id}/users/current") end |
#get_current_user_permissions ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/permissions.rb', line 6 def get("/1.1/#{account_id}/users/current/permissions") end |
#get_event(id) ⇒ Object
50 51 52 |
# File 'lib/timely-app/client/events.rb', line 50 def get_event(id) get("/1.1/#{account_id}/events/#{id}") end |
#get_events(**params) ⇒ Object
30 31 32 |
# File 'lib/timely-app/client/events.rb', line 30 def get_events(**params) get("/1.1/#{account_id}/events", params) end |
#get_filter_reports(**params) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/reports.rb', line 10 def get_filter_reports(**params) post("/1.1/#{account_id}/reports/filter", params) end |
#get_forecasts(**params) ⇒ Object
14 15 16 |
# File 'lib/timely-app/client/forecasts.rb', line 14 def get_forecasts(**params) get("/1.1/#{account_id}/forecasts", params) end |
#get_label(id) ⇒ Object
22 23 24 |
# File 'lib/timely-app/client/labels.rb', line 22 def get_label(id) get("/1.1/#{account_id}/labels/#{id}") end |
#get_labels(**params) ⇒ Object
18 19 20 |
# File 'lib/timely-app/client/labels.rb', line 18 def get_labels(**params) get("/1.1/#{account_id}/labels", params) end |
#get_oauth_authorize_url(client_id:, redirect_uri:) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/timely-app/client/auth.rb', line 6 def (client_id:, redirect_uri:) host_uri_join( "/1.1/oauth/authorize", response_type: 'code', redirect_uri: redirect_uri, client_id: client_id ) end |
#get_project(id) ⇒ Object
18 19 20 |
# File 'lib/timely-app/client/projects.rb', line 18 def get_project(id) get("/1.1/#{account_id}/projects/#{id}") end |
#get_project_events(project_id:, **params) ⇒ Object
34 35 36 |
# File 'lib/timely-app/client/events.rb', line 34 def get_project_events(project_id:, **params) get("/1.1/#{account_id}/projects/#{project_id}/events", params) end |
#get_projects(**params) ⇒ Object
14 15 16 |
# File 'lib/timely-app/client/projects.rb', line 14 def get_projects(**params) get("/1.1/#{account_id}/projects", params) end |
#get_reports(**params) ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/reports.rb', line 6 def get_reports(**params) post("/1.1/#{account_id}/reports", params) end |
#get_roles ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/roles.rb', line 6 def get_roles get("/1.1/#{account_id}/roles") end |
#get_team(id) ⇒ Object
18 19 20 |
# File 'lib/timely-app/client/teams.rb', line 18 def get_team(id) get("/1.1/#{account_id}/teams/#{id}") end |
#get_teams(**params) ⇒ Object
14 15 16 |
# File 'lib/timely-app/client/teams.rb', line 14 def get_teams(**params) get("/1.1/#{account_id}/teams", params) end |
#get_user(id) ⇒ Object
18 19 20 |
# File 'lib/timely-app/client/users.rb', line 18 def get_user(id) get("/1.1/#{account_id}/users/#{id}") end |
#get_user_capacities(user_id:) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/user_capacities.rb', line 10 def get_user_capacities(user_id:) get("/1.1/#{account_id}/users/#{user_id}/capacities") end |
#get_user_events(user_id:, **params) ⇒ Object
38 39 40 |
# File 'lib/timely-app/client/events.rb', line 38 def get_user_events(user_id:, **params) get("/1.1/#{account_id}/users/#{user_id}/events", params) end |
#get_user_permissions(user_id:) ⇒ Object
10 11 12 |
# File 'lib/timely-app/client/permissions.rb', line 10 def (user_id:) get("/1.1/#{account_id}/users/#{user_id}/permissions") end |
#get_users(**params) ⇒ Object
14 15 16 |
# File 'lib/timely-app/client/users.rb', line 14 def get_users(**params) get("/1.1/#{account_id}/users", params) end |
#get_users_capacities(**params) ⇒ Object
6 7 8 |
# File 'lib/timely-app/client/user_capacities.rb', line 6 def get_users_capacities(**params) get("/1.1/#{account_id}/users/capacities", params) end |
#get_webhook(id) ⇒ Object
18 19 20 |
# File 'lib/timely-app/client/webhooks.rb', line 18 def get_webhook(id) get("/1.1/#{account_id}/webhooks/#{id}") end |
#get_webhooks(**params) ⇒ Object
14 15 16 |
# File 'lib/timely-app/client/webhooks.rb', line 14 def get_webhooks(**params) get("/1.1/#{account_id}/webhooks", params) end |
#post_oauth_token(client_id:, client_secret:, code:, redirect_uri:, grant_type: "authorization_code") ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/timely-app/client/auth.rb', line 15 def post_oauth_token(client_id:, client_secret:, code:, redirect_uri:, grant_type: "authorization_code") post( "/1.1/oauth/token", redirect_uri: redirect_uri, code: code, client_id: client_id, client_secret: client_secret, grant_type: grant_type ) end |
#start_event_timer(id) ⇒ Object
54 55 56 |
# File 'lib/timely-app/client/events.rb', line 54 def start_event_timer(id) put("/1.1/#{account_id}/events/#{id}/start") end |
#stop_event_timer(id) ⇒ Object
58 59 60 |
# File 'lib/timely-app/client/events.rb', line 58 def stop_event_timer(id) put("/1.1/#{account_id}/events/#{id}/stop") end |
#update_bulk_events(update) ⇒ Object
66 67 68 |
# File 'lib/timely-app/client/events.rb', line 66 def update_bulk_events(update) post("/1.1/#{account_id}/bulk/events", update: update) end |
#update_client(id, name:, **params) ⇒ Object
18 19 20 |
# File 'lib/timely-app/client/clients.rb', line 18 def update_client(id, name:, **params) put("/1.1/#{account_id}/clients/#{id}", client: params.merge(name: name)) end |
#update_event(id, day:, hours:, minutes:, **params) ⇒ Object
62 63 64 |
# File 'lib/timely-app/client/events.rb', line 62 def update_event(id, day:, hours:, minutes:, **params) put("/1.1/#{account_id}/events/#{id}", event: params.merge(day: day, hours: hours, minutes: minutes)) end |
#update_forecast(id, project_id:, estimated_minutes:, **params) ⇒ Object
18 19 20 |
# File 'lib/timely-app/client/forecasts.rb', line 18 def update_forecast(id, project_id:, estimated_minutes:, **params) put("/1.1/#{account_id}/forecasts/#{id}", forecast: params.merge(project_id: project_id, estimated_minutes: estimated_minutes)) end |
#update_label(id, name:, **params) ⇒ Object
26 27 28 |
# File 'lib/timely-app/client/labels.rb', line 26 def update_label(id, name:, **params) put("/1.1/#{account_id}/labels/#{id}", label: params.merge(name: name)) end |
#update_project(id, name:, color:, client_id:, users:, **params) ⇒ Object
22 23 24 |
# File 'lib/timely-app/client/projects.rb', line 22 def update_project(id, name:, color:, client_id:, users:, **params) put("/1.1/#{account_id}/projects/#{id}", project: params.merge(name: name, color: color, client_id: client_id, users: users)) end |
#update_project_event(id, project_id:, day:, hours:, minutes:, **params) ⇒ Object
46 47 48 |
# File 'lib/timely-app/client/events.rb', line 46 def update_project_event(id, project_id:, day:, hours:, minutes:, **params) put("/1.1/#{account_id}/projects/#{project_id}/events/#{id}", event: params.merge(day: day, hours: hours, minutes: minutes)) end |
#update_team(id, name:, users:, **params) ⇒ Object
22 23 24 |
# File 'lib/timely-app/client/teams.rb', line 22 def update_team(id, name:, users:, **params) put("/1.1/#{account_id}/teams/#{id}", team: params.merge(name: name, users: users)) end |
#update_user(id, name:, email:, role_id:, **params) ⇒ Object
26 27 28 |
# File 'lib/timely-app/client/users.rb', line 26 def update_user(id, name:, email:, role_id:, **params) put("/1.1/#{account_id}/users/#{id}", user: params.merge(name: name, email: email, role_id: role_id)) end |
#update_user_event(id, user_id:, day:, hours:, minutes:, **params) ⇒ Object
42 43 44 |
# File 'lib/timely-app/client/events.rb', line 42 def update_user_event(id, user_id:, day:, hours:, minutes:, **params) put("/1.1/#{account_id}/users/#{user_id}/events/#{id}", event: params.merge(day: day, hours: hours, minutes: minutes)) end |
#update_webhook(id, url:, **params) ⇒ Object
22 23 24 |
# File 'lib/timely-app/client/webhooks.rb', line 22 def update_webhook(id, url:, **params) put("/1.1/#{account_id}/webhooks/#{id}", webhook: params.merge(url: url)) end |