Skip to content

Commit 78632de

Browse files
committed
feat: ruby test updates, small ruby and python generation updates, readme ruby usage example
1 parent a678e61 commit 78632de

File tree

11 files changed

+84
-61
lines changed

11 files changed

+84
-61
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,39 @@ with unit_python_sdk.ApiClient(configuration) as api_client:
297297
print("Exception when calling UnitApi->create_application: %s\n" % e)
298298
```
299299

300+
#### Ruby
301+
302+
```ruby
303+
token = "your_token"
304+
305+
@configuration = UnitOpenapiRubySdk::Configuration.new.tap do |config|
306+
config.access_token = token
307+
access_t = config.access_token
308+
config.api_key['Authorization'] = access_t
309+
config.api_key_prefix['Authorization'] = 'Bearer'
310+
end
311+
312+
let(:api_instance) { UnitOpenapiRubySdk::UnitApi.new(UnitOpenapiRubySdk::ApiClient.new(configuration)) }
313+
314+
315+
address = UnitOpenapiRubySdk::Address.new(street: '123 Main St', city: 'San Francisco', state: 'CA', postal_code: '94205', country: 'US')
316+
phone = UnitOpenapiRubySdk::Phone.new(country_code: '380', number: '555123222')
317+
318+
request = { data: UnitOpenapiRubySdk::CreateIndividualApplication
319+
.new(type: 'individualApplication',
320+
attributes: UnitOpenapiRubySdk::CreateIndividualApplicationAttributes
321+
.new(ssn: '123456789',
322+
full_name: UnitOpenapiRubySdk::FullName.new({ first: 'John', last: 'Kenn' }), date_of_birth: Date.new(1989, 2, 1),
323+
address: address,
324+
email: email,
325+
phone: phone,
326+
occupation: 'ArchitectOrEngineer',
327+
annual_income: 'UpTo10k',
328+
source_of_income: 'EmploymentOrPayrollIncome')).to_hash }
329+
330+
response = api_instance.create_application(request)
331+
```
332+
300333
## Known Generators Issues
301334

302335
### Java responses

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"fix-java-file-get-requests": "ts-node ./scripts/java/fixFileRelatedGetRequests.ts",
55
"add-version-header-to-java": "ts-node ./scripts/java/addVersionHeaderToApiClient.ts",
66
"generate-java": "rm -rf ./dist/java-sdk && npm run bundle && npx mkdirp dist/java-sdk/src/test/java/unit/java/sdk && cp -a ./unit/e2e_tests/java/. ./dist/java-sdk/src/test/java/unit/java/sdk && openapi-generator-cli generate -g java -i ./dist/bundledSchema.json -o ./dist/java-sdk -p hideGenerationTimestamp=true -p packageName=unit.java.sdk -p modelPackage=unit.java.sdk.model -p apiPackage=unit.java.sdk.api --library native -p useJakartaEe=true --openapi-normalizer REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true && npm run fix-java-file-get-requests -- --path=./dist/java-sdk/src/main/java/unit/java/sdk/api/UnitApi.java && npm run add-version-header-to-java -- --path=./dist/java-sdk/src/main/java/unit/java/sdk/ApiClient.java",
7-
"generate-ruby": "rm -rf ./dist/ruby-sdk && npm run bundle && cp -r unit ./dist/ruby-sdk && openapi-generator-cli generate -g ruby -i ./dist/bundledSchema.json -o ./dist/ruby-sdk",
8-
"generate-node": "rm -rf ./dist/node-sdk && npm run bundle && openapi-generator-cli generate -g typescript-axios -i ./dist/bundledSchema.json -o ./dist/node-sdk -p packageName=",
9-
"generate-python": "rm -rf ./dist/python-sdk && npm run bundle && openapi-generator-cli generate -i ./dist/bundledSchema.json -g python -o ./dist/python-sdk -p packageName=unit_python_sdk",
7+
"generate-ruby": "rm -rf ./dist/ruby-sdk && npm run bundle && openapi-generator-cli generate -g ruby -i ./dist/bundledSchema.json -o ./dist/ruby-sdk -p gemName=unit_openapi_ruby_sdk && rm -rf ./dist/ruby-sdk/spec && npx mkdirp dist/ruby-sdk/spec && cp -a ./unit/e2e_tests/ruby/spec ./dist/ruby-sdk",
8+
"generate-node": "rm -rf ./dist/node-sdk && npm run bundle && openapi-generator-cli generate -g typescript-axios -i ./dist/bundledSchema.json -o ./dist/node-sdk",
9+
"generate-python": "rm -rf ./dist/python-sdk && npm run bundle && openapi-generator-cli generate -i ./dist/bundledSchema.json -g python -o ./dist/python-sdk -p packageName=unit_openapi_python_sdk",
1010
"lint": "redocly lint --config .redocly.yaml openapi.json",
1111
"format": "prettier ./schemas --write"
1212
},

unit/e2e_tests/__init__.py

Whitespace-only changes.

unit/e2e_tests/ruby/spec/models/account_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77

88
describe 'test an instance of Account' do
99

10-
let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) }
10+
let(:api_instance) { UnitOpenapiRubySdk::UnitApi.new(UnitOpenapiRubySdk::ApiClient.new(configuration)) }
1111

1212
it 'Should create deposit account' do
1313
request = {
1414
data: {
1515
type: 'depositAccount',
16-
attributes: OpenapiClient::CreateDepositAccountAttributes.new(
16+
attributes: UnitOpenapiRubySdk::CreateDepositAccountAttributes.new(
1717
deposit_product: 'checking',
1818
tags: { "purpose": 'checking' },
1919
idempotency_key: '1234567890'
2020
).to_hash,
21-
relationships: OpenapiClient::CreateDepositAccountRelationships.new(
21+
relationships: UnitOpenapiRubySdk::CreateDepositAccountRelationships.new(
2222
customer: { "data": { "type": 'customer', "id": '751009' } }
2323
).to_hash
2424
}}
@@ -29,14 +29,14 @@
2929

3030

3131
it 'Should create a credit account' do
32-
request = { data: OpenapiClient::CreateCreditAccount.new(type: 'creditAccount',
32+
request = { data: UnitOpenapiRubySdk::CreateCreditAccount.new(type: 'creditAccount',
3333
attributes:
34-
OpenapiClient::CreateCreditAccountAttributes.new(
34+
UnitOpenapiRubySdk::CreateCreditAccountAttributes.new(
3535
{ credit_terms: 'credit_terms_test',
3636
credit_limit: 20_000,
3737
tags: { "purpose": 'tax' } }
3838
),
39-
relationships: OpenapiClient::CreateCreditAccountRelationships.new(
39+
relationships: UnitOpenapiRubySdk::CreateCreditAccountRelationships.new(
4040
customer: { "data": { "type": 'customer',
4141
"id": '851228' } }
4242
).to_hash).to_hash }
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'openapi_client'
3+
require 'unit_openapi_ruby_sdk'
44
require_relative '../spec_helper'
55
require 'json'
66
require 'date'
@@ -11,22 +11,16 @@
1111
end
1212

1313
describe 'test attribute "id"' do
14-
let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) }
14+
let(:api_instance) { UnitOpenapiRubySdk::UnitApi.new(UnitOpenapiRubySdk::ApiClient.new(configuration)) }
1515

1616
it 'should create an application' do
17-
request = { data: OpenapiClient::CreateIndividualApplication.new(type: 'individualApplication',
18-
attributes: OpenapiClient::CreateIndividualApplicationAttributes.new(
19-
ssn: '123456789', full_name: OpenapiClient::FullName.new({ first: 'John', last: 'Kenn' }), date_of_birth: Date.new(1989, 2, 1), address: ADDRESS, email: EMAIL, phone: PHONE,
17+
request = { data: UnitOpenapiRubySdk::CreateIndividualApplication.new(type: 'individualApplication',
18+
attributes: UnitOpenapiRubySdk::CreateIndividualApplicationAttributes.new(
19+
ssn: '123456789', full_name: UnitOpenapiRubySdk::FullName.new({ first: 'John', last: 'Kenn' }), date_of_birth: Date.new(1989, 2, 1), address: ADDRESS, email: EMAIL, phone: PHONE,
2020
occupation: 'ArchitectOrEngineer', annual_income: 'UpTo10k', source_of_income: 'EmploymentOrPayrollIncome'
2121
)).to_hash }
2222
response = api_instance.create_application(request)
2323
expect(response.data.type).to eq('individualApplication')
2424
end
25-
26-
it 'should upload a document for the application' do
27-
request = api_instance.upload_application_document_file('2624618', '541996', get_document_contents)
28-
29-
expect(request.data.type).to eq('document')
30-
end
3125
end
3226
end

unit/e2e_tests/ruby/spec/models/card_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'openapi_client'
3+
require 'unit_openapi_ruby_sdk'
44
require_relative '../spec_helper'
55

66
RSpec.describe 'Card' do
@@ -9,38 +9,38 @@
99
end
1010

1111
describe 'test an instance of CreateCard' do
12-
let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) }
12+
let(:api_instance) { UnitOpenapiRubySdk::UnitApi.new(UnitOpenapiRubySdk::ApiClient.new(configuration)) }
1313
let(:account_for_business) { api_instance.create_account(
1414
data: {
1515
type: 'depositAccount',
16-
attributes: OpenapiClient::CreateDepositAccountAttributes.new(
16+
attributes: UnitOpenapiRubySdk::CreateDepositAccountAttributes.new(
1717
deposit_product: 'checking',
1818
tags: { "purpose": 'checking' },
1919
idempotency_key: '1234567890'
2020
).to_hash, relationships: RELATIONSHIPS_BUSINESS }).data.id}
2121

2222

2323
it 'should create an individual debit card' do
24-
request = { data: OpenapiClient::CreateIndividualDebitCardRequest.new(type: 'individualDebitCard', attributes:
25-
OpenapiClient::CreateIndividualDebitCardRequestAttributes.new(
24+
request = { data: UnitOpenapiRubySdk::CreateIndividualDebitCardRequest.new(type: 'individualDebitCard', attributes:
25+
UnitOpenapiRubySdk::CreateIndividualDebitCardRequestAttributes.new(
2626
{ shipping_address: ADDRESS, tags: { "purpose": 'checking' },
2727
additional_embossed_text: 'additional_text', expiry_date: '03/28' }
2828
),
29-
relationships: OpenapiClient::CardRelationships.new(account: { "data": { "type": 'depositAccount',
29+
relationships: UnitOpenapiRubySdk::CardRelationships.new(account: { "data": { "type": 'depositAccount',
3030
"id": '4009403' } })).to_hash }
3131
response = api_instance.create_card(request)
3232
expect(response.data.type).to eq('individualDebitCard')
3333
end
3434

3535
it 'should create a business debit card' do
36-
request = { data: OpenapiClient::CreateBusinessDebitCardRequest.new(type: 'businessDebitCard', attributes:
37-
OpenapiClient::CreateBusinessDebitCardRequestAttributes.new(
36+
request = { data: UnitOpenapiRubySdk::CreateBusinessDebitCardRequest.new(type: 'businessDebitCard', attributes:
37+
UnitOpenapiRubySdk::CreateBusinessCardAttributes.new(
3838
{ shipping_address: ADDRESS, address: ADDRESS, full_name: FULL_NAME, phone: PHONE,
3939
email: EMAIL, date_of_birth: DATE_OF_BIRTH, nationality: 'US', ssn: SSN,
4040
tags: { "purpose": 'business' }, limits: LIMITS, idempotency_key: '1234567890',
4141
print_only_business_name: false, expiry_date: '03/28' }
4242
),
43-
relationships: OpenapiClient::CardRelationships.new(account: { "data": { "type": 'account',
43+
relationships: UnitOpenapiRubySdk::CardRelationships.new(account: { "data": { "type": 'account',
4444
"id": '3969030' } })).to_hash }
4545
response = api_instance.create_card(request)
4646
expect(response.data.type).to eq('businessDebitCard')

unit/e2e_tests/ruby/spec/models/customer_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
require 'json'
33
require 'date'
44

5-
# Unit tests for OpenapiClient::Customer
5+
# Unit tests for UnitOpenapiRubySdk::Customer
66
# Automatically generated by openapi-generator (https://openapi-generator.tech)
77
# Please update as you see appropriate
88
RSpec.describe 'Customer' do
99
before do
1010
configure_tests
1111
end
1212
describe 'test an instance of Customer' do
13-
let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) }
13+
let(:api_instance) { UnitOpenapiRubySdk::UnitApi.new(UnitOpenapiRubySdk::ApiClient.new(configuration)) }
1414
it 'should get an instance of individual Customer' do
1515
response = api_instance.get_customer('733576')
1616
expect(response.data.type).to eq('individualCustomer')
@@ -23,7 +23,7 @@
2323
end
2424

2525
describe 'test an instance of list customers' do
26-
let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) }
26+
let(:api_instance) { UnitOpenapiRubySdk::UnitApi.new(UnitOpenapiRubySdk::ApiClient.new(configuration)) }
2727

2828
it 'should list customers' do
2929
opts = { query_params: {"page[limit]": 10, "page[offset]": 0, "filter[email]": '[email protected]'}}

unit/e2e_tests/ruby/spec/models/payment_spec.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
require 'spec_helper'
22
require 'json'
33
require 'date'
4+
require 'dotenv'
45

5-
# Unit tests for OpenapiClient::Payment
6+
# Unit tests for UnitOpenapiRubySdk::Payment
67
# Automatically generated by openapi-generator (https://openapi-generator.tech)
78
# Please update as you see appropriate
89
RSpec.describe 'Payment' do
@@ -11,20 +12,21 @@
1112
end
1213

1314
describe 'test an instance of Payment' do
14-
let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) }
15+
let(:api_instance) { UnitOpenapiRubySdk::UnitApi.new(UnitOpenapiRubySdk::ApiClient.new(configuration)) }
1516

1617
it 'should create an instance of BookPayment' do
17-
request = { data: OpenapiClient::CreateBookPayment.new(type: 'bookPayment', attributes:
18-
OpenapiClient::CreateBookPaymentAttributes.new(amount: 1000, description: 'test payment', tags: { "test": 'test-tag' }),
19-
relationships: OpenapiClient::CreateBookPaymentRelationships.new(account: { "data": { "type": 'depositAccount', "id": '27573' } }, counterparty_account: { "data": { "type": 'depositAccount', "id": '36981' } }).to_hash).to_hash }
18+
request = { data: UnitOpenapiRubySdk::CreateBookPayment.new(type: 'bookPayment', attributes:
19+
UnitOpenapiRubySdk::CreateBookPaymentAttributes.new(amount: 1000, description: 'test payment', tags: { "test": 'test-tag' }),
20+
relationships: UnitOpenapiRubySdk::CreateBookPaymentRelationships.new(account: { "data": { "type": 'depositAccount', "id": '27573' } }, counterparty_account: { "data": { "type": 'depositAccount', "id": '36981' } }).to_hash).to_hash }
2021
response = api_instance.create_payment(request)
2122
expect(response.data.type).to eq('bookPayment')
2223
end
2324

2425
it 'should create an instance of AchPayment with plaid token' do
25-
request = { data: OpenapiClient::CreateAchPaymentPlaid.new(type: 'achPayment', attributes:
26-
OpenapiClient::CreateAchPaymentPlaidAttributes.new(amount: 1000, direction: 'Credit', description: 'test payment', plaid_processor_token: 'processor-sandbox-1424a3b1-2b56-4d46-9e11-1fdc70fd3724'),
27-
relationships: OpenapiClient::CreateAchPaymentRelationships.new(account: { "data": { "type": 'depositAccount', "id": '27573' } }).to_hash).to_hash }
26+
Dotenv.load
27+
request = { data: UnitOpenapiRubySdk::CreateAchPaymentPlaid.new(type: 'achPayment', attributes:
28+
UnitOpenapiRubySdk::CreateAchPaymentPlaidAttributes.new(amount: 1000, direction: 'Credit', description: 'test payment', plaid_processor_token: ENV['TEST_PLAID_TOKEN']),
29+
relationships: UnitOpenapiRubySdk::CreateAchPaymentRelationships.new(account: { "data": { "type": 'depositAccount', "id": '27573' } }).to_hash).to_hash }
2830
response = api_instance.create_payment(request)
2931
expect(response.data.type).to eq('achPayment')
3032
end

unit/e2e_tests/ruby/spec/models/received_payment_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'json'
33
require 'date'
44

5-
# Unit tests for OpenapiClient::Payment
5+
# Unit tests for UnitOpenapiRubySdk::Payment
66
# Automatically generated by openapi-generator (https://openapi-generator.tech)
77
# Please update as you see appropriate
88
RSpec.describe 'ReceivedPayment' do
@@ -11,7 +11,7 @@
1111
end
1212

1313
describe 'test an instance of Payment' do
14-
let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) }
14+
let(:api_instance) { UnitOpenapiRubySdk::UnitApi.new(UnitOpenapiRubySdk::ApiClient.new(configuration)) }
1515

1616
it 'should get an instance of ReceivedPayment' do
1717
response = api_instance.get_received_payment("8266")

unit/e2e_tests/ruby/spec/models/statement_spec.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
end
1212

1313
describe 'test an instance of Statement' do
14-
let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) }
14+
let(:api_instance) { UnitOpenapiRubySdk::UnitApi.new(UnitOpenapiRubySdk::ApiClient.new(configuration)) }
1515

1616

1717
it 'should get an instance of html statement' do
@@ -21,11 +21,7 @@
2121
language: 'en'
2222
}
2323
}
24-
response_data, status_code, headers = api_instance.get_statement_html('146206', opts)
25-
26-
expect(status_code).to eq(200)
27-
28-
expect(headers['Content-Type']).to include('text/html')
24+
response_data = api_instance.get_statement_html('146206', opts)
2925

3026
# Read the content from the IO stream, if it's an IO object
3127
content = if response_data.is_a?(Tempfile) || response_data.is_a?(File)
@@ -41,10 +37,7 @@
4137

4238
it 'should get an instance of pdf statement' do
4339
opts = { query_params: { customer_id: '22603' } }
44-
response_data, status_code, headers = api_instance.get_statement_pdf('146206', opts)
45-
46-
expect(status_code).to eq(200)
47-
expect(headers['Content-Type']).to include('application/pdf')
40+
response_data = api_instance.get_statement_pdf('146206', opts)
4841

4942
# Read the first few bytes of the Tempfile
5043
response_data.open
@@ -55,8 +48,7 @@
5548
end
5649

5750
it 'should get an instance of bank verification pdf statement' do
58-
response_data, status_code, headers = api_instance.get_statement_bank_pdf('36981')
59-
expect(status_code).to eq(200)
51+
response_data = api_instance.get_statement_bank_pdf('36981')
6052

6153
# If the response_data is a string:
6254
if response_data.is_a?(String)

0 commit comments

Comments
 (0)