moneybird 0.7.1 → 0.7.2
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 +4 -4
- data/lib/moneybird/client.rb +0 -1
- data/lib/moneybird/resource.rb +5 -5
- data/lib/moneybird/resource/contact.rb +2 -0
- data/lib/moneybird/resource/sales_invoice.rb +7 -0
- data/lib/moneybird/service/contact.rb +1 -3
- data/lib/moneybird/traits/find.rb +5 -1
- data/lib/moneybird/traits/find_all.rb +6 -2
- data/lib/moneybird/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59100f8dc41736af60512fec5fb092e474ed73a5
|
4
|
+
data.tar.gz: 9c2baa57eb08aefcff8d9a872b5e2dc20a070f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c13d41f9f9e08f60a213f9150af7df73569ece5ed324703b87e41c8909caecb349578e852f0b5d7519f583a4f70807329072536cdd90e445574bd7c69bb97903
|
7
|
+
data.tar.gz: a972ac75c25b9deb2e1c64a6c5d3b323b04a681fda410679418064db66b7aced67866a75d471dd6da353a5a5eed1c73961a1c68ad404bae58b57d1bc1dd76698
|
data/lib/moneybird/client.rb
CHANGED
data/lib/moneybird/resource.rb
CHANGED
@@ -15,10 +15,6 @@ module Moneybird
|
|
15
15
|
persisted? ? "/#{id}" : ""
|
16
16
|
end
|
17
17
|
|
18
|
-
def name
|
19
|
-
self.class.name.split('::').last.downcase
|
20
|
-
end
|
21
|
-
|
22
18
|
def attributes=(attributes)
|
23
19
|
@attributes = attributes
|
24
20
|
attributes.each do |attribute, value|
|
@@ -46,7 +42,7 @@ module Moneybird
|
|
46
42
|
end
|
47
43
|
|
48
44
|
def to_json
|
49
|
-
JSON.generate({
|
45
|
+
JSON.generate({self.class.resource => attributes})
|
50
46
|
end
|
51
47
|
|
52
48
|
module ClassMethods
|
@@ -63,6 +59,10 @@ module Moneybird
|
|
63
59
|
end
|
64
60
|
end
|
65
61
|
|
62
|
+
def resource
|
63
|
+
self.name.split('::').last.downcase
|
64
|
+
end
|
65
|
+
|
66
66
|
def has_attributes(attributes)
|
67
67
|
attr_accessor(*@attributes = attributes)
|
68
68
|
end
|
@@ -39,6 +39,7 @@ module Moneybird::Resource
|
|
39
39
|
url
|
40
40
|
workflow_id
|
41
41
|
events
|
42
|
+
details_attributes
|
42
43
|
)
|
43
44
|
|
44
45
|
def notes=(notes)
|
@@ -51,6 +52,12 @@ module Moneybird::Resource
|
|
51
52
|
|
52
53
|
def details=(line_items)
|
53
54
|
@details ||= line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
|
55
|
+
puts @details.inspect
|
56
|
+
puts ">>>>>>>>>>>>>>>"
|
57
|
+
end
|
58
|
+
|
59
|
+
def details_attributes
|
60
|
+
@details_attributes ||= (details || []).map.with_index{ |line_item, index| {index => line_item.attributes} }
|
54
61
|
end
|
55
62
|
|
56
63
|
def events=(events)
|
@@ -18,10 +18,8 @@ module Moneybird::Service
|
|
18
18
|
def find_by_customer_id(customer_id)
|
19
19
|
result = client.get("#{path}/customer_id/#{customer_id}")
|
20
20
|
|
21
|
-
if result.code.to_i ==
|
21
|
+
if result.code.to_i == GET_SUCCESS_CODE
|
22
22
|
build(JSON.parse(result.body))
|
23
|
-
else
|
24
|
-
JSON.parse(result.body)
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
@@ -1,10 +1,14 @@
|
|
1
1
|
module Moneybird
|
2
2
|
module Traits
|
3
3
|
module Find
|
4
|
+
GET_SUCCESS_CODE = 200
|
5
|
+
|
4
6
|
def find(id)
|
5
7
|
result = client.get("#{path}/#{id}")
|
6
8
|
|
7
|
-
|
9
|
+
if result.code.to_i == GET_SUCCESS_CODE
|
10
|
+
build(JSON.parse(result.body))
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
@@ -1,11 +1,15 @@
|
|
1
1
|
module Moneybird
|
2
2
|
module Traits
|
3
3
|
module FindAll
|
4
|
+
GET_SUCCESS_CODE = 200
|
5
|
+
|
4
6
|
def all
|
5
7
|
result = client.get(path)
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
if result.code.to_i == GET_SUCCESS_CODE
|
10
|
+
JSON.parse(result.body).map do |resource|
|
11
|
+
build(resource)
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
data/lib/moneybird/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moneybird
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maarten van Vliet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|