superfaktura 0.9.1 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +19 -3
- data/changelog.md +15 -0
- data/lib/superfaktura.rb +2 -1
- data/lib/superfaktura/base_api.rb +26 -3
- data/lib/superfaktura/configuration.rb +2 -1
- data/lib/superfaktura/invoices.rb +11 -0
- data/lib/superfaktura/locales.rb +23 -0
- data/lib/superfaktura/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1eb28dc05047ea0544cbca451fb5f8b35646c6f75c064a14756f0fbd1b6f4b6b
|
4
|
+
data.tar.gz: 7fef90b8606d61505394e104b3be710ce03591a91f5e0beb820834df96c85d04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79f972ad659323ba0ad8d41cfbfc04476f76523ee3b6bc50eef2bcd8bec4f921bef798b7e02fd9fbe028ef9657820a15b8f3a0cce8da7ff4cb865fecbb860b6e
|
7
|
+
data.tar.gz: ae3f6f428cdfd2e33efbbfdca47feb46ef350d9caf8e0715eddba08af7033b0be8a167a40d0904c8f9efcc2d8b768270819fea7c2a8b1503c86acb0a70404cb7
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://travis-ci.com/lubosch/superfaktura.svg?branch=master)](https://travis-ci.com/lubosch/superfaktura)
|
2
|
+
[![Coverage Status](https://codecov.io/gh/lubosch/superfaktura/branch/master/graph/badge.svg)](https://codecov.io/gh/lubosch/superfaktura)
|
1
3
|
# Superfaktura
|
2
4
|
|
3
5
|
Gem for easy integration with http://superfaktura.sk/
|
@@ -22,8 +24,10 @@ Or install it yourself as:
|
|
22
24
|
|
23
25
|
```
|
24
26
|
Superfaktura.configure do |config|
|
25
|
-
config.email = Rails.application.config_for(:superfaktura)[:email]
|
26
|
-
config.token = Rails.application.config_for(:superfaktura)[:token]
|
27
|
+
config.email = Rails.application.config_for(:superfaktura)[:email] # registration email
|
28
|
+
config.token = Rails.application.config_for(:superfaktura)[:token] # api key
|
29
|
+
# for sandbox create an account with the same email at https://sandbox.superfaktura.sk/
|
30
|
+
# config.sandbox = !Rails.env.production?
|
27
31
|
end
|
28
32
|
```
|
29
33
|
|
@@ -35,10 +39,22 @@ Initialize `exponea.rb` with this settings:
|
|
35
39
|
|
36
40
|
### Create invoice
|
37
41
|
```
|
38
|
-
Superfaktura::
|
42
|
+
Superfaktura::Invoices.create(attributes)
|
39
43
|
```
|
40
44
|
- **attributes**: hash for adding invoice. More info here: https://github.com/superfaktura/docs/blob/master/invoice.md#add-invoice
|
41
45
|
|
46
|
+
### Download invoice
|
47
|
+
```
|
48
|
+
Superfaktura::Invoices.download(id, locale: :en)
|
49
|
+
```
|
50
|
+
- **id**: superfaktura id
|
51
|
+
- **locale**: locale, iso2. More info in Superfaktura::Locales::LANGUAGES
|
52
|
+
|
53
|
+
### Check connection
|
54
|
+
```
|
55
|
+
Superfaktura::CheckConnection.call : Boolean
|
56
|
+
```
|
57
|
+
|
42
58
|
## Development
|
43
59
|
|
44
60
|
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.
|
data/changelog.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.9.6
|
4
|
+
Add sandbox
|
5
|
+
|
6
|
+
## 0.9.5
|
7
|
+
Update readme
|
8
|
+
|
9
|
+
## 0.9.4
|
10
|
+
Update readme
|
11
|
+
|
12
|
+
## 0.9.3
|
13
|
+
Rework invoice download
|
14
|
+
|
15
|
+
## 0.9.2
|
16
|
+
Adds download invoice option + locales mapper
|
17
|
+
|
3
18
|
## 0.9.1
|
4
19
|
Adds api status check
|
5
20
|
|
data/lib/superfaktura.rb
CHANGED
@@ -4,8 +4,9 @@ require 'faraday_middleware'
|
|
4
4
|
|
5
5
|
require 'superfaktura/version'
|
6
6
|
require 'superfaktura/configuration'
|
7
|
+
require 'superfaktura/locales'
|
7
8
|
require 'superfaktura/base_api'
|
8
|
-
require 'superfaktura/
|
9
|
+
require 'superfaktura/invoices'
|
9
10
|
require 'superfaktura/check_connection'
|
10
11
|
|
11
12
|
module Superfaktura
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Superfaktura
|
2
2
|
class BaseApi
|
3
3
|
SUPERFAKTURA_URL = 'https://moja.superfaktura.sk'.freeze
|
4
|
+
SANDBOX_SUPERFAKTURA_URL = 'https://sandbox.superfaktura.sk'.freeze
|
4
5
|
|
5
6
|
def self.client
|
6
|
-
Faraday.new(url:
|
7
|
+
Faraday.new(url: superfaktura_url) do |builder|
|
7
8
|
builder.request :url_encoded
|
8
9
|
builder.request :json
|
9
10
|
builder.response :json
|
@@ -12,12 +13,21 @@ module Superfaktura
|
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
16
|
+
def self.file_client
|
17
|
+
Faraday.new(url: superfaktura_url) do |builder|
|
18
|
+
builder.request :url_encoded
|
19
|
+
builder.request :json
|
20
|
+
|
21
|
+
builder.adapter Faraday.default_adapter
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
15
25
|
def self.request(uri, method = 'POST', payload = nil)
|
16
26
|
response = client.public_send(method.downcase.to_sym) do |request|
|
17
27
|
request.headers['Authorization'] = "SFAPI email=#{Superfaktura.config.email}&apikey=#{Superfaktura.config.token}"
|
18
28
|
|
19
29
|
request.url(uri)
|
20
|
-
request.body = "data=#{payload.to_json}"
|
30
|
+
request.body = "data=#{payload.to_json}" if payload
|
21
31
|
end
|
22
32
|
raise Superfaktura::Error, response.body['error_message'] unless response.body['error'].zero?
|
23
33
|
|
@@ -28,8 +38,21 @@ module Superfaktura
|
|
28
38
|
request(path, 'POST', payload)
|
29
39
|
end
|
30
40
|
|
31
|
-
def self.get(path, payload)
|
41
|
+
def self.get(path, payload = nil)
|
32
42
|
request(path, 'GET', payload)
|
33
43
|
end
|
44
|
+
|
45
|
+
def self.superfaktura_url
|
46
|
+
Superfaktura.config.sandbox ? SANDBOX_SUPERFAKTURA_URL : SUPERFAKTURA_URL
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.file(uri)
|
50
|
+
response = file_client.get(uri) do |request|
|
51
|
+
request.headers['Authorization'] = "SFAPI email=#{Superfaktura.config.email}&apikey=#{Superfaktura.config.token}"
|
52
|
+
end
|
53
|
+
raise Superfaktura::Error, response.body['error_message'] unless response.status == 200
|
54
|
+
|
55
|
+
response.body
|
56
|
+
end
|
34
57
|
end
|
35
58
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Superfaktura
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :email, :token
|
3
|
+
attr_accessor :email, :token, :sandbox
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@email = ENV['SUPERFAKTURA_EMAIL']
|
7
7
|
@token = ENV['SUPERFAKTURA_TOKEN']
|
8
|
+
@sandbox = ENV['SUPERFAKTURA_SANDBOX'] == 'true' ? true : false
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Superfaktura
|
2
|
+
class Locales
|
3
|
+
LANGUAGES = {
|
4
|
+
en: 'eng',
|
5
|
+
sk: 'slo',
|
6
|
+
hu: 'hun',
|
7
|
+
cs: 'cze',
|
8
|
+
de: 'deu',
|
9
|
+
hr: 'hrv',
|
10
|
+
it: 'ita',
|
11
|
+
pl: 'pol',
|
12
|
+
ro: 'rom',
|
13
|
+
ru: 'rus',
|
14
|
+
sl: 'slv',
|
15
|
+
es: 'spa',
|
16
|
+
uk: 'ukr'
|
17
|
+
}.freeze
|
18
|
+
|
19
|
+
def self.iso2_to_iso3(iso2)
|
20
|
+
LANGUAGES[iso2.to_sym] || 'eng'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/superfaktura/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superfaktura
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lubomir Vnenk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -149,6 +149,8 @@ files:
|
|
149
149
|
- lib/superfaktura/check_connection.rb
|
150
150
|
- lib/superfaktura/configuration.rb
|
151
151
|
- lib/superfaktura/create_invoice.rb
|
152
|
+
- lib/superfaktura/invoices.rb
|
153
|
+
- lib/superfaktura/locales.rb
|
152
154
|
- lib/superfaktura/version.rb
|
153
155
|
- superfaktura.gemspec
|
154
156
|
homepage: https://github.com/lubosch/superfaktura
|