harvesting 0.4.0 → 0.5.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
  SHA256:
3
- metadata.gz: 4452c68eed7a6097355f504450d77cf13e72424ca0ec6915fb041dd8abb155f7
4
- data.tar.gz: 82e16401985e4e19cd14ac1fb57f13b9f87f2d29188800e584516a68c3412ca7
3
+ metadata.gz: fb6b38d71800f5156d305c7702286b90f74b0db7a0718912495117acc11a5865
4
+ data.tar.gz: 548e13f94ef0e0cac713350afadad6e039f995ce481ff7166ee5de441c3cc3a9
5
5
  SHA512:
6
- metadata.gz: cf1b81f56a3ec9c5efc9c19816ea6da487927fc00f49d255e58f647d918de5e9ce5a54b5e6bf1c848fb0002e3239f1d25590720acaf0c84bbbc12247ef634b84
7
- data.tar.gz: a40d1ec6516ef528129aedc4747943189c19b3da0b5cf4ac950be1e735c06814008a192a303d2cf9a2f93b0336d0fae988be72fcaa8f5d1953511453a08b1a0d
6
+ metadata.gz: c8daf60be6c6c9fb503a1f7778a963390c8857d52f76b6aecfe8a1d046f589946defc9b56cd17c501aa84c6c6318224cb082f1c603a3ae0c38b3f92ab9109f9c
7
+ data.tar.gz: 781ed847b381891c9f66675720e4db332bc7835fb94d2362db73c65e5460f9580400b6a10812eefc5c6c10539f0f4c61603f0e1fb5dbd24452a891d521778704
data/.gitignore CHANGED
@@ -7,12 +7,14 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ # bundler
11
+ Gemfile.lock
12
+
10
13
  # environment variables
11
14
  .env
12
15
  .env.*
13
16
  !.env.sample
14
17
 
15
-
16
18
  # rspec failure tracking
17
19
  .rspec_status
18
20
 
@@ -1,9 +1,11 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.1
5
- - 2.5.1
4
+ - 2.4.10
5
+ - 2.5.8
6
+ - 2.6.6
7
+ - 2.7.1
6
8
  env:
7
9
  - HARVEST_FIRST_NAME=Aaron HARVEST_LAST_NAME=Burr HARVEST_ACCOUNT_ID=112341234 HARVEST_NON_ADMIN_ACCOUNT_ID=112341234 HARVEST_ACCESS_TOKEN=112341234 HARVEST_NON_ADMIN_ACCESS_TOKEN=112341234 HARVEST_ADMIN_FULL_NAME=112341234
8
10
 
9
- before_install: gem install bundler -v 1.17.3
11
+ before_install: gem install bundler -v 2.1.4
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Harvesting
2
2
 
