moneybird 0.9.9 → 0.10.1

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
  SHA256:
3
- metadata.gz: bb2e7783bb5c1bd07ba829b99c43d6ca6ea6eb5649d6249078d0280f0d259dab
4
- data.tar.gz: c8ef2679c43ee7188a36576afa9ccc83104814901913a96ba1d99c29428fe25b
3
+ metadata.gz: 4e51db36506d93746d8be9c4c38e3b7a1aff68caac9dbf23bfc246c32ec55a09
4
+ data.tar.gz: a69bcfe1969ee0a04188dd7818c5d4efcba26ab317823fdd44707e4d6e934582
5
5
  SHA512:
6
- metadata.gz: 225222a355ac19b5f2c0f389093530d9d56dfca297e696b9c94a299b01ac9cf847a917e955e052a1c58895cfcfd3237e9b131a7f5db86d0d7f9b8926145525c9
7
- data.tar.gz: 551b6160c997ad504335eb3aa383cee559d3b09fde1ea3434e382348d5452f08a09a610ae4af20b8c86c466a1645546c75b6f45dd5a7bcb6bc14a264658b14bc
6
+ metadata.gz: ab851017c096b28964609330aaebc76a4607214585ff9440c06bc005ffed4db5ae9bdbcc075aa18905dc0d33da68b92bca1640531c0292a5eb339641617d2fd6
7
+ data.tar.gz: '048064af32f069dcc729cbddb3e8e867825a0fda4ad4964b0b2d9d6a3fec303f55d63d8a67bca39d9b437c45c261991da59bae64ee4f2245c36a8e0c3ccababe'
data/.codeclimate.yml CHANGED
@@ -23,78 +23,4 @@ ratings:
23
23
  - "**.rb"
24
24
  exclude_paths:
25
25
  - spec/
26
- ---
27
- engines:
28
- duplication:
29
- enabled: true
30
- config:
31
- languages:
32
- - ruby
33
- - javascript
34
- - python
35
- - php
36
- fixme:
37
- enabled: true
38
- rubocop:
39
- enabled: true
40
- ratings:
41
- paths:
42
- - "**.inc"
43
- - "**.js"
44
- - "**.jsx"
45
- - "**.module"
46
- - "**.php"
47
- - "**.py"
48
- - "**.rb"
49
- exclude_paths:
50
- - spec/
51
- ---
52
- engines:
53
- duplication:
54
- enabled: true
55
- config:
56
- languages:
57
- - ruby
58
- - javascript
59
- - python
60
- - php
61
- fixme:
62
- enabled: true
63
- rubocop:
64
- enabled: true
65
- ratings:
66
- paths:
67
- - "**.inc"
68
- - "**.js"
69
- - "**.jsx"
70
- - "**.module"
71
- - "**.php"
72
- - "**.py"
73
- - "**.rb"
74
- exclude_paths:
75
- - spec/
76
- ---
77
- engines:
78
- duplication:
79
- enabled: true
80
- config:
81
- languages:
82
- - ruby
83
- - javascript
84
- - python
85
- - php
86
- fixme:
87
- enabled: true
88
- rubocop:
89
- enabled: true
90
- ratings:
91
- paths:
92
- - "**.inc"
93
- - "**.js"
94
- - "**.jsx"
95
- - "**.module"
96
- - "**.php"
97
- - "**.py"
98
- - "**.rb"
99
- exclude_paths:
100
- - spec/
26
+
@@ -1,23 +1,38 @@
1
1
  name: Ruby
2
2
 
3
- on: [push]
3
+ on: [push, pull_request]
4
4
 
5
5
  jobs:
6
6
  test:
7
-
8
7
  runs-on: ubuntu-latest
9
8
 
10
9
  strategy:
11
10
  matrix:
12
- ruby_version: [2.4, 2.5, 2.6]
11
+ ruby_version: [2.5, 2.6, 2.7, 3.0]
12
+
13
13
  steps:
14
- - uses: actions/checkout@v2.3.4
14
+ - uses: actions/checkout@v2.3.5
15
+
15
16
  - name: Set up Ruby
