|
333 | 333 | end |
334 | 334 | end |
335 | 335 | end |
| 336 | + |
| 337 | + context 'when billing_entity_code is provided' do |
| 338 | + let(:params_with_billing_entity) { params.merge(billing_entity_code: 'eu_entity') } |
| 339 | + let(:body_with_billing_entity) do |
| 340 | + body['wallet']['billing_entity_code'] = 'eu_entity' |
| 341 | + body |
| 342 | + end |
| 343 | + let(:response_with_billing_entity) do |
| 344 | + { |
| 345 | + 'wallet' => { |
| 346 | + 'lago_id' => 'this-is-lago-id', |
| 347 | + 'lago_customer_id' => factory_wallet.id, |
| 348 | + 'name' => factory_wallet.name, |
| 349 | + 'billing_entity_code' => 'eu_entity', |
| 350 | + 'expiration_at' => factory_wallet.expiration_at, |
| 351 | + 'balance_cents' => 10_000, |
| 352 | + 'rate_amount' => factory_wallet.rate_amount, |
| 353 | + 'created_at' => '2022-04-29T08:59:51Z', |
| 354 | + 'recurring_transaction_rules' => factory_wallet.recurring_transaction_rules, |
| 355 | + 'applies_to' => factory_wallet.applies_to, |
| 356 | + } |
| 357 | + }.to_json |
| 358 | + end |
| 359 | + |
| 360 | + before do |
| 361 | + stub_request(:post, 'https://api.getlago.com/api/v1/wallets') |
| 362 | + .with(body: body_with_billing_entity) |
| 363 | + .to_return(body: response_with_billing_entity, status: 200) |
| 364 | + end |
| 365 | + |
| 366 | + it 'returns a wallet with billing_entity_code' do |
| 367 | + wallet = resource.create(params_with_billing_entity) |
| 368 | + |
| 369 | + expect(wallet.billing_entity_code).to eq('eu_entity') |
| 370 | + end |
| 371 | + end |
336 | 372 | end |
337 | 373 |
|
338 | 374 | describe '#update' do |
|
675 | 711 | end |
676 | 712 | end |
677 | 713 |
|
| 714 | + context 'when billing_entity_codes is given' do |
| 715 | + before do |
| 716 | + stub_request( |
| 717 | + :get, |
| 718 | + 'https://api.getlago.com/api/v1/wallets?billing_entity_codes%5B%5D=eu_entity&billing_entity_codes%5B%5D=us_entity', |
| 719 | + ).to_return(body: response, status: 200) |
| 720 | + end |
| 721 | + |
| 722 | + it 'returns wallets filtered by billing_entity_codes' do |
| 723 | + response = resource.get_all({ 'billing_entity_codes[]': %w[eu_entity us_entity] }) |
| 724 | + |
| 725 | + expect(response['wallets'].first['lago_id']).to eq('this-is-lago-id') |
| 726 | + expect(response['meta']['current_page']).to eq(1) |
| 727 | + end |
| 728 | + end |
| 729 | + |
678 | 730 | context 'when there is an issue' do |
679 | 731 | before do |
680 | 732 | stub_request(:get, 'https://api.getlago.com/api/v1/wallets') |
|
0 commit comments