3
- [![Build Status](https://travis-ci.org/ombulabs/harvesting.svg?branch=master)](https://travis-ci.org/ombulabs/harvesting)
4
- [![Code Climate](https://codeclimate.com/github/ombulabs/harvesting/badges/gpa.svg)](https://codeclimate.com/github/ombulabs/harvesting)
3
+ [![Build Status](https://travis-ci.org/fastruby/harvesting.svg?branch=master)](https://travis-ci.org/ombulabs/harvesting)
4
+ [![Code Climate](https://codeclimate.com/github/fastruby/harvesting/badges/gpa.svg)](https://codeclimate.com/github/ombulabs/harvesting)
5
5
 
6
6
  A Ruby gem to interact with the Harvest API v2.0 and forward.
7
7
 
@@ -75,7 +75,7 @@ user.id
75
75
 
76
76
  ```ruby
77
77
  client.clients
78
- # => [#<Harvesting::Models::Client:0x007ff718d65fd0 @attributes={"id"=>6760580, "name"=>"Toto", "is_active"=>true, "address"=>"" ... >
78
+ # => #<Harvesting::Models::Clients:0x007ff718d65fd0>
79
79
 
80
80
  client = client.clients.first
81
81
  # => #<Harvesting::Models::Client:0x007ff718cf5fc8 @attributes={"id"=>6760580, "name"=>"Toto",
@@ -1,5 +1,18 @@
1
1
  # RELEASE NOTES
2
2
 
3
+ ### main
4
+
5
+ **Notes**
6
+
7
+ ### Version 0.5.0 - September 3, 2020
8
+
9
+ **Notes**
10
+ - Changed behavior of `client.clients` so that it returns an instance of `Harvesting::Models::Clients` instead of an `Array`: https://github.com/ombulabs/harvesting/pull/39
11
+
12
+ **Bug Fixes**
13
+ - Add support for Harvesting::RateLimitExceeded instead of a JSON::ParserError: https://github.com/fastruby/harvesting/pull/57
14
+ - Add support for RequestNotFound instead of a JSON::ParserError: https://github.com/fastruby/harvesting/pull/54
15
+
3
16
  ### Version 0.4.0 - June 6, 2020
4
17
 
5
18
  **Notes**
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{Ruby wrapper for the Harvest API v2.0}
13
13
  spec.description = %q{Interact with the Harvest API v2.0 from your Ruby application}
14
- spec.homepage = "https://github.com/ombulabs/harvesting"
14
+ spec.homepage = "https://github.com/fastruby/harvesting"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
  spec.add_dependency "http", "~> 3.3", ">= 3.3"
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "bundler", ">= 2.0", "< 3.0"
26
26
  spec.add_development_dependency "rake", "~> 13.0"
27
27
  spec.add_development_dependency "rspec", "~> 3.0"
28
28
  spec.add_development_dependency "guard-rspec", "~> 4.7", ">= 4.7"
@@ -16,6 +16,7 @@ require "harvesting/models/invoice"
16
16
  require "harvesting/models/line_item"
17
17
  require "harvesting/models/time_entry"
18
18
  # harvest record collections
19
+ require "harvesting/models/clients"
19
20
  require "harvesting/models/tasks"
20
21
  require "harvesting/models/users"
21
22
  require "harvesting/models/contact"
@@ -30,12 +30,10 @@ module Harvesting
30
30
  def me
31
31
  Harvesting::Models::User.new(get("users/me"), harvest_client: self)
32
32
  end
33
-
34
- # @return [Array<Harvesting::Models::Client>]
35
- def clients
36
- get("clients")["clients"].map do |result|
37
- Harvesting::Models::Client.new(result, harvest_client: self)
38
- end
33
+
34
+ # @return [Harvesting::Models::Clients]
35
+ def clients(opts = {})
36
+ Harvesting::Models::Clients.new(get("clients", opts), opts, harvest_client: self)
39
37
  end
40
38
 
41
39
  # @return [Array<Harvesting::Models::Contact>]
@@ -150,6 +148,8 @@ module Harvesting
150
148
 
151
149
  raise Harvesting::AuthenticationError.new(response.to_s) if auth_error?(response)
152
150
  raise Harvesting::UnprocessableRequest.new(response.to_s) if response.code.to_i == 422
151
+ raise Harvesting::RequestNotFound.new(uri) if response.code.to_i == 404
152
+ raise Harvesting::RateLimitExceeded.new(response.to_s) if response.code.to_i == 429
153
153
 
154
154
  response
155
155
  end
@@ -4,4 +4,13 @@ module Harvesting
4
4
 
5
5
  class UnprocessableRequest < StandardError
6
6
  end
7
+
8
+ class RequestNotFound < StandardError
9
+ def initialize(uri)
10
+ super("The page you were looking for may have been moved or the address misspelled: #{uri}")
11
+ end
12
+ end
13
+
14
+ class RateLimitExceeded < StandardError
15
+ end
7
16
  end
@@ -0,0 +1,18 @@
1
+ module Harvesting
2
+ module Models
3
+ class Clients < HarvestRecordCollection
4
+
5
+ def initialize(attrs, query_opts = {}, opts = {})
6
+ super(attrs.reject {|k,v| k == "clients" }, query_opts, opts)
7
+ @entries = attrs["clients"].map do |entry|
8
+ Harvesting::Models::Client.new(entry, harvest_client: opts[:harvest_client])
9
+ end
10
+ end
11
+
12
+ def fetch_next_page
13
+ @entries += harvest_client.clients(next_page_query_opts).entries
14
+ @attributes['page'] = page + 1
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Harvesting
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.5.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harvesting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernesto Tagwerker
@@ -9,42 +9,48 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-06-06 00:00:00.000000000 Z
12
+ date: 2020-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: http
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '3.3'
21
- - - "~>"
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: '3.3'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - ">="
28
+ - - "~>"
29
29
  - !ruby/object:Gem::Version
30
30
  version: '3.3'
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.3'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: bundler
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - - "<"
39
42
  - !ruby/object:Gem::Version
40
- version: '1.16'
43
+ version: '3.0'
41
44
  type: :development
42
45
  prerelease: false
43
46
  version_requirements: !ruby/object:Gem::Requirement
44
47
  requirements:
45
- - - "~>"
48
+ - - ">="
46
49
  - !ruby/object:Gem::Version
47
- version: '1.16'
50
+ version: '2.0'
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
48
54
  - !ruby/object:Gem::Dependency
49
55
  name: rake
50
56
  requirement: !ruby/object:Gem::Requirement
@@ -77,100 +83,100 @@ dependencies:
77
83
  name: guard-rspec
78
84
  requirement: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - ">="
86
+ - - "~>"
81
87
  - !ruby/object:Gem::Version
82
88
  version: '4.7'
83
- - - "~>"
89
+ - - ">="
84
90
  - !ruby/object:Gem::Version
85
91
  version: '4.7'
86
92
  type: :development
87
93
  prerelease: false
88
94
  version_requirements: !ruby/object:Gem::Requirement
89
95
  requirements:
90
- - - ">="
96
+ - - "~>"
91
97
  - !ruby/object:Gem::Version
92
98
  version: '4.7'
93
- - - "~>"
99
+ - - ">="
94
100
  - !ruby/object:Gem::Version
95
101
  version: '4.7'
96
102
  - !ruby/object:Gem::Dependency
97
103
  name: byebug
98
104
  requirement: !ruby/object:Gem::Requirement
99
105
  requirements:
100
- - - ">="
106
+ - - "~>"
101
107
  - !ruby/object:Gem::Version
102
108
  version: '10.0'
103
- - - "~>"
109
+ - - ">="
104
110
  - !ruby/object:Gem::Version
105
111
  version: '10.0'
106
112
  type: :development
107
113
  prerelease: false
108
114
  version_requirements: !ruby/object:Gem::Requirement
109
115
  requirements:
110
- - - ">="
116
+ - - "~>"
111
117
  - !ruby/object:Gem::Version
112
118
  version: '10.0'
113
- - - "~>"
119
+ - - ">="
114
120
  - !ruby/object:Gem::Version
115
121
  version: '10.0'
116
122
  - !ruby/object:Gem::Dependency
117
123
  name: vcr
118
124
  requirement: !ruby/object:Gem::Requirement
119
125
  requirements:
120
- - - ">="
126
+ - - "~>"
121
127
  - !ruby/object:Gem::Version
122
128
  version: '4.0'
123
- - - "~>"
129
+ - - ">="
124
130
  - !ruby/object:Gem::Version
125
131
  version: '4.0'
126
132
  type: :development
127
133
  prerelease: false
128
134
  version_requirements: !ruby/object:Gem::Requirement
129
135
  requirements:
130
- - - ">="
136
+ - - "~>"
131
137
  - !ruby/object:Gem::Version
132
138
  version: '4.0'
133
- - - "~>"
139
+ - - ">="
134
140
  - !ruby/object:Gem::Version
135
141
  version: '4.0'
136
142
  - !ruby/object:Gem::Dependency
137
143
  name: webmock
138
144
  requirement: !ruby/object:Gem::Requirement
139
145
  requirements:
140
- - - ">="
146
+ - - "~>"
141
147
  - !ruby/object:Gem::Version
142
148
  version: '3.4'
143
- - - "~>"
149
+ - - ">="
144
150
  - !ruby/object:Gem::Version
145
151
  version: '3.4'
146
152
  type: :development
147
153
  prerelease: false
148
154
  version_requirements: !ruby/object:Gem::Requirement
149
155
  requirements:
150
- - - ">="
156
+ - - "~>"
151
157
  - !ruby/object:Gem::Version
152
158
  version: '3.4'
153
- - - "~>"
159
+ - - ">="
154
160
  - !ruby/object:Gem::Version
155
161
  version: '3.4'
156
162
  - !ruby/object:Gem::Dependency
157
163
  name: dotenv
158
164
  requirement: !ruby/object:Gem::Requirement
159
165
  requirements:
160
- - - ">="
166
+ - - "~>"
161
167
  - !ruby/object:Gem::Version
162
168
  version: '2.5'
163
- - - "~>"
169
+ - - ">="
164
170
  - !ruby/object:Gem::Version
165
171
  version: '2.5'
166
172
  type: :development
167
173
  prerelease: false
168
174
  version_requirements: !ruby/object:Gem::Requirement
169
175
  requirements:
170
- - - ">="
176
+ - - "~>"
171
177
  - !ruby/object:Gem::Version
172
178
  version: '2.5'
173
- - - "~>"
179
+ - - ">="
174
180
  - !ruby/object:Gem::Version
175
181
  version: '2.5'
176
182
  description: Interact with the Harvest API v2.0 from your Ruby application
@@ -187,7 +193,6 @@ files:
187
193
  - CODE_OF_CONDUCT.md
188
194
  - Dockerfile
189
195
  - Gemfile
190
- - Gemfile.lock
191
196
  - Guardfile
192
197
  - LICENSE.txt
193
198
  - README.md
@@ -204,6 +209,7 @@ files:
204
209
  - lib/harvesting/errors.rb
205
210
  - lib/harvesting/models/base.rb
206
211
  - lib/harvesting/models/client.rb
212
+ - lib/harvesting/models/clients.rb
207
213
  - lib/harvesting/models/contact.rb
208
214
  - lib/harvesting/models/harvest_record.rb
209
215
  - lib/harvesting/models/harvest_record_collection.rb
@@ -223,7 +229,7 @@ files:
223
229
  - lib/harvesting/models/user.rb
224
230
  - lib/harvesting/models/users.rb
225
231
  - lib/harvesting/version.rb
226
- homepage: https://github.com/ombulabs/harvesting
232
+ homepage: https://github.com/fastruby/harvesting
227
233
  licenses:
228
234
  - MIT
229
235
  metadata: {}
@@ -242,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
248
  - !ruby/object:Gem::Version
243
249
  version: '0'
244
250
  requirements: []
245
- rubygems_version: 3.0.8
251
+ rubygems_version: 3.1.3
246
252
  signing_key:
247
253
  specification_version: 4
248
254
  summary: Ruby wrapper for the Harvest API v2.0
@@ -1,105 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- harvesting (0.3.0)
5
- http (~> 3.3, >= 3.3)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- addressable (2.5.2)
11
- public_suffix (>= 2.0.2, < 4.0)
12
- byebug (10.0.2)
13
- coderay (1.1.2)
14
- crack (0.4.3)
15
- safe_yaml (~> 1.0.0)
16
- diff-lcs (1.3)
17
- domain_name (0.5.20180417)
18
- unf (>= 0.0.5, < 1.0.0)
19
- dotenv (2.5.0)
20
- ffi (1.12.2)
21
- formatador (0.2.5)
22
- guard (2.14.2)
23
- formatador (>= 0.2.4)
24
- listen (>= 2.7, < 4.0)
25
- lumberjack (>= 1.0.12, < 2.0)
26
- nenv (~> 0.1)
27
- notiffany (~> 0.0)
28
- pry (>= 0.9.12)
29
- shellany (~> 0.0)
30
- thor (>= 0.18.1)
31
- guard-compat (1.2.1)
32
- guard-rspec (4.7.3)
33
- guard (~> 2.1)
34
- guard-compat (~> 1.1)
35
- rspec (>= 2.99.0, < 4.0)
36
- hashdiff (0.3.7)
37
- http (3.3.0)
38
- addressable (~> 2.3)
39
- http-cookie (~> 1.0)
40
- http-form_data (~> 2.0)
41
- http_parser.rb (~> 0.6.0)
42
- http-cookie (1.0.3)
43
- domain_name (~> 0.5)
44
- http-form_data (2.1.1)
45
- http_parser.rb (0.6.0)
46
- listen (3.1.5)
47
- rb-fsevent (~> 0.9, >= 0.9.4)
48
- rb-inotify (~> 0.9, >= 0.9.7)
49
- ruby_dep (~> 1.2)
50
- lumberjack (1.0.13)
51
- method_source (0.9.0)
52
- nenv (0.3.0)
53
- notiffany (0.1.1)
54
- nenv (~> 0.1)
55
- shellany (~> 0.0)
56
- pry (0.11.3)
57
- coderay (~> 1.1.0)
58
- method_source (~> 0.9.0)
59
- public_suffix (3.0.2)
60
- rake (13.0.1)
61
- rb-fsevent (0.10.3)
62
- rb-inotify (0.9.10)
63
- ffi (>= 0.5.0, < 2)
64
- rspec (3.7.0)
65
- rspec-core (~> 3.7.0)
66
- rspec-expectations (~> 3.7.0)
67
- rspec-mocks (~> 3.7.0)
68
- rspec-core (3.7.1)
69
- rspec-support (~> 3.7.0)
70
- rspec-expectations (3.7.0)
71
- diff-lcs (>= 1.2.0, < 2.0)
72
- rspec-support (~> 3.7.0)
73
- rspec-mocks (3.7.0)
74
- diff-lcs (>= 1.2.0, < 2.0)
75
- rspec-support (~> 3.7.0)
76
- rspec-support (3.7.1)
77
- ruby_dep (1.5.0)
78
- safe_yaml (1.0.4)
79
- shellany (0.0.1)
80
- thor (0.20.0)
81
- unf (0.1.4)
82
- unf_ext
83
- unf_ext (0.0.7.5)
84
- vcr (4.0.0)
85
- webmock (3.4.0)
86
- addressable (>= 2.3.6)
87
- crack (>= 0.3.2)
88
- hashdiff
89
-
90
- PLATFORMS
91
- ruby
92
-
93
- DEPENDENCIES
94
- bundler (~> 1.16)
95
- byebug (~> 10.0, >= 10.0)
96
- dotenv (~> 2.5, >= 2.5)
97
- guard-rspec (~> 4.7, >= 4.7)
98
- harvesting!
99
- rake (~> 13.0)
100
- rspec (~> 3.0)
101
- vcr (~> 4.0, >= 4.0)
102
- webmock (~> 3.4, >= 3.4)
103
-
104
- BUNDLED WITH
105
- 1.17.2