16
- uses: actions/setup-ruby@v1
17
+ uses: ruby/setup-ruby@v1
17
18
  with:
18
19
  ruby-version: ${{ matrix.ruby_version }}
20
+
21
+ - uses: amancevice/setup-code-climate@v0
22
+ name: CodeClimate Install
23
+ with:
24
+ cc_test_reporter_id: 0b8e41ecbc26637a7db4e6e9d4581c445441674f689016ab45fb5c51242b59bf
25
+
26
+ - name: CodeClimate Pre-build Notification
27
+ run: cc-test-reporter before-build
28
+
19
29
  - name: Build and test with Rake
30
+ env:
31
+ CI: true
20
32
  run: |
21
33
  gem install bundler
22
34
  bundle install --jobs 4 --retry 3
23
35
  bundle exec rake
36
+
37
+ - name: CodeClimate Post-build Notification
38
+ run: cc-test-reporter after-build
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Moneybird [![Build Status](https://travis-ci.org/maartenvanvliet/moneybird.svg?branch=master)](https://travis-ci.org/maartenvanvliet/moneybird) [![Code Climate](https://codeclimate.com/github/maartenvanvliet/moneybird/badges/gpa.svg)](https://codeclimate.com/github/maartenvanvliet/moneybird) [![Test Coverage](https://codeclimate.com/github/maartenvanvliet/moneybird/badges/coverage.svg)](https://codeclimate.com/github/maartenvanvliet/moneybird/coverage)
1
+ # Moneybird [![Build Status](https://github.com/maartenvanvliet/moneybird/workflows/Ruby/badge.svg?branch=master)](https://github.com/maartenvanvliet/moneybird/actions?query=workflow%3ARuby) [![Code Climate](https://codeclimate.com/github/maartenvanvliet/moneybird/badges/gpa.svg)](https://codeclimate.com/github/maartenvanvliet/moneybird) [![Test Coverage](https://codeclimate.com/github/maartenvanvliet/moneybird/badges/coverage.svg)](https://codeclimate.com/github/maartenvanvliet/moneybird/coverage)
2
2
 
3
3
  Gem to talk to the Moneybird REST API. Right now you'll need to get a 'bearer' token for the client to work, oauth2 support may added later. This gem is still under construction and any methods may still change signature without notice until 1.0 is released.
4
4
 
@@ -36,6 +36,9 @@ administration = administrations.first
36
36
  # List invoices
37
37
  administration.sales_invoices.all
38
38
 
39
+ # List invoices with a specific state
40
+ administration.sales_invoices.all(filter: 'state:uncollectible')
41
+
39
42
  # List contacts
40
43
  administration.contacts.all
41
44
 
@@ -82,4 +85,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/maarte
82
85
  ## License
83
86
 
84
87
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
85
-
@@ -37,6 +37,11 @@ module Moneybird
37
37
  %i[get patch post delete].each do |call|
38
38
  define_method call do |path, options = {}|
39
39
  http.public_send(call, "/api/#{version}/#{path}", options).body
40
+
41
+ rescue Faraday::ParsingError => e
42
+ return e.response['Location'] if e.response.status == 302
43
+
44
+ raise e
40
45
  end
41
46
  end
42
47
 
@@ -70,4 +75,4 @@ module Moneybird
70
75
  }
71
76
  end
72
77
  end
73
- end
78
+ end
@@ -56,6 +56,14 @@ module Moneybird::Resource
56
56
  Moneybird::Service::Workflow.new(@client, id)
57
57
  end
58
58
 
59
+ def custom_fields
60
+ Moneybird::Service::CustomField.new(@client, id)
61
+ end
62
+
63
+ def document_styles
64
+ Moneybird::Service::DocumentStyle.new(@client, id)
65
+ end
66
+
59
67
  def tax_rates
60
68
  Moneybird::Service::TaxRate.new(@client, id)
61
69
  end
@@ -54,11 +54,15 @@ module Moneybird::Resource
54
54
  )
55
55
 
56
56
  def notes=(notes)
