teamleader 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 598bd68872411fa4a73c8120d62b317f59eb532f
4
- data.tar.gz: c771f8ab3a78f57f5882d324e099dde187b0b31a
3
+ metadata.gz: 713b06675edb4fb8523c85d37d7a82458ed9ceeb
4
+ data.tar.gz: b9f28cfbe6608987d4ab1185b7ab68df148404d8
5
5
  SHA512:
6
- metadata.gz: 1f843a39ca3335a788dc8c0ce89c3d03cef9341fb29ca8b2fb3f91a8b3248b798a3fa59a4426b3721de9f702f91fe395b0f9b602a1329015e11570983f4df172
7
- data.tar.gz: 70684260d36e75af820c111ac667611ca3a07ace03787ecb33e5a940c7af0421cf2b1a7286b0b16e681890d21eac367bc6916337e3679dc400288f47ca2dc520
6
+ metadata.gz: 32ec36b96ca6e6b8c937c2ebbf7efce59a75e6df201dbfbdf3d9cf60e2edbf1810b7ac671bb613221dd5535fd07e7b19f5fa9ce0b08e598d97e9dab25a624b0c
7
+ data.tar.gz: c7897fb48ef323c28770018e4942e617a625aa4e8b118d6b27c3b325e047e046365e21863ace31412eb80f4d9790381b608065cdf53db91e302c86b0f616dbb5
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.13.0] - 2018-05-14
5
+ ### Added
6
+ - Allow configuration block
7
+ - Add 5 methods for `File` endpoint
8
+ - Add 5 methods for `Project` endpoint
9
+
10
+ ### Fixed
11
+ - invalid param for `getDeals`
12
+
4
13
  ## [0.12.0] - 2018-03-28
5
14
  ### Added
6
15
  - New methods related to subscriptions: `get_subscriptions`, `get_all_subscriptions`
data/README.md CHANGED
@@ -30,6 +30,16 @@ teamleader = Teamleader.new('Your API group', 'Your API secret')
30
30
  You can find your API key in your Teamleader account, under Settings > API & Webhooks. API access is available for every Teamleader account.
31
31
  Note that you need to be admin to access this page.
32
32
 
33
+ ### Configuration
34
+ For Rails application create a configuration file `config/initializers/teamleader.rb`. You can do this anywhere in your application before you make API calls using the gem.
35
+
36
+ ```ruby
37
+ Teamleader.configure do |config|
38
+ config.api_group = '45678'
39
+ config.api_secret = '31e56cf3b3c259f56666ba4a6089ee91c3150683611834f7eb2f5a7a4f039a17910f1fa2d65d282e9c344abcf895dad80a89b13af8fe917dfed1e0798c83350c'
40
+ end
41
+ ```
42
+
33
43
  ## Available methods
34
44
  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
45
 
@@ -102,6 +112,36 @@ teamleader.get_product({:product_id => 123})
102
112
  teamleader.delete_product({:product_id => 123})
103
113
  teamleader.get_products({:amount => 100, :pageno => 0}) # Pagination starts at 0
104
114
  ```
115
+
116
+ ### Projects
117
+
118
+ ```ruby
119
+ teamleader.get_project({ :project_id => 123 })
120
+ teamleader.get_projects_by_client({
121
+ contact_or_company: 'contact',
122
+ contact_or_company_id: '123',
123
+ deep_search: 1
124
+ })
125
+
126
+ teamleader.add_project({
127
+ :project_name => 123,
128
+ :project_budget => 300,
129
+ :project_responsible_user_id => 123,
130
+ :project_start_date => '12/01/2017',
131
+ :milestone_title => 'milestone title',
132
+ :milestone_budget => 200,
133
+ :milestone_invoiceable => 0,
134
+ :milestone_due_date => '12/03/2017',
135
+ :milestone_responsible_user_id => 123
136
+ })
137
+ teamleader.update_project({
138
+ :project_id => 123,
139
+ :track_changes => 0,
140
+ :title => "New Project Title"
141
+ })
142
+ teamleader.get_projects({ :amount => 50, pageno: 0 })
143
+ # Pagination starts at 0
144
+ ```
105
145
  ### Tickets
106
146
 
107
147
  Supported methods are: `add_ticket`, `update_ticket`, `add_ticket_message`, `get_tickets`, `get_ticket`, `get_ticket_messages`, `get_ticket_message`, `get_ticket_cloud_url`.
@@ -110,6 +150,30 @@ Supported methods are: `add_ticket`, `update_ticket`, `add_ticket_message`, `get
110
150
 
111
151
  Supported methods are: `add_note`, `get_notes`
112
152
 
153
+ ### Files
154
+
155
+ ```ruby
156
+ teamleader.get_file_info({ :file_id => '1236412' })
157
+
158
+ teamleader.download_file({ :file_id => '1236412' })
159
+
160
+ teamleader.upload_file({
161
+ :object_type => 'company',
162
+ :object_id => '1236412',
163
+ :file_content => 'Base64 encoded version the file',
164
+ :file_name => 'file.rb'
165
+ })
166
+
167
+ teamleader.delete_file({ :file_id => '1236412' })
168
+
169
+ teamleader.get_files({
170
+ :amount => 100,
171
+ :pageno => 0,
172
+ :object_type => 'contact',
173
+ :object_id => '1234567')
174
+ # Pagination starts at 0
175
+ ```
176
+
113
177
  ## License
