teamweek-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/teamweek-ruby.rb +7 -0
- data/lib/teamweek/api/client.rb +49 -0
- data/lib/teamweek/api/hash_constructed.rb +15 -0
- data/lib/teamweek/api/importer.rb +20 -0
- data/lib/teamweek/api/project.rb +20 -0
- data/lib/teamweek/api/task.rb +29 -0
- data/lib/teamweek/api/user.rb +27 -0
- data/lib/teamweek/api/version.rb +5 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
M2MyYTRlMjEwOWZjNTZjZDYzMWUxMzE4M2M3ZGEwMTViOTM4ZmVlOQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MzU4MDFjMzcwOGM2MDlkNDdiOWJiMDNjZDgyOTY2MzQwNDFmMDY2NQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2Q5ZjgyYTMxMmIyZTE2NGE4MGNiODRiMDI1M2QzOWJkOWJiYWE3YTM1ZDY5
|
10
|
+
ODRjNDNhNmVlZjBmNzc2NDc0OTRhYzM1ZmYwMmMwZmY5ZGM5ZDI2ZTIzOWUy
|
11
|
+
NGQyZDRmMjQ0YmIzMTAyYTFkODFjNjkxOWQ2NTU5YWZmYmUxMGY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MzY1ZjE3ZjU2Zjk1NzRkMmQ1Yjg5NWFkZmQ5ZWZjODY3ZDk1MWY3M2NjODRm
|
14
|
+
NmQ4OGUxZTZlNDViNzJmOTRmZmU0NzE3MTdmMGIyNWQ1N2JlZThjZjg3MWY2
|
15
|
+
MmE3NDE3MDZiZjA3ZjRjYzQyNmE0NGExM2Y1MTUyZGU1NTk0NzE=
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Teamweek
|
2
|
+
module Api
|
3
|
+
class Client
|
4
|
+
include Teamweek::Api::Importer
|
5
|
+
attr_accessor :client
|
6
|
+
attr_accessor :base_uri
|
7
|
+
|
8
|
+
def initialize(client, account_id, opts={})
|
9
|
+
@client = client
|
10
|
+
set_base_uri(opts[:base_uri], account_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Posts users to Teamweek bulk_import url.
|
14
|
+
#
|
15
|
+
# @param users: an array of users data as hash.
|
16
|
+
# @return [Teamweek::Api::User] the added or found Teamweek user instances
|
17
|
+
def import_users(data)
|
18
|
+
bulk_import('users', data, Teamweek::Api::User)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Posts projects to Teamweek bulk_import url.
|
22
|
+
#
|
23
|
+
# @param projects: an array of projects data as hash.
|
24
|
+
# @return [Teamweek::Api::Project] the added or found Teamweek project instances
|
25
|
+
def import_projects(data)
|
26
|
+
bulk_import('projects', data, Teamweek::Api::Project)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Posts tasks to Teamweek bulk_import url.
|
30
|
+
#
|
31
|
+
# @param tasks: an array of tasks data as hash.
|
32
|
+
# @return [Teamweek::Api::Task] the added or found Teamweek task instances
|
33
|
+
def import_tasks(data)
|
34
|
+
bulk_import('tasks', data, Teamweek::Api::Task)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def set_base_uri(site, account_id)
|
40
|
+
site ||= "https://teamweek.com"
|
41
|
+
@base_uri = "#{site}/api/v3/#{account_id}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def full_path(uri)
|
45
|
+
base_uri + uri
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Teamweek
|
2
|
+
module Api
|
3
|
+
module HashConstructed
|
4
|
+
attr_accessor :raw_data
|
5
|
+
# initalizes the object by pulling key-value pairs from the hash and
|
6
|
+
# mapping them to the object's instance variables
|
7
|
+
#
|
8
|
+
# @param [Hash] h hash containing key-value pairs to map to object instance variables
|
9
|
+
def initialize(h)
|
10
|
+
@raw_data = h
|
11
|
+
h.each { |k,v| send("#{k}=",v) if respond_to?("#{k}=") }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Teamweek
|
2
|
+
module Api
|
3
|
+
module Importer
|
4
|
+
|
5
|
+
def bulk_import(entity, data, context)
|
6
|
+
response = bulk_post(entity, data)
|
7
|
+
response.map { |h| context.new(h) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def bulk_post(entity, data)
|
11
|
+
client.post(bulk_uri(entity), { entity => data })
|
12
|
+
end
|
13
|
+
|
14
|
+
def bulk_uri(entity)
|
15
|
+
full_path("/#{entity}/bulk_import.json")
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Teamweek
|
2
|
+
module Api
|
3
|
+
class Project
|
4
|
+
include Teamweek::Api::HashConstructed
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :name
|
7
|
+
attr_accessor :color
|
8
|
+
attr_accessor :foreign_id
|
9
|
+
|
10
|
+
|
11
|
+
def to_hash
|
12
|
+
{
|
13
|
+
id: id,
|
14
|
+
name: name,
|
15
|
+
color: color
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Teamweek
|
2
|
+
module Api
|
3
|
+
class Task
|
4
|
+
include Teamweek::Api::HashConstructed
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :project_id
|
7
|
+
attr_accessor :user_id
|
8
|
+
attr_accessor :foreign_id
|
9
|
+
attr_accessor :name
|
10
|
+
attr_accessor :end_date
|
11
|
+
attr_accessor :start_date
|
12
|
+
attr_accessor :color
|
13
|
+
attr_accessor :done
|
14
|
+
|
15
|
+
def to_hash
|
16
|
+
{
|
17
|
+
id: id,
|
18
|
+
name: name,
|
19
|
+
color: color,
|
20
|
+
start_date: start_date,
|
21
|
+
end_date: end_date,
|
22
|
+
project_id: project_id,
|
23
|
+
user_id: user_id,
|
24
|
+
done: done
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Teamweek
|
2
|
+
module Api
|
3
|
+
class User
|
4
|
+
include Teamweek::Api::HashConstructed
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :name
|
7
|
+
attr_accessor :email
|
8
|
+
attr_accessor :dummy
|
9
|
+
attr_accessor :initials
|
10
|
+
attr_accessor :color
|
11
|
+
attr_accessor :foreign_id
|
12
|
+
attr_accessor :active
|
13
|
+
|
14
|
+
def to_hash
|
15
|
+
{
|
16
|
+
id: id,
|
17
|
+
name: name,
|
18
|
+
email: email,
|
19
|
+
dummy: dummy,
|
20
|
+
initials: initials,
|
21
|
+
color: color,
|
22
|
+
active: active
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: teamweek-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Toggl OÜ
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A very lightweight ruby library without an http client to communicate
|
56
|
+
with Teamweek API
|
57
|
+
email:
|
58
|
+
- support@teamweek.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- lib/teamweek-ruby.rb
|
64
|
+
- lib/teamweek/api/version.rb
|
65
|
+
- lib/teamweek/api/hash_constructed.rb
|
66
|
+
- lib/teamweek/api/task.rb
|
67
|
+
- lib/teamweek/api/importer.rb
|
68
|
+
- lib/teamweek/api/user.rb
|
69
|
+
- lib/teamweek/api/project.rb
|
70
|
+
- lib/teamweek/api/client.rb
|
71
|
+
homepage: https://github.com/teamweek/teamweek-ruby
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.1.9
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Ruby gem to communicate with Teamweek API.
|
95
|
+
test_files: []
|