invoiced 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39b105b4b640babd40cde28a5f86ebe06fcd437c
4
- data.tar.gz: 22171d541dec5d633d7c3c641b3fbc41709a43b1
3
+ metadata.gz: 7e1807afacc160361d8d7b3014164edb507e3970
4
+ data.tar.gz: c806be29c391920e499ed18c941f5d740cfa4b45
5
5
  SHA512:
6
- metadata.gz: c84fb6ea8cb08d14dcc24f43ba274da7cac2e62a9e31ceba5221c2c63e2d05b014107ab7002945f0462ce1b1039e4561c381e23167615533c741ea13dc1a4ce8
7
- data.tar.gz: 294e2408c6bc316d5dd7848fe9ca2d2fba35bc576971555f144348f3c847ce5f1e43a04f6c7cce10ebdb145a5c58f21f89a31db44579ec1eeabd732551b605b7
6
+ metadata.gz: 2dd95aa7ee089d9a7da05dd054be8ea58c81be724fb3d6309e8a6b49cf81e35b3abb0151e71462b626cb88e7754c2120429bf2d0bbdc9d182178e0a0c1237f7b
7
+ data.tar.gz: a381dffbc857778b616b71c5beb950e6d716106765b4bbd4d235681119435858fca7fe110dbd55fa7961e03ff5293177c537a1215011c1d9488a789cfa56e007
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2015 Invoiced, Inc. (https://invoiced.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
13
+ all 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
21
+ THE SOFTWARE.
@@ -1,11 +1,25 @@
1
1
  module Invoiced
2
2
  module Operations
3
3
  module Update
4
- def save
5
- response = @client.request(:patch, @endpoint, @unsaved)
4
+ def save(params = {})
5
+ update = {}
6
6
 
7
- @values = response[:body].dup.merge({:id => self.id})
8
- return response[:code] == 200
7
+ @unsaved.each do |k|
8
+ update[k] = @values[k]
9
+ end
10
+
11
+ update.merge(params)
12
+
13
+ # perform the update if there are any changes
14
+ if update.length > 0
15
+ response = @client.request(:patch, @endpoint, update)
16
+
17
+ # update the local values with the response
18
+ @values = response[:body].dup.merge({:id => self.id})
19
+ @unsaved = Set.new
20
+
21
+ return response[:code] == 200
22
+ end
9
23
  end
10
24
  end
11
25
  end
@@ -1,3 +1,3 @@
1
1
  module Invoiced
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
data/lib/invoiced.rb CHANGED
@@ -115,7 +115,7 @@ module Invoiced
115
115
  end
116
116
 
117
117
  case response.code
118
- when 400, 404
118
+ when 400, 403, 404
119
119
  raise invalid_request_error(error, response)
120
120
  when 401
121
121
  raise authentication_error(error, response)
@@ -141,7 +141,7 @@ module Invoiced
141
141
  end
142
142
 
143
143
  def general_api_error(code, body)
144
- raise ApiError.new("API Error #{code} - #{body}")
144
+ raise ApiError.new("API Error #{code} - #{body}", code)
145
145
  end
146
146
  end
147
147
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invoiced
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared King
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-29 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -117,6 +117,7 @@ files:
117
117
  - .gitignore
118
118
  - .travis.yml
119
119
  - Gemfile
120
+ - LICENSE
120
121
  - README.md
121
122
  - Rakefile
122
123
  - invoiced.gemspec