billomat 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,11 +3,9 @@
3
3
  require 'uri'
4
4
 
5
5
  module Billomat
6
- ##
7
- # This class provides the possibility to query the resources
6
+ # This class provides the possibility to query the resources.
8
7
  class Search
9
- ##
10
- # Creates a new search object
8
+ # Creates a new search object.
11
9
  #
12
10
  # @param [Class] resource The resource class to be queried
13
11
  # @param [Hash] hash The query
@@ -16,23 +14,22 @@ module Billomat
16
14
  @hash = hash
17
15
  end
18
16
 
19
- # @return [String] The path including the query
17
+ # @return [String] the path including the query
20
18
  def path
21
19
  "#{@resource.base_path}?#{hash_to_query}"
22
20
  end
23
21
 
24
- ##
25
- # Runs the query and calls the gateway
26
- # Currently it will always return an empty array when no query is provided
22
+ # Runs the query and calls the gateway.
23
+ # Currently it will always return an empty array when no query is provided.
27
24
  #
28
25
  # @return [Array<Billomat::Model::Base>]
29
26
  def run
30
- return [] if @hash.reject { |k, v| v.nil? }.empty?
27
+ return [] if @hash.reject { |_k, v| v.nil? }.empty?
28
+
31
29
  to_array(Billomat::Gateway.new(:get, path).run)
32
30
  end
33
31
 
34
- ##
35
- # Corrects the response to always return an array
32
+ # Corrects the response to always return an array.
36
33
  #
37
34
  # @todo Due to a strange API behaviour we have to fix the reponse here.
38
35
  # This may be fixed in a new API version.
@@ -53,21 +50,22 @@ module Billomat
53
50
  end
54
51
  end
55
52
 
56
- # @return [String] The name of the resource
53
+ # @return [String] the name of the resource
57
54
  def name
58
55
  @resource.resource_name
59
56
  end
60
57
 
61
58
  # @param [Hash] resp The response from the gateway
62
- # @return [Integer] The number of records found
59
+ # @return [Integer] the number of records found
63
60
  def count(resp)
64
61
  return 0 if resp.nil?
62
+
65
63
  resp["#{name}s"]['@total'].to_i
66
64
  end
67
65
 
68
66
  private
69
67
 
70
- # @return [String] The query as www encoded string
68
+ # @return [String] the query as www encoded string
71
69
  def hash_to_query
72
70
  URI.encode_www_form(@hash)
73
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Billomat
4
- VERSION = '0.2.0'.freeze
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/billomat.rb CHANGED
@@ -7,28 +7,25 @@ require 'billomat/actions'
7
7
  require 'billomat/search'
8
8
  require 'billomat/gateway'
9
9
 
10
- ##
11
- # An wrapper for the
12
- # <a href="https://billomat.com">Billomat</a>
13
- # API
10
+ # An wrapper for the Billomat API.
14
11
  module Billomat
15
12
  class << self
16
13
  attr_writer :configuration
17
- end
18
14
 
19
- # @return [Billomat::Configuration] The global billomat configuration
20
- def self.configuration
21
- @configuration ||= Billomat::Configuration.new
22
- end
15
+ # @return [Billomat::Configuration] the global billomat configuration
16
+ def configuration
17
+ @configuration ||= Billomat::Configuration.new
18
+ end
23
19
 
24
- # Class method to set and change the global configuration
25
- #
26
- # @example
27
- # Billomat.configure do |config|
28
- # config.subdomain = 'your-business-name'
29
- # config.api_key = 'a3b148a61cb642389b4f9953f6233f20'
30
- # end
31
- def self.configure
32
- yield(configuration)
20
+ # Class method to set and change the global configuration.
21
+ #
22
+ # @example
23
+ # Billomat.configure do |config|
24
+ # config.subdomain = 'your-business-name'
25
+ # config.api_key = 'a3b148a61cb642389b4f9953f6233f20'
26
+ # end
27
+ def configure
28
+ yield(configuration)
29
+ end
33
30
  end
34
31
  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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Vogt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-12 00:00:00.000000000 Z
11
+ date: 2021-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -64,6 +64,26 @@ dependencies:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0.11'
67
+ - !ruby/object:Gem::Dependency
68
+ name: railties
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 4.2.0
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: '6.1'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 4.2.0
84
+ - - "<"
85
+ - !ruby/object:Gem::Version
86
+ version: '6.1'
67
87
  - !ruby/object:Gem::Dependency
68
88
  name: rake
69
89
  requirement: !ruby/object:Gem::Requirement
