superfaktura 0.9.0 → 0.9.5
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 +31 -0
- data/changelog.md +15 -0
- data/lib/superfaktura.rb +3 -1
- data/lib/superfaktura/base_api.rb +23 -1
- data/lib/superfaktura/check_connection.rb +7 -0
- data/lib/superfaktura/invoices.rb +11 -0
- data/lib/superfaktura/locales.rb +23 -0
- data/lib/superfaktura/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc0f5e524cd0546243844a54b9dd9e0c09577c207403f1e626027e1c86a9d5ea
|
4
|
+
data.tar.gz: 83279b4c9cfa9baa0c01d4c79f7b1daf579d118b48ff730df43f61178990b3e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b68f27d6414d96e5a9df48e2a071716dba2c8c9df195539d96658f2c64fa88c0785897584908ac6181a5830ff01e2af48ebf8d7a62241fc7e930d7310a525a3
|
7
|
+
data.tar.gz: c721cedc92829d50f23918032c8af05aaee2e70829f85fafdfdf80255b0990cb5f470a7389d20d43fdab07144e53a3f380162042a74e88c06074b6a19b393617
|
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/
|
@@ -18,9 +20,38 @@ Or install it yourself as:
|
|
18
20
|
|
19
21
|
$ gem install superfaktura
|
20
22
|
|
23
|
+
## Configuration
|
24
|
+
|
25
|
+
```
|
26
|
+
Superfaktura.configure do |config|
|
27
|
+
config.email = Rails.application.config_for(:superfaktura)[:email]
|
28
|
+
config.token = Rails.application.config_for(:superfaktura)[:token]
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
Initialize `exponea.rb` with this settings:
|
33
|
+
- **email**: login email to superfaktura
|
34
|
+
- **token**: token generated from superfaktura
|
35
|
+
|
21
36
|
## Usage
|
22
37
|
|
38
|
+
### Create invoice
|
39
|
+
```
|
40
|
+
Superfaktura::Invoices.create(attributes)
|
41
|
+
```
|
42
|
+
- **attributes**: hash for adding invoice. More info here: https://github.com/superfaktura/docs/blob/master/invoice.md#add-invoice
|
43
|
+
|
44
|
+
### Download invoice
|
45
|
+
```
|
46
|
+
Superfaktura::Invoices.download(id, locale: :en)
|
47
|
+
```
|
48
|
+
- **id**: superfaktura id
|
49
|
+
- **locale**: locale, iso2. More info in Superfaktura::Locales::LANGUAGES
|
23
50
|
|
51
|
+
### Check connection
|
52
|
+
```
|
53
|
+
Superfaktura::CheckConnection.call : Boolean
|
54
|
+
```
|
24
55
|
|
25
56
|
## Development
|
26
57
|
|
data/changelog.md
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.9.5
|
4
|
+
Update readme
|
5
|
+
|
6
|
+
## 0.9.4
|
7
|
+
Update readme
|
8
|
+
|
9
|
+
## 0.9.3
|
10
|
+
Rework invoice download
|
11
|
+
|
12
|
+
## 0.9.2
|
13
|
+
Adds download invoice option + locales mapper
|
14
|
+
|
15
|
+
## 0.9.1
|
16
|
+
Adds api status check
|
17
|
+
|
3
18
|
## 0.9
|
4
19
|
Basic api created
|
data/lib/superfaktura.rb
CHANGED
@@ -4,8 +4,10 @@ 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'
|
10
|
+
require 'superfaktura/check_connection'
|
9
11
|
|
10
12
|
module Superfaktura
|
11
13
|
@configuration = Configuration.new
|
@@ -12,12 +12,21 @@ module Superfaktura
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.file_client
|
16
|
+
Faraday.new(url: SUPERFAKTURA_URL) do |builder|
|
17
|
+
builder.request :url_encoded
|
18
|
+
builder.request :json
|
19
|
+
|
20
|
+
builder.adapter Faraday.default_adapter
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
15
24
|
def self.request(uri, method = 'POST', payload = nil)
|
16
25
|
response = client.public_send(method.downcase.to_sym) do |request|
|
17
26
|
request.headers['Authorization'] = "SFAPI email=#{Superfaktura.config.email}&apikey=#{Superfaktura.config.token}"
|
18
27
|
|
19
28
|
request.url(uri)
|
20
|
-
request.body = "data=#{payload.to_json}"
|
29
|
+
request.body = "data=#{payload.to_json}" if payload
|
21
30
|
end
|
22
31
|
raise Superfaktura::Error, response.body['error_message'] unless response.body['error'].zero?
|
23
32
|
|
@@ -27,5 +36,18 @@ module Superfaktura
|
|
27
36
|
def self.post(path, payload)
|
28
37
|
request(path, 'POST', payload)
|
29
38
|
end
|
39
|
+
|
40
|
+
def self.get(path, payload = nil)
|
41
|
+
request(path, 'GET', payload)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.file(uri)
|
45
|
+
response = file_client.get(uri) do |request|
|
46
|
+
request.headers['Authorization'] = "SFAPI email=#{Superfaktura.config.email}&apikey=#{Superfaktura.config.token}"
|
47
|
+
end
|
48
|
+
raise Superfaktura::Error, response.body['error_message'] unless response.status == 200
|
49
|
+
|
50
|
+
response.body
|
51
|
+
end
|
30
52
|
end
|
31
53
|
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.5
|
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-03-
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -146,8 +146,11 @@ files:
|
|
146
146
|
- changelog.md
|
147
147
|
- lib/superfaktura.rb
|
148
148
|
- lib/superfaktura/base_api.rb
|
149
|
+
- lib/superfaktura/check_connection.rb
|
149
150
|
- lib/superfaktura/configuration.rb
|
150
151
|
- lib/superfaktura/create_invoice.rb
|
152
|
+
- lib/superfaktura/invoices.rb
|
153
|
+
- lib/superfaktura/locales.rb
|
151
154
|
- lib/superfaktura/version.rb
|
152
155
|
- superfaktura.gemspec
|
153
156
|
homepage: https://github.com/lubosch/superfaktura
|