-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
533 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
lib/eway_rapid/entities/direct_settlement_search_response.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module EwayRapid | ||
class DirectSettlementSearchResponse | ||
attr_accessor :settlement_summaries | ||
attr_accessor :settlement_transactions | ||
attr_accessor :error | ||
|
||
def to_json(summaries={}, transactions={}) | ||
{Constants::SETTLEMENT_SUMMARIES => summaries, | ||
Constants::SETTLEMENT_TRANSACTIONS => transactions, | ||
Constants::ERRORS_CAPITALIZED => error}.to_json | ||
end | ||
|
||
def self.from_json(json) | ||
hash = JSON.parse(json) | ||
from_hash(hash) | ||
end | ||
|
||
def self.from_hash(hash) | ||
settlement_search_response = DirectSettlementSearchResponse.new | ||
settlement_search_response.settlement_summaries = InternalModels::SettlementSummary.from_array(hash[Constants::SETTLEMENT_SUMMARIES]) | ||
settlement_search_response.settlement_transactions = InternalModels::SettlementTransaction.from_array(hash[Constants::SETTLEMENT_TRANSACTIONS]) | ||
settlement_search_response.error = hash[Constants::ERRORS_CAPITALIZED] | ||
settlement_search_response | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
lib/eway_rapid/message/convert/internal_settlement_to_settlement.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module EwayRapid | ||
module Message | ||
module Convert | ||
class InternalSettlementToSettlement | ||
|
||
# @param [InternalModels::SettlementTransaction] i_settlement | ||
# @return [Models::SettlementTransaction] | ||
def do_convert(i_settlement) | ||
settlement = Models::SettlementTransaction.new | ||
settlement.settlement_id = i_settlement.settlement_id | ||
settlement.eway_customer_id = i_settlement.eway_customer_id | ||
settlement.currency = i_settlement.currency | ||
settlement.currency_code = i_settlement.transaction_id | ||
settlement.transaction_id = i_settlement.transaction_id | ||
settlement.txn_reference = i_settlement.txn_reference | ||
settlement.card_type = i_settlement.card_type | ||
settlement.amount = i_settlement.amount | ||
settlement.transaction_type = i_settlement.transaction_type | ||
settlement.transaction_date = Time.at(i_settlement.transaction_date.delete('^0-9').to_i / 1000.0 ) | ||
settlement.settlement_date = Time.at(i_settlement.settlement_date.delete('^0-9').to_i / 1000.0 ) | ||
settlement | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
39 changes: 39 additions & 0 deletions
39
lib/eway_rapid/message/convert/internal_summary_to_summary.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module EwayRapid | ||
module Message | ||
module Convert | ||
class InternalSummaryToSummary | ||
|
||
# @param [InternalModels::SettlementSummary] i_summary | ||
# @return [Models::SettlementSummary] | ||
def do_convert(i_summary) | ||
summary = Models::SettlementSummary.new | ||
summary.settlement_id = i_summary.settlement_id | ||
summary.currency = i_summary.currency | ||
summary.currency_code = i_summary.currency_code | ||
summary.total_credit = i_summary.total_credit | ||
summary.total_debit = i_summary.total_debit | ||
summary.total_balance = i_summary.total_balance | ||
summary.balance_per_card_type = [] | ||
i_summary.balance_per_card_type.each {|balance| | ||
obj = get_balance(balance) | ||
summary.balance_per_card_type.push(obj) | ||
} | ||
summary | ||
end | ||
|
||
# @param [InternalModels::BalancePerCardType] i_balance | ||
# @return [Models::BalancePerCardType] | ||
def get_balance(i_balance) | ||
balance = Models::BalancePerCardType.new | ||
balance.card_type = i_balance.card_type | ||
balance.number_of_transactions = i_balance.number_of_transactions | ||
balance.credit = i_balance.credit | ||
balance.debit = i_balance.debit | ||
balance.balance = i_balance.balance | ||
balance | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
38 changes: 38 additions & 0 deletions
38
lib/eway_rapid/message/convert/response/direct_settlement_to_settlement.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module EwayRapid | ||
module Message | ||
module Convert | ||
module Response | ||
class DirectSettlementToSettlement | ||
|
||
# @param [DirectSettlementSearchResponse] response | ||
# @return [SettlementSearchResponse] | ||
def do_convert(response) | ||
settlement_search_response = SettlementSearchResponse.new | ||
|
||
if response.settlement_summaries && response.settlement_summaries.length > 0 | ||
summary_convert = InternalSummaryToSummary.new | ||
settlement_search_response.settlement_summaries = [] | ||
response.settlement_summaries.each {|summary| | ||
obj = summary_convert.do_convert(summary) | ||
settlement_search_response.settlement_summaries.push(obj) | ||
} | ||
end | ||
|
||
if response.settlement_transactions && response.settlement_summaries.length > 0 | ||
settlement_convert = InternalSettlementToSettlement.new | ||
settlement_search_response.settlement_transactions = [] | ||
response.settlement_transactions.each {|transaction| | ||
obj = settlement_convert.do_convert(transaction) | ||
settlement_search_response.settlement_transactions.push(obj) | ||
} | ||
end | ||
|
||
settlement_search_response.errors = response.error.split(/\s*,\s*/) if response.error | ||
|
||
settlement_search_response | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.