moneybird 0.7.5 → 0.8.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: e691e978069c76efa4acfa645a7a93ec5e688988
4
- data.tar.gz: 1e8527982d7080c2237a0400e897646a49d41b7a
3
+ metadata.gz: 944b2c8d8441278203f58d084b530147a0f23886
4
+ data.tar.gz: 1c7a0f696c363928717f41f4294544a853a1cf73
5
5
  SHA512:
6
- metadata.gz: 603d5265ee1084724fddb026c6329dc70c612c087a17f1ece84dec64e35454a9a7b13b21d12d4742b091ccc7dfb62fefc77b40b3b0c7c293221ec8f75611fe9d
7
- data.tar.gz: db8e896d1d3005f33fecbd38c0197218a8872a3cf2b35e9af5bd70707731a28ceb1d03b01a7632f7561a3e5a7531b2d6ef16772eacc7b6bacd615e23a6e049b3
6
+ metadata.gz: b527b144d9dcf62f37832b35e20f21875e00c223e865b738719bc73b9e6ada95c02b4bb57b603fdd5acac91d3d3d6d14e0f9ac5d7a476f58c618c1ec9bc9813a
7
+ data.tar.gz: 686f076396deeaa72a11445db74375eb3fee3d8c48adc0004c1a18114ffc9ec82ed5f8212902b451004caa3976c698d975b87af4a11276851c988c4e95010f93
data/.travis.yml CHANGED
@@ -1,8 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.2
3
+ - 2.2.2
4
4
  before_install: gem install bundler -v 1.11.2
5
5
 
6
6
  addons:
7
7
  code_climate:
8
- repo_token: 0b8e41ecbc26637a7db4e6e9d4581c445441674f689016ab45fb5c51242b59bf
8
+ repo_token: 0b8e41ecbc26637a7db4e6e9d4581c445441674f689016ab45fb5c51242b59bf
9
+
10
+ after_success:
11
+ - bundle exec codeclimate-test-reporter
data/lib/moneybird.rb CHANGED
@@ -1,3 +1,8 @@
1
+
2
+ require 'active_support'
3
+ require 'active_support/core_ext/object/json'
4
+ require 'active_support/core_ext/string/inflections'
5
+
1
6
  require 'logger'
2
7
  require 'uri'
3
8
  require 'json'
@@ -30,7 +30,9 @@ module Moneybird
30
30
  self.class.attributes.inject({}) do |attributes, attribute|
31
31
  value = send(attribute)
32
32
  if !value.nil?
33
- if value.respond_to?(:attributes)
33
+ if value.is_a?(Array) && value.first.respond_to?(:attributes)
34
+ attributes["#{attribute}_attributes"] = value.map { |item| item.attributes }
35
+ elsif value.respond_to?(:attributes)
34
36
  attributes["#{attribute}_attributes"] = value.attributes
35
37
  else
36
38
  unless self.class.nillable_attributes && self.class.nillable_attributes.include?(attribute)
@@ -42,7 +44,7 @@ module Moneybird
42
44
  end
43
45
 
44
46
  def to_json
45
- JSON.generate({self.class.resource => attributes})
47
+ JSON.generate({self.class.resource => attributes.as_json})
46
48
  end
47
49
 
48
50
  module ClassMethods
@@ -60,7 +62,7 @@ module Moneybird
60
62
  end
61
63
 
62
64
  def resource
63
- self.name.split('::').last.downcase
65
+ self.name.split('::').last.underscore
64
66
  end
65
67
 
66
68
  def has_attributes(attributes)
@@ -12,6 +12,10 @@ module Moneybird::Resource
12
12
  time_zone
13
13
  )
14
14
 
15
+ def ledger_accounts
16
+ Moneybird::Service::LedgerAccount.new(@client, id)
17
+ end
18
+
15
19
  def sales_invoices
16
20
  Moneybird::Service::SalesInvoice.new(@client, id)
17
21
  end
@@ -43,11 +43,11 @@ module Moneybird::Resource
43
43
  end
44
44
 
45
45
  def contact=(attributes)
46
- @contact ||= Moneybird::Resource::Contact.build(attributes)
46
+ @contact = Moneybird::Resource::Contact.build(attributes)
47
47
  end
48
48
 
49
49
  def details=(line_items)
50
- @details ||= line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
50
+ @details = line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
51
51
  end
52
52
 
53
53
  def events=(events)
@@ -46,11 +46,11 @@ module Moneybird::Resource
46
46
  end
47
47
 
48
48
  def contact=(attributes)
49
- @contact ||= Moneybird::Resource::Contact.build(attributes)
49
+ @contact = Moneybird::Resource::Contact.build(attributes)
50
50
  end
51
51
 
52
52
  def details=(line_items)
53
- @details ||= line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
53
+ @details = line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
54
54
  end
55
55
 
56
56
  def events=(events)
@@ -1,3 +1,3 @@
1
1
  module Moneybird
2
- VERSION = "0.7.5"
2
+ VERSION = "0.8.0"
3
3
  end
data/moneybird.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
+ spec.add_dependency "activesupport", '>= 3.0'
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.11"
24
25
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moneybird
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.8.0
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-09-01 00:00:00.000000000 Z
11
+ date: 2017-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -149,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
163
  version: '0'
150
164
  requirements: []
151
165
  rubyforge_project:
152
- rubygems_version: 2.6.3
166
+ rubygems_version: 2.5.2
153
167
  signing_key:
154
168
  specification_version: 4
155
169
  summary: Library to interface with Moneybird API