billomat 0.1.5 → 0.1.6

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
- SHA1:
3
- metadata.gz: a9927c08a163741acfca0254cf29d44d4f33ed33
4
- data.tar.gz: 9b0d59d29a27058d007c5acb47b26f7871f70abc
2
+ SHA256:
3
+ metadata.gz: f45599f6cc7b2c78849f97556c4420e757fdf05f7c2556d78c519cf6ae2410f3
4
+ data.tar.gz: e9d465ffa1069c9cedb125a8f03ac15b5f47bebd72e7b606c2385d32d6cca8ff
5
5
  SHA512:
6
- metadata.gz: d7d52189de2293ad19315636835f683501669328fe00c41b6feb07718b48114a3a4671259808cbc8a38dcd26616242eaa2684dae9d9743fcb3a84a591fe59f28
7
- data.tar.gz: 2b9184c6087ccb9e81eee312c86a37a2ccc119e583f4dcaa91b39045d70b29e228147e3c0aa37331abd5aa699f294c9ee3925a1698219a94383d1231e985a6b8
6
+ metadata.gz: 18f1e4f613bc73b4ee1b38fad96cc91430f01387950f32982edc27d2529108834f4d9425070c60df440a86d337007e77c21a3738a7c1b74586948a78f4e02237
7
+ data.tar.gz: 723a5490133704e97565d2d4b515a4273c78ce2b3a913dfb7f2c0d972343c568234c283f5cc78e446352db1e9f0647ee2b2a4da9c81eadb6381bec3e8d94a6c8
data/.editorconfig ADDED
@@ -0,0 +1,30 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = true
14
+
15
+ [*.json]
16
+ indent_style = space
17
+ indent_size = 2
18
+
19
+ [*.yml]
20
+ indent_style = space
21
+ indent_size = 2
22
+
23
+ [Makefile]
24
+ trim_trailing_whitespace = true
25
+ indent_style = tab
26
+ indent_size = 4
27
+
28
+ [*.sh]
29
+ indent_style = space
30
+ indent_size = 2
data/.simplecov ADDED
@@ -0,0 +1,3 @@
1
+ SimpleCov.start 'test_frameworks' do
2
+ add_filter '/vendor/bundle/'
3
+ end
data/.travis.yml CHANGED
@@ -1,14 +1,18 @@
1
+ sudo: false
2
+
1
3
  env:
2
4
  global:
3
5
  - CC_TEST_REPORTER_ID=a77802032cccc178727a1df1ff1f283a8255959f9a175f20b73b8231ca35da2f
4
- sudo: false
6
+
5
7
  language: ruby
6
8
  rvm:
7
- - 2.0
8
- - 2.1
9
- - 2.2
10
- - 2.3
9
+ - 2.5
11
10
  - 2.4
11
+ - 2.3
12
+ - 2.2
13
+ - 2.1
14
+ - 2.0
15
+
12
16
  before_install: gem install bundler -v 1.15.1
13
17
  before_script:
