Skip to content

Commit a5f6c82

Browse files
Merge pull request #19 from mxenabled/bm/support_lists
Support non-paginated list endpoints
2 parents 12bbdc0 + 14a1729 commit a5f6c82

4 files changed

Lines changed: 35 additions & 34 deletions

File tree

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
*.gem
22
*.swp
3-
.DS_Store
43
.bundle
54
.config
5+
.DS_Store
6+
.idea
67
.ruby-*
78
.rvmrc
89
.yardoc
9-
.idea
10-
Gemfile.lock
1110
coverage
11+
Gemfile.lock
1212
pkg/*
1313
tmp

.rubocop.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ AllCops:
33
SuggestExtensions: false # Disabling extension suggestions
44
TargetRubyVersion: 2.6
55

6+
Layout/LineLength:
7+
Description: Checks the length of lines in the source code
8+
Exclude:
9+
- 'spec/lib/**/*.rb' # Excluding to avoid multiline expect statements
10+
IgnoredPatterns: ['^ endpoint: ".*'] # Excluding since the endpoints may require longer lines
11+
Max: 120
12+
613
Metrics/AbcSize:
714
Description: Checks that the ABC size of methods is not higher than the configured maximum
815
Exclude:
916
- 'lib/mx-platform-ruby/pageable.rb' # Disabling because clarity > brevity
1017

11-
Metrics/MethodLength:
12-
Description: Checks if the length a method exceeds some maximum value
13-
Enabled: false # Disabling to allow class methods to grow with number of attributes
14-
1518
Metrics/BlockLength:
1619
Description: Checks if the length of a block exceeds some maximum value
1720
Exclude:
@@ -21,12 +24,9 @@ Metrics/ClassLength:
2124
Description: Checks if the length a class exceeds some maximum value
2225
Enabled: false # Disabling because clarity > brevity
2326

24-
Layout/LineLength:
25-
Description: Checks the length of lines in the source code
26-
Exclude:
27-
- 'spec/lib/**/*.rb' # Excluding to avoid multiline expect statements
28-
IgnoredPatterns: ['^ endpoint: ".*'] # Excluding since the endpoints may requrie longer lines
29-
Max: 120
27+
Metrics/MethodLength:
28+
Description: Checks if the length a method exceeds some maximum value
29+
Enabled: false # Disabling to allow class methods to grow with number of attributes
3030

3131
Naming/FileName:
3232
Description: Checks that Ruby source files have snake_case names

lib/mx-platform-ruby/enhanced_transaction.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ def self.enhance_transactions(options = {})
2525
enhance_transactions_options = enhance_transactions_options(options)
2626
response = ::MXPlatformRuby.client.make_request(enhance_transactions_options)
2727

28-
transactions_params = response['transactions']
29-
::MXPlatformRuby::EnhancedTransaction.new(transactions_params)
28+
response['transactions'].map { |attributes| ::MXPlatformRuby::EnhancedTransaction.new(attributes) }
3029
end
3130

3231
# Private class methods

spec/lib/mx-platform-ruby/enhanced_transaction_spec.rb

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,31 @@
3838
end
3939

4040
describe 'enhance_transactions' do
41-
let(:enhance_transactions_response) { { 'transactions' => enhanced_transaction_attributes } }
41+
let(:enhance_transactions_response) { { 'transactions' => [enhanced_transaction_attributes] } }
4242
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(enhance_transactions_response) }
4343

44-
it 'returns enhanced_transaction' do
44+
it 'returns an array of enhanced_transactions' do
4545
response = described_class.enhance_transactions
4646

47-
expect(response).to be_kind_of(::MXPlatformRuby::EnhancedTransaction)
48-
expect(response.amount).to eq(enhanced_transaction_attributes[:amount])
49-
expect(response.category).to eq(enhanced_transaction_attributes[:category])
50-
expect(response.description).to eq(enhanced_transaction_attributes[:description])
51-
expect(response.id).to eq(enhanced_transaction_attributes[:id])
52-
expect(response.is_bill_pay).to eq(enhanced_transaction_attributes[:is_bill_pay])
53-
expect(response.is_direct_deposit).to eq(enhanced_transaction_attributes[:is_direct_deposit])
54-
expect(response.is_expense).to eq(enhanced_transaction_attributes[:is_expense])
55-
expect(response.is_fee).to eq(enhanced_transaction_attributes[:is_fee])
56-
expect(response.is_income).to eq(enhanced_transaction_attributes[:is_income])
57-
expect(response.is_international).to eq(enhanced_transaction_attributes[:is_international])
58-
expect(response.is_overdraft_fee).to eq(enhanced_transaction_attributes[:is_overdraft_fee])
59-
expect(response.is_payroll_advance).to eq(enhanced_transaction_attributes[:is_payroll_advance])
60-
expect(response.merchant_category_code).to eq(enhanced_transaction_attributes[:merchant_category_code])
61-
expect(response.merchant_guid).to eq(enhanced_transaction_attributes[:merchant_guid])
62-
expect(response.original_description).to eq(enhanced_transaction_attributes[:original_description])
63-
expect(response.type).to eq(enhanced_transaction_attributes[:type])
47+
expect(response).to be_kind_of(::Array)
48+
expect(response.first).to be_kind_of(::MXPlatformRuby::EnhancedTransaction)
49+
expect(response.first.amount).to eq(enhanced_transaction_attributes[:amount])
50+
expect(response.first.category).to eq(enhanced_transaction_attributes[:category])
51+
expect(response.first.description).to eq(enhanced_transaction_attributes[:description])
52+
expect(response.first.id).to eq(enhanced_transaction_attributes[:id])
53+
expect(response.first.is_bill_pay).to eq(enhanced_transaction_attributes[:is_bill_pay])
54+
expect(response.first.is_direct_deposit).to eq(enhanced_transaction_attributes[:is_direct_deposit])
55+
expect(response.first.is_expense).to eq(enhanced_transaction_attributes[:is_expense])
56+
expect(response.first.is_fee).to eq(enhanced_transaction_attributes[:is_fee])
57+
expect(response.first.is_income).to eq(enhanced_transaction_attributes[:is_income])
58+
expect(response.first.is_international).to eq(enhanced_transaction_attributes[:is_international])
59+
expect(response.first.is_overdraft_fee).to eq(enhanced_transaction_attributes[:is_overdraft_fee])
60+
expect(response.first.is_payroll_advance).to eq(enhanced_transaction_attributes[:is_payroll_advance])
61+
expect(response.first.merchant_category_code).to eq(enhanced_transaction_attributes[:merchant_category_code])
62+
expect(response.first.merchant_guid).to eq(enhanced_transaction_attributes[:merchant_guid])
63+
expect(response.first.original_description).to eq(enhanced_transaction_attributes[:original_description])
64+
expect(response.first.type).to eq(enhanced_transaction_attributes[:type])
65+
expect(response.length).to eq(1)
6466
end
6567

6668
it 'makes a client request with the expected params' do

0 commit comments

Comments
 (0)