moneybird 0.1.0 → 0.2.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/.kick +17 -0
- data/Rakefile +6 -3
- data/lib/moneybird.rb +28 -6
- data/lib/moneybird/client.rb +5 -4
- data/lib/moneybird/resource/administration.rb +43 -0
- data/lib/moneybird/{contact.rb → resource/contact.rb} +1 -18
- data/lib/moneybird/resource/estimate.rb +61 -0
- data/lib/moneybird/resource/financial_account.rb +35 -0
- data/lib/moneybird/resource/financial_mutation.rb +33 -0
- data/lib/moneybird/resource/identity.rb +35 -0
- data/lib/moneybird/resource/product.rb +35 -0
- data/lib/moneybird/resource/recurring_sales_invoice.rb +58 -0
- data/lib/moneybird/{sales_invoice.rb → resource/sales_invoice.rb} +5 -5
- data/lib/moneybird/resource/tax_rate.rb +34 -0
- data/lib/moneybird/resource/webhook.rb +32 -0
- data/lib/moneybird/resource/workflow.rb +38 -0
- data/lib/moneybird/service/administration.rb +19 -0
- data/lib/moneybird/service/contact.rb +14 -0
- data/lib/moneybird/service/estimate.rb +14 -0
- data/lib/moneybird/service/product.rb +14 -0
- data/lib/moneybird/service/sales_invoice.rb +14 -0
- data/lib/moneybird/traits/administration_service.rb +12 -0
- data/lib/moneybird/traits/find_all.rb +13 -0
- data/lib/moneybird/version.rb +1 -1
- data/moneybird.gemspec +0 -1
- metadata +23 -19
- data/lib/moneybird/administration.rb +0 -39
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f4ecb53d09bc1ba540403d9904dd2fe6901c638
|
|
4
|
+
data.tar.gz: 054eddbe0ffd6cbc5c9db69436f1b385d81643e7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e39d70f345ef056dafd921018cb615e1dc976805cacf064222b1cf0e2eebef769ac07e08e37984906decde2b734e71718ccb7a4ce6afc2e0a1e13945088fcae
|
|
7
|
+
data.tar.gz: 410d875bc02399096676393fa17da05cf94c1ef186e8f9fb958c7b02bf57ba535ab747a1445573ec55acc31ebdcfbbffb9f4c94ff9a463a3c5b7751b095b47cf
|
data/.kick
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'set'
|
|
2
|
+
|
|
3
|
+
process do |file, flags|
|
|
4
|
+
test_files = Set.new
|
|
5
|
+
case file
|
|
6
|
+
when %r(^spec/.*_spec.rb$)
|
|
7
|
+
test_files << file
|
|
8
|
+
when %r(^lib/(.*).rb)
|
|
9
|
+
test_files << 'spec/lib/' + $1 + '_spec.rb'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
test_files = test_files.select { |filename| File.exist?(filename) }
|
|
13
|
+
|
|
14
|
+
unless test_files.empty?
|
|
15
|
+
watcher.execute("rake test TEST=#{test_files.to_a.join(' ')}")
|
|
16
|
+
end
|
|
17
|
+
end
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
require "bundler/gem_tasks"
|
|
2
|
-
require "
|
|
2
|
+
require "rake/testtask"
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Rake::TestTask.new do |t|
|
|
5
|
+
t.libs.push 'spec'
|
|
6
|
+
t.test_files = FileList['spec/**/*_spec.rb']
|
|
7
|
+
end
|
|
5
8
|
|
|
6
|
-
task :
|
|
9
|
+
task default: :test
|
data/lib/moneybird.rb
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
|
+
require 'uri'
|
|
1
2
|
require 'json'
|
|
2
|
-
require
|
|
3
|
-
require "moneybird/client"
|
|
4
|
-
require "moneybird/contact"
|
|
5
|
-
require "moneybird/administration"
|
|
6
|
-
require "moneybird/sales_invoice"
|
|
7
|
-
require "moneybird/version"
|
|
3
|
+
require 'net/http'
|
|
8
4
|
|
|
9
5
|
module Moneybird
|
|
6
|
+
module Service; end;
|
|
7
|
+
module Traits; end;
|
|
10
8
|
end
|
|
9
|
+
|
|
10
|
+
require "moneybird/traits/administration_service"
|
|
11
|
+
require "moneybird/traits/find_all"
|
|
12
|
+
|
|
13
|
+
require "moneybird/service/administration"
|
|
14
|
+
require "moneybird/service/contact"
|
|
15
|
+
require "moneybird/service/estimate"
|
|
16
|
+
require "moneybird/service/sales_invoice"
|
|
17
|
+
require "moneybird/service/product"
|
|
18
|
+
|
|
19
|
+
require "moneybird/client"
|
|
20
|
+
|
|
21
|
+
require "moneybird/resource"
|
|
22
|
+
require "moneybird/resource/contact"
|
|
23
|
+
require "moneybird/resource/administration"
|
|
24
|
+
require "moneybird/resource/product"
|
|
25
|
+
require "moneybird/resource/estimate"
|
|
26
|
+
require "moneybird/resource/workflow"
|
|
27
|
+
require "moneybird/resource/tax_rate"
|
|
28
|
+
require "moneybird/resource/webhook"
|
|
29
|
+
require "moneybird/resource/sales_invoice"
|
|
30
|
+
require "moneybird/resource/recurring_sales_invoice"
|
|
31
|
+
|
|
32
|
+
require "moneybird/version"
|
data/lib/moneybird/client.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
module Moneybird
|
|
2
2
|
class Client
|
|
3
|
-
attr_reader :
|
|
3
|
+
attr_reader :bearer_token, :_last_response
|
|
4
4
|
attr_accessor :errors
|
|
5
|
+
attr_writer :http
|
|
5
6
|
|
|
6
|
-
def initialize(
|
|
7
|
-
@
|
|
7
|
+
def initialize(bearer_token)
|
|
8
|
+
@bearer_token = bearer_token
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
def base_url
|
|
@@ -28,7 +29,7 @@ module Moneybird
|
|
|
28
29
|
{
|
|
29
30
|
'Accept' => 'application/json',
|
|
30
31
|
'Content-Type' => 'application/json',
|
|
31
|
-
'Authorization' => "Bearer #{
|
|
32
|
+
'Authorization' => "Bearer #{bearer_token}"
|
|
32
33
|
}
|
|
33
34
|
end
|
|
34
35
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Moneybird::Resource
|
|
2
|
+
class Administration
|
|
3
|
+
include Moneybird::Resource
|
|
4
|
+
extend Moneybird::Resource::ClassMethods
|
|
5
|
+
|
|
6
|
+
has_attributes %i(
|
|
7
|
+
id
|
|
8
|
+
name
|
|
9
|
+
language
|
|
10
|
+
currency
|
|
11
|
+
country
|
|
12
|
+
time_zone
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
def sales_invoices
|
|
16
|
+
Moneybird::SalesInvoice::Service.new(@client, id).all
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def recurring_sales_invoices
|
|
20
|
+
Moneybird::RecurringSalesInvoice::Service.new(@client, id).all
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def contacts
|
|
24
|
+
Moneybird::Contact::Service.new(@client, id).all
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def estimates
|
|
28
|
+
Moneybird::Estimate::Service.new(@client, id).all
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def products
|
|
32
|
+
Moneybird::Product::Service.new(@client, id).all
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def webhooks
|
|
36
|
+
Moneybird::Webhook::Service.new(@client, id).all
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def workflows
|
|
40
|
+
Moneybird::Workflow::Service.new(@client, id).all
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module Moneybird
|
|
1
|
+
module Moneybird::Resource
|
|
2
2
|
class Contact
|
|
3
3
|
include Moneybird::Resource
|
|
4
4
|
extend Moneybird::Resource::ClassMethods
|
|
@@ -41,23 +41,6 @@ module Moneybird
|
|
|
41
41
|
notes
|
|
42
42
|
custom_fields
|
|
43
43
|
)
|
|
44
|
-
|
|
45
|
-
class Service
|
|
46
|
-
attr_reader :client, :administation_id
|
|
47
|
-
|
|
48
|
-
def initialize(client, administation_id)
|
|
49
|
-
@client = client
|
|
50
|
-
@administation_id = administation_id
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def all
|
|
54
|
-
result = client.get("#{administation_id}/contacts")
|
|
55
|
-
|
|
56
|
-
JSON.parse(result.body).map do |invoice|
|
|
57
|
-
Contact.new(self, invoice)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
44
|
end
|
|
62
45
|
end
|
|
63
46
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module Moneybird::Resource
|
|
2
|
+
class Estimate
|
|
3
|
+
include Moneybird::Resource
|
|
4
|
+
extend Moneybird::Resource::ClassMethods
|
|
5
|
+
|
|
6
|
+
has_attributes %i(
|
|
7
|
+
id
|
|
8
|
+
contact_id
|
|
9
|
+
contact
|
|
10
|
+
details
|
|
11
|
+
estimate_id
|
|
12
|
+
workflow_id
|
|
13
|
+
document_style_id
|
|
14
|
+
identity_id
|
|
15
|
+
state
|
|
16
|
+
estimate_date
|
|
17
|
+
due_date
|
|
18
|
+
reference
|
|
19
|
+
language
|
|
20
|
+
currency
|
|
21
|
+
exchange_rate
|
|
22
|
+
discount
|
|
23
|
+
original_estimate_id
|
|
24
|
+
show_tax
|
|
25
|
+
sign_online
|
|
26
|
+
sent_at
|
|
27
|
+
accepted_at
|
|
28
|
+
rejected_at
|
|
29
|
+
archived_at
|
|
30
|
+
created_at
|
|
31
|
+
updated_at
|
|
32
|
+
pre_text
|
|
33
|
+
post_text
|
|
34
|
+
total_price_excl_tax
|
|
35
|
+
total_price_excl_tax_base
|
|
36
|
+
total_price_incl_tax
|
|
37
|
+
total_price_incl_tax_base
|
|
38
|
+
url
|
|
39
|
+
custom_fields
|
|
40
|
+
notes
|
|
41
|
+
attachments
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
class Service
|
|
45
|
+
attr_reader :client, :administration_id
|
|
46
|
+
|
|
47
|
+
def initialize(client, administration_id)
|
|
48
|
+
@client = client
|
|
49
|
+
@administration_id = administration_id
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def all
|
|
53
|
+
result = client.get("#{administration_id}/estimates")
|
|
54
|
+
|
|
55
|
+
JSON.parse(result.body).map do |invoice|
|
|
56
|
+
Estimate.new(self, invoice)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Moneybird::Resource
|
|
2
|
+
class FinancialAccount
|
|
3
|
+
include Moneybird::Resource
|
|
4
|
+
extend Moneybird::Resource::ClassMethods
|
|
5
|
+
|
|
6
|
+
has_attributes %i(
|
|
7
|
+
id
|
|
8
|
+
description
|
|
9
|
+
price
|
|
10
|
+
tax_rate_id
|
|
11
|
+
ledger_account_id
|
|
12
|
+
created_at
|
|
13
|
+
updated_at
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
class Service
|
|
17
|
+
attr_reader :client, :administration_id
|
|
18
|
+
|
|
19
|
+
def initialize(client, administration_id)
|
|
20
|
+
@client = client
|
|
21
|
+
@administration_id = administration_id
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def all
|
|
25
|
+
result = client.get("#{administration_id}/financial_accounts")
|
|
26
|
+
|
|
27
|
+
JSON.parse(result.body).map do |invoice|
|
|
28
|
+
FinancialAccount.new(self, invoice)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Moneybird::Resource
|
|
2
|
+
class FinancialMutation
|
|
3
|
+
include Moneybird::Resource
|
|
4
|
+
extend Moneybird::Resource::ClassMethods
|
|
5
|
+
|
|
6
|
+
has_attributes %i(
|
|
7
|
+
id
|
|
8
|
+
description
|
|
9
|
+
price
|
|
10
|
+
tax_rate_id
|
|
11
|
+
ledger_account_id
|
|
12
|
+
created_at
|
|
13
|
+
updated_at
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
class Service
|
|
17
|
+
attr_reader :client, :administration_id
|
|
18
|
+
|
|
19
|
+
def initialize(client, administration_id)
|
|
20
|
+
@client = client
|
|
21
|
+
@administration_id = administration_id
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def all
|
|
25
|
+
result = client.get("#{administration_id}/financial_mutations")
|
|
26
|
+
|
|
27
|
+
JSON.parse(result.body).map do |invoice|
|
|
28
|
+
FinancialMutation.new(self, invoice)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Moneybird::Resource
|
|
2
|
+
class Identity
|
|
3
|
+
include Moneybird::Resource
|
|
4
|
+
extend Moneybird::Resource::ClassMethods
|
|
5
|
+
|
|
6
|
+
has_attributes %i(
|
|
7
|
+
id
|
|
8
|
+
description
|
|
9
|
+
price
|
|
10
|
+
tax_rate_id
|
|
11
|
+
ledger_account_id
|
|
12
|
+
created_at
|
|
13
|
+
updated_at
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
class Service
|
|
17
|
+
attr_reader :client, :administration_id
|
|
18
|
+
|
|
19
|
+
def initialize(client, administration_id)
|
|
20
|
+
@client = client
|
|
21
|
+
@administration_id = administration_id
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def all
|
|
25
|
+
result = client.get("#{administration_id}/identities")
|
|
26
|
+
|
|
27
|
+
JSON.parse(result.body).map do |invoice|
|
|
28
|
+
Identity.new(self, invoice)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Moneybird::Resource
|
|
2
|
+
class Product
|
|
3
|
+
include Moneybird::Resource
|
|
4
|
+
extend Moneybird::Resource::ClassMethods
|
|
5
|
+
|
|
6
|
+
has_attributes %i(
|
|
7
|
+
id
|
|
8
|
+
description
|
|
9
|
+
price
|
|
10
|
+
tax_rate_id
|
|
11
|
+
ledger_account_id
|
|
12
|
+
created_at
|
|
13
|
+
updated_at
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
class Service
|
|
17
|
+
attr_reader :client, :administration_id
|
|
18
|
+
|
|
19
|
+
def initialize(client, administration_id)
|
|
20
|
+
@client = client
|
|
21
|
+
@administration_id = administration_id
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def all
|
|
25
|
+
result = client.get("#{administration_id}/products")
|
|
26
|
+
|
|
27
|
+
JSON.parse(result.body).map do |invoice|
|
|
28
|
+
Product.new(self, invoice)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
module Moneybird::Resource
|
|
2
|
+
class RecurringSalesInvoice
|
|
3
|
+
include Moneybird::Resource
|
|
4
|
+
extend Moneybird::Resource::ClassMethods
|
|
5
|
+
|
|
6
|
+
has_attributes %i(
|
|
7
|
+
id
|
|
8
|
+
contact_id
|
|
9
|
+
contact
|
|
10
|
+
workflow_id
|
|
11
|
+
start_date
|
|
12
|
+
invoice_date
|
|
13
|
+
last_date
|
|
14
|
+
active
|
|
15
|
+
payment_conditions
|
|
16
|
+
reference
|
|
17
|
+
language
|
|
18
|
+
currency
|
|
19
|
+
discount
|
|
20
|
+
first_due_interval
|
|
21
|
+
auto_send
|
|
22
|
+
sending_scheduled_at
|
|
23
|
+
sending_scheduled_user_id
|
|
24
|
+
frequency_type
|
|
25
|
+
frequency
|
|
26
|
+
created_at
|
|
27
|
+
updated_at
|
|
28
|
+
prices_are_incl_tax
|
|
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
|
+
notes
|
|
35
|
+
attachments
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
class Service
|
|
39
|
+
attr_reader :client, :administration_id
|
|
40
|
+
|
|
41
|
+
def initialize(client, administration_id)
|
|
42
|
+
@client = client
|
|
43
|
+
@administration_id = administration_id
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def all
|
|
47
|
+
result = client.get("#{administration_id}/recurring_sales_invoices")
|
|
48
|
+
|
|
49
|
+
JSON.parse(result.body).map do |invoice|
|
|
50
|
+
RecurringSalesInvoice.new(self, invoice)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module Moneybird
|
|
1
|
+
module Moneybird::Resource
|
|
2
2
|
class SalesInvoice
|
|
3
3
|
include Moneybird::Resource
|
|
4
4
|
extend Moneybird::Resource::ClassMethods
|
|
@@ -40,15 +40,15 @@ module Moneybird
|
|
|
40
40
|
)
|
|
41
41
|
|
|
42
42
|
class Service
|
|
43
|
-
attr_reader :client, :
|
|
43
|
+
attr_reader :client, :administration_id
|
|
44
44
|
|
|
45
|
-
def initialize(client,
|
|
45
|
+
def initialize(client, administration_id)
|
|
46
46
|
@client = client
|
|
47
|
-
@
|
|
47
|
+
@administration_id = administration_id
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def all
|
|
51
|
-
result = client.get("#{
|
|
51
|
+
result = client.get("#{administration_id}/sales_invoices")
|
|
52
52
|
|
|
53
53
|
JSON.parse(result.body).map do |invoice|
|
|
54
54
|
SalesInvoice.new(self, invoice)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Moneybird::Resource
|
|
2
|
+
class TaxRate
|
|
3
|
+
include Moneybird::Resource
|
|
4
|
+
extend Moneybird::Resource::ClassMethods
|
|
5
|
+
|
|
6
|
+
has_attributes %i(
|
|
7
|
+
id
|
|
8
|
+
name
|
|
9
|
+
percentage
|
|
10
|
+
tax_rate_type
|
|
11
|
+
show_tax
|
|
12
|
+
active
|
|
13
|
+
created_at
|
|
14
|
+
updated_at
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
class Service
|
|
18
|
+
attr_reader :client, :administration_id
|
|
19
|
+
|
|
20
|
+
def initialize(client, administration_id)
|
|
21
|
+
@client = client
|
|
22
|
+
@administration_id = administration_id
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def all
|
|
26
|
+
result = client.get("#{administration_id}/tax_rates")
|
|
27
|
+
|
|
28
|
+
JSON.parse(result.body).map do |invoice|
|
|
29
|
+
TaxRate.new(self, invoice)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Moneybird::Resource
|
|
2
|
+
class Webhook
|
|
3
|
+
include Moneybird::Resource
|
|
4
|
+
extend Moneybird::Resource::ClassMethods
|
|
5
|
+
|
|
6
|
+
has_attributes %i(
|
|
7
|
+
id
|
|
8
|
+
url
|
|
9
|
+
last_http_status
|
|
10
|
+
last_http_body
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
class Service
|
|
14
|
+
attr_reader :client, :administration_id
|
|
15
|
+
|
|
16
|
+
def initialize(client, administration_id)
|
|
17
|
+
@client = client
|
|
18
|
+
@administration_id = administration_id
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def all
|
|
22
|
+
result = client.get("#{administration_id}/webhooks")
|
|
23
|
+
|
|
24
|
+
JSON.parse(result.body).map do |invoice|
|
|
25
|
+
Webhook.new(self, invoice)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Moneybird::Resource
|
|
2
|
+
class Workflow
|
|
3
|
+
include Moneybird::Resource
|
|
4
|
+
extend Moneybird::Resource::ClassMethods
|
|
5
|
+
|
|
6
|
+
has_attributes %i(
|
|
7
|
+
id
|
|
8
|
+
type
|
|
9
|
+
name
|
|
10
|
+
default
|
|
11
|
+
currency
|
|
12
|
+
language
|
|
13
|
+
active
|
|
14
|
+
prices_are_incl_tax
|
|
15
|
+
created_at
|
|
16
|
+
updated_at
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
class Service
|
|
20
|
+
attr_reader :client, :administration_id
|
|
21
|
+
|
|
22
|
+
def initialize(client, administration_id)
|
|
23
|
+
@client = client
|
|
24
|
+
@administration_id = administration_id
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def all
|
|
28
|
+
result = client.get("#{administration_id}/workflows")
|
|
29
|
+
|
|
30
|
+
JSON.parse(result.body).map do |invoice|
|
|
31
|
+
Workflow.new(self, invoice)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Moneybird::Service
|
|
2
|
+
class Administration
|
|
3
|
+
include Moneybird::Traits::FindAll
|
|
4
|
+
|
|
5
|
+
attr_reader :client
|
|
6
|
+
|
|
7
|
+
def initialize(client)
|
|
8
|
+
@client = client
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def resource_class
|
|
12
|
+
Moneybird::Resource::Administration
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def path
|
|
16
|
+
'/administrations'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Moneybird::Service
|
|
2
|
+
class Contact
|
|
3
|
+
include Moneybird::Traits::AdministrationService
|
|
4
|
+
include Moneybird::Traits::FindAll
|
|
5
|
+
|
|
6
|
+
def resource_class
|
|
7
|
+
Moneybird::Resource::Contact
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def path
|
|
11
|
+
"#{administration_id}/contacts"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Moneybird::Service
|
|
2
|
+
class Estimate
|
|
3
|
+
include Moneybird::Traits::AdministrationService
|
|
4
|
+
include Moneybird::Traits::FindAll
|
|
5
|
+
|
|
6
|
+
def resource_class
|
|
7
|
+
Moneybird::Resource::Estimate
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def path
|
|
11
|
+
"#{administration_id}/estimates"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Moneybird::Service
|
|
2
|
+
class Product
|
|
3
|
+
include Moneybird::Traits::AdministrationService
|
|
4
|
+
include Moneybird::Traits::FindAll
|
|
5
|
+
|
|
6
|
+
def resource_class
|
|
7
|
+
Moneybird::Resource::Product
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def path
|
|
11
|
+
"#{administration_id}/products"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Moneybird::Service
|
|
2
|
+
class SalesInvoice
|
|
3
|
+
include Moneybird::Traits::AdministrationService
|
|
4
|
+
include Moneybird::Traits::FindAll
|
|
5
|
+
|
|
6
|
+
def resource_class
|
|
7
|
+
Moneybird::Resource::SalesInvoice
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def path
|
|
11
|
+
"#{administration_id}/sales_invoices"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
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.2.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-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -38,20 +38,6 @@ dependencies:
|
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '10.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rspec
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '3.4'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '3.4'
|
|
55
41
|
description: 'Library to interface with Moneybird API: http://developer.moneybird.com/'
|
|
56
42
|
email:
|
|
57
43
|
- maartenvanvliet@gmail.com
|
|
@@ -60,6 +46,7 @@ extensions: []
|
|
|
60
46
|
extra_rdoc_files: []
|
|
61
47
|
files:
|
|
62
48
|
- ".gitignore"
|
|
49
|
+
- ".kick"
|
|
63
50
|
- ".rspec"
|
|
64
51
|
- ".travis.yml"
|
|
65
52
|
- CODE_OF_CONDUCT.md
|
|
@@ -70,11 +57,27 @@ files:
|
|
|
70
57
|
- bin/console
|
|
71
58
|
- bin/setup
|
|
72
59
|
- lib/moneybird.rb
|
|
73
|
-
- lib/moneybird/administration.rb
|
|
74
60
|
- lib/moneybird/client.rb
|
|
75
|
-
- lib/moneybird/contact.rb
|
|
76
61
|
- lib/moneybird/resource.rb
|
|
77
|
-
- lib/moneybird/
|
|
62
|
+
- lib/moneybird/resource/administration.rb
|
|
63
|
+
- lib/moneybird/resource/contact.rb
|
|
64
|
+
- lib/moneybird/resource/estimate.rb
|
|
65
|
+
- lib/moneybird/resource/financial_account.rb
|
|
66
|
+
- lib/moneybird/resource/financial_mutation.rb
|
|
67
|
+
- lib/moneybird/resource/identity.rb
|
|
68
|
+
- lib/moneybird/resource/product.rb
|
|
69
|
+
- lib/moneybird/resource/recurring_sales_invoice.rb
|
|
70
|
+
- lib/moneybird/resource/sales_invoice.rb
|
|
71
|
+
- lib/moneybird/resource/tax_rate.rb
|
|
72
|
+
- lib/moneybird/resource/webhook.rb
|
|
73
|
+
- lib/moneybird/resource/workflow.rb
|
|
74
|
+
- lib/moneybird/service/administration.rb
|
|
75
|
+
- lib/moneybird/service/contact.rb
|
|
76
|
+
- lib/moneybird/service/estimate.rb
|
|
77
|
+
- lib/moneybird/service/product.rb
|
|
78
|
+
- lib/moneybird/service/sales_invoice.rb
|
|
79
|
+
- lib/moneybird/traits/administration_service.rb
|
|
80
|
+
- lib/moneybird/traits/find_all.rb
|
|
78
81
|
- lib/moneybird/version.rb
|
|
79
82
|
- moneybird.gemspec
|
|
80
83
|
homepage: https://github.com/maartenvanvliet/moneybird
|
|
@@ -102,3 +105,4 @@ signing_key:
|
|
|
102
105
|
specification_version: 4
|
|
103
106
|
summary: Library to interface with Moneybird API
|
|
104
107
|
test_files: []
|
|
108
|
+
has_rdoc:
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
module Moneybird
|
|
2
|
-
class Administration
|
|
3
|
-
include Moneybird::Resource
|
|
4
|
-
extend Moneybird::Resource::ClassMethods
|
|
5
|
-
|
|
6
|
-
has_attributes %i(
|
|
7
|
-
id
|
|
8
|
-
name
|
|
9
|
-
language
|
|
10
|
-
currency
|
|
11
|
-
country
|
|
12
|
-
time_zone
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
def sales_invoices
|
|
16
|
-
Moneybird::SalesInvoice::Service.new(@client, id).all
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def contacts
|
|
20
|
-
Moneybird::Contact::Service.new(@client, id).all
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
class Service
|
|
24
|
-
attr_reader :client
|
|
25
|
-
|
|
26
|
-
def initialize(client)
|
|
27
|
-
@client = client
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def all
|
|
31
|
-
result = client.get('/administrations')
|
|
32
|
-
|
|
33
|
-
JSON.parse(result.body).map do |administration|
|
|
34
|
-
Administration.new(client, administration)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|