billogram 0.0.1 → 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/.gitignore +0 -8
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/LICENSE.txt +17 -18
- data/README.md +31 -15
- data/Rakefile +6 -9
- data/billogram.gemspec +8 -12
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/billogram.rb +21 -14
- data/lib/billogram/client.rb +5 -13
- data/lib/billogram/relation_builder.rb +55 -0
- data/lib/billogram/resource.rb +33 -42
- data/lib/billogram/resources/address.rb +5 -0
- data/lib/billogram/resources/bookkeeping.rb +5 -0
- data/lib/billogram/resources/callback.rb +8 -0
- data/lib/billogram/resources/contact.rb +5 -0
- data/lib/billogram/resources/customer.rb +9 -0
- data/lib/billogram/resources/data.rb +9 -0
- data/lib/billogram/resources/delivery_address.rb +5 -0
- data/lib/billogram/resources/event.rb +9 -0
- data/lib/billogram/resources/info.rb +6 -0
- data/lib/billogram/resources/invoice.rb +15 -2
- data/lib/billogram/resources/item.rb +8 -0
- data/lib/billogram/resources/regional_sweden.rb +5 -0
- data/lib/billogram/version.rb +1 -1
- metadata +27 -71
- data/test/billogram_test.rb +0 -26
- data/test/fakeweb_helper.rb +0 -31
- data/test/resource_test.rb +0 -32
- data/test/resources/invoice_test.rb +0 -17
- data/test/stubs/errors/403 +0 -9
- data/test/stubs/errors/404 +0 -9
- data/test/stubs/invoice/index +0 -54
- data/test/stubs/invoice/show +0 -125
- data/test/test_helper.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 413126d96eb6392012e781f51b6e55ee2aa96caa
|
4
|
+
data.tar.gz: 4b6ade05a3d41a5f93d3e6fb117b1e6bf02b1a3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd39f9925577645dce7f92eadb6e6fdc37cd30b07df889fb9f1fd4b777d6372954ab0a9f9d9c33a430c3bb2347ea12ff9f119b6556d1c63ff3bd21f87938e0d8
|
7
|
+
data.tar.gz: ca621f3971aa723a343c3188576bbdbdabffbc126d2dd0d01e987c60990acd0711373c616089de46d4eddf93777c798aa3a0a4bba875b90655bbaa1cb72bbe10
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/LICENSE.txt
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
3
|
+
Copyright (c) 2015 Mark
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
the following conditions:
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
12
11
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
15
14
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OF
|
22
|
-
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,25 +1,41 @@
|
|
1
1
|
# Billogram
|
2
2
|
|
3
|
-
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/billogram`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
4
6
|
|
5
7
|
## Installation
|
6
|
-
$ gem install billogram
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'billogram'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install billogram
|
14
22
|
|
15
23
|
## Usage
|
16
|
-
|
17
|
-
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
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.
|
30
|
+
|
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).
|
18
32
|
|
19
33
|
## Contributing
|
20
34
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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).
|
41
|
+
|
data/Rakefile
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
test.pattern = 'test/**/*_test.rb'
|
8
|
-
test.verbose = true
|
9
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|
data/billogram.gemspec
CHANGED
@@ -8,22 +8,18 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Billogram::VERSION
|
9
9
|
spec.authors = ["Mark Birman"]
|
10
10
|
spec.email = ["birmanmark@gmail.com"]
|
11
|
-
|
12
|
-
spec.
|
13
|
-
spec.homepage = ""
|
11
|
+
|
12
|
+
spec.summary = %q{Simple ruby wrapper over Billogram API}
|
13
|
+
spec.homepage = "http://github.com/mbirman/billogram"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.
|
18
|
-
spec.
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_development_dependency "
|
24
|
-
spec.add_development_dependency "fakeweb", ["~> 1.3"]
|
25
|
-
|
23
|
+
spec.add_development_dependency "rspec"
|
26
24
|
spec.add_dependency "httparty"
|
27
|
-
spec.add_dependency "json"
|
28
|
-
spec.add_dependency "hashie"
|
29
25
|
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "billogram"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/billogram.rb
CHANGED
@@ -1,24 +1,31 @@
|
|
1
1
|
require "httparty"
|
2
|
-
require "
|
3
|
-
require "
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
require "billogram/client"
|
3
|
+
require "billogram/relation_builder"
|
4
|
+
require "billogram/resource"
|
5
|
+
require 'billogram/resources/address'
|
6
|
+
require 'billogram/resources/bookkeeping'
|
7
|
+
require 'billogram/resources/callback'
|
8
|
+
require 'billogram/resources/contact'
|
9
|
+
require 'billogram/resources/customer'
|
10
|
+
require 'billogram/resources/data'
|
11
|
+
require 'billogram/resources/delivery_address'
|
12
|
+
require 'billogram/resources/event'
|
13
|
+
require 'billogram/resources/info'
|
14
|
+
require 'billogram/resources/invoice'
|
15
|
+
require 'billogram/resources/item'
|
16
|
+
require 'billogram/resources/regional_sweden'
|
17
|
+
require "billogram/version"
|
8
18
|
|
9
19
|
module Billogram
|
10
|
-
CONFIG_KEYS = [:api_key, :api_user, :base_url].freeze
|
11
|
-
|
12
20
|
class << self
|
13
|
-
attr_accessor
|
21
|
+
attr_accessor :username, :password, :base_uri
|
14
22
|
|
15
|
-
def
|
16
|
-
|
17
|
-
self
|
23
|
+
def client
|
24
|
+
@client ||= Client.new(username, password, base_uri)
|
18
25
|
end
|
19
26
|
|
20
|
-
def
|
21
|
-
|
27
|
+
def configure
|
28
|
+
yield self if block_given?
|
22
29
|
end
|
23
30
|
end
|
24
31
|
end
|
data/lib/billogram/client.rb
CHANGED
@@ -1,22 +1,14 @@
|
|
1
1
|
module Billogram
|
2
|
-
# https://github.com/lendai/billogram-api-clients/tree/master/ruby
|
3
2
|
class Client
|
4
3
|
include HTTParty
|
5
|
-
extend Forwardable
|
6
|
-
|
7
|
-
HEADERS = {
|
8
|
-
"Accept" => "application/json",
|
9
|
-
"Content-Type" => "application/json"
|
10
|
-
}
|
11
|
-
|
12
|
-
headers HEADERS
|
13
4
|
format :json
|
14
5
|
|
15
|
-
|
6
|
+
def initialize(username, password, base_uri)
|
7
|
+
self.class.default_options.merge!(base_uri: base_uri, basic_auth: {username: username, password: password})
|
8
|
+
end
|
16
9
|
|
17
|
-
def
|
18
|
-
self.class.
|
19
|
-
self.class.basic_auth username, password
|
10
|
+
def get(*args)
|
11
|
+
self.class.get(*args)
|
20
12
|
end
|
21
13
|
end
|
22
14
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Billogram
|
2
|
+
class RelationBuilder
|
3
|
+
attr_reader :resource, :attributes
|
4
|
+
|
5
|
+
def initialize(resource, attributes)
|
6
|
+
@resource = resource
|
7
|
+
@attributes = attributes
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
resource_relations.each do |type, relation_names|
|
12
|
+
build_relation(type, relation_names)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def relation_class(relation_name)
|
19
|
+
Object.const_get("Billogram::#{relation_name.to_s.split('_').map(&:capitalize).join()}")
|
20
|
+
end
|
21
|
+
|
22
|
+
def relation_attributes(relation_name)
|
23
|
+
attributes.delete(relation_name.to_s)
|
24
|
+
end
|
25
|
+
|
26
|
+
def resource_relations
|
27
|
+
resource.class.relations
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_relation(type, relation_names)
|
31
|
+
relation_names.each do |name|
|
32
|
+
if type == :one
|
33
|
+
build_one_relation(name)
|
34
|
+
elsif type == :many
|
35
|
+
build_many_relation(name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def build_one_relation(name)
|
41
|
+
if attrs = relation_attributes(name)
|
42
|
+
value = relation_class(name).new attrs
|
43
|
+
resource.instance_variable_set("@#{name}", value)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_many_relation(name)
|
48
|
+
if attrs = relation_attributes(name)
|
49
|
+
singular = name[0..name.length-2]
|
50
|
+
value = attrs.map{|item| relation_class(singular).new(item) }
|
51
|
+
resource.instance_variable_set("@#{name}", value)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/billogram/resource.rb
CHANGED
@@ -1,61 +1,52 @@
|
|
1
1
|
module Billogram
|
2
2
|
class Resource
|
3
|
+
attr_reader :data
|
4
|
+
|
5
|
+
DEFAULT_OPTIONS = { page: 1, page_size: 2 }
|
6
|
+
|
3
7
|
class << self
|
4
|
-
|
8
|
+
def relations
|
9
|
+
@relations ||= { one: Set.new, many: Set.new }
|
10
|
+
end
|
5
11
|
|
6
|
-
def endpoint
|
7
|
-
@endpoint
|
12
|
+
def endpoint(value = nil)
|
13
|
+
@endpoint = value if value
|
14
|
+
@endpoint || name.demodulize.underscore.pluralize
|
8
15
|
end
|
9
16
|
|
10
|
-
def
|
11
|
-
|
17
|
+
def search(options = {})
|
18
|
+
query = DEFAULT_OPTIONS.merge(options)
|
19
|
+
response = Billogram.client.get("#{endpoint}", {query: query})
|
20
|
+
parse_response(response.parsed_response["data"])
|
12
21
|
end
|
13
22
|
|
14
|
-
|
23
|
+
def fetch(id)
|
24
|
+
response = Billogram.client.get("#{endpoint}/#{id}")
|
25
|
+
parse_response(response.parsed_response["data"])
|
26
|
+
end
|
15
27
|
|
16
|
-
def
|
17
|
-
|
28
|
+
def parse_response(data)
|
29
|
+
# TODO: refactor, error handling
|
30
|
+
case data
|
31
|
+
when Hash then new(data)
|
32
|
+
when Array then data.map{|item| parse_response(item) }
|
33
|
+
when nil
|
34
|
+
else data
|
35
|
+
end
|
18
36
|
end
|
19
37
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
38
|
+
def relation(relation_name, relation_type = :one)
|
39
|
+
relations[relation_type] << relation_name
|
40
|
+
attr_reader relation_name
|
23
41
|
end
|
24
42
|
end
|
25
43
|
|
26
|
-
attr_reader :attributes
|
27
|
-
|
28
44
|
def initialize(attributes = {})
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
def update(attributes = {})
|
33
|
-
Billogram.client.put("/#{endpoint}/#{id}", attributes)
|
34
|
-
end
|
35
|
-
|
36
|
-
def delete
|
37
|
-
Billogram.client.delete("/#{endpoint}/#{id}")
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def method_missing(method, *args)
|
43
|
-
method_name = method.to_s
|
44
|
-
|
45
|
-
if method_name =~ /(=|\?)$/
|
46
|
-
case $1
|
47
|
-
when '='
|
48
|
-
attributes[$`] = args.first
|
49
|
-
when '?'
|
50
|
-
attributes[$`]
|
51
|
-
end
|
52
|
-
else
|
53
|
-
if attributes.respond_to?(method)
|
54
|
-
attributes[method]
|
55
|
-
else
|
56
|
-
super
|
57
|
-
end
|
45
|
+
Hash(attributes).each do |key, value|
|
46
|
+
instance_variable_set("@#{key}", value) if respond_to?(key)
|
58
47
|
end
|
48
|
+
|
49
|
+
RelationBuilder.new(self, attributes).call
|
59
50
|
end
|
60
51
|
end
|
61
52
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Billogram
|
2
|
+
class Data < Resource
|
3
|
+
attr_accessor :invoice_no, :delivery_method, :letter_id, :amount, :payer_name,
|
4
|
+
:banking_amount, :manual, :reminder_fee, :reminder_count, :interest_rate,
|
5
|
+
:customer_email, :ip, :type, :message, :collector_method, :collector_reference,
|
6
|
+
:factoring_method, :factoring_reference, :sells_for, :sold_for,
|
7
|
+
:total_sum, :remaining_sum, :scanning_central
|
8
|
+
end
|
9
|
+
end
|
@@ -1,6 +1,19 @@
|
|
1
1
|
module Billogram
|
2
|
-
# https://billogram.com/api/documentation#billogram
|
3
2
|
class Invoice < Resource
|
4
|
-
|
3
|
+
endpoint 'billogram'
|
4
|
+
|
5
|
+
attr_accessor :id, :invoice_no, :ocr_number, :invoice_date, :due_date, :due_days,
|
6
|
+
:invoice_fee, :invoice_fee_vat, :reminder_fee, :interest_rate,
|
7
|
+
:interest_fee, :currency, :delivery_method, :state, :url, :flags,
|
8
|
+
:remaining_sum, :total_sum, :rounding_value, :automatic_reminders,
|
9
|
+
:reminder_count, :created_at, :attested_at, :updated_at, :detailed_sums,
|
10
|
+
:attachment
|
11
|
+
|
12
|
+
relation :info, :one
|
13
|
+
relation :customer, :one
|
14
|
+
relation :regional_sweden, :one
|
15
|
+
|
16
|
+
relation :items, :many
|
17
|
+
relation :events, :many
|
5
18
|
end
|
6
19
|
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.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Birman
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: fakeweb
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.3'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.3'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: httparty
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,35 +66,7 @@ dependencies:
|
|
80
66
|
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
|
-
|
84
|
-
name: json
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: hashie
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
description: Ruby wrapper over Billogram API
|
69
|
+
description:
|
112
70
|
email:
|
113
71
|
- birmanmark@gmail.com
|
114
72
|
executables: []
|
@@ -116,26 +74,33 @@ extensions: []
|
|
116
74
|
extra_rdoc_files: []
|
117
75
|
files:
|
118
76
|
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
119
79
|
- Gemfile
|
120
80
|
- LICENSE.txt
|
121
81
|
- README.md
|
122
82
|
- Rakefile
|
123
83
|
- billogram.gemspec
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
124
86
|
- lib/billogram.rb
|
125
87
|
- lib/billogram/client.rb
|
88
|
+
- lib/billogram/relation_builder.rb
|
126
89
|
- lib/billogram/resource.rb
|
90
|
+
- lib/billogram/resources/address.rb
|
91
|
+
- lib/billogram/resources/bookkeeping.rb
|
92
|
+
- lib/billogram/resources/callback.rb
|
93
|
+
- lib/billogram/resources/contact.rb
|
94
|
+
- lib/billogram/resources/customer.rb
|
95
|
+
- lib/billogram/resources/data.rb
|
96
|
+
- lib/billogram/resources/delivery_address.rb
|
97
|
+
- lib/billogram/resources/event.rb
|
98
|
+
- lib/billogram/resources/info.rb
|
127
99
|
- lib/billogram/resources/invoice.rb
|
100
|
+
- lib/billogram/resources/item.rb
|
101
|
+
- lib/billogram/resources/regional_sweden.rb
|
128
102
|
- lib/billogram/version.rb
|
129
|
-
|
130
|
-
- test/fakeweb_helper.rb
|
131
|
-
- test/resource_test.rb
|
132
|
-
- test/resources/invoice_test.rb
|
133
|
-
- test/stubs/errors/403
|
134
|
-
- test/stubs/errors/404
|
135
|
-
- test/stubs/invoice/index
|
136
|
-
- test/stubs/invoice/show
|
137
|
-
- test/test_helper.rb
|
138
|
-
homepage: ''
|
103
|
+
homepage: http://github.com/mbirman/billogram
|
139
104
|
licenses:
|
140
105
|
- MIT
|
141
106
|
metadata: {}
|
@@ -155,17 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
120
|
version: '0'
|
156
121
|
requirements: []
|
157
122
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.4.8
|
159
124
|
signing_key:
|
160
125
|
specification_version: 4
|
161
|
-
summary:
|
162
|
-
test_files:
|
163
|
-
- test/billogram_test.rb
|
164
|
-
- test/fakeweb_helper.rb
|
165
|
-
- test/resource_test.rb
|
166
|
-
- test/resources/invoice_test.rb
|
167
|
-
- test/stubs/errors/403
|
168
|
-
- test/stubs/errors/404
|
169
|
-
- test/stubs/invoice/index
|
170
|
-
- test/stubs/invoice/show
|
171
|
-
- test/test_helper.rb
|
126
|
+
summary: Simple ruby wrapper over Billogram API
|
127
|
+
test_files: []
|
data/test/billogram_test.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Billogram do
|
4
|
-
Billogram::CONFIG_KEYS.each do |method|
|
5
|
-
it "should respond to #{method}" do
|
6
|
-
Billogram.must_respond_to method
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '.configure' do
|
11
|
-
it 'should set values' do
|
12
|
-
Billogram.configure do |config|
|
13
|
-
Billogram::CONFIG_KEYS.each do |method|
|
14
|
-
config.send("#{method}=", method.to_s)
|
15
|
-
Billogram.send(method).must_equal method.to_s
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '.client' do
|
22
|
-
it 'should be instance of Billogram::Client' do
|
23
|
-
Billogram.client.must_be_kind_of Billogram::Client
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/test/fakeweb_helper.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'fakeweb'
|
2
|
-
|
3
|
-
def stub_file(stub)
|
4
|
-
File.join(File.dirname(__FILE__), 'stubs', stub)
|
5
|
-
end
|
6
|
-
|
7
|
-
def fake_it_all
|
8
|
-
FakeWeb.clean_registry
|
9
|
-
|
10
|
-
{
|
11
|
-
# GET URLs
|
12
|
-
:get => {
|
13
|
-
%r{https://\w+:\w+@billogram.com/api/v2/billogram/$} => File.join('invoice', 'index'),
|
14
|
-
%r{https://\w+:\w+@billogram.com/api/v2/billogram/\w+} => File.join('invoice', 'show')
|
15
|
-
},
|
16
|
-
# POST URLs
|
17
|
-
:post => {
|
18
|
-
'https://billogram.com/api/v2/billogram' => File.join('invoice', 'create'),
|
19
|
-
%r{https://billogram.com/api/v2/\w+/command/send} => File.join('invoice', 'send')
|
20
|
-
},
|
21
|
-
# PUT URLs
|
22
|
-
:put => {
|
23
|
-
%r{https://billogram.com/api/v2/\w+} => File.join('invoice', 'update')
|
24
|
-
}
|
25
|
-
}.
|
26
|
-
each do |method, requests|
|
27
|
-
requests.each do |url, response|
|
28
|
-
FakeWeb.register_uri(method, url, :response => stub_file(response))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/test/resource_test.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Billogram::Resource do
|
4
|
-
describe '.endpoint' do
|
5
|
-
it 'should set value' do
|
6
|
-
Billogram::Resource.endpoint = 'test_endpoint'
|
7
|
-
Billogram::Resource.endpoint.must_equal 'test_endpoint'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should return downcased class name by default' do
|
11
|
-
Billogram::Resource.endpoint = nil
|
12
|
-
Billogram::Resource.endpoint.must_equal 'resource'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '.new' do
|
17
|
-
it 'should set attributes' do
|
18
|
-
resource = Billogram::Resource.new({string_attribute: 'test', zero_attribute: 0, integer_attribute: 2, false_attribute: false, nil_attribute: nil})
|
19
|
-
resource.string_attribute.must_equal 'test'
|
20
|
-
resource.zero_attribute.must_equal 0
|
21
|
-
resource.integer_attribute.must_equal 2
|
22
|
-
resource.false_attribute.must_equal false
|
23
|
-
resource.nil_attribute.must_equal nil
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should have setters for attributes' do
|
28
|
-
resource = Billogram::Resource.new({first: 'test'})
|
29
|
-
resource.first = 'first'
|
30
|
-
resource.first.must_equal 'first'
|
31
|
-
end
|
32
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Billogram::Invoice do
|
4
|
-
before(:each) do
|
5
|
-
configure_billogram
|
6
|
-
fake_it_all
|
7
|
-
@billogram = Billogram::Invoice.get('gQjEEZL')
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should return an instance of Billogram::Invoice' do
|
11
|
-
@billogram.must_be_kind_of Billogram::Invoice
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should return id' do
|
15
|
-
@billogram.id.must_equal 'gQjEEZL'
|
16
|
-
end
|
17
|
-
end
|
data/test/stubs/errors/403
DELETED
data/test/stubs/errors/404
DELETED
data/test/stubs/invoice/index
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
HTTP/1.1 200 OK
|
2
|
-
Content-Type: application/json
|
3
|
-
|
4
|
-
{
|
5
|
-
"status":"OK",
|
6
|
-
"meta":{
|
7
|
-
"total_count":171,
|
8
|
-
"total_remaining_sum":"159145.00"
|
9
|
-
},
|
10
|
-
"data":[
|
11
|
-
{
|
12
|
-
"customer":{
|
13
|
-
"name":"Happy customer",
|
14
|
-
"email":null,
|
15
|
-
"org_no":null,
|
16
|
-
"customer_no":5
|
17
|
-
},
|
18
|
-
"due_date":"2014-11-01",
|
19
|
-
"total_sum":3148.0,
|
20
|
-
"created_at":"2014-10-19 21:32:12",
|
21
|
-
"invoice_date":"2014-10-17",
|
22
|
-
"updated_at":"2014-10-19 21:32:12",
|
23
|
-
"currency":"SEK",
|
24
|
-
"state":"Unattested",
|
25
|
-
"remaining_sum":3148.0,
|
26
|
-
"flags":[
|
27
|
-
],
|
28
|
-
"ocr_number":null,
|
29
|
-
"invoice_no":null,
|
30
|
-
"id":"u9PQW3E"
|
31
|
-
},
|
32
|
-
{
|
33
|
-
"customer":{
|
34
|
-
"name":"Systembolaget",
|
35
|
-
"email":"invoice@systembolaget.se",
|
36
|
-
"org_no":"",
|
37
|
-
"customer_no":1
|
38
|
-
},
|
39
|
-
"due_date":"2014-10-15",
|
40
|
-
"total_sum":72269.0,
|
41
|
-
"created_at":"2014-09-15 00:55:22",
|
42
|
-
"invoice_date":"2014-09-15",
|
43
|
-
"updated_at":"2014-09-15 01:07:19",
|
44
|
-
"currency":"SEK",
|
45
|
-
"state":"Unattested",
|
46
|
-
"remaining_sum":72269.0,
|
47
|
-
"flags":[
|
48
|
-
],
|
49
|
-
"ocr_number":null,
|
50
|
-
"invoice_no":null,
|
51
|
-
"id":"EjWs4CP"
|
52
|
-
}
|
53
|
-
]
|
54
|
-
}
|
data/test/stubs/invoice/show
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
HTTP/1.1 200 OK
|
2
|
-
Content-Type: application/json
|
3
|
-
|
4
|
-
{
|
5
|
-
"status":"OK",
|
6
|
-
"data":{
|
7
|
-
"due_days":15,
|
8
|
-
"info":{
|
9
|
-
"reference_number":null,
|
10
|
-
"our_reference":"John Doe",
|
11
|
-
"order_no":"AIB033",
|
12
|
-
"shipping_date":"2014-10-30",
|
13
|
-
"order_date":"2014-10-24",
|
14
|
-
"message":"Thank you!",
|
15
|
-
"delivery_date":"2014-10-30",
|
16
|
-
"your_reference":""
|
17
|
-
},
|
18
|
-
"attested_at":"2014-10-24 07:30:45",
|
19
|
-
"updated_at":"2015-01-23 23:44:17",
|
20
|
-
"currency":"SEK",
|
21
|
-
"detailed_sums":{
|
22
|
-
"credited_sum":0,
|
23
|
-
"net_sum":445,
|
24
|
-
"gross_sum":556.25,
|
25
|
-
"invoice_fee_vat":0,
|
26
|
-
"paid_sum":0,
|
27
|
-
"interest_fee":0,
|
28
|
-
"vat_sum":111.25,
|
29
|
-
"reminder_fee":0,
|
30
|
-
"invoice_fee":0,
|
31
|
-
"rounding":-0.25,
|
32
|
-
"regional_sweden":{
|
33
|
-
"rotavdrag_sum":0
|
34
|
-
},
|
35
|
-
"collector_paid_sum":0,
|
36
|
-
"remaining_sum":556
|
37
|
-
},
|
38
|
-
"id":"gQjEEZL",
|
39
|
-
"reminder_fee":"50",
|
40
|
-
"interest_rate":8.5,
|
41
|
-
"state":"Overdue",
|
42
|
-
"attachment":null,
|
43
|
-
"automatic_reminders":false,
|
44
|
-
"rounding_value":-0.25,
|
45
|
-
"ocr_number":"6409920018890569",
|
46
|
-
"events":[
|
47
|
-
{
|
48
|
-
"type":"BillogramCreated",
|
49
|
-
"created_at":"2014-10-24 07:30:42",
|
50
|
-
"data":null
|
51
|
-
},
|
52
|
-
{
|
53
|
-
"type":"BillogramSent",
|
54
|
-
"created_at":"2014-10-24 07:30:45",
|
55
|
-
"data":{
|
56
|
-
"letter_id":"Tk5NTQzQxNjQ14bccc9e8c0YTAwMjRmMGM3NANc8131024c90a0d24b1fc73",
|
57
|
-
"total_sum":556,
|
58
|
-
"scanning_central":null,
|
59
|
-
"remaining_sum":556,
|
60
|
-
"delivery_method":"Letter",
|
61
|
-
"invoice_no":190
|
62
|
-
}
|
63
|
-
},
|
64
|
-
{
|
65
|
-
"type":"Overdue",
|
66
|
-
"created_at":"2014-11-08 23:00:00",
|
67
|
-
"data":{
|
68
|
-
"remaining_sum":"556.00"
|
69
|
-
}
|
70
|
-
}
|
71
|
-
],
|
72
|
-
"due_date":"2014-11-08",
|
73
|
-
"invoice_fee_vat":0,
|
74
|
-
"invoice_date":"2014-10-24",
|
75
|
-
"reminder_count":0,
|
76
|
-
"interest_fee":0.0,
|
77
|
-
"invoice_no":190,
|
78
|
-
"customer":{
|
79
|
-
"name":"Cool Customer",
|
80
|
-
"vat_no":null,
|
81
|
-
"phone":"+46 40 44 65 787",
|
82
|
-
"customer_no":3,
|
83
|
-
"address":{
|
84
|
-
"city":"",
|
85
|
-
"country":"SE",
|
86
|
-
"attention":"",
|
87
|
-
"zipcode":"62156",
|
88
|
-
"careof":"",
|
89
|
-
"street_address":"Schweitzergr\u00e4nd 10A"
|
90
|
-
},
|
91
|
-
"email":null,
|
92
|
-
"org_no":null
|
93
|
-
},
|
94
|
-
"invoice_fee":0,
|
95
|
-
"url":"https://billogram.com/r/2001905699988640/N9PCC4",
|
96
|
-
"items":[
|
97
|
-
{
|
98
|
-
"count":5.0,
|
99
|
-
"item_no":"110-1",
|
100
|
-
"description":"75cl Bigger Lager 7,5% - Imperial Pilsner - All In Brewing/Toccalmatto",
|
101
|
-
"title":"Bigger Lager 7,5% 75cl",
|
102
|
-
"regional_sweden":{
|
103
|
-
"rotavdrag":false
|
104
|
-
},
|
105
|
-
"price":89.0,
|
106
|
-
"discount":0.0,
|
107
|
-
"unit":"unit",
|
108
|
-
"vat":25
|
109
|
-
}
|
110
|
-
],
|
111
|
-
"created_at":"2014-10-24 07:30:42",
|
112
|
-
"total_sum":556.0,
|
113
|
-
"delivery_method":"Letter",
|
114
|
-
"remaining_sum":556.0,
|
115
|
-
"flags":[
|
116
|
-
|
117
|
-
],
|
118
|
-
"regional_sweden":{
|
119
|
-
"rotavdrag_personal_number":null,
|
120
|
-
"rotavdrag":0,
|
121
|
-
"reversed_vat":null,
|
122
|
-
"rotavdrag_description":null
|
123
|
-
}
|
124
|
-
}
|
125
|
-
}
|
data/test/test_helper.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require './lib/billogram'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'minitest/spec'
|
4
|
-
require 'fakeweb_helper.rb'
|
5
|
-
|
6
|
-
FakeWeb.allow_net_connect = false
|
7
|
-
|
8
|
-
def configure_billogram
|
9
|
-
Billogram.configure do |config|
|
10
|
-
config.base_url = 'https://billogram.com/api/v2/'
|
11
|
-
config.api_user = 'username'
|
12
|
-
config.api_key = 'password'
|
13
|
-
end
|
14
|
-
end
|