@@ -92,20 +112,76 @@ dependencies:
92
112
  - - "~>"
93
113
  - !ruby/object:Gem::Version
94
114
  version: '3.0'
115
+ - !ruby/object:Gem::Dependency
116
+ name: rubocop
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: 0.63.1
122
+ type: :development
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - "~>"
127
+ - !ruby/object:Gem::Version
128
+ version: 0.63.1
129
+ - !ruby/object:Gem::Dependency
130
+ name: rubocop-rspec
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - "~>"
134
+ - !ruby/object:Gem::Version
135
+ version: '1.31'
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - "~>"
141
+ - !ruby/object:Gem::Version
142
+ version: '1.31'
95
143
  - !ruby/object:Gem::Dependency
96
144
  name: simplecov
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "<"
148
+ - !ruby/object:Gem::Version
149
+ version: '0.18'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - "<"
155
+ - !ruby/object:Gem::Version
156
+ version: '0.18'
157
+ - !ruby/object:Gem::Dependency
158
+ name: yard
97
159
  requirement: !ruby/object:Gem::Requirement
98
160
  requirements:
99
161
  - - "~>"
100
162
  - !ruby/object:Gem::Version
101
- version: '0.15'
163
+ version: 0.9.18
102
164
  type: :development
103
165
  prerelease: false
104
166
  version_requirements: !ruby/object:Gem::Requirement
105
167
  requirements:
106
168
  - - "~>"
107
169
  - !ruby/object:Gem::Version
108
- version: '0.15'
170
+ version: 0.9.18
171
+ - !ruby/object:Gem::Dependency
172
+ name: yard-activesupport-concern
173
+ requirement: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - "~>"
176
+ - !ruby/object:Gem::Version
177
+ version: 0.0.1
178
+ type: :development
179
+ prerelease: false
180
+ version_requirements: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - "~>"
183
+ - !ruby/object:Gem::Version
184
+ version: 0.0.1
109
185
  description:
110
186
  email:
111
187
  - henning.vogt@hausgold.de
@@ -114,18 +190,29 @@ extensions: []
114
190
  extra_rdoc_files: []
115
191
  files:
116
192
  - ".editorconfig"
193
+ - ".github/workflows/documentation.yml"
194
+ - ".github/workflows/test.yml"
117
195
  - ".gitignore"
118
196
  - ".rspec"
197
+ - ".rubocop.yml"
119
198
  - ".simplecov"
120
- - ".travis.yml"
199
+ - ".yardopts"
200
+ - CHANGELOG.md
201
+ - Dockerfile
202
+ - Envfile
121
203
  - Gemfile
122
204
  - LICENSE
205
+ - Makefile
123
206
  - README.md
124
207
  - Rakefile
125
208
  - billomat.gemspec
126
209
  - bin/console
127
210
  - bin/setup
211
+ - config/docker/.bash_profile
212
+ - config/docker/.bashrc
213
+ - config/docker/.inputrc
128
214
  - doc/assets/project.svg
215
+ - docker-compose.yml
129
216
  - lib/billomat.rb
130
217
  - lib/billomat/actions.rb
131
218
  - lib/billomat/actions/cancel.rb
@@ -139,6 +226,8 @@ files:
139
226
  - lib/billomat/models/base.rb
140
227
  - lib/billomat/models/client.rb
141
228
  - lib/billomat/models/contact.rb
229
+ - lib/billomat/models/credit_note.rb
230
+ - lib/billomat/models/credit_note_item.rb
142
231
  - lib/billomat/models/invoice.rb
143
232
  - lib/billomat/models/invoice_item.rb
144
233
  - lib/billomat/models/invoice_payment.rb
@@ -159,7 +248,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
248
  requirements:
160
249
  - - ">="
161
250
  - !ruby/object:Gem::Version
162
- version: '2.0'
251
+ version: '0'
163
252
  required_rubygems_version: !ruby/object:Gem::Requirement
164
253
  requirements:
165
254
  - - ">="
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- sudo: false
2
- env:
3
- global:
4
- - CC_TEST_REPORTER_ID=0038fa77f81e980be74aed2e240dbcedd853de3a3ea3ff71cbb344e282d284a9
5
- language: ruby
6
- rvm:
7
- - 2.6
8
- - 2.5
9
- - 2.4
10
- - 2.3
11
- before_install: gem install bundler
12
- before_script:
13
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
14
- - chmod +x ./cc-test-reporter
15
- - ./cc-test-reporter before-build
16
- script:
17
- - bundle exec rspec
18
- after_script:
19
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT