Skip to content

Commit

Permalink
removed chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitdas13 committed May 27, 2024
1 parent 01c60f5 commit 3eaf6ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion documents/transfers.md
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ Razorpay::Transfer.fetch(transferId).edit(para_attr)
### Fetch Reversals for a Transfer
```rb
transferId = "trf_JhemwjNekar9Za"
Razorpay::Transfer.fetch(transferId).reversals
Razorpay::Transfer.reversals(transferId)
```

**Parameters:**
Expand Down
4 changes: 2 additions & 2 deletions lib/razorpay/transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def self.fetch_settlements
request.get "?expand[]=recipient_settlement"
end

def reversals
self.class.request.get "#{id}/reversals"
def self.reversals(id)
request.get "#{id}/reversals"
end
end
end
4 changes: 2 additions & 2 deletions test/razorpay/test_transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ def test_transfer_direct_transfer

def test_fetch_reversals
stub_get(%r{/transfers/#{@transfer_id}/reversals$}, 'reversals_collection')
transfer = Razorpay::Transfer.fetch(@transfer_id).reversals
transfer = Razorpay::Transfer.reversals(@transfer_id)
assert_instance_of Razorpay::Collection, transfer , 'Transfer should be an array'
refute_empty transfer.items , 'Transfer should be more than one'
end

def test_fetch_reversals_exception
stub_get(%r{/transfers/#{@transfer_id}/reversals$}, 'transfer_error')
assert_raises(Razorpay::Error) do
transfer = Razorpay::Transfer.fetch(@transfer_id).reversals
transfer = Razorpay::Transfer.reversals(@transfer_id)
if transfer.error
raise Razorpay::Error.new, transfer.error['code']
end
Expand Down

0 comments on commit 3eaf6ba

Please sign in to comment.