moneybird 0.9.6 → 0.9.7

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
- SHA1:
3
- metadata.gz: fd3bbfa23e8c17db1d1acdec2a586d9cea28276e
4
- data.tar.gz: e2ad36cff2837ac4f4e760620bbff99124751d5f
2
+ SHA256:
3
+ metadata.gz: 4765ac62f2740e67304409f4e00320ab578467f7fe95681fe7e23f3749d5c826
4
+ data.tar.gz: 98e590e61c8089a5ac94ee13e5b0a074ca11253117625b173190ac6543fe355f
5
5
  SHA512:
6
- metadata.gz: 69b3618158f91006fd4f956ffe2d3384dd247c0891b1f6600c450b735a56ee171da47b854e92237cf43733a97406214c2c25425b838ca2399dc086848c61289a
7
- data.tar.gz: e7af996d8a016de028db757602dc0697a14a64746fe592d29a12ef315f4d165e6aefc0b95802c702ea51252e053e8a939aeb6c607465f2476751139b7f7551ff
6
+ metadata.gz: e6c1994278c86217b870285f46089507076f7c4445a9c231fe0733d3128ac0c3468187497bc3bf0de6855a88235d1da81df234c4cbe5f881d2e00de02458763d
7
+ data.tar.gz: 5c64e52708e35013a116dce3c97492bab860d0185cf1525a0f675463001e88cdd6128665bb6c83ccdf04b50af527bea314966f72138f32eb3862d6d0ceb58657
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
3
+ - 2.4
4
+ - 2.5
5
+ - 2.6
4
6
  before_install: gem install bundler -v 1.11.2
5
7
 
6
8
  addons:
@@ -56,7 +56,6 @@ require 'moneybird/resource/financial_mutation'
56
56
  require 'moneybird/resource/identity'
57
57
  require 'moneybird/resource/ledger_account'
58
58
  require 'moneybird/resource/product'
59
- require 'moneybird/resource/purchase_invoice' # Depends on generic and invoice resources
60
59
  require 'moneybird/resource/recurring_sales_invoice' # Depends on generic and invoice resources
61
60
  require 'moneybird/resource/sales_invoice' # Depends on generic and invoice resources
62
61
  require 'moneybird/resource/synchronization'
@@ -90,12 +89,12 @@ require 'moneybird/service/financial_mutation'
90
89
  require 'moneybird/service/identity'
91
90
  require 'moneybird/service/ledger_account'
92
91
  require 'moneybird/service/product'
93
- require 'moneybird/service/purchase_invoice'
94
92
  require 'moneybird/service/recurring_sales_invoice'
95
93
  require 'moneybird/service/sales_invoice'
96
94
  require 'moneybird/service/tax_rate'
97
95
  require 'moneybird/service/webhook'
98
96
  require 'moneybird/service/workflow'
97
+ require 'moneybird/service/payment'
99
98
 
100
99
  ##
101
100
  # Special cases
@@ -103,4 +102,4 @@ require 'moneybird/resource/administration' # Depends on services
103
102
  require 'moneybird/service/administration' # Depends on administration resource
104
103
  require 'moneybird/client'
105
104
  require 'moneybird/version'
106
- require 'moneybird/webhook'
105
+ require 'moneybird/webhook'
@@ -29,9 +29,7 @@ module Moneybird
29
29
  faraday.response :json
30
30
  faraday.use Moneybird::Middleware::ErrorHandling
31
31
  faraday.use Moneybird::Middleware::Pagination
32
- # faraday.response :logger do |logger|
33
- # logger.filter(/(Bearer)\s(\S+)/, '\1[REMOVED]')
34
- # end
32
+
35
33
  faraday.adapter faraday_adapter
36
34
  end
37
35
  end
@@ -16,6 +16,7 @@ module Moneybird
16
16
 
17
17
  def attributes=(attributes)
18
18
  @attributes = attributes
19
+ self.client ||= attributes[:client]
19
20
  attributes.each do |attribute, value|
20
21
  if respond_to?(writer = attribute.to_s + '=')
21
22
  send(writer, value)
@@ -4,46 +4,54 @@ module Moneybird::Resource::Documents
4
4
  extend Moneybird::Resource::ClassMethods
5
5
 
6
6
  has_attributes %i(
7
- id
8
7
  administration_id
8
+ attachments
9
9
  contact
10
10
  contact_id
11
- reference
11
+ created_at
12
+ currency
12
13
  date
14
+ details
13
15
  due_date
14
16
  entry_number
15
- state
17
+ events
16
18
  exchange_rate
17
- created_at
18
- updated_at
19
- version
19
+ id
20
20
  notes
21
- attachments
22
- events
23
- currency
24
- revenue_invoice
25
- prices_are_incl_tax
26
21
  origin
27
22
  paid_at
28
- tax_number
29
- total_price_excl_tax
30
- total_price_excl_tax_base
31
- total_price_incl_tax
32
- total_price_incl_tax_base
33
- details
34
23
  payments
35
- currency
36
- revenue_invoice
37
24
  prices_are_incl_tax
38
- origin
39
- paid_at
25
+ reference
26
+ revenue_invoice
27
+ state
40
28
  tax_number
41
29
  total_price_excl_tax
42
30
  total_price_excl_tax_base
43
31
  total_price_incl_tax
44
32
  total_price_incl_tax_base
45
- details
46
- payments
33
+ updated_at
34
+ version
47
35
  )