14
18
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
data/README.md CHANGED
@@ -4,8 +4,17 @@
4
4
  [![Gem Version](https://badge.fury.io/rb/billomat.svg)](https://badge.fury.io/rb/billomat)
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/49baf848f42a2e5b95db/maintainability)](https://codeclimate.com/github/hausgold/billomat/maintainability)
6
6
  [![Test Coverage](https://api.codeclimate.com/v1/badges/49baf848f42a2e5b95db/test_coverage)](https://codeclimate.com/github/hausgold/billomat/test_coverage)
7
+ [![API docs](https://img.shields.io/badge/docs-API-blue.svg)](https://www.rubydoc.info/gems/billomat)
7
8
 
8
- This gem provides a Ruby API for [billomat.com](https://billomat.com) - an online accounting service.
9
+ This gem provides a Ruby API for [billomat.com](https://billomat.com) - an
10
+ online accounting service.
11
+
12
+ - [Installation](#installation)
13
+ - [Usage](#usage)
14
+ - [Configuration](#configuration)
15
+ - [Basic usage](#basic-usage)
16
+ - [Development](#development)
17
+ - [Contributing](#contributing)
9
18
 
10
19
  ## Installation
11
20
 
@@ -37,9 +46,18 @@ or inside an initializer.
37
46
 
38
47
  ```ruby
39
48
  Billomat.configure do |config|
40
- config.subdomain = 'example' # Subdomain, e.g. example.billomat.net
41
- config.api_key = '4aefdc...' # API key
42
- config.timeout = 5 # timeout in seconds
49
+ # Subdomain, e.g. example.billomat.net
50
+ config.subdomain = 'example'
51
+ # API key
52
+ config.api_key = '4aefdc...'
53
+ # timeout in seconds
54
+ config.timeout = 5
55
+
56
+ # You can also configure a registerd app to increase your
57
+ # API call limit as described here:
58
+ # https://www.billomat.com/en/api/basics/rate-limiting/
59
+ config.app_id = '12345'
60
+ config.app_secret = 'c3df...'
43
61
  end
44
62
  ```
45
63
 
@@ -67,17 +85,19 @@ client.delete
67
85
  => true
68
86
  ```
69
87
 
70
- ### Documentation
71
-
72
- The RubyDoc is available [here](http://www.rubydoc.info/gems/billomat).
73
-
74
-
75
88
  ## Development
76
89
 
77
- 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.
90
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
91
+ `rake spec` to run the tests. You can also run `bin/console` for an interactive
92
+ prompt that will allow you to experiment.
78
93
 
79
- 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).
94
+ To install this gem onto your local machine, run `bundle exec rake install`. To
95
+ release a new version, update the version number in `version.rb`, and then run
96
+ `bundle exec rake release`, which will create a git tag for the version, push
97
+ git commits and tags, and push the `.gem` file to
98
+ [rubygems.org](https://rubygems.org).
80
99
 
81
100
  ## Contributing
82
101
 
83
- Bug reports and pull requests are welcome on GitHub at https://github.com/hausgold/billomat.
102
+ Bug reports and pull requests are welcome on GitHub at
103
+ https://github.com/hausgold/billomat.
data/billomat.gemspec CHANGED
@@ -1,40 +1,43 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "billomat/version"
5
+ require 'billomat/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "billomat"
8
+ spec.name = 'billomat'
8
9
  spec.version = Billomat::VERSION
9
10
  spec.licenses = ['MIT']
10
- spec.authors = ["Henning Vogt"]
11
- spec.email = ["henning.vogt@hausgold.de"]
11
+ spec.authors = ['Henning Vogt']
12
+ spec.email = ['henning.vogt@hausgold.de']
12
13
 
13
- spec.summary = %q{Wrapper for the Billomat API}
14
- spec.homepage = "https://github.com/hausgold/billomat"
14
+ spec.summary = 'Wrapper for the Billomat API'
15
+ spec.homepage = 'https://github.com/hausgold/billomat'
15
16
 
16
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
- # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the
18
+ # 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing
20
+ # to any host.
18
21
  if spec.respond_to?(:metadata)
19
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
23
  else
21
- raise "RubyGems 2.0 or newer is required to protect against " \
22
- "public gem pushes."
24
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
25
+ 'public gem pushes.'
23
26
  end
24
27
 
25
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
29
  f.match(%r{^(test|spec|features)/})
27
30
  end
28
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
- spec.require_paths = ["lib"]
32
+ spec.require_paths = ['lib']
30
33
 
31
34
  spec.required_ruby_version = '>= 2.0'
32
35
 
33
36
  spec.add_dependency 'rest-client', '~> 2.0', '>= 2.0.2'
34
37
 
35
- spec.add_development_dependency "bundler", "~> 1.15"
36
- spec.add_development_dependency "rake", "~> 10.0"
37
- spec.add_development_dependency "rspec", "~> 3.0"
38
- spec.add_development_dependency "simplecov", "~> 0.15"
39
- spec.add_development_dependency "pry", "~> 0.11"
38
+ spec.add_development_dependency 'bundler', '~> 1.15'
39
+ spec.add_development_dependency 'pry', '~> 0.11'
40
+ spec.add_development_dependency 'rake', '~> 10.0'
41
+ spec.add_development_dependency 'rspec', '~> 3.0'
42
+ spec.add_development_dependency 'simplecov', '~> 0.15'
40
43
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Billomat
4
4
  class Configuration
5
- attr_accessor :api_key, :subdomain, :timeout
5
+ attr_accessor :api_key, :subdomain, :timeout, :app_id, :app_secret
6
6
  end
7
7
  end
@@ -33,18 +33,22 @@ module Billomat
33
33
  # Executes the API call
34
34
  # @return [Hash] The response body
35
35
  def run
36
- resp = RestClient::Request.execute(
36
+ resp = response
37
+
38
+ raise GatewayError, resp.body if resp.code > 299
39
+ return nil if resp.body.empty?
40
+
41
+ JSON.parse(resp.body)
42
+ end
43
+
44
+ def response
45
+ RestClient::Request.execute(
37
46
  method: method,
38
47
  url: url,
39
48
  timeout: timeout,
40
49
  headers: headers,
41
50
  payload: body.to_json
42
51
  )
43
-
44
- raise GatewayError, resp.body if resp.code > 299
45
- return nil if resp.body.empty?
46
-
47
- JSON.parse(resp.body)
48
52
  end
49
53
 
50
54
  # @return [String] The complete URL for the request
@@ -62,11 +66,15 @@ module Billomat
62
66
  {
63
67
  'Accept' => 'application/json',
64
68
  'Content-Type' => 'application/json',
65
- 'X-BillomatApiKey' => config.api_key
66
- }
69
+ 'X-BillomatApiKey' => config.api_key,
70
+ 'X-AppId' => config.app_id,
71
+ 'X-AppSecret' => config.app_secret
72
+ }.reject { |_, val| val.nil? }
67
73
  end
68
74
 
69
75
  # @return [Billomat::Configuration] The global gem configuration
76
+ #
77
+ # :reek:UtilityFunction because it's a shorthand
70
78
  def config
71
79
  Billomat.configuration
72
80
  end
@@ -98,7 +98,7 @@ module Billomat
98
98
  # Returns the object with the right JSON structure
99
99
  #
100
100
  # @return [Hash] The objects data
101
- def as_json(options = nil)
101
+ def as_json(_options = nil)
102
102
  @data.to_h
103
103
  end
104
104
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Billomat
4
- VERSION = "0.1.5"
4
+ VERSION = '0.1.6'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: billomat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Vogt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-14 00:00:00.000000000 Z
11
+ date: 2018-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -45,61 +45,61 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.15'
47
47
  - !ruby/object:Gem::Dependency
48
- name: rake
48
+ name: pry
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '10.0'
53
+ version: '0.11'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '10.0'
60
+ version: '0.11'
61
61
  - !ruby/object:Gem::Dependency
62
- name: rspec
62
+ name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '3.0'
67
+ version: '10.0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '3.0'
74
+ version: '10.0'
75
75
  - !ruby/object:Gem::Dependency
76
- name: simplecov
76
+ name: rspec
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0.15'
81
+ version: '3.0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '0.15'
88
+ version: '3.0'
89
89
  - !ruby/object:Gem::Dependency
90
- name: pry
90
+ name: simplecov
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '0.11'
95
+ version: '0.15'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '0.11'
102
+ version: '0.15'
103
103
  description:
104
104
  email:
105
105
  - henning.vogt@hausgold.de
@@ -107,8 +107,10 @@ executables: []
107
107
  extensions: []
108
108
  extra_rdoc_files: []
109
109
  files:
110
+ - ".editorconfig"
110
111
  - ".gitignore"
111
112
  - ".rspec"
113
+ - ".simplecov"
112
114
  - ".travis.yml"
113
115
  - Gemfile
114
116
  - LICENSE
@@ -159,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
161
  version: '0'
160
162
  requirements: []
161
163
  rubyforge_project:
162
- rubygems_version: 2.6.11
164
+ rubygems_version: 2.7.6
163
165
  signing_key:
164
166
  specification_version: 4
165
167
  summary: Wrapper for the Billomat API