Class: WorkSnaps::Client

Inherits:
Object
  • Object
show all
Includes:
API::Projects, API::TaskAssignments, API::Tasks, API::UserAssignments, API::Users
Defined in:
lib/worksnaps/client.rb

Constant Summary

Constants included from API::Utils

API::Utils::DEFAULT_CURSOR

Instance Method Summary collapse

Methods included from API::TaskAssignments

#create_task_assignment, #delete_task_assignment, #task_assignment, #task_assignments

Methods included from API::UserAssignments

#create_user_assignment, #delete_user_assignment, #update_user_assignment, #user_assignment, #user_assignments

Methods included from API::Projects

#create_project, #project, #projects, #update_project

Methods included from API::Tasks

#create_task, #delete_task, #task, #tasks, #update_task

Methods included from API::Users

#create_user, #current_user, #update_user, #user

Constructor Details

#initialize(options = {}) ⇒ WorkSnaps::Client

Initializes a new Client object

Parameters:

  • options (Hash) (defaults to: {})


22
23
24
25
26
# File 'lib/worksnaps/client.rb', line 22

def initialize(options={})
  Wsnaps.keys.each do |key|
    instance_variable_set(:"@#{key}", options[key] || WorkSnaps.instance_variable_get(:"@#{key}"))
  end
end

Instance Method Details

#delete(path, params = {}) ⇒ Object

Perform an HTTP DELETE request



29
30
31
# File 'lib/worksnaps/client.rb', line 29

def delete(path, params={})
  request(:delete, path, params)
end

#get(path, params = {}) ⇒ Object

Perform an HTTP GET request



34
35
36
# File 'lib/worksnaps/client.rb', line 34

def get(path, params={})
  request(:get, path, params)
end

#post(path, params = {}) ⇒ Object

Perform an HTTP POST request



39
40
41
42
# File 'lib/worksnaps/client.rb', line 39

def post(path, params={})
  signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params
  request(:post, path, params.to_xml, signature_params)
end

#put(path, params = {}) ⇒ Object

Perform an HTTP PUT request



45
46
47
# File 'lib/worksnaps/client.rb', line 45

def put(path, params={})
  request(:put, path, params)
end