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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a71f6c3bf7c67ce566d5e65b601c5d18e088b6e
4
- data.tar.gz: 84f430b9085ea231a82d768f8b24e6fab55f1fa6
3
+ metadata.gz: 59100f8dc41736af60512fec5fb092e474ed73a5
4
+ data.tar.gz: 9c2baa57eb08aefcff8d9a872b5e2dc20a070f47
5
5
  SHA512:
6
- metadata.gz: 894f446517bea40ccc38c2dd302f9b6bbbeba66f356ee6f3a9178e3c0efa9deee4f30f4edc11edde696029f1021924e27b61fb6208dec8f4f1d3075e08f4eb58
7
- data.tar.gz: cb7727d232e24e1ab5954867562e7623f9b043eac3e4931ad1bcafe6ffbb43ef8302d0c7122505d33d926fa677d68f2655386fd314a7a4655ecfdf52250a1ef8
6
+ metadata.gz: c13d41f9f9e08f60a213f9150af7df73569ece5ed324703b87e41c8909caecb349578e852f0b5d7519f583a4f70807329072536cdd90e445574bd7c69bb97903
7
+ data.tar.gz: a972ac75c25b9deb2e1c64a6c5d3b323b04a681fda410679418064db66b7aced67866a75d471dd6da353a5a5eed1c73961a1c68ad404bae58b57d1bc1dd76698
@@ -70,7 +70,6 @@ module Moneybird
70
70
 
71
71
  private
72
72
  def perform(request)
73
- puts request.body.inspect
74
73
  @_last_response = http.request(request)
75
74
  end
76
75
  end
@@ -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({name => attributes})
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
@@ -43,6 +43,8 @@ module Moneybird::Resource
43
43
  notes
44
44
  custom_fields
45
45
  events
46
+ email_ubl
47
+ sales_invoices_url
46
48
  )
47
49
 
48
50
  def notes=(notes)
@@ -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 == 200
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
- build(JSON.parse(result.body))
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
- JSON.parse(result.body).map do |resource|
8
- build(resource)
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
@@ -1,3 +1,3 @@
1
1
  module Moneybird
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
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.1
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-23 00:00:00.000000000 Z
11
+ date: 2016-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler