moneybird 0.5.0 → 0.6.0
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/.codeclimate.yml +100 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +4 -0
- data/README.md +18 -1
- data/lib/moneybird.rb +2 -0
- data/lib/moneybird/resource.rb +8 -1
- data/lib/moneybird/resource/contact.rb +5 -0
- data/lib/moneybird/resource/estimate.rb +5 -0
- data/lib/moneybird/resource/generic/note.rb +22 -0
- data/lib/moneybird/resource/invoice/details.rb +0 -4
- data/lib/moneybird/resource/recurring_sales_invoice.rb +6 -0
- data/lib/moneybird/resource/sales_invoice.rb +5 -0
- data/lib/moneybird/version.rb +1 -1
- data/moneybird.gemspec +1 -0
- metadata +19 -2
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Moneybird
|
1
|
+
# Moneybird [](https://travis-ci.org/maartenvanvliet/moneybird) [](https://codeclimate.com/github/maartenvanvliet/moneybird) [](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
|
|
@@ -39,6 +39,12 @@ administration.sales_invoices.all
|
|
39
39
|
# List contacts
|
40
40
|
administration.contacts.all
|
41
41
|
|
42
|
+
# Find contact
|
43
|
+
administration.contacts.find(moneybird_id)
|
44
|
+
|
45
|
+
# Find contact by customer id
|
46
|
+
administration.contacts.find_by_customer_id(customer_id)
|
47
|
+
|
42
48
|
# Create contact
|
43
49
|
administrations.contacts.create(company_name: 'ACME', firstname: 'Foo', lastname: 'Bar')
|
44
50
|
|
@@ -47,8 +53,19 @@ contact = administration.contacts.all.first
|
|
47
53
|
contact.company_name = 'Something new'
|
48
54
|
administrations.contacts.save(contact)
|
49
55
|
|
56
|
+
# Delete contact
|
57
|
+
administrations.contacts.delete(contact)
|
58
|
+
|
50
59
|
# Works similarly with other resources
|
51
60
|
|
61
|
+
```
|
62
|
+
### Webhooks
|
63
|
+
|
64
|
+
Moneybird, if so configured, sends webhooks to specified endpoints. This gem can deal with these requests.
|
65
|
+
```ruby
|
66
|
+
webhook = Moneybird::Webhook.from_json(request.body)
|
67
|
+
sales_invoice = webhook.build_entity
|
68
|
+
sales_invoice.state
|
52
69
|
```
|
53
70
|
|
54
71
|
## Development
|
data/lib/moneybird.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'logger'
|
1
2
|
require 'uri'
|
2
3
|
require 'json'
|
3
4
|
require 'net/http'
|
@@ -16,6 +17,7 @@ require "moneybird/traits/delete"
|
|
16
17
|
require "moneybird/client"
|
17
18
|
require "moneybird/resource"
|
18
19
|
require "moneybird/resource/invoice/details"
|
20
|
+
require "moneybird/resource/generic/note"
|
19
21
|
require "moneybird/webhook"
|
20
22
|
|
21
23
|
resources = %w(
|
data/lib/moneybird/resource.rb
CHANGED
@@ -21,7 +21,7 @@ module Moneybird
|
|
21
21
|
if respond_to?(writer = attribute.to_s + '=')
|
22
22
|
send(writer, value)
|
23
23
|
else
|
24
|
-
|
24
|
+
self.class.logger.warn "#{self.class} does not have an `#{attribute}' attribute"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -47,11 +47,18 @@ module Moneybird
|
|
47
47
|
|
48
48
|
module ClassMethods
|
49
49
|
attr_reader :attributes, :nillable_attributes
|
50
|
+
attr_writer :logger
|
50
51
|
|
51
52
|
def build(attributes)
|
52
53
|
new(attributes)
|
53
54
|
end
|
54
55
|
|
56
|
+
def logger
|
57
|
+
@logger ||= begin
|
58
|
+
logger = Logger.new(STDOUT)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
55
62
|
def has_attributes(attributes)
|
56
63
|
attr_accessor(*@attributes = attributes)
|
57
64
|
end
|
@@ -39,8 +39,13 @@ module Moneybird::Resource
|
|
39
39
|
custom_fields
|
40
40
|
notes
|
41
41
|
attachments
|
42
|
+
events
|
42
43
|
)
|
43
44
|
|
45
|
+
def notes=(notes)
|
46
|
+
@notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
|
47
|
+
end
|
48
|
+
|
44
49
|
def contact=(attributes)
|
45
50
|
@contact ||= Moneybird::Resource::Contact.build(attributes)
|
46
51
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Moneybird::Resource::Generic
|
2
|
+
class Note
|
3
|
+
include Moneybird::Resource
|
4
|
+
extend Moneybird::Resource::ClassMethods
|
5
|
+
|
6
|
+
has_attributes %i(
|
7
|
+
id
|
8
|
+
entity_id
|
9
|
+
entity_type
|
10
|
+
user_id
|
11
|
+
assignee_id
|
12
|
+
todo
|
13
|
+
note
|
14
|
+
completed_at
|
15
|
+
completed_by_id
|
16
|
+
todo_type
|
17
|
+
data
|
18
|
+
created_at
|
19
|
+
updated_at
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Moneybird::Resource
|
2
2
|
class RecurringSalesInvoice
|
3
3
|
include Moneybird::Resource
|
4
|
+
|
4
5
|
extend Moneybird::Resource::ClassMethods
|
5
6
|
|
6
7
|
has_attributes %i(
|
@@ -33,8 +34,13 @@ module Moneybird::Resource
|
|
33
34
|
details
|
34
35
|
notes
|
35
36
|
attachments
|
37
|
+
events
|
36
38
|
)
|
37
39
|
|
40
|
+
def notes=(notes)
|
41
|
+
@notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
|
42
|
+
end
|
43
|
+
|
38
44
|
def contact=(attributes)
|
39
45
|
@contact ||= Moneybird::Resource::Contact.build(attributes)
|
40
46
|
end
|
@@ -37,8 +37,13 @@ module Moneybird::Resource
|
|
37
37
|
updated_at
|
38
38
|
url
|
39
39
|
workflow_id
|
40
|
+
events
|
40
41
|
)
|
41
42
|
|
43
|
+
def notes=(notes)
|
44
|
+
@notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
|
45
|
+
end
|
46
|
+
|
42
47
|
def contact=(attributes)
|
43
48
|
@contact ||= Moneybird::Resource::Contact.build(attributes)
|
44
49
|
end
|
data/lib/moneybird/version.rb
CHANGED
data/moneybird.gemspec
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.
|
4
|
+
version: 0.6.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-03-
|
11
|
+
date: 2016-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: codeclimate-test-reporter
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: 'Library to interface with Moneybird API: http://developer.moneybird.com/'
|
42
56
|
email:
|
43
57
|
- maartenvanvliet@gmail.com
|
@@ -45,9 +59,11 @@ executables: []
|
|
45
59
|
extensions: []
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
62
|
+
- ".codeclimate.yml"
|
48
63
|
- ".gitignore"
|
49
64
|
- ".kick"
|
50
65
|
- ".rspec"
|
66
|
+
- ".rubocop.yml"
|
51
67
|
- ".travis.yml"
|
52
68
|
- CODE_OF_CONDUCT.md
|
53
69
|
- Gemfile
|
@@ -65,6 +81,7 @@ files:
|
|
65
81
|
- lib/moneybird/resource/estimate.rb
|
66
82
|
- lib/moneybird/resource/financial_account.rb
|
67
83
|
- lib/moneybird/resource/financial_mutation.rb
|
84
|
+
- lib/moneybird/resource/generic/note.rb
|
68
85
|
- lib/moneybird/resource/identity.rb
|
69
86
|
- lib/moneybird/resource/invoice/details.rb
|
70
87
|
- lib/moneybird/resource/ledger_account.rb
|