billogram 0.3.6 → 0.4.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/README.md +12 -12
- data/lib/billogram.rb +19 -13
- data/lib/billogram/relation.rb +27 -0
- data/lib/billogram/relation_builder.rb +16 -20
- data/lib/billogram/resource.rb +5 -5
- data/lib/billogram/resources/address.rb +2 -1
- data/lib/billogram/resources/bookkeeping.rb +8 -1
- data/lib/billogram/resources/customer.rb +3 -2
- data/lib/billogram/resources/domestic_bank_account.rb +5 -0
- data/lib/billogram/resources/event.rb +1 -1
- data/lib/billogram/resources/international_bank_account.rb +5 -0
- data/lib/billogram/resources/invoice.rb +2 -2
- data/lib/billogram/resources/invoice_defaults.rb +6 -0
- data/lib/billogram/resources/payment.rb +8 -0
- data/lib/billogram/resources/settings.rb +13 -0
- data/lib/billogram/resources/tax.rb +5 -0
- data/lib/billogram/version.rb +1 -1
- metadata +9 -4
- data/lib/billogram/inflections.rb +0 -5
- data/lib/billogram/resources/delivery_address.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d7211264da1c2a244ae49fe823f3a40a2a18e98
|
4
|
+
data.tar.gz: 9d66bdce3035c05061059e04fa1361d44722bb54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6837655055e15ddb79db3decf6e7282b5fc61135e8af8120c8c0d366b57884f0e3e426e85e5f5b07789dc4fc383e695d79be1373531974ddb868825d1cdca6d2
|
7
|
+
data.tar.gz: 361595e478a07938f8ea6d94269d22da334e0eefd3b715d566a0ffeaff2e86c524c7c6cd4d2e8842734c26935e6efecd8f930b6612d5c0d7bcb31e80ae0586a0
|
data/README.md
CHANGED
@@ -22,20 +22,20 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
TODO: Write usage instructions here
|
26
26
|
|
27
|
-
|
28
|
-
Billogram.configure do |config|
|
29
|
-
config.username = '6012-qJzHT0qU'
|
30
|
-
config.password = '55105e0460d5844274dc8f7070fc0a41'
|
31
|
-
config.base_uri = "https://sandbox.billogram.com/api/v2/"
|
32
|
-
end
|
27
|
+
## Development
|
33
28
|
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
34
30
|
|
35
|
-
|
36
|
-
````
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
37
32
|
|
38
|
-
|
39
|
-
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/billogram.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
40
41
|
|
41
|
-
```
|
data/lib/billogram.rb
CHANGED
@@ -1,21 +1,27 @@
|
|
1
1
|
require "httparty"
|
2
2
|
require "billogram/client"
|
3
3
|
require "billogram/error"
|
4
|
+
require "billogram/relation"
|
4
5
|
require "billogram/relation_builder"
|
5
6
|
require "billogram/resource"
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
7
|
+
require "billogram/resources/address"
|
8
|
+
require "billogram/resources/bookkeeping"
|
9
|
+
require "billogram/resources/callbacks"
|
10
|
+
require "billogram/resources/contact"
|
11
|
+
require "billogram/resources/customer"
|
12
|
+
require "billogram/resources/data"
|
13
|
+
require "billogram/resources/detailed_sums"
|
14
|
+
require "billogram/resources/domestic_bank_account"
|
15
|
+
require "billogram/resources/event"
|
16
|
+
require "billogram/resources/info"
|
17
|
+
require "billogram/resources/international_bank_account"
|
18
|
+
require "billogram/resources/invoice"
|
19
|
+
require "billogram/resources/invoice_defaults"
|
20
|
+
require "billogram/resources/item"
|
21
|
+
require "billogram/resources/regional_sweden"
|
22
|
+
require "billogram/resources/payment"
|
23
|
+
require "billogram/resources/settings"
|
24
|
+
require "billogram/resources/tax"
|
19
25
|
require "billogram/version"
|
20
26
|
|
21
27
|
require "billogram/inflections"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Billogram
|
2
|
+
class Relation
|
3
|
+
attr_reader :name, :type, :class_override
|
4
|
+
|
5
|
+
def initialize(name, type, class_override: nil)
|
6
|
+
@name = name
|
7
|
+
@type = type
|
8
|
+
@class_override = class_override
|
9
|
+
end
|
10
|
+
|
11
|
+
def relation_class
|
12
|
+
"Billogram::#{class_override || class_name}".constantize
|
13
|
+
end
|
14
|
+
|
15
|
+
def class_name
|
16
|
+
@class_name ||= send("class_name_for_#{type}").classify
|
17
|
+
end
|
18
|
+
|
19
|
+
def class_name_for_one
|
20
|
+
name.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def class_name_for_many
|
24
|
+
name.to_s.singularize
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -8,38 +8,34 @@ module Billogram
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call
|
11
|
-
resource_relations.each do |
|
12
|
-
build_relation(
|
11
|
+
resource_relations.each do |relation|
|
12
|
+
build_relation(relation)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def relation_attributes(relation_name)
|
23
|
-
attributes.delete(relation_name.to_s)
|
18
|
+
def extract_attributes(relation)
|
19
|
+
attributes.delete(relation.name.to_s)
|
24
20
|
end
|
25
21
|
|
26
22
|
def resource_relations
|
27
23
|
resource.class.relations
|
28
24
|
end
|
29
25
|
|
30
|
-
def build_relation(
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
value = relation_class(name).new(attrs)
|
35
|
-
elsif type == :many
|
36
|
-
singular = name.to_s.singularize
|
37
|
-
value = attrs.map{|item| relation_class(singular).new(item) }
|
38
|
-
end
|
39
|
-
|
40
|
-
resource.public_send("#{name}=", value)
|
41
|
-
end
|
26
|
+
def build_relation(relation)
|
27
|
+
if attrs = extract_attributes(relation)
|
28
|
+
value = send("build_#{relation.type}", relation, attrs)
|
29
|
+
resource.public_send("#{relation.name}=", value)
|
42
30
|
end
|
43
31
|
end
|
32
|
+
|
33
|
+
def build_one(relation, attrs)
|
34
|
+
relation.relation_class.new(attrs)
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_many(relation, attrs)
|
38
|
+
attrs.map{|item| relation.relation_class.new(item) }
|
39
|
+
end
|
44
40
|
end
|
45
41
|
end
|
data/lib/billogram/resource.rb
CHANGED
@@ -6,7 +6,7 @@ module Billogram
|
|
6
6
|
|
7
7
|
class << self
|
8
8
|
def relations
|
9
|
-
@relations ||=
|
9
|
+
@relations ||= []
|
10
10
|
end
|
11
11
|
|
12
12
|
def endpoint(value = nil)
|
@@ -19,7 +19,7 @@ module Billogram
|
|
19
19
|
perform_request("#{endpoint}", :get, query)
|
20
20
|
end
|
21
21
|
|
22
|
-
def fetch(id)
|
22
|
+
def fetch(id = nil)
|
23
23
|
perform_request("#{endpoint}/#{id}", :get)
|
24
24
|
end
|
25
25
|
|
@@ -35,9 +35,9 @@ module Billogram
|
|
35
35
|
Billogram.client.put("#{endpoint}/#{id}")
|
36
36
|
end
|
37
37
|
|
38
|
-
def relation(
|
39
|
-
relations
|
40
|
-
attr_accessor
|
38
|
+
def relation(name, type, class_override: nil)
|
39
|
+
relations << Relation.new(name, type, class_override: class_override)
|
40
|
+
attr_accessor name
|
41
41
|
end
|
42
42
|
|
43
43
|
def build_objects(data)
|
@@ -1,5 +1,12 @@
|
|
1
1
|
module Billogram
|
2
2
|
class Bookkeeping < Resource
|
3
|
-
attr_accessor :income_account, :vat_account
|
3
|
+
attr_accessor :income_account, :vat_account, :income_account_for_vat_25,
|
4
|
+
:income_account_for_vat_12, :income_account_for_vat_6,
|
5
|
+
:income_account_for_vat_0, :reversed_vat_account, :vat_account_for_vat_25,
|
6
|
+
:vat_account_for_vat_12, :vat_account_for_vat_6, :account_receivable_account,
|
7
|
+
:client_funds_account, :banking_account, :interest_fee_account,
|
8
|
+
:reminder_fee_account, :rounding_account, :factoring_receivable_account
|
9
|
+
|
10
|
+
relation :regional_sweden, :one
|
4
11
|
end
|
5
12
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Billogram
|
2
2
|
class Customer < Resource
|
3
|
-
attr_accessor :customer_no, :name, :notes, :org_no, :vat_no, :created_at,
|
3
|
+
attr_accessor :customer_no, :name, :notes, :org_no, :vat_no, :created_at,
|
4
|
+
:updated_at, :company_type
|
4
5
|
|
5
6
|
relation :address, :one
|
6
7
|
relation :contact, :one
|
7
|
-
relation :delivery_address, :one
|
8
|
+
relation :delivery_address, :one, class_override: "Address"
|
8
9
|
end
|
9
10
|
end
|
@@ -12,8 +12,8 @@ module Billogram
|
|
12
12
|
relation :info, :one
|
13
13
|
relation :customer, :one
|
14
14
|
relation :regional_sweden, :one
|
15
|
-
relation :callbacks, :one
|
16
|
-
relation :detailed_sums, :one
|
15
|
+
relation :callbacks, :one, class_override: "Callbacks"
|
16
|
+
relation :detailed_sums, :one, class_override: "DetailedSums"
|
17
17
|
|
18
18
|
relation :items, :many
|
19
19
|
relation :events, :many
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Billogram
|
2
|
+
class Settings < Resource
|
3
|
+
|
4
|
+
attr_accessor :name, :org_no
|
5
|
+
|
6
|
+
relation :contact, :one
|
7
|
+
relation :address, :one
|
8
|
+
relation :payment, :one
|
9
|
+
relation :tax, :one
|
10
|
+
relation :bookkeeping, :one
|
11
|
+
relation :invoices, :one, class_override: "InvoiceDefaults"
|
12
|
+
end
|
13
|
+
end
|
data/lib/billogram/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: billogram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Birman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -143,7 +143,7 @@ files:
|
|
143
143
|
- lib/billogram.rb
|
144
144
|
- lib/billogram/client.rb
|
145
145
|
- lib/billogram/error.rb
|
146
|
-
- lib/billogram/
|
146
|
+
- lib/billogram/relation.rb
|
147
147
|
- lib/billogram/relation_builder.rb
|
148
148
|
- lib/billogram/resource.rb
|
149
149
|
- lib/billogram/resources/address.rb
|
@@ -152,13 +152,18 @@ files:
|
|
152
152
|
- lib/billogram/resources/contact.rb
|
153
153
|
- lib/billogram/resources/customer.rb
|
154
154
|
- lib/billogram/resources/data.rb
|
155
|
-
- lib/billogram/resources/delivery_address.rb
|
156
155
|
- lib/billogram/resources/detailed_sums.rb
|
156
|
+
- lib/billogram/resources/domestic_bank_account.rb
|
157
157
|
- lib/billogram/resources/event.rb
|
158
158
|
- lib/billogram/resources/info.rb
|
159
|
+
- lib/billogram/resources/international_bank_account.rb
|
159
160
|
- lib/billogram/resources/invoice.rb
|
161
|
+
- lib/billogram/resources/invoice_defaults.rb
|
160
162
|
- lib/billogram/resources/item.rb
|
163
|
+
- lib/billogram/resources/payment.rb
|
161
164
|
- lib/billogram/resources/regional_sweden.rb
|
165
|
+
- lib/billogram/resources/settings.rb
|
166
|
+
- lib/billogram/resources/tax.rb
|
162
167
|
- lib/billogram/version.rb
|
163
168
|
homepage: http://github.com/mbirman/billogram
|
164
169
|
licenses:
|