114
178
  The Teamleader GEM is released under the MIT License.
115
179
 
@@ -0,0 +1,28 @@
1
+ module Teamleader
2
+ module Files
3
+ def get_files(params={})
4
+ required_params(%i[amount pageno object_type object_id], params)
5
+ request '/getFiles.php', params
6
+ end
7
+
8
+ def get_file_info(params={})
9
+ required_params(%i[file_id], params)
10
+ request '/getFileInfo.php', params
11
+ end
12
+
13
+ def download_file(params={})
14
+ required_params(%i[file_id], params)
15
+ request '/downloadFile.php', params
16
+ end
17
+
18
+ def upload_file(params={})
19
+ required_params(%i[object_type object_id file_content file_name], params)
20
+ request '/uploadFile.php', params
21
+ end
22
+
23
+ def delete_file(params={})
24
+ required_params(%i[file_id], params)
25
+ request '/deleteFile.php', params
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ module Teamleader
2
+ module Projects
3
+ def get_project(params={})
4
+ required_params(%i[project_id], params)
5
+ request '/getProject.php', params
6
+ end
7
+
8
+ def get_projects(params={})
9
+ required_params(%i[amount pageno], params)
10
+ request '/getProjects.php', params
11
+ end
12
+
13
+ def get_projects_by_client(params={})
14
+ required_params(%i[contact_or_company contact_or_company_id deep_search], params)
15
+ request '/getProjectsByClient.php', params
16
+ end
17
+
18
+ def add_project(params={})
19
+ required_params(%i[project_name project_budget project_responsible_user_id project_start_date
20
+ milestone_title milestone_budget milestone_invoiceable milestone_due_date
21
+ milestone_responsible_user_id], params)
22
+ request '/addProject.php', params
23
+ end
24
+
25
+ def update_project(params={})
26
+ required_params(%i[project_id track_changes title], params)
27
+ request '/updateProject.php', params
28
+ end
29
+ end
30
+ end
@@ -7,6 +7,9 @@ module Teamleader
7
7
  API_BASE_URL = "https://app.teamleader.eu/api"
8
8
 
9
9
  class Api
10
+ include Teamleader::Files
11
+ include Teamleader::Projects
12
+
10
13
  def initialize(group, secret)
11
14
  @api_group = group
12
15
  @api_secret = secret
@@ -98,7 +101,7 @@ module Teamleader
98
101
  end
99
102
 
100
103
  def get_deals(params={})
101
- raise "mount is required" if params[:mount].nil?
104
+ raise "amount is required" if params[:amount].nil?
102
105
  raise "pageno is required" if params[:pageno].nil?
103
106
  request "/getDeals.php", params
104
107
  end
@@ -372,6 +375,7 @@ module Teamleader
372
375
  end
373
376
 
374
377
  private
378
+
375
379
  def request(path, data={})
376
380
  headers = {
377
381
  "Content-Type" => "application/x-www-form-urlencoded"
@@ -399,5 +403,9 @@ module Teamleader
399
403
  raise "HTTP Error #{code}: " + err
400
404
  end
401
405
  end
406
+
407
+ def required_params(attributes, params)
408
+ attributes.each { |attr| raise "#{attr} is required" if params[attr].nil? }
409
+ end
402
410
  end
403
411
  end
@@ -0,0 +1,8 @@
1
+ class Configuration
2
+ attr_accessor :api_group, :api_secret
3
+
4
+ def initialize
5
+ @api_group = 'Your API group'
6
+ @api_secret = 'Your API secret'
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Teamleader
2
- VERSION = "0.12.0"
2
+ VERSION = "0.13.0"
3
3
  end
data/lib/teamleader.rb CHANGED
@@ -1,11 +1,23 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'teamleader/api/files'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), 'teamleader/api/projects'))
1
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'teamleader/api'))
2
4
  require File.expand_path(File.join(File.dirname(__FILE__), 'teamleader/extended_api'))
3
5
  require File.expand_path(File.join(File.dirname(__FILE__), 'teamleader/version'))
6
+ require File.expand_path(File.join(File.dirname(__FILE__), 'teamleader/configuration'))
4
7
 
5
8
  module Teamleader
6
9
  extend self
10
+ attr_accessor :configuration
7
11
 
8
- def new(group, secret)
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ def configure
17
+ yield(configuration)
18
+ end
19
+
20
+ def new(group = Teamleader.configuration.api_group, secret = Teamleader.configuration.api_secret)
9
21
  ExtendedApi.new(group, secret)
10
22
  end
11
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teamleader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre-Yves Orban
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-28 00:00:00.000000000 Z
11
+ date: 2018-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,6 +113,9 @@ files:
113
113
  - bin/setup
114
114
  - lib/teamleader.rb
115
115
  - lib/teamleader/api.rb
116
+ - lib/teamleader/api/files.rb
117
+ - lib/teamleader/api/projects.rb
118
+ - lib/teamleader/configuration.rb
116
119
  - lib/teamleader/extended_api.rb
117
120
  - lib/teamleader/version.rb
118
121
  - teamleader.gemspec