payabli 3.0.4 → 3.0.6
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/.fern/metadata.json +4 -4
- data/lib/payabli/bill/client.rb +119 -0
- data/lib/payabli/boarding/client.rb +209 -0
- data/lib/payabli/charge_backs/client.rb +20 -0
- data/lib/payabli/check_capture/client.rb +10 -0
- data/lib/payabli/client.rb +8 -6
- data/lib/payabli/cloud/client.rb +29 -0
- data/lib/payabli/customer/client.rb +54 -0
- data/lib/payabli/export/client.rb +321 -0
- data/lib/payabli/funding/client.rb +9 -0
- data/lib/payabli/ghost_card/client.rb +31 -0
- data/lib/payabli/hosted_payment_pages/client.rb +23 -0
- data/lib/payabli/import/client.rb +15 -0
- data/lib/payabli/internal/http/raw_client.rb +26 -0
- data/lib/payabli/internal/oauth_provider.rb +8 -2
- data/lib/payabli/internal/routing_auth_provider.rb +51 -0
- data/lib/payabli/invoice/client.rb +118 -0
- data/lib/payabli/line_item/client.rb +43 -0
- data/lib/payabli/management/client.rb +13 -0
- data/lib/payabli/money_in/client.rb +238 -0
- data/lib/payabli/money_out/client.rb +94 -0
- data/lib/payabli/notification/client.rb +46 -0
- data/lib/payabli/notificationlogs/client.rb +27 -0
- data/lib/payabli/ocr/client.rb +10 -0
- data/lib/payabli/organization/client.rb +91 -0
- data/lib/payabli/payment_link/client.rb +367 -0
- data/lib/payabli/payment_method_domain/client.rb +56 -0
- data/lib/payabli/payout_subscription/client.rb +50 -0
- data/lib/payabli/paypoint/client.rb +56 -0
- data/lib/payabli/query/client.rb +414 -0
- data/lib/payabli/statistic/client.rb +39 -0
- data/lib/payabli/subscription/client.rb +46 -0
- data/lib/payabli/templates/client.rb +28 -0
- data/lib/payabli/token/client.rb +8 -0
- data/lib/payabli/token_storage/client.rb +55 -0
- data/lib/payabli/types/application_data.rb +1 -1
- data/lib/payabli/types/application_data_managed.rb +1 -1
- data/lib/payabli/types/application_data_odp.rb +1 -1
- data/lib/payabli/types/application_data_pay_in.rb +1 -1
- data/lib/payabli/types/on_create.rb +1 -1
- data/lib/payabli/types/pay_method_body_all_fields.rb +1 -1
- data/lib/payabli/user/client.rb +67 -0
- data/lib/payabli/vendor/client.rb +102 -0
- data/lib/payabli/version.rb +1 -1
- data/lib/payabli/wallet/client.rb +34 -0
- data/lib/payabli.rb +1 -0
- data/reference.md +219 -219
- data/wiremock/wiremock-mappings.json +32 -1302
- metadata +3 -2
|
@@ -21,13 +21,22 @@ module Payabli
|
|
|
21
21
|
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
22
22
|
# @option request_options [Integer] :timeout_in_seconds
|
|
23
23
|
#
|
|
24
|
+
# @example
|
|
25
|
+
# client.funding.deposit_funds(
|
|
26
|
+
# amount: 10,
|
|
27
|
+
# entrypoint: "48acde49",
|
|
28
|
+
# account_id: "333"
|
|
29
|
+
# )
|
|
30
|
+
#
|
|
24
31
|
# @return [Payabli::Types::DepositFundsResponse]
|
|
25
32
|
def deposit_funds(request_options: {}, **params)
|
|
26
33
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
34
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
27
35
|
request = Payabli::Internal::JSON::Request.new(
|
|
28
36
|
base_url: request_options[:base_url],
|
|
29
37
|
method: "POST",
|
|
30
38
|
path: "Funding/depositFunds",
|
|
39
|
+
headers: headers,
|
|
31
40
|
body: Payabli::Funding::Types::DepositFundsRequest.new(params).to_h,
|
|
32
41
|
request_options: request_options
|
|
33
42
|
)
|
|
@@ -28,6 +28,26 @@ module Payabli
|
|
|
28
28
|
# @option request_options [Integer] :timeout_in_seconds
|
|
29
29
|
# @option params [Payabli::Types::Entry] :entry
|
|
30
30
|
#
|
|
31
|
+
# @example
|
|
32
|
+
# client.ghost_card.create_ghost_card(
|
|
33
|
+
# entry: "8cfec329267",
|
|
34
|
+
# vendor_id: 456,
|
|
35
|
+
# expense_limit: 500,
|
|
36
|
+
# amount: 500,
|
|
37
|
+
# max_number_of_uses: 3,
|
|
38
|
+
# exact_amount: false,
|
|
39
|
+
# expense_limit_period: "monthly",
|
|
40
|
+
# billing_cycle: "monthly",
|
|
41
|
+
# billing_cycle_day: "1",
|
|
42
|
+
# daily_transaction_count: 5,
|
|
43
|
+
# daily_amount_limit: 200,
|
|
44
|
+
# transaction_amount_limit: 100,
|
|
45
|
+
# mcc: "5411",
|
|
46
|
+
# tcc: "R",
|
|
47
|
+
# misc_1: "PO-98765",
|
|
48
|
+
# misc_2: "Dept-Finance"
|
|
49
|
+
# )
|
|
50
|
+
#
|
|
31
51
|
# @return [Payabli::Types::CreateGhostCardResponse]
|
|
32
52
|
def create_ghost_card(request_options: {}, **params)
|
|
33
53
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
@@ -35,10 +55,12 @@ module Payabli
|
|
|
35
55
|
non_body_param_names = %w[entry]
|
|
36
56
|
body = request_data.except(*non_body_param_names)
|
|
37
57
|
|
|
58
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
38
59
|
request = Payabli::Internal::JSON::Request.new(
|
|
39
60
|
base_url: request_options[:base_url],
|
|
40
61
|
method: "POST",
|
|
41
62
|
path: "MoneyOutCard/GhostCard/#{URI.encode_uri_component(params[:entry].to_s)}",
|
|
63
|
+
headers: headers,
|
|
42
64
|
body: body,
|
|
43
65
|
request_options: request_options
|
|
44
66
|
)
|
|
@@ -67,6 +89,13 @@ module Payabli
|
|
|
67
89
|
# @option request_options [Integer] :timeout_in_seconds
|
|
68
90
|
# @option params [Payabli::Types::Entry] :entry
|
|
69
91
|
#
|
|
92
|
+
# @example
|
|
93
|
+
# client.ghost_card.update_card(
|
|
94
|
+
# entry: "8cfec329267",
|
|
95
|
+
# card_token: "gc_abc123def456",
|
|
96
|
+
# status: "Cancelled"
|
|
97
|
+
# )
|
|
98
|
+
#
|
|
70
99
|
# @return [Payabli::Types::PayabliApiResponse]
|
|
71
100
|
def update_card(request_options: {}, **params)
|
|
72
101
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
@@ -74,10 +103,12 @@ module Payabli
|
|
|
74
103
|
non_body_param_names = %w[entry]
|
|
75
104
|
body = request_data.except(*non_body_param_names)
|
|
76
105
|
|
|
106
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
77
107
|
request = Payabli::Internal::JSON::Request.new(
|
|
78
108
|
base_url: request_options[:base_url],
|
|
79
109
|
method: "PATCH",
|
|
80
110
|
path: "MoneyOutCard/card/#{URI.encode_uri_component(params[:entry].to_s)}",
|
|
111
|
+
headers: headers,
|
|
81
112
|
body: body,
|
|
82
113
|
request_options: request_options
|
|
83
114
|
)
|
|
@@ -23,13 +23,21 @@ module Payabli
|
|
|
23
23
|
# @option params [String] :entry
|
|
24
24
|
# @option params [String] :subdomain
|
|
25
25
|
#
|
|
26
|
+
# @example
|
|
27
|
+
# client.hosted_payment_pages.load_page(
|
|
28
|
+
# entry: "8cfec329267",
|
|
29
|
+
# subdomain: "pay-your-fees-1"
|
|
30
|
+
# )
|
|
31
|
+
#
|
|
26
32
|
# @return [Payabli::Types::PayabliPages]
|
|
27
33
|
def load_page(request_options: {}, **params)
|
|
28
34
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
35
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
29
36
|
request = Payabli::Internal::JSON::Request.new(
|
|
30
37
|
base_url: request_options[:base_url],
|
|
31
38
|
method: "GET",
|
|
32
39
|
path: "Paypoint/load/#{URI.encode_uri_component(params[:entry].to_s)}/#{URI.encode_uri_component(params[:subdomain].to_s)}",
|
|
40
|
+
headers: headers,
|
|
33
41
|
request_options: request_options
|
|
34
42
|
)
|
|
35
43
|
begin
|
|
@@ -60,6 +68,12 @@ module Payabli
|
|
|
60
68
|
# @option params [String] :entry
|
|
61
69
|
# @option params [String, nil] :idempotency_key
|
|
62
70
|
#
|
|
71
|
+
# @example
|
|
72
|
+
# client.hosted_payment_pages.new_page(
|
|
73
|
+
# entry: "8cfec329267",
|
|
74
|
+
# idempotency_key: "6B29FC40-CA47-1067-B31D-00DD010662DA"
|
|
75
|
+
# )
|
|
76
|
+
#
|
|
63
77
|
# @return [Payabli::Types::PayabliApiResponse00Responsedatanonobject]
|
|
64
78
|
def new_page(request_options: {}, **params)
|
|
65
79
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
@@ -69,6 +83,7 @@ module Payabli
|
|
|
69
83
|
headers = {}
|
|
70
84
|
headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]
|
|
71
85
|
|
|
86
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers)
|
|
72
87
|
request = Payabli::Internal::JSON::Request.new(
|
|
73
88
|
base_url: request_options[:base_url],
|
|
74
89
|
method: "POST",
|
|
@@ -103,13 +118,21 @@ module Payabli
|
|
|
103
118
|
# @option params [String] :entry
|
|
104
119
|
# @option params [String] :subdomain
|
|
105
120
|
#
|
|
121
|
+
# @example
|
|
122
|
+
# client.hosted_payment_pages.save_page(
|
|
123
|
+
# entry: "8cfec329267",
|
|
124
|
+
# subdomain: "pay-your-fees-1"
|
|
125
|
+
# )
|
|
126
|
+
#
|
|
106
127
|
# @return [Payabli::Types::PayabliApiResponse00Responsedatanonobject]
|
|
107
128
|
def save_page(request_options: {}, **params)
|
|
108
129
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
130
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
109
131
|
request = Payabli::Internal::JSON::Request.new(
|
|
110
132
|
base_url: request_options[:base_url],
|
|
111
133
|
method: "PUT",
|
|
112
134
|
path: "Paypoint/#{URI.encode_uri_component(params[:entry].to_s)}/#{URI.encode_uri_component(params[:subdomain].to_s)}",
|
|
135
|
+
headers: headers,
|
|
113
136
|
body: Payabli::Types::PayabliPages.new(params).to_h,
|
|
114
137
|
request_options: request_options
|
|
115
138
|
)
|
|
@@ -22,6 +22,9 @@ module Payabli
|
|
|
22
22
|
# @option request_options [Integer] :timeout_in_seconds
|
|
23
23
|
# @option params [String] :entry
|
|
24
24
|
#
|
|
25
|
+
# @example
|
|
26
|
+
# client.import.import_bills(entry: "8cfec329267")
|
|
27
|
+
#
|
|
25
28
|
# @return [Payabli::Types::PayabliApiResponseImport]
|
|
26
29
|
def import_bills(request_options: {}, **params)
|
|
27
30
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
@@ -29,10 +32,12 @@ module Payabli
|
|
|
29
32
|
|
|
30
33
|
body.add_part(params[:file].to_form_data_part(name: "file")) if params[:file]
|
|
31
34
|
|
|
35
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
32
36
|
request = Payabli::Internal::Multipart::Request.new(
|
|
33
37
|
base_url: request_options[:base_url],
|
|
34
38
|
method: "POST",
|
|
35
39
|
path: "Import/billsForm/#{URI.encode_uri_component(params[:entry].to_s)}",
|
|
40
|
+
headers: headers,
|
|
36
41
|
body: body,
|
|
37
42
|
request_options: request_options
|
|
38
43
|
)
|
|
@@ -63,6 +68,9 @@ module Payabli
|
|
|
63
68
|
# @option params [Payabli::Types::Entrypointfield] :entry
|
|
64
69
|
# @option params [Integer, nil] :replace_existing
|
|
65
70
|
#
|
|
71
|
+
# @example
|
|
72
|
+
# client.import.import_customer(entry: "8cfec329267")
|
|
73
|
+
#
|
|
66
74
|
# @return [Payabli::Types::PayabliApiResponseImport]
|
|
67
75
|
def import_customer(request_options: {}, **params)
|
|
68
76
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
@@ -70,10 +78,12 @@ module Payabli
|
|
|
70
78
|
|
|
71
79
|
body.add_part(params[:file].to_form_data_part(name: "file")) if params[:file]
|
|
72
80
|
|
|
81
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
73
82
|
request = Payabli::Internal::Multipart::Request.new(
|
|
74
83
|
base_url: request_options[:base_url],
|
|
75
84
|
method: "POST",
|
|
76
85
|
path: "Import/customersForm/#{URI.encode_uri_component(params[:entry].to_s)}",
|
|
86
|
+
headers: headers,
|
|
77
87
|
body: body,
|
|
78
88
|
request_options: request_options
|
|
79
89
|
)
|
|
@@ -103,6 +113,9 @@ module Payabli
|
|
|
103
113
|
# @option request_options [Integer] :timeout_in_seconds
|
|
104
114
|
# @option params [Payabli::Types::Entrypointfield] :entry
|
|
105
115
|
#
|
|
116
|
+
# @example
|
|
117
|
+
# client.import.import_vendor(entry: "8cfec329267")
|
|
118
|
+
#
|
|
106
119
|
# @return [Payabli::Types::PayabliApiResponseImport]
|
|
107
120
|
def import_vendor(request_options: {}, **params)
|
|
108
121
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
@@ -110,10 +123,12 @@ module Payabli
|
|
|
110
123
|
|
|
111
124
|
body.add_part(params[:file].to_form_data_part(name: "file")) if params[:file]
|
|
112
125
|
|
|
126
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
113
127
|
request = Payabli::Internal::Multipart::Request.new(
|
|
114
128
|
base_url: request_options[:base_url],
|
|
115
129
|
method: "POST",
|
|
116
130
|
path: "Import/vendorsForm/#{URI.encode_uri_component(params[:entry].to_s)}",
|
|
131
|
+
headers: headers,
|
|
117
132
|
body: body,
|
|
118
133
|
request_options: request_options
|
|
119
134
|
)
|
|
@@ -177,6 +177,18 @@ module Payabli
|
|
|
177
177
|
@auth_provider.auth_headers
|
|
178
178
|
end
|
|
179
179
|
|
|
180
|
+
# Resolves the auth headers for a single endpoint given its declared security
|
|
181
|
+
# requirements. Under endpoint-security each endpoint applies only the schemes it
|
|
182
|
+
# declares, so it delegates to the routing auth provider with its own `security`.
|
|
183
|
+
# Returns an empty hash when no auth provider is configured.
|
|
184
|
+
# @param security [Array, nil] The endpoint's security requirements.
|
|
185
|
+
# @return [Hash] The auth headers to send for this endpoint.
|
|
186
|
+
def auth_headers_for_endpoint(security:)
|
|
187
|
+
return {} if @auth_provider.nil?
|
|
188
|
+
|
|
189
|
+
@auth_provider.auth_headers_for_endpoint(security: security)
|
|
190
|
+
end
|
|
191
|
+
|
|
180
192
|
# @param url [URI::Generic] The url to the resource.
|
|
181
193
|
# @param method [String] The HTTP method to use.
|
|
182
194
|
# @param headers [Hash] The headers for the request.
|
|
@@ -197,9 +209,23 @@ module Payabli
|
|
|
197
209
|
request_headers.each { |name, value| request[name] = value }
|
|
198
210
|
request.body = body if body
|
|
199
211
|
|
|
212
|
+
# Net::HTTP disables its transparent gzip/deflate decoding as soon as an
|
|
213
|
+
# Accept-Encoding header is set explicitly on the request. Re-enable it so
|
|
214
|
+
# that compressed response bodies are still inflated.
|
|
215
|
+
request.extend(DecodeContent) if request_headers.keys.any? { |name| name.to_s.casecmp("accept-encoding").zero? }
|
|
216
|
+
|
|
200
217
|
request
|
|
201
218
|
end
|
|
202
219
|
|
|
220
|
+
# Keeps Net::HTTP's transparent gzip/deflate response decoding enabled
|
|
221
|
+
# even when an Accept-Encoding header is set explicitly on the request.
|
|
222
|
+
# @api private
|
|
223
|
+
module DecodeContent
|
|
224
|
+
def decode_content # rubocop:disable Naming/PredicateMethod
|
|
225
|
+
true
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
203
229
|
# @param query [Hash] The query for the request.
|
|
204
230
|
# @return [String, nil] The encoded query.
|
|
205
231
|
def encode_query(query)
|
|
@@ -12,18 +12,24 @@ module Payabli
|
|
|
12
12
|
def initialize(auth_client:, options:)
|
|
13
13
|
@auth_client = auth_client
|
|
14
14
|
@options = options
|
|
15
|
+
@mutex = Mutex.new
|
|
15
16
|
@access_token = nil
|
|
16
17
|
@expires_at = nil
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
# Returns a cached access token, refreshing if necessary.
|
|
20
21
|
# Refreshes the token if it's nil, or if we're within the buffer period before expiration.
|
|
22
|
+
# Only one thread refreshes the token at a time.
|
|
21
23
|
#
|
|
22
24
|
# @return [String]
|
|
23
25
|
def token
|
|
24
|
-
return
|
|
26
|
+
return @access_token unless @access_token.nil? || token_needs_refresh?
|
|
25
27
|
|
|
26
|
-
@
|
|
28
|
+
@mutex.synchronize do
|
|
29
|
+
return @access_token unless @access_token.nil? || token_needs_refresh?
|
|
30
|
+
|
|
31
|
+
refresh
|
|
32
|
+
end
|
|
27
33
|
end
|
|
28
34
|
|
|
29
35
|
# Returns the authentication headers to be included in requests.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Payabli
|
|
4
|
+
module Internal
|
|
5
|
+
class RoutingAuthProvider
|
|
6
|
+
# @param api_key [untyped]
|
|
7
|
+
# @param oauth_provider [untyped]
|
|
8
|
+
#
|
|
9
|
+
# @return [void]
|
|
10
|
+
def initialize(api_key: nil, oauth_provider: nil)
|
|
11
|
+
@api_key = api_key
|
|
12
|
+
@oauth_provider = oauth_provider
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Endpoint-security applies auth per-endpoint, so no auth headers are added to every request.
|
|
16
|
+
#
|
|
17
|
+
# @return [Hash[String, String]]
|
|
18
|
+
def auth_headers
|
|
19
|
+
{}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns the auth headers for a single endpoint given its static security requirements.
|
|
23
|
+
# Builds only the headers for the first requirement whose schemes all have credentials available (OR across the
|
|
24
|
+
# list, AND within a requirement). Raises when none is satisfiable.
|
|
25
|
+
#
|
|
26
|
+
# @param security [untyped]
|
|
27
|
+
#
|
|
28
|
+
# @return [Hash[String, String]]
|
|
29
|
+
def auth_headers_for_endpoint(security:)
|
|
30
|
+
return {} if security.nil? || security.empty?
|
|
31
|
+
|
|
32
|
+
available_auth_headers = {}
|
|
33
|
+
available_auth_headers["APIKeyAuth"] = { "requestToken" => @api_key.to_s } unless @api_key.nil?
|
|
34
|
+
available_auth_headers["BearerAuth"] = @oauth_provider.auth_headers unless @oauth_provider.nil?
|
|
35
|
+
|
|
36
|
+
security.each do |requirement|
|
|
37
|
+
next unless requirement.keys.all? { |scheme_key| available_auth_headers.key?(scheme_key) }
|
|
38
|
+
|
|
39
|
+
combined_headers = {}
|
|
40
|
+
requirement.each_key { |scheme_key| combined_headers.merge!(available_auth_headers[scheme_key]) }
|
|
41
|
+
return combined_headers
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
missing_schemes = security.map do |requirement|
|
|
45
|
+
requirement.keys.reject { |scheme_key| available_auth_headers.key?(scheme_key) }.join(" AND ")
|
|
46
|
+
end
|
|
47
|
+
raise ArgumentError, "No authentication credentials provided that satisfy the endpoint's security requirements. Please provide credentials for: #{missing_schemes.join(" OR ")}"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -23,6 +23,40 @@ module Payabli
|
|
|
23
23
|
# @option params [Boolean, nil] :force_customer_creation
|
|
24
24
|
# @option params [String, nil] :idempotency_key
|
|
25
25
|
#
|
|
26
|
+
# @example
|
|
27
|
+
# client.invoice.add_invoice(
|
|
28
|
+
# entry: "8cfec329267",
|
|
29
|
+
# customer_data: {
|
|
30
|
+
# first_name: "Tamara",
|
|
31
|
+
# last_name: "Bagratoni",
|
|
32
|
+
# customer_number: "C-90010"
|
|
33
|
+
# },
|
|
34
|
+
# invoice_data: {
|
|
35
|
+
# items: [{
|
|
36
|
+
# item_product_name: "Adventure Consult",
|
|
37
|
+
# item_description: "Consultation for Georgian tours",
|
|
38
|
+
# item_cost: 100,
|
|
39
|
+
# item_qty: 2,
|
|
40
|
+
# item_mode: 2,
|
|
41
|
+
# item_total_amount: 200
|
|
42
|
+
# }, {
|
|
43
|
+
# item_product_name: "Deposit ",
|
|
44
|
+
# item_description: "Deposit for trip planning",
|
|
45
|
+
# item_cost: 882.37,
|
|
46
|
+
# item_qty: 1,
|
|
47
|
+
# item_mode: 2,
|
|
48
|
+
# item_total_amount: 882.37
|
|
49
|
+
# }],
|
|
50
|
+
# invoice_date: "2025-10-19",
|
|
51
|
+
# invoice_type: 0,
|
|
52
|
+
# invoice_status: 1,
|
|
53
|
+
# frequency: "onetime",
|
|
54
|
+
# invoice_amount: 1082.37,
|
|
55
|
+
# discount: 10,
|
|
56
|
+
# invoice_number: "INV-2345"
|
|
57
|
+
# }
|
|
58
|
+
# )
|
|
59
|
+
#
|
|
26
60
|
# @return [Payabli::Types::InvoiceResponseWithoutData]
|
|
27
61
|
def add_invoice(request_options: {}, **params)
|
|
28
62
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
@@ -37,6 +71,7 @@ module Payabli
|
|
|
37
71
|
headers = {}
|
|
38
72
|
headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]
|
|
39
73
|
|
|
74
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers)
|
|
40
75
|
request = Payabli::Internal::JSON::Request.new(
|
|
41
76
|
base_url: request_options[:base_url],
|
|
42
77
|
method: "POST",
|
|
@@ -73,16 +108,24 @@ module Payabli
|
|
|
73
108
|
# @option params [String] :filename
|
|
74
109
|
# @option params [Boolean, nil] :return_object
|
|
75
110
|
#
|
|
111
|
+
# @example
|
|
112
|
+
# client.invoice.get_attached_file_from_invoice(
|
|
113
|
+
# id_invoice: 1,
|
|
114
|
+
# filename: "filename"
|
|
115
|
+
# )
|
|
116
|
+
#
|
|
76
117
|
# @return [Payabli::Types::FileContent]
|
|
77
118
|
def get_attached_file_from_invoice(request_options: {}, **params)
|
|
78
119
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
79
120
|
query_params = {}
|
|
80
121
|
query_params["returnObject"] = params[:return_object] if params.key?(:return_object)
|
|
81
122
|
|
|
123
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
82
124
|
request = Payabli::Internal::JSON::Request.new(
|
|
83
125
|
base_url: request_options[:base_url],
|
|
84
126
|
method: "GET",
|
|
85
127
|
path: "Invoice/attachedFileFromInvoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}/#{URI.encode_uri_component(params[:filename].to_s)}",
|
|
128
|
+
headers: headers,
|
|
86
129
|
query: query_params,
|
|
87
130
|
request_options: request_options
|
|
88
131
|
)
|
|
@@ -112,13 +155,21 @@ module Payabli
|
|
|
112
155
|
# @option params [Integer] :id_invoice
|
|
113
156
|
# @option params [String] :filename
|
|
114
157
|
#
|
|
158
|
+
# @example
|
|
159
|
+
# client.invoice.delete_attached_from_invoice(
|
|
160
|
+
# id_invoice: 23548884,
|
|
161
|
+
# filename: "0_Bill.pdf"
|
|
162
|
+
# )
|
|
163
|
+
#
|
|
115
164
|
# @return [Payabli::Types::InvoiceResponseWithoutData]
|
|
116
165
|
def delete_attached_from_invoice(request_options: {}, **params)
|
|
117
166
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
167
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
118
168
|
request = Payabli::Internal::JSON::Request.new(
|
|
119
169
|
base_url: request_options[:base_url],
|
|
120
170
|
method: "DELETE",
|
|
121
171
|
path: "Invoice/attachedFileFromInvoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}/#{URI.encode_uri_component(params[:filename].to_s)}",
|
|
172
|
+
headers: headers,
|
|
122
173
|
request_options: request_options
|
|
123
174
|
)
|
|
124
175
|
begin
|
|
@@ -146,13 +197,18 @@ module Payabli
|
|
|
146
197
|
# @option request_options [Integer] :timeout_in_seconds
|
|
147
198
|
# @option params [Integer] :id_invoice
|
|
148
199
|
#
|
|
200
|
+
# @example
|
|
201
|
+
# client.invoice.get_invoice(id_invoice: 23548884)
|
|
202
|
+
#
|
|
149
203
|
# @return [Payabli::Types::GetInvoiceRecord]
|
|
150
204
|
def get_invoice(request_options: {}, **params)
|
|
151
205
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
206
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
152
207
|
request = Payabli::Internal::JSON::Request.new(
|
|
153
208
|
base_url: request_options[:base_url],
|
|
154
209
|
method: "GET",
|
|
155
210
|
path: "Invoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}",
|
|
211
|
+
headers: headers,
|
|
156
212
|
request_options: request_options
|
|
157
213
|
)
|
|
158
214
|
begin
|
|
@@ -181,6 +237,22 @@ module Payabli
|
|
|
181
237
|
# @option params [Integer] :id_invoice
|
|
182
238
|
# @option params [Boolean, nil] :force_customer_creation
|
|
183
239
|
#
|
|
240
|
+
# @example
|
|
241
|
+
# client.invoice.edit_invoice(
|
|
242
|
+
# id_invoice: 23548884,
|
|
243
|
+
# invoice_data: {
|
|
244
|
+
# items: [{
|
|
245
|
+
# item_product_name: "Deposit",
|
|
246
|
+
# item_description: "Deposit for trip planning",
|
|
247
|
+
# item_cost: 882.37,
|
|
248
|
+
# item_qty: 1
|
|
249
|
+
# }],
|
|
250
|
+
# invoice_date: "2025-10-19",
|
|
251
|
+
# invoice_amount: 982.37,
|
|
252
|
+
# invoice_number: "INV-2345"
|
|
253
|
+
# }
|
|
254
|
+
# )
|
|
255
|
+
#
|
|
184
256
|
# @return [Payabli::Types::InvoiceResponseWithoutData]
|
|
185
257
|
def edit_invoice(request_options: {}, **params)
|
|
186
258
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
@@ -192,10 +264,12 @@ module Payabli
|
|
|
192
264
|
query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation)
|
|
193
265
|
params = params.except(*query_param_names)
|
|
194
266
|
|
|
267
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
195
268
|
request = Payabli::Internal::JSON::Request.new(
|
|
196
269
|
base_url: request_options[:base_url],
|
|
197
270
|
method: "PUT",
|
|
198
271
|
path: "Invoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}",
|
|
272
|
+
headers: headers,
|
|
199
273
|
query: query_params,
|
|
200
274
|
body: Payabli::Types::InvoiceDataRequest.new(body_params).to_h,
|
|
201
275
|
request_options: request_options
|
|
@@ -225,13 +299,18 @@ module Payabli
|
|
|
225
299
|
# @option request_options [Integer] :timeout_in_seconds
|
|
226
300
|
# @option params [Integer] :id_invoice
|
|
227
301
|
#
|
|
302
|
+
# @example
|
|
303
|
+
# client.invoice.delete_invoice(id_invoice: 23548884)
|
|
304
|
+
#
|
|
228
305
|
# @return [Payabli::Types::InvoiceResponseWithoutData]
|
|
229
306
|
def delete_invoice(request_options: {}, **params)
|
|
230
307
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
308
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
231
309
|
request = Payabli::Internal::JSON::Request.new(
|
|
232
310
|
base_url: request_options[:base_url],
|
|
233
311
|
method: "DELETE",
|
|
234
312
|
path: "Invoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}",
|
|
313
|
+
headers: headers,
|
|
235
314
|
request_options: request_options
|
|
236
315
|
)
|
|
237
316
|
begin
|
|
@@ -259,13 +338,18 @@ module Payabli
|
|
|
259
338
|
# @option request_options [Integer] :timeout_in_seconds
|
|
260
339
|
# @option params [String] :entry
|
|
261
340
|
#
|
|
341
|
+
# @example
|
|
342
|
+
# client.invoice.get_invoice_number(entry: "8cfec329267")
|
|
343
|
+
#
|
|
262
344
|
# @return [Payabli::Types::InvoiceNumberResponse]
|
|
263
345
|
def get_invoice_number(request_options: {}, **params)
|
|
264
346
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
347
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
265
348
|
request = Payabli::Internal::JSON::Request.new(
|
|
266
349
|
base_url: request_options[:base_url],
|
|
267
350
|
method: "GET",
|
|
268
351
|
path: "Invoice/getNumber/#{URI.encode_uri_component(params[:entry].to_s)}",
|
|
352
|
+
headers: headers,
|
|
269
353
|
request_options: request_options
|
|
270
354
|
)
|
|
271
355
|
begin
|
|
@@ -299,6 +383,14 @@ module Payabli
|
|
|
299
383
|
# @option params [Hash[String, String, nil], nil] :parameters
|
|
300
384
|
# @option params [String, nil] :sort_by
|
|
301
385
|
#
|
|
386
|
+
# @example
|
|
387
|
+
# client.invoice.list_invoices(
|
|
388
|
+
# entry: "8cfec329267",
|
|
389
|
+
# from_record: 251,
|
|
390
|
+
# limit_record: 0,
|
|
391
|
+
# sort_by: "desc(field_name)"
|
|
392
|
+
# )
|
|
393
|
+
#
|
|
302
394
|
# @return [Payabli::Types::QueryInvoiceResponse]
|
|
303
395
|
def list_invoices(request_options: {}, **params)
|
|
304
396
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
@@ -309,10 +401,12 @@ module Payabli
|
|
|
309
401
|
query_params["parameters"] = params[:parameters] if params.key?(:parameters)
|
|
310
402
|
query_params["sortBy"] = params[:sort_by] if params.key?(:sort_by)
|
|
311
403
|
|
|
404
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
312
405
|
request = Payabli::Internal::JSON::Request.new(
|
|
313
406
|
base_url: request_options[:base_url],
|
|
314
407
|
method: "GET",
|
|
315
408
|
path: "Query/invoices/#{URI.encode_uri_component(params[:entry].to_s)}",
|
|
409
|
+
headers: headers,
|
|
316
410
|
query: query_params,
|
|
317
411
|
request_options: request_options
|
|
318
412
|
)
|
|
@@ -347,6 +441,14 @@ module Payabli
|
|
|
347
441
|
# @option params [Hash[String, String, nil], nil] :parameters
|
|
348
442
|
# @option params [String, nil] :sort_by
|
|
349
443
|
#
|
|
444
|
+
# @example
|
|
445
|
+
# client.invoice.list_invoices_org(
|
|
446
|
+
# org_id: 123,
|
|
447
|
+
# from_record: 251,
|
|
448
|
+
# limit_record: 0,
|
|
449
|
+
# sort_by: "desc(field_name)"
|
|
450
|
+
# )
|
|
451
|
+
#
|
|
350
452
|
# @return [Payabli::Types::QueryInvoiceResponse]
|
|
351
453
|
def list_invoices_org(request_options: {}, **params)
|
|
352
454
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
@@ -357,10 +459,12 @@ module Payabli
|
|
|
357
459
|
query_params["parameters"] = params[:parameters] if params.key?(:parameters)
|
|
358
460
|
query_params["sortBy"] = params[:sort_by] if params.key?(:sort_by)
|
|
359
461
|
|
|
462
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
360
463
|
request = Payabli::Internal::JSON::Request.new(
|
|
361
464
|
base_url: request_options[:base_url],
|
|
362
465
|
method: "GET",
|
|
363
466
|
path: "Query/invoices/org/#{URI.encode_uri_component(params[:org_id].to_s)}",
|
|
467
|
+
headers: headers,
|
|
364
468
|
query: query_params,
|
|
365
469
|
request_options: request_options
|
|
366
470
|
)
|
|
@@ -391,6 +495,13 @@ module Payabli
|
|
|
391
495
|
# @option params [Boolean, nil] :attachfile
|
|
392
496
|
# @option params [String, nil] :mail_2
|
|
393
497
|
#
|
|
498
|
+
# @example
|
|
499
|
+
# client.invoice.send_invoice(
|
|
500
|
+
# id_invoice: 23548884,
|
|
501
|
+
# attachfile: true,
|
|
502
|
+
# mail_2: "tamara@example.com"
|
|
503
|
+
# )
|
|
504
|
+
#
|
|
394
505
|
# @return [Payabli::Types::SendInvoiceResponse]
|
|
395
506
|
def send_invoice(request_options: {}, **params)
|
|
396
507
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
@@ -398,10 +509,12 @@ module Payabli
|
|
|
398
509
|
query_params["attachfile"] = params[:attachfile] if params.key?(:attachfile)
|
|
399
510
|
query_params["mail2"] = params[:mail_2] if params.key?(:mail_2)
|
|
400
511
|
|
|
512
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
401
513
|
request = Payabli::Internal::JSON::Request.new(
|
|
402
514
|
base_url: request_options[:base_url],
|
|
403
515
|
method: "GET",
|
|
404
516
|
path: "Invoice/send/#{URI.encode_uri_component(params[:id_invoice].to_s)}",
|
|
517
|
+
headers: headers,
|
|
405
518
|
query: query_params,
|
|
406
519
|
request_options: request_options
|
|
407
520
|
)
|
|
@@ -430,13 +543,18 @@ module Payabli
|
|
|
430
543
|
# @option request_options [Integer] :timeout_in_seconds
|
|
431
544
|
# @option params [Integer] :id_invoice
|
|
432
545
|
#
|
|
546
|
+
# @example
|
|
547
|
+
# client.invoice.get_invoice_pdf(id_invoice: 23548884)
|
|
548
|
+
#
|
|
433
549
|
# @return [Hash[String, Object]]
|
|
434
550
|
def get_invoice_pdf(request_options: {}, **params)
|
|
435
551
|
params = Payabli::Internal::Types::Utils.normalize_keys(params)
|
|
552
|
+
headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
|
|
436
553
|
request = Payabli::Internal::JSON::Request.new(
|
|
437
554
|
base_url: request_options[:base_url],
|
|
438
555
|
method: "GET",
|
|
439
556
|
path: "Export/invoicePdf/#{URI.encode_uri_component(params[:id_invoice].to_s)}",
|
|
557
|
+
headers: headers,
|
|
440
558
|
request_options: request_options
|
|
441
559
|
)
|
|
442
560
|
begin
|