36
+
37
+ def notes=(notes)
38
+ @notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
39
+ end
40
+
41
+ def contact=(attributes)
42
+ @contact = Moneybird::Resource::Contact.build(attributes)
43
+ end
44
+
45
+ def details=(line_items)
46
+ @details = line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
47
+ end
48
+
49
+ def events=(events)
50
+ @events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
51
+ end
52
+
53
+ def payments=(payments)
54
+ @payments ||= payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
55
+ end
48
56
  end
49
- end
57
+ end
@@ -4,32 +4,54 @@ module Moneybird::Resource::Documents
4
4
  extend Moneybird::Resource::ClassMethods
5
5
 
6
6
  has_attributes %i(
7
- id
8
7
  administration_id
8
+ attachments
9
+ contact
10
+ contact_id
11
+ created_at
9
12
  currency
10
- revenue_invoice
11
- prices_are_incl_tax
13
+ date
14
+ details
15
+ due_date
16
+ entry_number
17
+ events
18
+ exchange_rate
19
+ id
20
+ notes
12
21
  origin
13
22
  paid_at
14
- tax_number
15
- total_price_excl_tax
16
- total_price_excl_tax_base
17
- total_price_incl_tax
18
- total_price_incl_tax_base
19
- details
20
23
  payments
21
- currency
22
- revenue_invoice
23
24
  prices_are_incl_tax
24
- origin
25
- paid_at
25
+ reference
26
+ revenue_invoice
27
+ state
26
28
  tax_number
27
29
  total_price_excl_tax
28
30
  total_price_excl_tax_base
29
31
  total_price_incl_tax
30
32
  total_price_incl_tax_base
31
- details
32
- payments
33
+ updated_at
34
+ version
33
35
  )
36
+
37
+ def notes=(notes)
38
+ @notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
39
+ end
40
+
41
+ def contact=(attributes)
42
+ @contact = Moneybird::Resource::Contact.build(attributes)
43
+ end
44
+
45
+ def details=(line_items)
46
+ @details = line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
47
+ end
48
+
49
+ def events=(events)
50
+ @events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
51
+ end
52
+
53
+ def payments=(payments)
54
+ @payments ||= payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
55
+ end
34
56
  end
35
- end
57
+ end
@@ -57,10 +57,15 @@ module Moneybird::Resource
57
57
  end
58
58
 
59
59
  def send_invoice(options = {})
60
- invoice_service = Moneybird::Service::SalesInvoice.new(@client, administration_id)
60
+ invoice_service = Moneybird::Service::SalesInvoice.new(client, administration_id)
61
61
  invoice_service.send_invoice(self, options)
62
62
  end
63
63
 
64
+ def payments=(payments)
65
+ payment_data = payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
66
+ @payments = Moneybird::Service::Payment.new(client, administration_id, preloaded_data: payment_data, invoice_id: id)
67
+ end
68
+
64
69
  def details=(line_items)
65
70
  @details = line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
66
71
  end
@@ -3,10 +3,11 @@ module Moneybird::Service
3
3
  include Moneybird::Traits::FindAll
4
4
  include Moneybird::Traits::Service
5
5
 
6
- attr_reader :client
6
+ attr_reader :client, :preloaded_data
7
7
 
8
8
  def initialize(client)
9
9
  @client = client
10
+ @preloaded_data = nil
10
11
  end
11
12
 
12
13
  def find(id)
@@ -20,7 +21,7 @@ module Moneybird::Service
20
21
  end
21
22
 
22
23
  def path
23
- '/administrations'
24
+ 'administrations'
24
25
  end
25
26
  end
26
27
  end
@@ -1,8 +1,7 @@
1
1
  module Moneybird::Service
2
- class PurchaseInvoice
2
+ class Payment
3
3
  include Moneybird::Traits::AdministrationService
4
4
  include Moneybird::Traits::Service
5
- include Moneybird::Traits::Find
6
5
  include Moneybird::Traits::FindAll
7
6
  include Moneybird::Traits::Save
8
7
  include Moneybird::Traits::Delete
@@ -10,11 +9,11 @@ module Moneybird::Service
10
9
  private
11
10
 
12
11
  def resource_class
13
- Moneybird::Resource::PurchaseInvoice
12
+ Moneybird::Resource::Invoice::Payment
14
13
  end