57
- @notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
57
+ @notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
58
58
  end
59
59
 
60
60
  def events=(events)
61
- @events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
61
+ @events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
62
+ end
63
+
64
+ def custom_fields=(custom_fields)
65
+ @custom_fields = custom_fields.map { |custom_field| Moneybird::Resource::CustomField.build(custom_field) }
62
66
  end
63
67
  end
64
68
  end
@@ -0,0 +1,16 @@
1
+ module Moneybird::Resource
2
+ class CustomField
3
+ include Moneybird::Resource
4
+ extend Moneybird::Resource::ClassMethods
5
+
6
+ has_attributes %i(
7
+ administration_id
8
+ created_at
9
+ id
10
+ name
11
+ source
12
+ updated_at
13
+ value
14
+ )
15
+ end
16
+ end
@@ -35,7 +35,7 @@ module Moneybird::Resource::Documents
35
35
  )
36
36
 
37
37
  def notes=(notes)
38
- @notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
38
+ @notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
39
39
  end
40
40
 
41
41
  def contact=(attributes)
@@ -47,11 +47,11 @@ module Moneybird::Resource::Documents
47
47
  end
48
48
 
49
49
  def events=(events)
50
- @events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
50
+ @events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
51
51
  end
52
52
 
53
53
  def payments=(payments)
54
- @payments ||= payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
54
+ @payments = payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
55
55
  end
56
56
  end
57
57
  end
@@ -35,7 +35,7 @@ module Moneybird::Resource::Documents
35
35
  )
36
36
 
37
37
  def notes=(notes)
38
- @notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
38
+ @notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
39
39
  end
40
40
 
41
41
  def contact=(attributes)
@@ -47,11 +47,11 @@ module Moneybird::Resource::Documents
47
47
  end
48
48
 
49
49
  def events=(events)
50
- @events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
50
+ @events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
51
51
  end
52
52
 
53
53
  def payments=(payments)
54
- @payments ||= payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
54
+ @payments = payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
55
55
  end
56
56
  end
57
57
  end
@@ -48,15 +48,15 @@ module Moneybird::Resource
48
48
  )
49
49
 
50
50
  def notes=(notes)
51
- @notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
51
+ @notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
52
52
  end
53
53
 
54
54
  def contact=(attributes)
55
- @contact ||= Moneybird::Resource::Contact.build(attributes)
55
+ @contact = Moneybird::Resource::Contact.build(attributes)
56
56
  end
57
57
 
58
58
  def details=(line_items)
59
- @details ||= line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
59
+ @details = line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
60
60
  end
61
61
  end
62
- end
62
+ end
@@ -38,7 +38,7 @@ module Moneybird::Resource
38
38
  )
39
39
 
40
40
  def notes=(notes)
41
- @notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
41
+ @notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
42
42
  end
43
43
 
44
44
  def contact=(attributes)
@@ -55,7 +55,7 @@ module Moneybird::Resource
55
55
  end
56
56
 
57
57
  def events=(events)
58
- @events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
58
+ @events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
59
59
  end
60
60
  end
61
61
  end
@@ -22,4 +22,8 @@ module Moneybird::Resource
22
22
  updated_at
23
23
  )
24
24
  end
25
- end
25
+
26
+ def custom_fields=(custom_fields)
27
+ @custom_fields = custom_fields.map { |custom_field| Moneybird::Resource::CustomField.build(custom_field) }
28
+ end
29
+ end
@@ -40,7 +40,7 @@ module Moneybird::Resource
40
40
  )
41
41
 
42
42
  def notes=(notes)
43
- @notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
43
+ @notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
44
44
  end
45
45
 
46
46
  def contact=(attributes)
@@ -52,7 +52,7 @@ module Moneybird::Resource
52
52
  end
53
53
 
54
54
  def events=(events)
55
- @events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
55
+ @events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
56
56
  end
57
57
  end
58
58
  end
@@ -22,12 +22,15 @@ module Moneybird::Resource
22
22
  invoice_id
23
23
  invoice_sequence_id
24
24
  language
