aurepay 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 695c5a72cd18ad993fe620e32b4d0f739ec2c41fa45f128d14a7d17004ec4c0c
4
+ data.tar.gz: a0416882bf39fa09cf35b9891444dd683212c48da7315e638c6bf0cc86e70ac1
5
+ SHA512:
6
+ metadata.gz: e1a6bfc23e65d99bbc827b1c48297dfc1eca64d0ad3442e3dfb7d0ef2f9d45e6374bfbb4dd8f83368ae35821c53ef78cf932e4ff14861fdd1fb090caf4cd74f1
7
+ data.tar.gz: 5c6713cebb798abfdba5f85e3ee044b686489655bfb0c1c16ddafbb5d93fc202c0314a413bc3a7588f98b8258af13adcf90488bcaf8eb83dd19f72d00f7cde6d
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) AurePay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # aurepay
2
+
3
+ SDK oficial da API AurePay para Ruby.
4
+
5
+ ## Instalação
6
+
7
+ ```bash
8
+ gem install aurepay
9
+ ```
10
+
11
+ ## Uso
12
+
13
+ ```ruby
14
+ require 'aurepay'
15
+
16
+ aure = AurePay.new(
17
+ api_key: ENV['AUREPAY_API_KEY'],
18
+ api_secret: ENV['AUREPAY_API_SECRET']
19
+ )
20
+
21
+ aure.deposits.create({ amount: 10_000, method: 'pix' })
22
+ aure.webhooks.list
23
+ aure.company.balance
24
+ ```
25
+
26
+ Docs: https://api.aurepay.com.br/docs/sdks
27
+ OpenAPI: https://api.aurepay.com.br/openapi.yaml
@@ -0,0 +1,195 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'net/http'
5
+ require 'uri'
6
+
7
+ module AurePay
8
+ # Erro tipado da API AurePay.
9
+ class Error < StandardError
10
+ attr_reader :code, :details, :status_code
11
+
12
+ def initialize(message, code: nil, details: nil, status_code: 0)
13
+ super(message)
14
+ @code = code
15
+ @details = details
16
+ @status_code = status_code
17
+ end
18
+ end
19
+
20
+ # Transporte HTTP autenticado com retry em 429.
21
+ class HttpTransport
22
+ def initialize(api_key:, api_secret:, base_url:, max_retries: 2)
23
+ @api_key = api_key
24
+ @api_secret = api_secret
25
+ @base_url = base_url.sub(%r{/\z}, '')
26
+ @max_retries = max_retries
27
+ end
28
+
29
+ # Executa requisição autenticada e desempacota o envelope `data`.
30
+ def request(method, path, body: nil, extra_headers: {})
31
+ url = URI("#{@base_url}/#{path.sub(%r{\A/}, '')}")
32
+ attempt = 0
33
+
34
+ loop do
35
+ attempt += 1
36
+ http = Net::HTTP.new(url.host, url.port)
37
+ http.use_ssl = url.scheme == 'https'
38
+
39
+ verb = method.to_s.upcase
40
+ request_class = {
41
+ 'GET' => Net::HTTP::Get,
42
+ 'POST' => Net::HTTP::Post,
43
+ 'PUT' => Net::HTTP::Put,
44
+ 'PATCH' => Net::HTTP::Patch,
45
+ 'DELETE' => Net::HTTP::Delete
46
+ }.fetch(verb)
47
+
48
+ request = request_class.new(url)
49
+ request['X-Api-Key'] = @api_key
50
+ request['X-Api-Secret'] = @api_secret
51
+ request['Accept'] = 'application/json'
52
+ request['Content-Type'] = 'application/json'
53
+ extra_headers.each { |key, value| request[key] = value }
54
+ request.body = JSON.generate(body) unless body.nil?
55
+
56
+ response = http.request(request)
57
+ status = response.code.to_i
58
+ raw = response.body.to_s
59
+ decoded = raw.empty? ? nil : JSON.parse(raw)
60
+
61
+ if status == 429 && attempt <= @max_retries + 1
62
+ sleep([1, (response['Retry-After'] || '1').to_i].max)
63
+ next
64
+ end
65
+
66
+ if status >= 400
67
+ error = decoded.is_a?(Hash) ? decoded['error'] : nil
68
+ message = error.is_a?(Hash) ? (error['message'] || 'Request failed.') : 'Request failed.'
69
+ raise Error.new(
70
+ message.to_s,
71
+ code: error.is_a?(Hash) ? error['code'] : nil,
72
+ details: error.is_a?(Hash) ? error['details'] : nil,
73
+ status_code: status
74
+ )
75
+ end
76
+
77
+ return decoded['data'] if decoded.is_a?(Hash) && decoded.key?('data')
78
+
79
+ return decoded
80
+ end
81
+ end
82
+ end
83
+
84
+ # Recurso CRUD genérico (list/create/get/update/delete).
85
+ class CrudResource
86
+ def initialize(http, base_path)
87
+ @http = http
88
+ @base_path = base_path
89
+ end
90
+
91
+ def list(query = {})
92
+ path = @base_path
93
+ unless query.nil? || query.empty?
94
+ path = "#{path}?#{URI.encode_www_form(query)}"
95
+ end
96
+ @http.request('Get', path)
97
+ end
98
+
99
+ def create(payload, idempotency_key: nil)
100
+ headers = idempotency_key ? { 'Idempotency-Key' => idempotency_key } : {}
101
+ @http.request('Post', @base_path, body: payload, extra_headers: headers)
102
+ end
103
+
104
+ def get(id)
105
+ @http.request('Get', "#{@base_path}/#{URI.encode_www_form_component(id)}")
106
+ end
107
+
108
+ def update(id, payload)
109
+ @http.request('Put', "#{@base_path}/#{URI.encode_www_form_component(id)}", body: payload)
110
+ end
111
+
112
+ def delete(id)
113
+ @http.request('Delete', "#{@base_path}/#{URI.encode_www_form_component(id)}")
114
+ end
115
+ end
116
+
117
+ # Empresa autenticada e saldo.
118
+ class Company
119
+ def initialize(http)
120
+ @http = http
121
+ end
122
+
123
+ # Dados da empresa (GET /company).
124
+ def get
125
+ @http.request('Get', '/company')
126
+ end
127
+
128
+ # Saldo disponível (GET /company/balance).
129
+ def balance
130
+ @http.request('Get', '/company/balance')
131
+ end
132
+ end
133
+
134
+ # Conversões BRL/USDT.
135
+ class Conversions < CrudResource
136
+ def initialize(http)
137
+ super(http, '/conversions')
138
+ end
139
+
140
+ # Cotação de conversão (POST /conversions/quote).
141
+ def quote(payload)
142
+ @http.request('Post', '/conversions/quote', body: payload)
143
+ end
144
+ end
145
+
146
+ # Infrações / MED.
147
+ class Chargebacks
148
+ def initialize(http)
149
+ @http = http
150
+ end
151
+
152
+ def list(query = {})
153
+ path = '/chargebacks'
154
+ unless query.nil? || query.empty?
155
+ path = "#{path}?#{URI.encode_www_form(query)}"
156
+ end
157
+ @http.request('Get', path)
158
+ end
159
+
160
+ def get(id)
161
+ @http.request('Get', "/chargebacks/#{URI.encode_www_form_component(id)}")
162
+ end
163
+ end
164
+
165
+ # Facade principal da API AurePay.
166
+ class Client
167
+ attr_reader :deposits, :withdrawals, :webhooks, :company, :conversions, :chargebacks, :wallets
168
+
169
+ def initialize(api_key:, api_secret:, base_url: 'https://api.aurepay.com.br/v1', max_retries: 2)
170
+ api_key = api_key.to_s.strip
171
+ api_secret = api_secret.to_s.strip
172
+ raise Error.new('api_key and api_secret are required.') if api_key.empty? || api_secret.empty?
173
+
174
+ http = HttpTransport.new(
175
+ api_key: api_key,
176
+ api_secret: api_secret,
177
+ base_url: base_url,
178
+ max_retries: max_retries
179
+ )
180
+
181
+ @deposits = CrudResource.new(http, '/deposits')
182
+ @withdrawals = CrudResource.new(http, '/withdrawals')
183
+ @webhooks = CrudResource.new(http, '/webhooks')
184
+ @company = Company.new(http)
185
+ @conversions = Conversions.new(http)
186
+ @chargebacks = Chargebacks.new(http)
187
+ @wallets = CrudResource.new(http, '/wallets')
188
+ end
189
+ end
190
+
191
+ # Alias ergonômico: AurePay.new(...)
192
+ def self.new(**kwargs)
193
+ Client.new(**kwargs)
194
+ end
195
+ end
@@ -0,0 +1,138 @@
1
+ =begin
2
+ #AurePay REST API
3
+
4
+ #API REST AurePay (camelCase inglês): depósitos PIX, saques, conversões BRL/USDT, webhooks, empresa, carteiras e MED/chargebacks. Auth: headers `X-Api-Key` e `X-Api-Secret`. Envelope: `{ \"success\": true, \"data\": ... }` / `{ \"success\": false, \"error\": { \"code\", \"message\", \"details\" } }`. Fonte para agentes: https://api.aurepay.com.br/llms-full.txt
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.23.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module AurePay
16
+ class ChargebacksApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Consulta infração / MED
23
+ # @param id [String] Identificador ULID do recurso
24
+ # @param [Hash] opts the optional parameters
25
+ # @return [SuccessEnvelope]
26
+ def chargebacks_get(id, opts = {})
27
+ data, _status_code, _headers = chargebacks_get_with_http_info(id, opts)
28
+ data
29
+ end
30
+
31
+ # Consulta infração / MED
32
+ # @param id [String] Identificador ULID do recurso
33
+ # @param [Hash] opts the optional parameters
34
+ # @return [Array<(SuccessEnvelope, Integer, Hash)>] SuccessEnvelope data, response status code and response headers
35
+ def chargebacks_get_with_http_info(id, opts = {})
36
+ if @api_client.config.debugging
37
+ @api_client.config.logger.debug 'Calling API: ChargebacksApi.chargebacks_get ...'
38
+ end
39
+ # verify the required parameter 'id' is set
40
+ if @api_client.config.client_side_validation && id.nil?
41
+ fail ArgumentError, "Missing the required parameter 'id' when calling ChargebacksApi.chargebacks_get"
42
+ end
43
+ # resource path
44
+ local_var_path = '/chargebacks/{id}'.sub('{id}', CGI.escape(id.to_s))
45
+
46
+ # query parameters
47
+ query_params = opts[:query_params] || {}
48
+
49
+ # header parameters
50
+ header_params = opts[:header_params] || {}
51
+ # HTTP header 'Accept' (if needed)
52
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
53
+
54
+ # form parameters
55
+ form_params = opts[:form_params] || {}
56
+
57
+ # http body (model)
58
+ post_body = opts[:debug_body]
59
+
60
+ # return_type
61
+ return_type = opts[:debug_return_type] || 'SuccessEnvelope'
62
+
63
+ # auth_names
64
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth', 'ApiSecretAuth']
65
+
66
+ new_options = opts.merge(
67
+ :operation => :"ChargebacksApi.chargebacks_get",
68
+ :header_params => header_params,
69
+ :query_params => query_params,
70
+ :form_params => form_params,
71
+ :body => post_body,
72
+ :auth_names => auth_names,
73
+ :return_type => return_type
74
+ )
75
+
76
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
77
+ if @api_client.config.debugging
78
+ @api_client.config.logger.debug "API called: ChargebacksApi#chargebacks_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
79
+ end
80
+ return data, status_code, headers
81
+ end
82
+
83
+ # Lista infrações / MED
84
+ # @param [Hash] opts the optional parameters
85
+ # @return [SuccessEnvelope]
86
+ def chargebacks_list(opts = {})
87
+ data, _status_code, _headers = chargebacks_list_with_http_info(opts)
88
+ data
89
+ end
90
+
91
+ # Lista infrações / MED
92
+ # @param [Hash] opts the optional parameters
93
+ # @return [Array<(SuccessEnvelope, Integer, Hash)>] SuccessEnvelope data, response status code and response headers
94
+ def chargebacks_list_with_http_info(opts = {})
95
+ if @api_client.config.debugging
96
+ @api_client.config.logger.debug 'Calling API: ChargebacksApi.chargebacks_list ...'
97
+ end
98
+ # resource path
99
+ local_var_path = '/chargebacks'
100
+
101
+ # query parameters
102
+ query_params = opts[:query_params] || {}
103
+
104
+ # header parameters
105
+ header_params = opts[:header_params] || {}
106
+ # HTTP header 'Accept' (if needed)
107
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
108
+
109
+ # form parameters
110
+ form_params = opts[:form_params] || {}
111
+
112
+ # http body (model)
113
+ post_body = opts[:debug_body]
114
+
115
+ # return_type
116
+ return_type = opts[:debug_return_type] || 'SuccessEnvelope'
117
+
118
+ # auth_names
119
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth', 'ApiSecretAuth']
120
+
121
+ new_options = opts.merge(
122
+ :operation => :"ChargebacksApi.chargebacks_list",
123
+ :header_params => header_params,
124
+ :query_params => query_params,
125
+ :form_params => form_params,
126
+ :body => post_body,
127
+ :auth_names => auth_names,
128
+ :return_type => return_type
129
+ )
130
+
131
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
132
+ if @api_client.config.debugging
133
+ @api_client.config.logger.debug "API called: ChargebacksApi#chargebacks_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
134
+ end
135
+ return data, status_code, headers
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,132 @@
1
+ =begin
2
+ #AurePay REST API
3
+
4
+ #API REST AurePay (camelCase inglês): depósitos PIX, saques, conversões BRL/USDT, webhooks, empresa, carteiras e MED/chargebacks. Auth: headers `X-Api-Key` e `X-Api-Secret`. Envelope: `{ \"success\": true, \"data\": ... }` / `{ \"success\": false, \"error\": { \"code\", \"message\", \"details\" } }`. Fonte para agentes: https://api.aurepay.com.br/llms-full.txt
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.23.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module AurePay
16
+ class CompanyApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Saldo disponível
23
+ # @param [Hash] opts the optional parameters
24
+ # @return [SuccessEnvelope]
25
+ def company_balance(opts = {})
26
+ data, _status_code, _headers = company_balance_with_http_info(opts)
27
+ data
28
+ end
29
+
30
+ # Saldo disponível
31
+ # @param [Hash] opts the optional parameters
32
+ # @return [Array<(SuccessEnvelope, Integer, Hash)>] SuccessEnvelope data, response status code and response headers
33
+ def company_balance_with_http_info(opts = {})
34
+ if @api_client.config.debugging
35
+ @api_client.config.logger.debug 'Calling API: CompanyApi.company_balance ...'
36
+ end
37
+ # resource path
38
+ local_var_path = '/company/balance'
39
+
40
+ # query parameters
41
+ query_params = opts[:query_params] || {}
42
+
43
+ # header parameters
44
+ header_params = opts[:header_params] || {}
45
+ # HTTP header 'Accept' (if needed)
46
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
47
+
48
+ # form parameters
49
+ form_params = opts[:form_params] || {}
50
+
51
+ # http body (model)
52
+ post_body = opts[:debug_body]
53
+
54
+ # return_type
55
+ return_type = opts[:debug_return_type] || 'SuccessEnvelope'
56
+
57
+ # auth_names
58
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth', 'ApiSecretAuth']
59
+
60
+ new_options = opts.merge(
61
+ :operation => :"CompanyApi.company_balance",
62
+ :header_params => header_params,
63
+ :query_params => query_params,
64
+ :form_params => form_params,
65
+ :body => post_body,
66
+ :auth_names => auth_names,
67
+ :return_type => return_type
68
+ )
69
+
70
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
71
+ if @api_client.config.debugging
72
+ @api_client.config.logger.debug "API called: CompanyApi#company_balance\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
73
+ end
74
+ return data, status_code, headers
75
+ end
76
+
77
+ # Dados da empresa autenticada
78
+ # @param [Hash] opts the optional parameters
79
+ # @return [SuccessEnvelope]
80
+ def company_get(opts = {})
81
+ data, _status_code, _headers = company_get_with_http_info(opts)
82
+ data
83
+ end
84
+
85
+ # Dados da empresa autenticada
86
+ # @param [Hash] opts the optional parameters
87
+ # @return [Array<(SuccessEnvelope, Integer, Hash)>] SuccessEnvelope data, response status code and response headers
88
+ def company_get_with_http_info(opts = {})
89
+ if @api_client.config.debugging
90
+ @api_client.config.logger.debug 'Calling API: CompanyApi.company_get ...'
91
+ end
92
+ # resource path
93
+ local_var_path = '/company'
94
+
95
+ # query parameters
96
+ query_params = opts[:query_params] || {}
97
+
98
+ # header parameters
99
+ header_params = opts[:header_params] || {}
100
+ # HTTP header 'Accept' (if needed)
101
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
102
+
103
+ # form parameters
104
+ form_params = opts[:form_params] || {}
105
+
106
+ # http body (model)
107
+ post_body = opts[:debug_body]
108
+
109
+ # return_type
110
+ return_type = opts[:debug_return_type] || 'SuccessEnvelope'
111
+
112
+ # auth_names
113
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth', 'ApiSecretAuth']
114
+
115
+ new_options = opts.merge(
116
+ :operation => :"CompanyApi.company_get",
117
+ :header_params => header_params,
118
+ :query_params => query_params,
119
+ :form_params => form_params,
120
+ :body => post_body,
121
+ :auth_names => auth_names,
122
+ :return_type => return_type
123
+ )
124
+
125
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
126
+ if @api_client.config.debugging
127
+ @api_client.config.logger.debug "API called: CompanyApi#company_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
128
+ end
129
+ return data, status_code, headers
130
+ end
131
+ end
132
+ end