frilans_finans_api 0.2.1 → 0.4.0
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 +4 -4
- data/README.md +6 -4
- data/frilans_finans_api.gemspec +1 -1
- data/lib/frilans_finans_api.rb +1 -1
- data/lib/frilans_finans_api/client/client.rb +1 -1
- data/lib/frilans_finans_api/client/fixture_client.rb +1 -1
- data/lib/frilans_finans_api/client/nil_client.rb +1 -1
- data/lib/frilans_finans_api/client/request.rb +6 -6
- data/lib/frilans_finans_api/client/terms.rb +1 -1
- data/lib/frilans_finans_api/client/walker.rb +2 -2
- data/lib/frilans_finans_api/document.rb +1 -1
- data/lib/frilans_finans_api/models/company.rb +2 -2
- data/lib/frilans_finans_api/models/currency.rb +2 -2
- data/lib/frilans_finans_api/models/employment_certificate.rb +2 -2
- data/lib/frilans_finans_api/models/invoice.rb +4 -4
- data/lib/frilans_finans_api/models/profession.rb +3 -3
- data/lib/frilans_finans_api/models/salary.rb +2 -2
- data/lib/frilans_finans_api/models/tax.rb +2 -2
- data/lib/frilans_finans_api/models/user.rb +5 -5
- data/lib/frilans_finans_api/nil_event_logger.rb +1 -1
- data/lib/frilans_finans_api/nil_logger.rb +1 -1
- data/lib/frilans_finans_api/parse_log.rb +2 -2
- data/lib/frilans_finans_api/resource.rb +1 -1
- data/lib/frilans_finans_api/statuses.rb +1 -1
- data/lib/frilans_finans_api/test_helper.rb +7 -7
- data/lib/frilans_finans_api/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6c8f67e590ba957b8e667a3f48d18d77d44ec051
|
|
4
|
+
data.tar.gz: 45fae99718b042d1c9418c7b9e73bcd1677729ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 632e7d458891e82f5e9a4aba87581b36a5c8c204a7e274059c5c838e2aae22ac36eb99d2552cf9be7e4ba4f695e71301b8cdd0fc9881bc6fefb91a4157ee9820
|
|
7
|
+
data.tar.gz: a6dbea109dd234f3d90d528a190bcb7f62b319c158f61bcde5151c69b4b9e1c72492ef6491a8b4acd5e0861e13e81c043d58591306399a2909a792dd7774c071
|
data/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# FrilansFinansAPI
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/buren/frilans_finans_api)
|
|
2
4
|
|
|
3
5
|
Interact with Frilans Finans API.
|
|
4
6
|
|
|
@@ -21,8 +23,8 @@ Or install it yourself as:
|
|
|
21
23
|
__Configure__
|
|
22
24
|
|
|
23
25
|
```ruby
|
|
24
|
-
|
|
25
|
-
config.client_klass =
|
|
26
|
+
FrilansFinansAPI.configure do |config|
|
|
27
|
+
config.client_klass = FrilansFinansAPI::Client
|
|
26
28
|
config.base_uri = ENV.fetch('FRILANS_FINANS_BASE_URI')
|
|
27
29
|
config.client_id = ENV.fetch('FRILANS_FINANS_CLIENT_ID')
|
|
28
30
|
config.client_secret = ENV.fetch('FRILANS_FINANS_CLIENT_SECRET')
|
|
@@ -32,7 +34,7 @@ end
|
|
|
32
34
|
## Usage
|
|
33
35
|
|
|
34
36
|
```ruby
|
|
35
|
-
include
|
|
37
|
+
include FrilansFinansAPI
|
|
36
38
|
|
|
37
39
|
# GET /professions?page=1
|
|
38
40
|
document = Profession.index(page: 1)
|
data/frilans_finans_api.gemspec
CHANGED
|
@@ -7,7 +7,7 @@ require 'frilans_finans_api/version'
|
|
|
7
7
|
|
|
8
8
|
Gem::Specification.new do |spec|
|
|
9
9
|
spec.name = 'frilans_finans_api'
|
|
10
|
-
spec.version =
|
|
10
|
+
spec.version = FrilansFinansAPI::VERSION
|
|
11
11
|
spec.authors = ['Jacob Burenstam']
|
|
12
12
|
spec.email = ['burenstam@gmail.com']
|
|
13
13
|
|
data/lib/frilans_finans_api.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'httparty'
|
|
4
4
|
|
|
5
|
-
module
|
|
5
|
+
module FrilansFinansAPI
|
|
6
6
|
class Request
|
|
7
7
|
USER_AGENT = {
|
|
8
8
|
'User-Agent' => 'FrilansFinansAPI - Ruby client'
|
|
@@ -18,11 +18,11 @@ module FrilansFinansApi
|
|
|
18
18
|
attr_reader :credentials, :base_uri, :access_token
|
|
19
19
|
|
|
20
20
|
def initialize(base_uri: nil, client_id: nil, client_secret: nil)
|
|
21
|
-
@base_uri = base_uri ||
|
|
21
|
+
@base_uri = base_uri || FrilansFinansAPI.config.base_uri
|
|
22
22
|
@credentials = {
|
|
23
23
|
grant_type: GRANT_TYPE,
|
|
24
|
-
client_id: client_id ||
|
|
25
|
-
client_secret: client_secret ||
|
|
24
|
+
client_id: client_id || FrilansFinansAPI.config.client_id,
|
|
25
|
+
client_secret: client_secret || FrilansFinansAPI.config.client_secret
|
|
26
26
|
}
|
|
27
27
|
@access_token = nil
|
|
28
28
|
end
|
|
@@ -134,12 +134,12 @@ module FrilansFinansApi
|
|
|
134
134
|
"STATUS: #{status}",
|
|
135
135
|
"BODY: #{body}"
|
|
136
136
|
].join(' ')
|
|
137
|
-
|
|
137
|
+
FrilansFinansAPI.config.event_logger.request_event(params: json_params,
|
|
138
138
|
status: status,
|
|
139
139
|
verb: verb,
|
|
140
140
|
uri: uri,
|
|
141
141
|
body: body)
|
|
142
|
-
|
|
142
|
+
FrilansFinansAPI.config.logger.info log_body
|
|
143
143
|
end
|
|
144
144
|
end
|
|
145
145
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'httparty'
|
|
4
4
|
|
|
5
|
-
module
|
|
5
|
+
module FrilansFinansAPI
|
|
6
6
|
class Terms
|
|
7
7
|
USER_URL = 'https://www.frilansfinans.se/just-arrived-employment-agreement/'.freeze
|
|
8
8
|
COMPANY_USER_URL = 'https://www.frilansfinans.se/just-arrived-consultancy-agreement/'.freeze
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module FrilansFinansAPI
|
|
4
4
|
module Walker
|
|
5
5
|
def self.included(base)
|
|
6
6
|
base.extend(ClassMethods)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
module ClassMethods
|
|
10
|
-
def walk(client:
|
|
10
|
+
def walk(client: FrilansFinansAPI.config.client_klass.new)
|
|
11
11
|
current_page = 1
|
|
12
12
|
total_pages = 2
|
|
13
13
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module FrilansFinansAPI
|
|
4
4
|
class Company
|
|
5
|
-
def self.create(attributes:, client:
|
|
5
|
+
def self.create(attributes:, client: FrilansFinansAPI.config.client_klass.new)
|
|
6
6
|
response = client.create_company(attributes: attributes)
|
|
7
7
|
Document.new(response)
|
|
8
8
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module FrilansFinansAPI
|
|
4
4
|
class Currency
|
|
5
5
|
include Walker
|
|
6
6
|
|
|
7
|
-
def self.index(page: 1, client:
|
|
7
|
+
def self.index(page: 1, client: FrilansFinansAPI.config.client_klass.new)
|
|
8
8
|
response = client.currencies(page: page)
|
|
9
9
|
Document.new(response)
|
|
10
10
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module FrilansFinansAPI
|
|
4
4
|
class EmploymentCertificate
|
|
5
|
-
def self.create(attributes:, client:
|
|
5
|
+
def self.create(attributes:, client: FrilansFinansAPI.config.client_klass.new)
|
|
6
6
|
client.create_employment_certificate(attributes: attributes)
|
|
7
7
|
nil
|
|
8
8
|
end
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module FrilansFinansAPI
|
|
4
4
|
class Invoice
|
|
5
|
-
def self.create(attributes:, client:
|
|
5
|
+
def self.create(attributes:, client: FrilansFinansAPI.config.client_klass.new)
|
|
6
6
|
response = client.create_invoice(attributes: attributes)
|
|
7
7
|
Document.new(response)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def self.show(id:, client:
|
|
10
|
+
def self.show(id:, client: FrilansFinansAPI.config.client_klass.new)
|
|
11
11
|
response = client.invoice(id: id)
|
|
12
12
|
Document.new(response)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def self.update(id:, attributes:, client:
|
|
15
|
+
def self.update(id:, attributes:, client: FrilansFinansAPI.config.client_klass.new)
|
|
16
16
|
response = client.update_invoice(id: id, attributes: attributes)
|
|
17
17
|
Document.new(response)
|
|
18
18
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module FrilansFinansAPI
|
|
4
4
|
class Profession
|
|
5
5
|
include Walker
|
|
6
6
|
|
|
7
|
-
def self.index(page: 1, client:
|
|
7
|
+
def self.index(page: 1, client: FrilansFinansAPI.config.client_klass.new)
|
|
8
8
|
response = client.professions(page: page)
|
|
9
9
|
Document.new(response)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def self.show(id:, client:
|
|
12
|
+
def self.show(id:, client: FrilansFinansAPI.config.client_klass.new)
|
|
13
13
|
response = client.profession(id: id)
|
|
14
14
|
Document.new(response)
|
|
15
15
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module FrilansFinansAPI
|
|
4
4
|
class Salary
|
|
5
|
-
def self.index(invoice_id:, page: 1, client:
|
|
5
|
+
def self.index(invoice_id:, page: 1, client: FrilansFinansAPI.config.client_klass.new)
|
|
6
6
|
response = client.salaries(invoice_id: invoice_id, page: page)
|
|
7
7
|
Document.new(response)
|
|
8
8
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module FrilansFinansAPI
|
|
4
4
|
class Tax
|
|
5
5
|
include Walker
|
|
6
6
|
|
|
7
|
-
def self.index(page: 1, only_standard: false, client:
|
|
7
|
+
def self.index(page: 1, only_standard: false, client: FrilansFinansAPI.config.client_klass.new) # rubocop:disable Metrics/LineLength
|
|
8
8
|
response = client.taxes(page: page, only_standard: only_standard)
|
|
9
9
|
Document.new(response)
|
|
10
10
|
end
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module FrilansFinansAPI
|
|
4
4
|
class User
|
|
5
5
|
include Walker
|
|
6
6
|
|
|
7
|
-
def self.create(attributes:, client:
|
|
7
|
+
def self.create(attributes:, client: FrilansFinansAPI.config.client_klass.new)
|
|
8
8
|
response = client.create_user(attributes: attributes)
|
|
9
9
|
Document.new(response)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def self.update(id:, attributes:, client:
|
|
12
|
+
def self.update(id:, attributes:, client: FrilansFinansAPI.config.client_klass.new)
|
|
13
13
|
response = client.update_user(id: id, attributes: attributes)
|
|
14
14
|
Document.new(response)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
def self.index(page: 1, email: nil, client:
|
|
17
|
+
def self.index(page: 1, email: nil, client: FrilansFinansAPI.config.client_klass.new)
|
|
18
18
|
response = client.users(page: page, email: email)
|
|
19
19
|
Document.new(response)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def self.show(id:, client:
|
|
22
|
+
def self.show(id:, client: FrilansFinansAPI.config.client_klass.new)
|
|
23
23
|
response = client.user(id: id)
|
|
24
24
|
Document.new(response)
|
|
25
25
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module FrilansFinansAPI
|
|
4
4
|
module ParseLog
|
|
5
5
|
class LogRequest
|
|
6
6
|
attr_reader :uri, :params, :body, :status
|
|
@@ -30,7 +30,7 @@ module FrilansFinansApi
|
|
|
30
30
|
def self.call(filename)
|
|
31
31
|
lines = []
|
|
32
32
|
File.foreach(filename) do |log_line|
|
|
33
|
-
next unless log_line.index('[
|
|
33
|
+
next unless log_line.index('[FrilansFinansAPI::Request]')
|
|
34
34
|
|
|
35
35
|
# MATCH BODY
|
|
36
36
|
body_match = 'BODY: '
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module FrilansFinansAPI
|
|
4
4
|
module TestHelper
|
|
5
5
|
module_function
|
|
6
6
|
|
|
7
7
|
def isolate_frilans_finans_client(klass)
|
|
8
|
-
before_klass =
|
|
9
|
-
|
|
8
|
+
before_klass = FrilansFinansAPI.config.client_klass
|
|
9
|
+
FrilansFinansAPI.config.client_klass = klass
|
|
10
10
|
result = yield(before_klass)
|
|
11
|
-
|
|
11
|
+
FrilansFinansAPI.config.client_klass = before_klass
|
|
12
12
|
result
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def stub_frilans_finans_auth_request
|
|
16
16
|
# Stub auth request
|
|
17
|
-
base_uri =
|
|
17
|
+
base_uri = FrilansFinansAPI.config.base_uri
|
|
18
18
|
headers = { 'User-Agent' => 'FrilansFinansAPI - Ruby client' }
|
|
19
19
|
body = [
|
|
20
20
|
'grant_type=client_credentials',
|
|
21
|
-
"client_id=#{
|
|
22
|
-
"client_secret=#{
|
|
21
|
+
"client_id=#{FrilansFinansAPI.config.client_id}",
|
|
22
|
+
"client_secret=#{FrilansFinansAPI.config.client_secret}"
|
|
23
23
|
].join('&')
|
|
24
24
|
|
|
25
25
|
response_body = JSON.dump(
|