25
+ marked_dubious_on
26
+ marked_uncollectible_on
25
27
  notes
26
28
  original_sales_invoice_id
27
29
  paid_at
28
30
  paused
29
31
  payment_conditions
30
32
  payment_reference
33
+ payment_url
31
34
  payments
32
35
  prices_are_incl_tax
33
36
  public_view_code
@@ -52,7 +55,7 @@ module Moneybird::Resource
52
55
  )
53
56
 
54
57
  def notes=(notes)
55
- @notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
58
+ @notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
56
59
  end
57
60
 
58
61
  def contact=(attributes)
@@ -79,7 +82,11 @@ module Moneybird::Resource
79
82
  end
80
83
 
81
84
  def events=(events)
82
- @events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
85
+ @events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
86
+ end
87
+
88
+ def custom_fields=(custom_fields)
89
+ @custom_fields = custom_fields.map { |custom_field| Moneybird::Resource::CustomField.build(custom_field) }
83
90
  end
84
91
  end
85
92
  end
@@ -10,6 +10,7 @@ module Moneybird::Resource
10
10
  last_http_status
11
11
  last_http_body
12
12
  events
13
+ token
13
14
  )
14
15
 
15
16
  def to_json
@@ -0,0 +1,17 @@
1
+ module Moneybird::Service
2
+ class CustomField
3
+ include Moneybird::Traits::AdministrationService
4
+ include Moneybird::Traits::Service
5
+ include Moneybird::Traits::FindAll
6
+
7
+ private
8
+
9
+ def resource_class
10
+ Moneybird::Resource::CustomField
11
+ end
12
+
13
+ def path
14
+ "#{administration_id}/custom_fields"
15
+ end
16
+ end
17
+ end
@@ -7,6 +7,7 @@ module Moneybird::Service
7
7
  include Moneybird::Traits::Save
8
8
  include Moneybird::Traits::Delete
9
9
  include Moneybird::Traits::Synchronization
10
+ include Moneybird::Traits::DownloadPdf
10
11
  include Moneybird::Traits::SendInvoice
11
12
  include Moneybird::Traits::MarkAsUncollectible
12
13
 
@@ -0,0 +1,9 @@
1
+ module Moneybird
2
+ module Traits
3
+ module DownloadPdf
4
+ def download_pdf(id)
5
+ client.get("#{path}/#{id}/download_pdf")
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Moneybird
2
- VERSION = "0.9.9"
2
+ VERSION = "0.10.1"
3
3
  end
@@ -6,6 +6,7 @@ module Moneybird
6
6
  has_attributes %i(
7
7
  administration_id
8
8
  webhook_id
9
+ webhook_token
9
10
  entity_type
10
11
  entity_id
11
12
  state
@@ -14,7 +15,7 @@ module Moneybird
14
15
  )
15
16
 
16
17
  def build_entity
17
- entity_resource_class.new(entity)
18
+ entity_resource_class.new(entity) if entity
18
19
  end
19
20
 
20
21
  def entity_resource_class
@@ -25,4 +26,4 @@ module Moneybird
25
26
  build(JSON.parse(payload))
26
27
  end
27
28
  end
28
- end
29
+ end
data/lib/moneybird.rb CHANGED
@@ -50,6 +50,7 @@ require 'moneybird/resource/invoice/details'
50
50
  require 'moneybird/resource/invoice/payment'
51
51
  require 'moneybird/resource/contact' # Depends on generic resources
52
52
  require 'moneybird/resource/document_style'
53
+ require 'moneybird/resource/custom_field'
53
54
  require 'moneybird/resource/estimate'
54
55
  require 'moneybird/resource/financial_account'
55
56
  require 'moneybird/resource/financial_mutation'
@@ -68,13 +69,14 @@ require 'moneybird/resource/workflow'
68
69
  # Traits
69
70
  require 'moneybird/traits/administration_service'
70
71
  require 'moneybird/traits/delete'
72
+ require 'moneybird/traits/download_pdf'
71
73
  require 'moneybird/traits/find'
72
74
  require 'moneybird/traits/find_all'