15
14
 
16
15
  def path
17
- "#{administration_id}/documents/purchase_invoices"
16
+ "#{administration_id}/sales_invoices/#{options[:invoice_id]}/payments"
18
17
  end
19
18
  end
20
- end
19
+ end
@@ -1,11 +1,13 @@
1
1
  module Moneybird
2
2
  module Traits
3
3
  module AdministrationService
4
- attr_reader :client, :administration_id
4
+ attr_reader :client, :administration_id, :preloaded_data, :options
5
5
 
6
- def initialize(client, administration_id)
6
+ def initialize(client, administration_id, options = {})
7
7
  @client = client
8
8
  @administration_id = administration_id
9
+ @preloaded_data = options.delete(:preloaded_data)
10
+ @options = options
9
11
  end
10
12
  end
11
13
  end
@@ -14,9 +14,15 @@ module Moneybird
14
14
 
15
15
  def each(params = {})
16
16
  return enum_for(:each, params) unless block_given?
17
- each_page(params).each do |resources|
18
- resources.each do |resource|
19
- yield resource
17
+ if preloaded_data
18
+ preloaded_data.each do |data|
19
+ yield data
20
+ end
21
+ else
22
+ each_page(params).each do |resources|
23
+ resources.each do |resource|
24
+ yield resource
25
+ end
20
26
  end
21
27
  end
22
28
  end
@@ -1,3 +1,3 @@
1
1
  module Moneybird
2
- VERSION = "0.9.6"
2
+ VERSION = "0.9.7"
3
3
  end
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency "link_header", "~> 0.0.8"
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.11"
28
- spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rake", "~> 12.3"
29
29
  spec.add_development_dependency "codeclimate-test-reporter"
30
30
  spec.add_development_dependency "minitest"
31
31
  spec.add_development_dependency "webmock", "~> 3.1"
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.9.6
4
+ version: 0.9.7
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: 2018-02-05 00:00:00.000000000 Z
11
+ date: 2019-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '10.0'
89
+ version: '12.3'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '10.0'
96
+ version: '12.3'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: codeclimate-test-reporter
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +190,6 @@ files:
190
190
  - lib/moneybird/resource/invoice/payment.rb
191
191
  - lib/moneybird/resource/ledger_account.rb
192
192
  - lib/moneybird/resource/product.rb
193
- - lib/moneybird/resource/purchase_invoice.rb
194
193
  - lib/moneybird/resource/recurring_sales_invoice.rb
195
194
  - lib/moneybird/resource/sales_invoice.rb
196
195
  - lib/moneybird/resource/synchronization.rb
@@ -210,8 +209,8 @@ files:
210
209
  - lib/moneybird/service/financial_mutation.rb
211
210
  - lib/moneybird/service/identity.rb
212
211
  - lib/moneybird/service/ledger_account.rb
212
+ - lib/moneybird/service/payment.rb
213
213
  - lib/moneybird/service/product.rb
214
- - lib/moneybird/service/purchase_invoice.rb
215
214
  - lib/moneybird/service/recurring_sales_invoice.rb
216
215
  - lib/moneybird/service/sales_invoice.rb
217
216
  - lib/moneybird/service/tax_rate.rb
@@ -247,8 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
246
  - !ruby/object:Gem::Version
248
247
  version: '0'
249
248
  requirements: []
250
- rubyforge_project:
251
- rubygems_version: 2.6.14
249
+ rubygems_version: 3.0.2
252
250
  signing_key:
253
251
  specification_version: 4
254
252
  summary: Library to interface with Moneybird API
@@ -1,57 +0,0 @@
1
- module Moneybird::Resource
2
- class PurchaseInvoice
3
- include Moneybird::Resource
4
- extend Moneybird::Resource::ClassMethods
5
-
6
- has_attributes %i(
7
- administration_id
8
- attachments
9
- contact
10
- contact_id
11
- created_at
12
- currency
13
- date
14
- details
15
- due_date
16
- entry_number
17
- events
18
- exchange_rate
19
- id
20
- notes
21
- origin
22
- paid_at
23
- payments
24
- prices_are_incl_tax
25
- reference
26
- revenue_invoice
27
- state
28
- tax_number
29
- total_price_excl_tax
30
- total_price_excl_tax_base
31
- total_price_incl_tax
32
- total_price_incl_tax_base
33
- updated_at
34
- version
35
- )
36
-
37
- def notes=(notes)
38
- @notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
39
- end
40
-
41
- def contact=(attributes)
42
- @contact = Moneybird::Resource::Contact.build(attributes)
43
- end
44
-
45
- def details=(line_items)
46
- @details = line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
47
- end
48
-
49
- def events=(events)
50
- @events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
51
- end
52
-
53
- def payments=(payments)
54
- @payments ||= payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
55
- end
56
- end
57
- end