teamleader 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +72 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/teamleader/api.rb +100 -0
- data/lib/teamleader/version.rb +3 -0
- data/lib/teamleader.rb +10 -0
- data/teamleader.gemspec +32 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MmYwNDNjYWFjNTc3MTJkYTg2YWIyNzEyNWE2YzI1MzFlMTQ3NGZlNw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MWNiODM1NjJiYjRhNmE4YzIzYzFjYmRmZjE5YWZhOTc0Y2MzMTFjOQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MmI2OGE4ZmIxMjZkMzRmMGI2YWY1MGNmM2VhZDk4ZGRlMjIxYWNmM2Y3ZmNl
|
10
|
+
ZjVlYjhmZDYyNTIwODk1YTA5OTk0ZGQ4ZjQ0MTY5Y2I4OTlkMTQ3MTZiMTU5
|
11
|
+
ZDc1MWUzMWRmNWUwNjFlMzRjMWFkYWJhNzYzMzgwOTFhMzUyNjY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MGZjNTY1ZGI2NTAyMjUwZTI4ZTI5MTg2NmU1NjdlYzk0NmNmZTE5ZmU0NDhh
|
14
|
+
MzU2OTE4MGU0ZWMwYjRiZTQ4ZjAzZDkwYjNiMTViNDE3ZDA1OTFlZTE3ZWFl
|
15
|
+
ZDIzYzQ0MjNkNGNkNmQ3NzYyMWIyYTkyMjkxYjM4MWE3ZGU1ZWY=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Javry.com
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Teamleader
|
2
|
+
|
3
|
+
A ruby wrapper around Teamleader.eu API.
|
4
|
+
|
5
|
+
**This Teamleader client is still in development, only a few endpoints are supported (see below).**
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'teamleader'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install teamleader
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'teamleader'
|
27
|
+
teamleader = Teamleader.new('Your API group', 'Your API secret')
|
28
|
+
|
29
|
+
```
|
30
|
+
You can find your API key in your Teamleader account, under Settings > API & Webhooks. API access is available for every Teamleader account.
|
31
|
+
Note that you need to be admin to access this page.
|
32
|
+
|
33
|
+
## Available methods
|
34
|
+
When a method expects a hash as argument, the hash keys have the same name as described in [Teamleader API documentation](http://apidocs.teamleader.be/).
|
35
|
+
|
36
|
+
If a required parameter is missing or if the API returns an error, the method will throw an exception.
|
37
|
+
|
38
|
+
### Users
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
teamleader.get_users
|
42
|
+
```
|
43
|
+
### Companies
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
teamleader.add_company({:name => "Hello World"})
|
47
|
+
teamleader.get_company(12345)
|
48
|
+
teamleader.get_companies({:amount => 100, :pageno => 0, :searchby => "hello"}) # pagination starts at 0
|
49
|
+
```
|
50
|
+
|
51
|
+
### Invoices
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
teamleader.get_invoice(12345)
|
55
|
+
teamleader.get_invoices({:date_from => "01/01/2017", :date_to => "01/05/2017"})
|
56
|
+
```
|
57
|
+
|
58
|
+
## License
|
59
|
+
The Teamleader GEM is released under the MIT License.
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
1. Fork it
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
5. Create a new Pull Request
|
68
|
+
|
69
|
+
## Credits
|
70
|
+
This gem is inspired by the [hunterio gem](https://github.com/prospectio/hunterio/) made by Vincenzo Ruggiero
|
71
|
+
|
72
|
+
Made with ️❤️️️ by [Javry](https://javry.com) in Belgium.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "teamleader"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
module Teamleader
|
7
|
+
API_BASE_URL = "https://app.teamleader.eu/api"
|
8
|
+
|
9
|
+
class Api
|
10
|
+
def initialize(group, secret)
|
11
|
+
@api_group = group
|
12
|
+
@api_secret = secret
|
13
|
+
uri = URI.parse(API_BASE_URL)
|
14
|
+
@http = Net::HTTP.new(uri.host, uri.port)
|
15
|
+
@http.use_ssl = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_users(params={})
|
19
|
+
request "/getUsers.php", params
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_departments
|
23
|
+
request "/getDepartments.php"
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_tags
|
27
|
+
request "/getTags.php"
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns the ID of the contact
|
31
|
+
def add_contact(params={})
|
32
|
+
raise "forename is required" if params[:forename].nil?
|
33
|
+
raise "surname is required" if params[:surname].nil?
|
34
|
+
raise "email is required" if params[:email].nil?
|
35
|
+
request "/addContact.php", params
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns the ID of the company
|
39
|
+
def add_company(params={})
|
40
|
+
raise "name is required" if params[:name].nil?
|
41
|
+
request "/addCompany.php", params
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_company(id)
|
45
|
+
request "/getCompany.php", {:company_id => id}
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_companies(params={})
|
49
|
+
raise "amount is required" if params[:amount].nil?
|
50
|
+
raise "pageno is required" if params[:pageno].nil?
|
51
|
+
request "/getCompanies.php", params
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_invoice(params={})
|
55
|
+
raise "contact_or_company" if params[:contact_or_company].nil?
|
56
|
+
raise "contact_or_company_id" if params[:contact_or_company_id].nil?
|
57
|
+
raise "sys_department_id" if params[:sys_department_id].nil?
|
58
|
+
request "/addInvoice.php", params
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_invoice(id)
|
62
|
+
request "/getInvoice.php", {:invoice_id => id}
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_invoices(params={})
|
66
|
+
raise "date_from is required" if params[:date_from].nil?
|
67
|
+
raise "date_to is required" if params[:date_to].nil?
|
68
|
+
request "/getInvoices.php", params
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
def request(path, data={})
|
73
|
+
headers = {
|
74
|
+
"Content-Type" => "application/x-www-form-urlencoded"
|
75
|
+
}
|
76
|
+
data[:api_group] = @api_group
|
77
|
+
data[:api_secret] = @api_secret
|
78
|
+
data = URI.encode_www_form data
|
79
|
+
response = @http.post "/api" + path, data, headers
|
80
|
+
code = Integer(response.code)
|
81
|
+
if code >= 200 && code < 300
|
82
|
+
begin
|
83
|
+
JSON.parse response.body, :symbolize_names => true
|
84
|
+
rescue
|
85
|
+
response.body
|
86
|
+
end
|
87
|
+
elsif code == 505
|
88
|
+
raise "Error: API rate limit reached"
|
89
|
+
else
|
90
|
+
err = "unknown error"
|
91
|
+
begin
|
92
|
+
err = JSON.parse(response.body)["reason"]
|
93
|
+
rescue
|
94
|
+
err = "#{response.body}"
|
95
|
+
end
|
96
|
+
raise "HTTP Error #{code}: " + err
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/lib/teamleader.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'teamleader/api'))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'teamleader/version'))
|
3
|
+
|
4
|
+
module Teamleader
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def new(group, secret)
|
8
|
+
Api.new(group, secret)
|
9
|
+
end
|
10
|
+
end
|
data/teamleader.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require File.expand_path('../lib/teamleader/version', __FILE__)
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "teamleader"
|
8
|
+
spec.version = Teamleader::VERSION
|
9
|
+
spec.authors = ["Pierre-Yves Orban"]
|
10
|
+
spec.email = ["pyo@javry.com"]
|
11
|
+
spec.homepage = 'https://github.com/Pyo25/teamleader-ruby'
|
12
|
+
|
13
|
+
spec.summary = %q{A Ruby wrapper around Teamleader.eu API}
|
14
|
+
spec.description = %q{A ruby wrapper around Teamleader.eu API.}
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency 'rspec', "~> 3.6"
|
25
|
+
spec.add_development_dependency "vcr", "~> 3.0"
|
26
|
+
spec.add_development_dependency "typhoeus", "~> 1.1"
|
27
|
+
|
28
|
+
spec.required_ruby_version = ">= 1.9.3"
|
29
|
+
|
30
|
+
spec.add_dependency "json", "~> 2.1"
|
31
|
+
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: teamleader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pierre-Yves Orban
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: typhoeus
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: json
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.1'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.1'
|
97
|
+
description: A ruby wrapper around Teamleader.eu API.
|
98
|
+
email:
|
99
|
+
- pyo@javry.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .rspec
|
106
|
+
- .travis.yml
|
107
|
+
- CHANGELOG.md
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- lib/teamleader.rb
|
115
|
+
- lib/teamleader/api.rb
|
116
|
+
- lib/teamleader/version.rb
|
117
|
+
- teamleader.gemspec
|
118
|
+
homepage: https://github.com/Pyo25/teamleader-ruby
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 1.9.3
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ! '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.6.11
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: A Ruby wrapper around Teamleader.eu API
|
142
|
+
test_files: []
|