73
75
  require 'moneybird/traits/mark_as_uncollectible'
74
76
  require 'moneybird/traits/save'
77
+ require 'moneybird/traits/send_invoice'
75
78
  require 'moneybird/traits/service'
76
79
  require 'moneybird/traits/synchronization' # Depends on synchronization resource
77
- require 'moneybird/traits/send_invoice'
78
80
 
79
81
  ##
80
82
  # Services (all depend on traits and it's associated resource)
@@ -85,6 +87,7 @@ require 'moneybird/service/documents/receipt'
85
87
  require 'moneybird/service/documents/typeless_document'
86
88
  require 'moneybird/service/contact'
87
89
  require 'moneybird/service/document_style'
90
+ require 'moneybird/service/custom_field'
88
91
  require 'moneybird/service/estimate'
89
92
  require 'moneybird/service/financial_account'
90
93
  require 'moneybird/service/financial_mutation'
data/moneybird.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_development_dependency "bundler", [">= 1.11", "< 3.0"]
28
28
  spec.add_development_dependency "rake", "~> 13.0"
29
- spec.add_development_dependency "codeclimate-test-reporter"
29
+ spec.add_development_dependency "simplecov", "= 0.21.2"
30
30
  spec.add_development_dependency "minitest"
31
31
  spec.add_development_dependency "webmock", "~> 3.1"
32
32
  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.9.9
4
+ version: 0.10.1
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: 2020-11-11 00:00:00.000000000 Z
11
+ date: 2021-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -101,19 +101,19 @@ dependencies:
101
101
  - !ruby/object:Gem::Version
102
102
  version: '13.0'
103
103
  - !ruby/object:Gem::Dependency
104
- name: codeclimate-test-reporter
104
+ name: simplecov
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - ">="
107
+ - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: '0'
109
+ version: 0.21.2
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - ">="
114
+ - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: '0'
116
+ version: 0.21.2
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: minitest
119
119
  requirement: !ruby/object:Gem::Requirement
@@ -156,7 +156,6 @@ files:
156
156
  - ".kick"
157
157
  - ".rspec"
158
158
  - ".rubocop.yml"
159
- - ".travis.yml"
160
159
  - CODE_OF_CONDUCT.md
161
160
  - Gemfile
162
161
  - LICENSE.txt
@@ -182,6 +181,7 @@ files:
182
181
  - lib/moneybird/resource.rb
183
182
  - lib/moneybird/resource/administration.rb
184
183
  - lib/moneybird/resource/contact.rb
184
+ - lib/moneybird/resource/custom_field.rb
185
185
  - lib/moneybird/resource/document_style.rb
186
186
  - lib/moneybird/resource/documents/general_document.rb
187
187
  - lib/moneybird/resource/documents/general_journal_document.rb
@@ -207,6 +207,7 @@ files:
207
207
  - lib/moneybird/resource/workflow.rb
208
208
  - lib/moneybird/service/administration.rb
209
209
  - lib/moneybird/service/contact.rb
210
+ - lib/moneybird/service/custom_field.rb
210
211
  - lib/moneybird/service/document_style.rb
211
212
  - lib/moneybird/service/documents/general_document.rb
212
213
  - lib/moneybird/service/documents/general_journal_document.rb
@@ -228,6 +229,7 @@ files:
228
229
  - lib/moneybird/service/workflow.rb
229
230
  - lib/moneybird/traits/administration_service.rb
230
231
  - lib/moneybird/traits/delete.rb
232
+ - lib/moneybird/traits/download_pdf.rb
231
233
  - lib/moneybird/traits/find.rb
232
234
  - lib/moneybird/traits/find_all.rb
233
235
  - lib/moneybird/traits/mark_as_uncollectible.rb
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4
4
- - 2.5
5
- - 2.6
6
- before_install: gem install bundler -v 1.11.2
7
-
8
- addons:
9
- code_climate:
10
- repo_token: 0b8e41ecbc26637a7db4e6e9d4581c445441674f689016ab45fb5c51242b59bf
11
-
12
- after_success:
13
- - bundle exec codeclimate-test-reporter