superfaktura 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 473f54ead212b9d9d660a1c2beb650d3ce4f0176ce3214203e124bedd041eccd
4
+ data.tar.gz: 411d7b07b54b6d236c220ab9d4c76a0ad26d85484de9630781a005761eddba57
5
+ SHA512:
6
+ metadata.gz: 30da1ba5bd8607d811e7717ccce13702239d8f725ad0546cbdf59f69db16c384c4e1cfc94f215b4c2129fbd03bba03068c86ba774953f849d08aea0e41b60f70
7
+ data.tar.gz: 3efed501e76fe59adf8a510b6a2a3e52d1dccb6ccb880a5bd24c8f93d3b20b3e1420191afe787a7cb6016d229c88d83a2241132ef372190bc250aabdd8dc2277
data/.codeclimate.yml ADDED
@@ -0,0 +1,16 @@
1
+ ---
2
+ engines:
3
+ duplication:
4
+ enabled: true
5
+ config:
6
+ languages:
7
+ - ruby
8
+ fixme:
9
+ enabled: false
10
+ rubocop:
11
+ enabled: false
12
+ ratings:
13
+ paths:
14
+ - "**.rb"
15
+ exclude_paths:
16
+ - spec/
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,54 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+ NewCops: enable
4
+
5
+ Layout/LineLength:
6
+ IgnoredPatterns: ['^#']
7
+ Max: 150
8
+
9
+ Style/FrozenStringLiteralComment:
10
+ Enabled: false
11
+
12
+ Metrics/BlockLength:
13
+ Exclude:
14
+ - 'spec/**/*'
15
+ - 'superfaktura.gemspec'
16
+
17
+ Layout/MultilineOperationIndentation:
18
+ EnforcedStyle: indented
19
+
20
+ Style/OptionalBooleanParameter:
21
+ Enabled: false
22
+
23
+ #Layout/HashAlignment:
24
+ # EnforcedColonStyle:
25
+
26
+ Metrics/AbcSize:
27
+ Max: 25
28
+
29
+ Style/Documentation:
30
+ Enabled: false
31
+
32
+ Layout/FirstArgumentIndentation:
33
+ EnforcedStyle: consistent
34
+
35
+ Metrics/CyclomaticComplexity:
36
+ Max: 10
37
+
38
+ Metrics/PerceivedComplexity:
39
+ Max: 10
40
+
41
+ Metrics/ClassLength:
42
+ Max: 200
43
+
44
+ Metrics/MethodLength:
45
+ Max: 15
46
+
47
+ Layout/MultilineMethodCallIndentation:
48
+ EnforcedStyle: indented_relative_to_receiver
49
+
50
+ Style/EmptyMethod:
51
+ EnforcedStyle: expanded
52
+
53
+ Style/DoubleNegation:
54
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,19 @@
1
+ ---
2
+ sudo: false
3
+ dist: trusty
4
+
5
+ language: ruby
6
+
7
+ cache: bundler
8
+
9
+ notifications:
10
+ email: false
11
+
12
+ rvm:
13
+ - 2.7.2
14
+
15
+ before_install:
16
+ - gem install bundler
17
+
18
+ script:
19
+ - bundle exec rspec --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in superfaktura.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,88 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ superfaktura (0.9.0)
5
+ faraday (~> 1)
6
+ faraday_middleware (~> 1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ast (2.4.2)
14
+ codecov (0.1.21)
15
+ json
16
+ simplecov
17
+ crack (0.4.5)
18
+ rexml
19
+ diff-lcs (1.4.4)
20
+ docile (1.3.5)
21
+ faraday (1.3.0)
22
+ faraday-net_http (~> 1.0)
23
+ multipart-post (>= 1.2, < 3)
24
+ ruby2_keywords
25
+ faraday-net_http (1.0.1)
26
+ faraday_middleware (1.0.0)
27
+ faraday (~> 1.0)
28
+ hashdiff (1.0.1)
29
+ json (2.5.1)
30
+ multipart-post (2.1.1)
31
+ parallel (1.20.1)
32
+ parser (3.0.0.0)
33
+ ast (~> 2.4.1)
34
+ public_suffix (4.0.6)
35
+ rainbow (3.0.0)
36
+ rake (13.0.3)
37
+ regexp_parser (2.1.1)
38
+ rexml (3.2.4)
39
+ rspec (3.10.0)
40
+ rspec-core (~> 3.10.0)
41
+ rspec-expectations (~> 3.10.0)
42
+ rspec-mocks (~> 3.10.0)
43
+ rspec-core (3.10.1)
44
+ rspec-support (~> 3.10.0)
45
+ rspec-expectations (3.10.1)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.10.0)
48
+ rspec-mocks (3.10.2)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.10.0)
51
+ rspec-support (3.10.2)
52
+ rubocop (0.93.1)
53
+ parallel (~> 1.10)
54
+ parser (>= 2.7.1.5)
55
+ rainbow (>= 2.2.2, < 4.0)
56
+ regexp_parser (>= 1.8)
57
+ rexml
58
+ rubocop-ast (>= 0.6.0)
59
+ ruby-progressbar (~> 1.7)
60
+ unicode-display_width (>= 1.4.0, < 2.0)
61
+ rubocop-ast (1.4.1)
62
+ parser (>= 2.7.1.5)
63
+ ruby-progressbar (1.11.0)
64
+ ruby2_keywords (0.0.4)
65
+ simplecov (0.18.5)
66
+ docile (~> 1.1)
67
+ simplecov-html (~> 0.11)
68
+ simplecov-html (0.12.3)
69
+ unicode-display_width (1.7.0)
70
+ webmock (3.9.5)
71
+ addressable (>= 2.3.6)
72
+ crack (>= 0.3.2)
73
+ hashdiff (>= 0.4.0, < 2.0.0)
74
+
75
+ PLATFORMS
76
+ ruby
77
+
78
+ DEPENDENCIES
79
+ codecov (~> 0.1.10)
80
+ rake (~> 13.0)
81
+ rspec (~> 3.6)
82
+ rubocop (~> 0.93.0)
83
+ simplecov (~> 0.18.5)
84
+ superfaktura!
85
+ webmock (~> 3.9.0)
86
+
87
+ BUNDLED WITH
88
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Lubomir Vnenk
4
+
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:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
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 ADDED
@@ -0,0 +1,38 @@
1
+ # Superfaktura
2
+
3
+ Gem for easy integration with http://superfaktura.sk/
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'superfaktura'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install superfaktura
20
+
21
+ ## Usage
22
+
23
+
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/superfaktura.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'superfaktura'
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/changelog.md ADDED
@@ -0,0 +1,4 @@
1
+ # Changelog
2
+
3
+ ## 0.9
4
+ Basic api created
@@ -0,0 +1,23 @@
1
+ require 'json'
2
+ require 'faraday'
3
+ require 'faraday_middleware'
4
+
5
+ require 'superfaktura/version'
6
+ require 'superfaktura/configuration'
7
+ require 'superfaktura/base_api'
8
+ require 'superfaktura/create_invoice'
9
+
10
+ module Superfaktura
11
+ @configuration = Configuration.new
12
+
13
+ def self.config
14
+ @configuration
15
+ end
16
+
17
+ def self.configure
18
+ yield(@configuration)
19
+ end
20
+
21
+ class Error < StandardError
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ module Superfaktura
2
+ class BaseApi
3
+ SUPERFAKTURA_URL = 'https://moja.superfaktura.sk'.freeze
4
+
5
+ def self.client
6
+ Faraday.new(url: SUPERFAKTURA_URL) do |builder|
7
+ builder.request :url_encoded
8
+ builder.request :json
9
+ builder.response :json
10
+
11
+ builder.adapter Faraday.default_adapter
12
+ end
13
+ end
14
+
15
+ def self.request(uri, method = 'POST', payload = nil)
16
+ response = client.public_send(method.downcase.to_sym) do |request|
17
+ request.headers['Authorization'] = "SFAPI email=#{Superfaktura.config.email}&apikey=#{Superfaktura.config.token}"
18
+
19
+ request.url(uri)
20
+ request.body = "data=#{payload.to_json}"
21
+ end
22
+ raise Superfaktura::Error, response.body['error_message'] unless response.body['error'].zero?
23
+
24
+ response.body
25
+ end
26
+
27
+ def self.post(path, payload)
28
+ request(path, 'POST', payload)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,10 @@
1
+ module Superfaktura
2
+ class Configuration
3
+ attr_accessor :email, :token
4
+
5
+ def initialize
6
+ @email = ENV['SUPERFAKTURA_EMAIL']
7
+ @token = ENV['SUPERFAKTURA_TOKEN']
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Superfaktura
2
+ class CreateInvoice < BaseApi
3
+ def self.call(attributes)
4
+ post('/invoices/create', attributes)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Superfaktura
2
+ VERSION = '0.9.0'.freeze
3
+ end
@@ -0,0 +1,38 @@
1
+ require_relative 'lib/superfaktura/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'superfaktura'
5
+ spec.version = Superfaktura::VERSION
6
+ spec.authors = ['Lubomir Vnenk']
7
+ spec.email = ['lubomir.vnenk@zoho.com']
8
+
9
+ spec.summary = 'Gem to integrate superfaktura into your app.'
10
+ spec.description = 'Gem to integrate superfaktura into your app.'
11
+ spec.homepage = 'https://github.com/lubosch/superfaktura'
12
+ spec.license = 'MIT'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
14
+
15
+ spec.extra_rdoc_files = %w[README.md changelog.md]
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'https://github.com/lubosch/superfaktura'
18
+ spec.metadata['changelog_uri'] = 'https://github.com/lubosch/superfaktura/blob/master/changelog.md'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_dependency 'faraday', '~> 1'
30
+ spec.add_dependency 'faraday_middleware', '~> 1'
31
+
32
+ spec.add_development_dependency 'codecov', '~> 0.1.10'
33
+ spec.add_development_dependency 'rake', '~> 13.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.6'
35
+ spec.add_development_dependency 'rubocop', '~> 0.93.0'
36
+ spec.add_development_dependency 'simplecov', '~> 0.18.5'
37
+ spec.add_development_dependency 'webmock', '~> 3.9.0'
38
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: superfaktura
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Lubomir Vnenk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: codecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.10
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.10
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '13.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '13.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.93.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.93.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.18.5
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.18.5
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 3.9.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 3.9.0
125
+ description: Gem to integrate superfaktura into your app.
126
+ email:
127
+ - lubomir.vnenk@zoho.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files:
131
+ - README.md
132
+ - changelog.md
133
+ files:
134
+ - ".codeclimate.yml"
135
+ - ".gitignore"
136
+ - ".rspec"
137
+ - ".rubocop.yml"
138
+ - ".travis.yml"
139
+ - Gemfile
140
+ - Gemfile.lock
141
+ - LICENSE.txt
142
+ - README.md
143
+ - Rakefile
144
+ - bin/console
145
+ - bin/setup
146
+ - changelog.md
147
+ - lib/superfaktura.rb
148
+ - lib/superfaktura/base_api.rb
149
+ - lib/superfaktura/configuration.rb
150
+ - lib/superfaktura/create_invoice.rb
151
+ - lib/superfaktura/version.rb
152
+ - superfaktura.gemspec
153
+ homepage: https://github.com/lubosch/superfaktura
154
+ licenses:
155
+ - MIT
156
+ metadata:
157
+ homepage_uri: https://github.com/lubosch/superfaktura
158
+ source_code_uri: https://github.com/lubosch/superfaktura
159
+ changelog_uri: https://github.com/lubosch/superfaktura/blob/master/changelog.md
160
+ post_install_message:
161
+ rdoc_options: []
162
+ require_paths:
163
+ - lib
164
+ required_ruby_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: 2.4.0
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ requirements: []
175
+ rubygems_version: 3.1.4
176
+ signing_key:
177
+ specification_version: 4
178
+ summary: Gem to integrate superfaktura into your app.
179
+ test_files: []