maventa 0.1
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 +7 -0
- data/CHANGELOG.md +0 -0
- data/README.md +54 -0
- data/Rakefile +8 -0
- data/lib/maventa/access_token.rb +31 -0
- data/lib/maventa/analysis.rb +15 -0
- data/lib/maventa/client.rb +94 -0
- data/lib/maventa/companies.rb +19 -0
- data/lib/maventa/company.rb +110 -0
- data/lib/maventa/definitions.rb +11 -0
- data/lib/maventa/documents.rb +23 -0
- data/lib/maventa/error.rb +15 -0
- data/lib/maventa/fi_bank_messages.rb +31 -0
- data/lib/maventa/files.rb +11 -0
- data/lib/maventa/invoices.rb +99 -0
- data/lib/maventa/jwk.rb +7 -0
- data/lib/maventa/lookup.rb +15 -0
- data/lib/maventa/oauth2.rb +37 -0
- data/lib/maventa/odp.rb +11 -0
- data/lib/maventa/operator.rb +51 -0
- data/lib/maventa/partner.rb +23 -0
- data/lib/maventa/request_error.rb +4 -0
- data/lib/maventa/resource.rb +85 -0
- data/lib/maventa/server_error.rb +4 -0
- data/lib/maventa/services.rb +99 -0
- data/lib/maventa/status.rb +7 -0
- data/lib/maventa/users.rb +7 -0
- data/lib/maventa/version.rb +5 -0
- data/lib/maventa.rb +56 -0
- metadata +211 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 951849460866fc0307f6862409e97a5ad38cc8217e31e3670b94f25bd17fdace
|
4
|
+
data.tar.gz: a363d93c1eb2fbe47f80a971204c42754ed9846ca5227475a0b80fe7827fed78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46c6c82f9ecd3ef5e5c27d2b7b9f24b504ec361e40684a5c160946d8eec2b72aabce3f84dbbee794ea395f80f1678591b5aad76c9bd0ffcb67058627f76217a8
|
7
|
+
data.tar.gz: 4a1b11a72f205bcc7bca8b0a7aa2f4b77f765e54530e75fadf7101f866e181991d5d0d2e053a78b95dec50bb1aa060ddc4adefcf5e117cd79157bfc25815f356
|
data/CHANGELOG.md
ADDED
File without changes
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
Maventa API library.
|
2
|
+
|
3
|
+
## Status
|
4
|
+
|
5
|
+
Consider this as sort of an alpha or beta release. Things might be working just fine, but this won't work in production yet.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
For using this gem, you'll need to provide company UUID, user API key, and vendor API key. You'll need to register a Maventa account in order to get these.
|
10
|
+
|
11
|
+
```
|
12
|
+
Maventa::configure do |config|
|
13
|
+
config[:client_id] = company_uuid
|
14
|
+
config[:client_secret] = user_api_key
|
15
|
+
config[:vendor_api_key] = vendor_api_key
|
16
|
+
end
|
17
|
+
|
18
|
+
@client = Maventa::Client.new(mode: :testing)
|
19
|
+
@client.authorize(scope: "global company invoice:send")
|
20
|
+
|
21
|
+
file_path = "/path/to/invoice.xml"
|
22
|
+
params = {
|
23
|
+
disabled_routes: ["print", "email"]
|
24
|
+
}
|
25
|
+
|
26
|
+
response = @client.invoices.create(file_path, **params)
|
27
|
+
response = @client.invoices.list(direction: :sent)
|
28
|
+
```
|
29
|
+
|
30
|
+
## Implemented actions
|
31
|
+
|
32
|
+
- companies
|
33
|
+
- list
|
34
|
+
- status
|
35
|
+
- company
|
36
|
+
- list_network_registrations
|
37
|
+
- list_settings
|
38
|
+
- list_notification_subscriptions
|
39
|
+
- vendor_api_key_status
|
40
|
+
- show_authorization_status
|
41
|
+
- list_users
|
42
|
+
- invoices
|
43
|
+
- list
|
44
|
+
- show
|
45
|
+
- create
|
46
|
+
- actions
|
47
|
+
- report_definitions
|
48
|
+
- oauth2
|
49
|
+
- token
|
50
|
+
- services
|
51
|
+
- list_atg_agreements
|
52
|
+
- list_detect_checks
|
53
|
+
- status
|
54
|
+
- authenticated
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Maventa
|
2
|
+
class AccessToken
|
3
|
+
attr_accessor :token, :expires_in, :expires_at, :token_type, :scope
|
4
|
+
|
5
|
+
EXPIRATION_MARGIN = 60
|
6
|
+
|
7
|
+
def initialize(token:, expires_in:, token_type:, scope:)
|
8
|
+
@token = token
|
9
|
+
@expires_in = expires_in
|
10
|
+
@expires_at = Time.now.to_i + expires_in
|
11
|
+
@token_type = token_type
|
12
|
+
@scope = scope
|
13
|
+
end
|
14
|
+
|
15
|
+
def scopes
|
16
|
+
@scope.split " "
|
17
|
+
end
|
18
|
+
|
19
|
+
def expired?
|
20
|
+
Time.now.to_i > @expires_at
|
21
|
+
end
|
22
|
+
|
23
|
+
def valid?
|
24
|
+
!expired?
|
25
|
+
end
|
26
|
+
|
27
|
+
def expired_or_about_to_expire?
|
28
|
+
Time.now.to_i > (@expires_at - EXPIRATION_MARGIN)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Maventa
|
2
|
+
class Client
|
3
|
+
def initialize(client_id: nil, client_secret: nil, vendor_api_key: nil, mode: :production)
|
4
|
+
@client_id = client_id || Maventa::config[:client_id]
|
5
|
+
@client_secret = client_secret || Maventa::config[:client_secret]
|
6
|
+
@vendor_api_key = vendor_api_key || Maventa::config[:vendor_api_key]
|
7
|
+
@mode = mode
|
8
|
+
@access_token = nil
|
9
|
+
|
10
|
+
@connection = Faraday.new(
|
11
|
+
url: Maventa::API_URL[mode],
|
12
|
+
headers: {
|
13
|
+
"Content-Type" => "application/x-www-form-urlencoded"
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def authorize(grant_type: "client_credentials", scope: "global company")
|
19
|
+
if @access_token&.valid?
|
20
|
+
@access_token
|
21
|
+
else
|
22
|
+
@access_token = oauth2.token(grant_type:, scope:)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def oauth2
|
27
|
+
@oauth2 ||= OAuth2.new(@connection, client_id: @client_id, client_secret: @client_secret, vendor_api_key: @vendor_api_key)
|
28
|
+
end
|
29
|
+
|
30
|
+
def analysis
|
31
|
+
@analysis ||= Analysis.new(@connection, @access_token)
|
32
|
+
end
|
33
|
+
|
34
|
+
def companies
|
35
|
+
@companies ||= Companies.new(@connection, @access_token)
|
36
|
+
end
|
37
|
+
|
38
|
+
def company
|
39
|
+
@company ||= Company.new(@connection, @access_token)
|
40
|
+
end
|
41
|
+
|
42
|
+
def definitions
|
43
|
+
@definitions ||= Definitions.new(@connection, @access_token)
|
44
|
+
end
|
45
|
+
|
46
|
+
def documents
|
47
|
+
@documents ||= Documents.new(@connection, @access_token)
|
48
|
+
end
|
49
|
+
|
50
|
+
def fi_bank_messages
|
51
|
+
@fi_bank_messages ||= FiBankMessages.new(@connection, @access_token)
|
52
|
+
end
|
53
|
+
|
54
|
+
def files
|
55
|
+
@files ||= Files.new(@connection, @access_token)
|
56
|
+
end
|
57
|
+
|
58
|
+
def invoices
|
59
|
+
@invoices ||= Invoices.new(@connection, @access_token)
|
60
|
+
end
|
61
|
+
|
62
|
+
def jwk
|
63
|
+
@jwk ||= Jwk.new(@connection, @access_token)
|
64
|
+
end
|
65
|
+
|
66
|
+
def lookup
|
67
|
+
@lookup ||= Lookup.new(@connection, @access_token)
|
68
|
+
end
|
69
|
+
|
70
|
+
def odp
|
71
|
+
@odp ||= Odp.new(@connection, @access_token)
|
72
|
+
end
|
73
|
+
|
74
|
+
def operator
|
75
|
+
@operator ||= Operator.new(@connection, @access_token)
|
76
|
+
end
|
77
|
+
|
78
|
+
def partner
|
79
|
+
@partner ||= Partner.new(@connection, @access_token)
|
80
|
+
end
|
81
|
+
|
82
|
+
def services
|
83
|
+
@services ||= Services.new(@connection, @access_token)
|
84
|
+
end
|
85
|
+
|
86
|
+
def status
|
87
|
+
@status ||= Status.new(@connection, @access_token)
|
88
|
+
end
|
89
|
+
|
90
|
+
def users
|
91
|
+
@users ||= Users.new(@connection, @access_token)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Maventa
|
2
|
+
class Companies < Resource
|
3
|
+
def list
|
4
|
+
request(:get, "/v1/companies/")
|
5
|
+
end
|
6
|
+
|
7
|
+
def create
|
8
|
+
raise "Not implemented"
|
9
|
+
end
|
10
|
+
|
11
|
+
def authorize
|
12
|
+
raise "Not implemented"
|
13
|
+
end
|
14
|
+
|
15
|
+
def status(id)
|
16
|
+
request(:get, "/v1/companies/#{id}/status")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Maventa
|
2
|
+
class Company < Resource
|
3
|
+
NETWORKS = [:visma, :peppol, :nemhandel, :aisproom, :bank, :scan, :inexchange, :vismascanner, :receivables]
|
4
|
+
STATUSES = [:active, :pending, :error]
|
5
|
+
SETTING_FIELDS = [:invoice_notifications, :send_invoice_email, :address, :details, :send_invoice_print, :send_invoice_general, :logos, :email_reports, :billing_details]
|
6
|
+
|
7
|
+
def create_network_registration_request
|
8
|
+
raise "Not implemented"
|
9
|
+
end
|
10
|
+
|
11
|
+
def list_network_registrations(networks: NETWORKS, statuses: STATUSES)
|
12
|
+
params = {
|
13
|
+
network: networks.map{ |n| n.to_s.upcase},
|
14
|
+
status: statuses.map{ |s| s.to_s }
|
15
|
+
}
|
16
|
+
request(:get, "/v1/company/profiles", params:)
|
17
|
+
end
|
18
|
+
|
19
|
+
def update_network_registration
|
20
|
+
raise "Not implemented"
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete_network_registration
|
24
|
+
raise "Not implemented"
|
25
|
+
end
|
26
|
+
|
27
|
+
def show_network_registration
|
28
|
+
raise "Not implemented"
|
29
|
+
end
|
30
|
+
|
31
|
+
def update_settings
|
32
|
+
raise "Not implemented"
|
33
|
+
end
|
34
|
+
|
35
|
+
def list_settings(fields: SETTING_FIELDS)
|
36
|
+
params = {
|
37
|
+
fields: fields.map{ |f| f.to_s }
|
38
|
+
}
|
39
|
+
request(:get, "/v1/company/settings", params:)
|
40
|
+
end
|
41
|
+
|
42
|
+
def list_consumers
|
43
|
+
raise "Not implemented"
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_notification_subscription
|
47
|
+
raise "Not implemented"
|
48
|
+
end
|
49
|
+
|
50
|
+
def list_notification_subscriptions
|
51
|
+
request(:get, "/v1/company/notifications")
|
52
|
+
end
|
53
|
+
|
54
|
+
def delete_notification_subscription
|
55
|
+
raise "Not implemented"
|
56
|
+
end
|
57
|
+
|
58
|
+
def show_notification_subscription
|
59
|
+
raise "Not implemented"
|
60
|
+
end
|
61
|
+
|
62
|
+
def vendor_api_key_status
|
63
|
+
request(:get, "/v1/company/vendors")
|
64
|
+
end
|
65
|
+
|
66
|
+
def unlink_vendor_api_key
|
67
|
+
raise "Not implemented"
|
68
|
+
end
|
69
|
+
|
70
|
+
def link_vendor_api_key
|
71
|
+
raise "Not implemented"
|
72
|
+
end
|
73
|
+
|
74
|
+
def authorize_company
|
75
|
+
raise "Not implemented"
|
76
|
+
end
|
77
|
+
|
78
|
+
def show_authorization_status
|
79
|
+
request(:get, "/v1/company/authorization")
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_user
|
83
|
+
raise "Not implemented"
|
84
|
+
end
|
85
|
+
|
86
|
+
def list_users
|
87
|
+
request(:get, "/v1/company/users")
|
88
|
+
end
|
89
|
+
|
90
|
+
def show_user
|
91
|
+
raise "Not implemented"
|
92
|
+
end
|
93
|
+
|
94
|
+
def update_user
|
95
|
+
raise "Not implemented"
|
96
|
+
end
|
97
|
+
|
98
|
+
def remove_user
|
99
|
+
raise "Not implemented"
|
100
|
+
end
|
101
|
+
|
102
|
+
def update_user_role
|
103
|
+
raise "Not implemented"
|
104
|
+
end
|
105
|
+
|
106
|
+
def mark_active
|
107
|
+
raise "Not implemented"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Maventa
|
2
|
+
class Documents < Resource
|
3
|
+
def create
|
4
|
+
raise "Not implemented"
|
5
|
+
end
|
6
|
+
|
7
|
+
def list
|
8
|
+
raise "Not implemented"
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
raise "Not implemented"
|
13
|
+
end
|
14
|
+
|
15
|
+
def update
|
16
|
+
raise "Not implemented"
|
17
|
+
end
|
18
|
+
|
19
|
+
def events
|
20
|
+
raise "Not implemented"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Maventa
|
2
|
+
class Error < StandardError
|
3
|
+
attr_reader :message, :code, :details
|
4
|
+
attr_reader :response_status, :response_body, :response_headers
|
5
|
+
|
6
|
+
def initialize(message = nil, response_status: nil, response_body: nil, response_headers: nil, code: nil, details: nil)
|
7
|
+
@message = message
|
8
|
+
@code = code
|
9
|
+
@details = details
|
10
|
+
@response_status = response_status
|
11
|
+
@response_body = response_body
|
12
|
+
@response_headers = response_headers
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Maventa
|
2
|
+
class FiBankMessages < Resource
|
3
|
+
def delete_ri_message
|
4
|
+
raise "Not implemented"
|
5
|
+
end
|
6
|
+
|
7
|
+
def show_ri_message
|
8
|
+
raise "Not implemented"
|
9
|
+
end
|
10
|
+
|
11
|
+
def list_ri_messages
|
12
|
+
raise "Not implemented"
|
13
|
+
end
|
14
|
+
|
15
|
+
def show_error_message
|
16
|
+
raise "Not implemented"
|
17
|
+
end
|
18
|
+
|
19
|
+
def list_error_messages
|
20
|
+
raise "Not implemented"
|
21
|
+
end
|
22
|
+
|
23
|
+
def show
|
24
|
+
raise "Not implemented"
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
raise "Not implemented"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Maventa
|
2
|
+
class Invoices < Resource
|
3
|
+
def list(
|
4
|
+
direction: :sent,
|
5
|
+
status: [],
|
6
|
+
ids: nil,
|
7
|
+
number: nil,
|
8
|
+
reference: nil,
|
9
|
+
received_at_start: nil,
|
10
|
+
received_at_end: nil,
|
11
|
+
sort: nil,
|
12
|
+
channel_details_version: 1,
|
13
|
+
page: 1,
|
14
|
+
per_page: 10
|
15
|
+
)
|
16
|
+
payload = {
|
17
|
+
direction: direction.to_s.upcase,
|
18
|
+
status:,
|
19
|
+
ids:,
|
20
|
+
number:,
|
21
|
+
reference:,
|
22
|
+
received_at_start:,
|
23
|
+
received_at_end:,
|
24
|
+
sort:,
|
25
|
+
channel_details_version:,
|
26
|
+
page:,
|
27
|
+
per_page:
|
28
|
+
}
|
29
|
+
|
30
|
+
request(:get, "/v1/invoices", payload:)
|
31
|
+
end
|
32
|
+
|
33
|
+
def show(id, return_format: nil, channel_details_version: 1)
|
34
|
+
payload = {
|
35
|
+
return_format: return_format.to_s.upcase,
|
36
|
+
channel_details_version:
|
37
|
+
}
|
38
|
+
expected_response_format = case return_format
|
39
|
+
when :finvoice30
|
40
|
+
:xml
|
41
|
+
else
|
42
|
+
:json
|
43
|
+
end
|
44
|
+
|
45
|
+
request(:get, "v1/invoices/#{id}", payload:, expected_response_format:)
|
46
|
+
end
|
47
|
+
|
48
|
+
def create(
|
49
|
+
filename,
|
50
|
+
format: :finvoice30,
|
51
|
+
recipient_eia: nil,
|
52
|
+
recipient_email: nil,
|
53
|
+
recipient_operator: nil,
|
54
|
+
disabled_routes: [],
|
55
|
+
sender_comment: nil,
|
56
|
+
uuid: nil,
|
57
|
+
route_order: [],
|
58
|
+
recipient_phone_number: nil,
|
59
|
+
prevent_routing: false
|
60
|
+
)
|
61
|
+
payload = {
|
62
|
+
format: format.to_s.upcase,
|
63
|
+
recipient_eia:,
|
64
|
+
recipient_email:,
|
65
|
+
recipient_operator:,
|
66
|
+
disabled_routes:,
|
67
|
+
sender_comment:,
|
68
|
+
uuid:,
|
69
|
+
route_order:,
|
70
|
+
recipient_phone_number:,
|
71
|
+
prevent_routing:
|
72
|
+
}
|
73
|
+
payload[:file] = Faraday::Multipart::FilePart.new(
|
74
|
+
File.open(filename),
|
75
|
+
"text/xml",
|
76
|
+
"invoice.xml"
|
77
|
+
)
|
78
|
+
|
79
|
+
request(:post, "/v1/invoices", payload:, multipart: true)
|
80
|
+
end
|
81
|
+
|
82
|
+
def actions(
|
83
|
+
id,
|
84
|
+
type: [:received, :created, :sent, :delivered, :info, :error],
|
85
|
+
channel_details_version: 1
|
86
|
+
)
|
87
|
+
payload = {
|
88
|
+
type: type.map { |t| t.to_s.upcase },
|
89
|
+
channel_details_version:
|
90
|
+
}
|
91
|
+
|
92
|
+
request(:get, "/v1/invoices/#{id}/actions", payload:)
|
93
|
+
end
|
94
|
+
|
95
|
+
def reports_definitions
|
96
|
+
request(:get, "/v1/invoices/reports/definitions")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/maventa/jwk.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Maventa
|
2
|
+
class OAuth2 < Resource
|
3
|
+
def initialize(connection, client_id:, client_secret:, vendor_api_key:)
|
4
|
+
super(connection, nil)
|
5
|
+
@client_id = client_id
|
6
|
+
@client_secret = client_secret
|
7
|
+
@vendor_api_key = vendor_api_key
|
8
|
+
end
|
9
|
+
|
10
|
+
def token(grant_type: "client_credentials", scope: "invoice:send")
|
11
|
+
payload = {
|
12
|
+
grant_type:,
|
13
|
+
scope:,
|
14
|
+
vendor_api_key: @vendor_api_key
|
15
|
+
}
|
16
|
+
|
17
|
+
request(:post, "/oauth2/token", payload:) do |received_data|
|
18
|
+
AccessToken.new(
|
19
|
+
token: received_data["access_token"],
|
20
|
+
expires_in: received_data["expires_in"],
|
21
|
+
token_type: received_data["token_type"],
|
22
|
+
scope: received_data["scope"]
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def current
|
28
|
+
raise "Not implemented"
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def auth_string
|
34
|
+
"Basic #{Base64.strict_encode64("#{@client_id}:#{@client_secret}")}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/maventa/odp.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module Maventa
|
2
|
+
class Operator < Resource
|
3
|
+
def register_participant
|
4
|
+
raise "Not implemented"
|
5
|
+
end
|
6
|
+
|
7
|
+
def list participants
|
8
|
+
raise "Not implemented"
|
9
|
+
end
|
10
|
+
|
11
|
+
def update_participant
|
12
|
+
raise "Not implemented"
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete_participant
|
16
|
+
raise "Not implemented"
|
17
|
+
end
|
18
|
+
|
19
|
+
def show_participant
|
20
|
+
raise "Not implemented"
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_notification
|
24
|
+
raise "Not implemented"
|
25
|
+
end
|
26
|
+
|
27
|
+
def list_notifications
|
28
|
+
raise "Not implemented"
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete_notification
|
32
|
+
raise "Not implemented"
|
33
|
+
end
|
34
|
+
|
35
|
+
def show_notification
|
36
|
+
raise "Not implemented"
|
37
|
+
end
|
38
|
+
|
39
|
+
def list_companies
|
40
|
+
raise "Not implemented"
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_account_statement
|
44
|
+
raise "Not implemented"
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_invoice_image
|
48
|
+
raise "Not implemented"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Maventa
|
2
|
+
class Partner < Resource
|
3
|
+
def list_companies
|
4
|
+
raise "Not implemented"
|
5
|
+
end
|
6
|
+
|
7
|
+
def list_outbound_invoice_errors
|
8
|
+
raise "Not implemented"
|
9
|
+
end
|
10
|
+
|
11
|
+
def list_received_invoice_actions
|
12
|
+
raise "Not implemented"
|
13
|
+
end
|
14
|
+
|
15
|
+
def list_outbound_invoice_errors
|
16
|
+
raise "Not implemented"
|
17
|
+
end
|
18
|
+
|
19
|
+
def list_inbound_invoice_actions
|
20
|
+
raise "Not implemented"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Maventa
|
2
|
+
class Resource
|
3
|
+
def initialize(connection, access_token)
|
4
|
+
@connection = connection
|
5
|
+
@access_token = access_token
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def connection(multipart: false)
|
11
|
+
if multipart
|
12
|
+
Faraday.new(
|
13
|
+
url: @connection.url_prefix,
|
14
|
+
headers: @connection.headers
|
15
|
+
) do |faraday|
|
16
|
+
faraday.request :multipart, content_type: "multipart/form-data"
|
17
|
+
faraday.request :url_encoded
|
18
|
+
end
|
19
|
+
else
|
20
|
+
@connection
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def auth_string
|
25
|
+
"#{@access_token&.token_type&.capitalize} #{@access_token&.token}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def request(
|
29
|
+
method,
|
30
|
+
url,
|
31
|
+
params: {},
|
32
|
+
payload: {},
|
33
|
+
expected_response_format: :json,
|
34
|
+
multipart: false
|
35
|
+
)
|
36
|
+
response = connection(multipart:).send(method, url) do |request|
|
37
|
+
request.headers["Authorization"] = auth_string
|
38
|
+
|
39
|
+
if multipart
|
40
|
+
request.headers["Content-Type"] = "multipart/form-data"
|
41
|
+
request.headers["Content-Disposition"] = 'form-data; name="file"; filename="invoice.xml"'
|
42
|
+
end
|
43
|
+
|
44
|
+
request.body = URI.encode_www_form(payload.compact)
|
45
|
+
end
|
46
|
+
|
47
|
+
check_status(response)
|
48
|
+
response_data = parse(response, format: expected_response_format)
|
49
|
+
|
50
|
+
if block_given?
|
51
|
+
yield response_data
|
52
|
+
else
|
53
|
+
response_data
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def check_status(response)
|
58
|
+
case response&.status
|
59
|
+
when 400..499
|
60
|
+
response_data = parse(response)
|
61
|
+
raise Maventa::RequestError.new(
|
62
|
+
response_data["message"],
|
63
|
+
code: response_data["code"]
|
64
|
+
)
|
65
|
+
when 500..599
|
66
|
+
raise Maventa::ServerError.new("Maventa API responded with 5xx")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def parse(response, format: :json)
|
71
|
+
case format
|
72
|
+
when :json
|
73
|
+
JSON.parse(response.body)
|
74
|
+
when :xml
|
75
|
+
Nokogiri::XML(response.body) do |options|
|
76
|
+
options.strict
|
77
|
+
end
|
78
|
+
else
|
79
|
+
raise "Unknown format"
|
80
|
+
end
|
81
|
+
rescue JSON::ParserError
|
82
|
+
rescue Nokogiri::XML::SyntaxError
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Maventa
|
2
|
+
class Services < Resource
|
3
|
+
def update_receivables
|
4
|
+
raise "Not implemented"
|
5
|
+
end
|
6
|
+
|
7
|
+
def disable_receivables
|
8
|
+
raise "Not implemented"
|
9
|
+
end
|
10
|
+
|
11
|
+
def start_receivables_onboarding
|
12
|
+
raise "Not implemented"
|
13
|
+
end
|
14
|
+
|
15
|
+
def show_receivables_state
|
16
|
+
raise "Not implemented"
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_atg_agreement
|
20
|
+
raise "Not implemented"
|
21
|
+
end
|
22
|
+
|
23
|
+
def list_atg_agreements
|
24
|
+
request(:get, "/v1/services/atg")
|
25
|
+
end
|
26
|
+
|
27
|
+
def list_b2c_atg_mandates
|
28
|
+
raise "Not implemented"
|
29
|
+
end
|
30
|
+
|
31
|
+
def update_atg_agreement
|
32
|
+
raise "Not implemented"
|
33
|
+
end
|
34
|
+
|
35
|
+
def show_atg_agreement
|
36
|
+
raise "Not implemented"
|
37
|
+
end
|
38
|
+
|
39
|
+
def show_op_invoice_account_statement
|
40
|
+
raise "Not implemented"
|
41
|
+
end
|
42
|
+
|
43
|
+
def make_op_invoice_direct_payment
|
44
|
+
raise "Not implemented"
|
45
|
+
end
|
46
|
+
|
47
|
+
def make_op_invoice_withdrawal
|
48
|
+
raise "Not implemented"
|
49
|
+
end
|
50
|
+
|
51
|
+
def check_op_invoice_credit_balance
|
52
|
+
raise "Not implemented"
|
53
|
+
end
|
54
|
+
|
55
|
+
def start_op_invoice_onboarding
|
56
|
+
raise "Not implemented"
|
57
|
+
end
|
58
|
+
|
59
|
+
def show_op_invoice_state
|
60
|
+
raise "Not implemented"
|
61
|
+
end
|
62
|
+
|
63
|
+
def update_op_invoice_settings
|
64
|
+
raise "Not implemented"
|
65
|
+
end
|
66
|
+
|
67
|
+
def show_op_invoice_settings
|
68
|
+
raise "Not implemented"
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_op_invoice_offer
|
72
|
+
raise "Not implemented"
|
73
|
+
end
|
74
|
+
|
75
|
+
def update_detect_checks
|
76
|
+
raise "Not implemented"
|
77
|
+
end
|
78
|
+
|
79
|
+
def list_detect_checks
|
80
|
+
request(:get, "/v1/services/detect/checks")
|
81
|
+
end
|
82
|
+
|
83
|
+
def show_b2cno_agreement_info
|
84
|
+
raise "Not implemented"
|
85
|
+
end
|
86
|
+
|
87
|
+
def list_b2cno_consumers
|
88
|
+
raise "Not implemented"
|
89
|
+
end
|
90
|
+
|
91
|
+
def show_b2cse_network_registration_request_status
|
92
|
+
raise "Not implemented"
|
93
|
+
end
|
94
|
+
|
95
|
+
def create_b2cse_network_registration_request
|
96
|
+
raise "Not implemented"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/maventa.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "faraday/multipart"
|
3
|
+
require "json"
|
4
|
+
require "uri"
|
5
|
+
require "nokogiri"
|
6
|
+
|
7
|
+
require_relative "maventa/version"
|
8
|
+
require_relative "maventa/error"
|
9
|
+
require_relative "maventa/request_error"
|
10
|
+
require_relative "maventa/server_error"
|
11
|
+
require_relative "maventa/resource"
|
12
|
+
require_relative "maventa/access_token"
|
13
|
+
require_relative "maventa/oauth2"
|
14
|
+
require_relative "maventa/client"
|
15
|
+
|
16
|
+
require_relative "maventa/analysis"
|
17
|
+
require_relative "maventa/companies"
|
18
|
+
require_relative "maventa/company"
|
19
|
+
require_relative "maventa/definitions"
|
20
|
+
require_relative "maventa/documents"
|
21
|
+
require_relative "maventa/files"
|
22
|
+
require_relative "maventa/fi_bank_messages"
|
23
|
+
require_relative "maventa/invoices"
|
24
|
+
require_relative "maventa/jwk"
|
25
|
+
require_relative "maventa/lookup"
|
26
|
+
require_relative "maventa/odp"
|
27
|
+
require_relative "maventa/operator"
|
28
|
+
require_relative "maventa/partner"
|
29
|
+
require_relative "maventa/services"
|
30
|
+
require_relative "maventa/status"
|
31
|
+
require_relative "maventa/users"
|
32
|
+
|
33
|
+
module Maventa
|
34
|
+
API_URL = {
|
35
|
+
testing: "https://ax-stage.maventa.com",
|
36
|
+
production: ""
|
37
|
+
}
|
38
|
+
|
39
|
+
DEFAULT_CONFIG = {
|
40
|
+
client_id: nil,
|
41
|
+
client_secret: nil,
|
42
|
+
vendor_api_key: nil
|
43
|
+
}
|
44
|
+
|
45
|
+
@config = DEFAULT_CONFIG.dup
|
46
|
+
|
47
|
+
class << self
|
48
|
+
attr_accessor :config
|
49
|
+
end
|
50
|
+
|
51
|
+
def configure
|
52
|
+
yield @config
|
53
|
+
end
|
54
|
+
|
55
|
+
module_function :configure
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maventa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mika Haulo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-02-28 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: '2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday-multipart
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.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.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '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'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: byebug
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: vcr
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: dotenv
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: Maventa API gem
|
154
|
+
email: mika@hey.com
|
155
|
+
executables: []
|
156
|
+
extensions: []
|
157
|
+
extra_rdoc_files: []
|
158
|
+
files:
|
159
|
+
- CHANGELOG.md
|
160
|
+
- README.md
|
161
|
+
- Rakefile
|
162
|
+
- lib/maventa.rb
|
163
|
+
- lib/maventa/access_token.rb
|
164
|
+
- lib/maventa/analysis.rb
|
165
|
+
- lib/maventa/client.rb
|
166
|
+
- lib/maventa/companies.rb
|
167
|
+
- lib/maventa/company.rb
|
168
|
+
- lib/maventa/definitions.rb
|
169
|
+
- lib/maventa/documents.rb
|
170
|
+
- lib/maventa/error.rb
|
171
|
+
- lib/maventa/fi_bank_messages.rb
|
172
|
+
- lib/maventa/files.rb
|
173
|
+
- lib/maventa/invoices.rb
|
174
|
+
- lib/maventa/jwk.rb
|
175
|
+
- lib/maventa/lookup.rb
|
176
|
+
- lib/maventa/oauth2.rb
|
177
|
+
- lib/maventa/odp.rb
|
178
|
+
- lib/maventa/operator.rb
|
179
|
+
- lib/maventa/partner.rb
|
180
|
+
- lib/maventa/request_error.rb
|
181
|
+
- lib/maventa/resource.rb
|
182
|
+
- lib/maventa/server_error.rb
|
183
|
+
- lib/maventa/services.rb
|
184
|
+
- lib/maventa/status.rb
|
185
|
+
- lib/maventa/users.rb
|
186
|
+
- lib/maventa/version.rb
|
187
|
+
homepage: https://github.com/mhaulo/maventa
|
188
|
+
licenses:
|
189
|
+
- MIT
|
190
|
+
metadata:
|
191
|
+
rubygems_mfa_required: 'true'
|
192
|
+
post_install_message:
|
193
|
+
rdoc_options: []
|
194
|
+
require_paths:
|
195
|
+
- lib
|
196
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '2.7'
|
201
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
|
+
requirements:
|
203
|
+
- - ">="
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
requirements: []
|
207
|
+
rubygems_version: 3.5.22
|
208
|
+
signing_key:
|
209
|
+
specification_version: 4
|
210
|
+
summary: Maventa API gem
|
211
|
+
test_files: []
|